feat(bitcoin-snap): update to keyring v2 - #43
Conversation
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
|
@SocketSecurity ignore npm/@metamask/snaps-controllers@21.0.0 |
| transaction: 'notAPsbt', | ||
| }, | ||
| code: -32603, | ||
| message: 'Invalid PSBT', |
There was a problem hiding this comment.
Because handleKeyringRequest either throws SnapError or Error , the middleware doesn't catch it as FormatError, hence the "Invalid format: " prefix gets stripped
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Sync with bitcoin keyring v2 (#43) and regenerate yarn.lock after resolving the lockfile conflict.
Bump snaps-cli, snaps-sdk, superstruct, keyring-api, and keyring-snap-sdk declarations to match bitcoin-/tron-wallet-snap after #43 (installed versions unchanged).
Explanation
Original PR & reviewer comments here: MetaMask/snap-bitcoin-wallet#645
Migrates the Bitcoin snap to the v2 Keyring API and declares the corresponding capabilities in the manifest. Also removes all v1-only keyring methods and replaces the manual routing table with the v2 dispatcher.
Rewrites
KeyringHandlerto implementKeyringSnapRpc(from@metamask/keyring-api/v2): addsgetAccounts,getAccount,createAccounts,exportAccount,getAccountBalances,getAccountAssets,getAccountTransactions,deleteAccount,submitRequest,setSelectedAccounts, andresolveAccountAddressRemoves v1-only flows (
createAccount,discoverAccounts,filterAccountChains,updateAccount) and stops emittingAccountCreated/AccountDeletedeventsFolds
bip44:discoverintocreateAccounts: callsAccountUseCases.discover(), deletes the account from state if no transactions are found, and returns[]to signal end-of-discoveryAdds
exportAccountwith WIF private-key export (Base58Check, version byte 0x80/0xEF); usesis()notassert()to prevent the private key from appearing in aStructErrormessage on encoding failureReads
SUPPORTED_SCOPESdirectly fromsnap.manifest.jsoncapabilities block (same pattern as Solana snap) instead of hardcoding the networkSwitches
handleKeyringRequestto the v2 dispatcher (@metamask/keyring-snap-sdk/v2)Adds
endowment:keyring.capabilitiestosnap.manifest.json:scopes,privateKey.exportFormats, andbip44 derive/discoverflagsSets
module: "ESNext"andmoduleResolution: "bundler"inpackages/snap/tsconfig.jsonso /v2 subpath exports resolve correctlyBumps
@metamask/keyring-api → ^23.5.0,keyring-snap-sdk → ^9.2.0,snaps-sdk → ^11.2.0,snaps-cli → ^8.4.1,snaps-jest → ^10.2.0Updates
KeyringHandler.test.ts: removes v1-only describe blocks, addsexportAccountandbip44:discovercoverage, mockswifmodule, addsbeforeEach(() => jest.resetAllMocks())to fix mock-call accumulation between testsReferences
N/A
Checklist