Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bitcoin base support #3230

Merged
merged 31 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
030f6ec
chore: add bip122 namespace
zoruka Nov 11, 2024
eb72b53
feat: add base bitcoin adapter package
zoruka Nov 11, 2024
08b421a
feat: add bitcoin WalletStandardConnector
zoruka Nov 11, 2024
f54566c
feat: add bitcoin network
zoruka Nov 11, 2024
4deb7f1
refactor: add provider to clean up repeated connectors
zoruka Nov 11, 2024
910f5a5
feat: add chains to WalletStandardConnector
zoruka Nov 11, 2024
544f79b
feat: add bitcoin test page on laboratory
zoruka Nov 11, 2024
336fd86
chore: setup connect for bitcoin connector
zoruka Nov 12, 2024
51285df
feat: attempt to use WBIP standard as connector to bitcoin
zoruka Nov 12, 2024
53e430b
Merge branch 'main' of github.com:reown-com/appkit into feat/bitcoin-…
tomiir Nov 18, 2024
bd3e406
feat: add connection feature for WalletStandardConnector
zoruka Nov 18, 2024
8162ce1
feat: sats connect connector (#3258)
tomiir Nov 19, 2024
015fa39
feat: add base for sign message (#3283)
zoruka Nov 20, 2024
f6bd0e9
feat: implement transfers (#3284)
tomiir Nov 20, 2024
7eda96a
Merge branch 'main' of github.com:reown-com/appkit into feat/bitcoin-…
tomiir Nov 20, 2024
679a0c1
chore: remove new-ui code
tomiir Nov 20, 2024
1cacf96
chore: remove new-ui code in gallery
tomiir Nov 20, 2024
732dd92
feat: WalletConnect Bitcoin Provider (#3302)
tomiir Nov 21, 2024
3d83ce7
chore: remove logs
tomiir Nov 21, 2024
265dc65
chore: sort method order
tomiir Nov 21, 2024
863dfd0
chore: rollback base provider type change
tomiir Nov 21, 2024
086c072
Merge branch 'main' into feat/bitcoin-support
tomiir Nov 21, 2024
adbe82c
chore: prettier fix
tomiir Nov 21, 2024
89ac74d
Merge branch 'feat/bitcoin-support' of github.com:reown-com/appkit in…
tomiir Nov 21, 2024
2f031fd
fix: bitcoin exports
zoruka Nov 21, 2024
3b2dd42
chore: build command for adapters folder
zoruka Nov 21, 2024
fc14080
chore: build command for adapters folder
zoruka Nov 21, 2024
66ae1bc
chore: remove test command
zoruka Nov 21, 2024
2ec6221
fix: not static package version
zoruka Nov 21, 2024
1055565
fix: clean state usage
zoruka Nov 21, 2024
c5bc301
Merge branch 'main' into feat/bitcoin-support
tomiir Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["@examples/*", "@apps/gallery-new", "@reown/appkit-ui-new"]
"ignore": ["@examples/*", "@apps/gallery-new", "@reown/appkit-ui-new", "@reown/appkit-adapter-bitcoin"]
}
1 change: 1 addition & 0 deletions apps/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@reown/appkit-adapter-ethers5": "workspace:*",
"@reown/appkit-adapter-solana": "workspace:*",
"@reown/appkit-adapter-wagmi": "workspace:*",
"@reown/appkit-adapter-bitcoin": "workspace:*",
"@reown/appkit-experimental": "workspace:*",
"@reown/appkit-siwe": "workspace:*",
"@reown/appkit-siwx": "workspace:*",
Expand Down
4 changes: 3 additions & 1 deletion apps/laboratory/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
ethers5SdkOptions,
featuredSdkOptions,
multichainSdkOptions,
testingSdkOptions
testingSdkOptions,
bitcoinSdkOptions
} from '../utils/DataUtil'
import { ConfigurationList } from '../components/ConfigurationList'

Expand All @@ -19,6 +20,7 @@ export default function HomePage() {
<ConfigurationList title="Ethers" sdkOptions={ethersSdkOptions} />
<ConfigurationList title="Ethers 5" sdkOptions={ethers5SdkOptions} />
<ConfigurationList title="Solana" sdkOptions={solanaSdkOptions} />
<ConfigurationList title="Bitcoin" sdkOptions={bitcoinSdkOptions} />
<ConfigurationList
title={
<>
Expand Down
112 changes: 112 additions & 0 deletions apps/laboratory/src/pages/library/bitcoin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
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 BitcoinConnector } 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 } = useAppKitProvider<BitcoinConnector>('bip122')
const { address } = useAppKitAccount()
const [loading, setLoading] = useState(false)

const toast = useToast()
async function signMessage() {
if (!walletProvider || !address) {
toast({
title: 'No connection detected',
status: 'error',
isClosable: true
})

return
}

setLoading(true)

try {
const signature = await walletProvider.signMessage({
address,
message: 'Hello, World!'
})
toast({ title: 'Signature', description: signature, status: 'success' })
} catch (error) {
toast({ title: 'Error', description: (error as Error).message, status: 'error' })
} finally {
setLoading(false)
}
}

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

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

toast({
title: `Transfer sent: ${signature}`,
status: 'success',
isClosable: true
})
} catch (error) {
toast({ title: 'Error', description: (error as Error).message, status: 'error' })
} finally {
setLoading(false)
}
}

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>
)}
</>
)
}
6 changes: 5 additions & 1 deletion apps/laboratory/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
gnosis,
unichainSepolia,
hedera,
aurora
aurora,
bitcoin
} from '@reown/appkit/networks'
import type { AppKitNetwork } from '@reown/appkit/networks'
import { getLocalStorageItem } from './LocalStorage'
Expand Down Expand Up @@ -86,6 +87,8 @@ const SolanaNetworks = [solana, solanaTestnet, solanaDevnet, solanaNotExist] as
...AppKitNetwork[]
]

