Skip to content

Commit

Permalink
chore: bitcoin adapter unit testing (#3516)
Browse files Browse the repository at this point in the history
Co-authored-by: tomiir <rocchitomas@gmail.com>
  • Loading branch information
zoruka and tomiir authored Dec 19, 2024
1 parent 15bfe49 commit 04208c8
Show file tree
Hide file tree
Showing 4 changed files with 416 additions and 21 deletions.
23 changes: 23 additions & 0 deletions .changeset/tall-carrots-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Add unit testing for Bitcoin adapter and fix unused default values
23 changes: 11 additions & 12 deletions packages/adapters/bitcoin/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ export class BitcoinAdapter extends AdapterBlueprint<BitcoinConnector> {
}
}
override async getAccounts(
_params: AdapterBlueprint.GetAccountsParams
params: AdapterBlueprint.GetAccountsParams
): Promise<AdapterBlueprint.GetAccountsResult> {
const addresses = await this.connector?.getAccountAddresses()
const addresses = await this.connectors
.find(connector => connector.id === params.id)
?.getAccountAddresses()
.catch(() => [])

const accounts = addresses?.map(a =>
CoreHelperUtil.createAccount(
'bip122',
a.address,
(a.purpose || 'payment') as BitcoinConnector.AccountAddress['purpose']
)
CoreHelperUtil.createAccount('bip122', a.address, a.purpose || 'payment')
)

return {
Expand Down Expand Up @@ -134,7 +134,7 @@ export class BitcoinAdapter extends AdapterBlueprint<BitcoinConnector> {
): Promise<AdapterBlueprint.ConnectResult> {
return this.connect({
id: params.id,
chainId: params.chainId || this.networks[0]?.id || '',
chainId: params.chainId,
type: ''
})
}
Expand Down Expand Up @@ -182,8 +182,6 @@ export class BitcoinAdapter extends AdapterBlueprint<BitcoinConnector> {
this.unbindEvents()
}

// -- Unused => Refactor ------------------------------------------- //

override async getBalance(
params: AdapterBlueprint.GetBalanceParams
): Promise<AdapterBlueprint.GetBalanceResult> {
Expand All @@ -210,6 +208,8 @@ export class BitcoinAdapter extends AdapterBlueprint<BitcoinConnector> {
})
}

// -- Unused => Refactor ------------------------------------------- //

override getProfile(
_params: AdapterBlueprint.GetProfileParams
): Promise<AdapterBlueprint.GetProfileResult> {
Expand Down Expand Up @@ -280,8 +280,7 @@ export class BitcoinAdapter extends AdapterBlueprint<BitcoinConnector> {
const [newAccount] = data
if (newAccount) {
this.emit('accountChanged', {
address: newAccount,
chainId: this.networks[0]?.id || ''
address: newAccount
})
}
}
Expand Down
Loading

0 comments on commit 04208c8

Please sign in to comment.