Skip to content

Commit

Permalink
chore: fix btc page on lab
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir committed Nov 22, 2024
1 parent 62b936e commit ad2bede
Showing 1 changed file with 0 additions and 111 deletions.
111 changes: 0 additions & 111 deletions apps/laboratory/src/pages/library/bitcoin.tsx
Original file line number Diff line number Diff line change
@@ -1,113 +1,3 @@
<<<<<<< HEAD
import {
createAppKit,
useAppKitAccount,
useAppKitProvider,
type CaipNetwork
} from '@reown/appkit/react'
import { ThemeStore } from '../../utils/StoreUtil'
import { ConstantsUtil } from '../../utils/ConstantsUtil'

import { AppKitButtons } from '../../components/AppKitButtons'

import { BitcoinAdapter, type BitcoinProvider } from '@reown/appkit-adapter-bitcoin'
import { Button, Stack, useToast } from '@chakra-ui/react'
import { useState } from 'react'

const networks = ConstantsUtil.BitcoinNetworks

const bitcoinAdapter = new BitcoinAdapter({
networks: networks as CaipNetwork[],
projectId: ConstantsUtil.ProjectId
})

const appkit = createAppKit({
adapters: [bitcoinAdapter],
networks,
projectId: ConstantsUtil.ProjectId,
features: {
analytics: true,
email: false,
socials: []
},
metadata: ConstantsUtil.Metadata,
debug: true
})

ThemeStore.setModal(appkit)

export default function MultiChainBitcoinAdapterOnly() {
const { walletProvider, walletProviderType } = useAppKitProvider<BitcoinProvider>('bip122')
const { address } = useAppKitAccount()
const [loading, setLoading] = useState(false)

console.log('>> WALLET PROVIDER', walletProvider, walletProviderType)
const toast = useToast()
async function signMessage() {
if (!walletProvider) {
toast({
title: 'No wallet provider',
status: 'error',
isClosable: true
})

return
}

setLoading(true)
const signature = await walletProvider
.signMessage({
address,
message: 'Hello, World!'
})
.catch((error: unknown) => {
console.error('>> ERROR', error)
})
.finally(() => {
setLoading(false)
})

toast({ title: 'Signature', description: signature, status: 'success' })
}

async function sendTransfer() {
if (!walletProvider) {
toast({
title: 'No wallet provider',
status: 'error',
isClosable: true
})
}

const signature = await walletProvider.sendTransfer({
recipient: 'bc1qcer94ntpu33lcj0fnave79lu8tghkll47eeu9u',
amount: '100000'
})

toast({
title: `Transfer sent: ${signature}`,
status: 'success',
isClosable: true
})
}

return (
<>
<AppKitButtons />
{address && (
<Stack direction={['column', 'column', 'row']} pt="8">
<Button data-testid="sign-transaction-button" onClick={signMessage} isDisabled={loading}>
Sign Message
</Button>
<Button data-testid="send-transfer-button" onClick={sendTransfer} isDisabled={loading}>
Send Transfer
</Button>
</Stack>
)}
</>
)
}
=======
import {
createAppKit,
useAppKitAccount,
Expand Down Expand Up @@ -220,4 +110,3 @@ export default function MultiChainBitcoinAdapterOnly() {
</>
)
}
>>>>>>> 479fdb6b103a25f3993f7c58626b5d6549d3ba57

0 comments on commit ad2bede

Please sign in to comment.