const BitcoinNetworks = [bitcoin] as [AppKitNetwork, ...AppKitNetwork[]]

export const ConstantsUtil = {
SigningSucceededToastTitle: 'Signing Succeeded',
SigningFailedToastTitle: 'Signing Failed',
Expand Down Expand Up @@ -142,5 +145,6 @@ export const ConstantsUtil = {
ProjectId: projectId,
EvmNetworks,
SolanaNetworks,
BitcoinNetworks,
AllNetworks: [...EvmNetworks, ...SolanaNetworks] as [AppKitNetwork, ...AppKitNetwork[]]
}
8 changes: 8 additions & 0 deletions apps/laboratory/src/utils/DataUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,11 @@ export const featuredSdkOptions: SdkOption[] = [
description: 'Configuration with no adapters enabled for AppKit'
}
]

export const bitcoinSdkOptions: SdkOption[] = [
{
title: 'Default',
link: '/library/bitcoin',
description: 'Basic configuration using bitcoin as a driving library'
}
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:sample-apps": "turbo run build --filter={./examples/*}",
"build:example:wagmi-cdn": "pnpm build; pnpm --filter @examples/html-wagmi-cdn build",
"build:example:vue-wagmi": "pnpm --filter @examples/vue-wagmi build",
"build": "turbo run build --filter={./packages/*} --concurrency=31",
"build": "turbo run build --filter={./packages/**/*} --concurrency=31",
"watch": "turbo run watch --filter={./packages/*,./packages/adapters/*} --concurrency=50 --continue",
"gallery": "turbo run dev --filter={./apps/gallery}",
"gallery-new": "turbo run dev --filter={./apps/gallery-new}",
Expand Down
4 changes: 4 additions & 0 deletions packages/adapters/bitcoin/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["plugin:require-extensions/recommended", "../../../.eslintrc.json"],
"plugins": ["require-extensions"]
}
11 changes: 11 additions & 0 deletions packages/adapters/bitcoin/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.log
*.env
tests
src
exports
node_modules
.eslintrc.json
.turbo
package-lock.json
tsconfig.json
index.ts
1 change: 1 addition & 0 deletions packages/adapters/bitcoin/exports/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../src/index.js'
50 changes: 50 additions & 0 deletions packages/adapters/bitcoin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@reown/appkit-adapter-bitcoin",
"version": "1.5.1",
"type": "module",
"main": "./dist/esm/exports/index.js",
"types": "./dist/types/exports/index.d.ts",
"files": [
"dist",
"!tsconfig.tsbuildinfo"
],
"scripts": {
"build:clean": "rm -rf dist",
"build": "tsc --build tsconfig.build.json",
"watch": "tsc --watch",
"typecheck": "tsc --noEmit",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"exports": {
".": {
"types": "./dist/types/exports/index.d.ts",
"import": "./dist/esm/exports/index.js",
"default": "./dist/esm/exports/index.js"
}
},
"dependencies": {
"@exodus/bitcoin-wallet-standard": "0.0.0",
"@reown/appkit": "workspace:*",
"@reown/appkit-common": "workspace:*",
"@reown/appkit-core": "workspace:*",
"@wallet-standard/app": "1.0.1",
"@wallet-standard/base": "1.0.1",
"@walletconnect/universal-provider": "2.17.0",
"sats-connect": "3.0.1"
},
"devDependencies": {
"@vitest/coverage-v8": "2.1.3",
"@walletconnect/types": "2.17.0",
"vitest": "2.1.3"
},
"author": "Reown <[email protected]> (https://reown.com)",
"license": "Apache-2.0",
"homepage": "https://github.com/reown-com/appkit",
"repository": {
"type": "git",
"url": "git+https://github.com/reown-com/appkit.git"
},
"bugs": {
"url": "https://github.com/reown-com/appkit/issues"
}
}
Loading
Loading