fix(bitcoin-wallet-snap): return Json directly from onKeyringRequest - #100
Conversation
ccharly
left a comment
There was a problem hiding this comment.
My bad for not paying attention on this one! Looks like we only use the Solana Snap to do submitRequest calls!
| psbtBase64: string, | ||
| feeRate?: number, | ||
| ): Promise<KeyringResponse> { | ||
| ): Promise<Json> { |
There was a problem hiding this comment.
I have one concern with these type transformations, Json takes away a lot of information about what the objects actually have. Is this the only way? Isn't there a more fitting type?
|
To add to my comment above: wouldn't it make sense that the Keyring respecting methods return a type that is all-encompassing, like |
IMO that makes total sense, and that's much better if we use stricter types! As long as those types are |
|
@hmalik88 does it mean that we have to deprecate v2.0.0 of the bitcoin snap ? Also I was testing preview build, including the send bitcoin flow, and that trx was signed, sent and confirmed ? I can see from the description that it should fail with v2.0.0 |
Yes we should deprecate once the fix is released to avoid anyone pinning to the wrong version. Could you share which extension build/version you were testing against? Depending on that, it might explain why send appeared to work. The behavior of v2.0.0 differs based on whether the extension was doing envelope unwrapping or not |
|
@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. |
I usually test with the latest |
Explanation
Bitcoin wallet snap v2.0.0 incorrectly wrapped all
onKeyringRequestresponses in the v1{ pending: false, result }envelope. MetaMask detects v2 snaps via the capabilities field in the manifest and skips envelope unwrapping, so callers received the wrapper as the result instead of the inner value. This brokesignMessage,signPsbt,sendTransaction, and other signing operations.Removes
#toKeyringResponseand updates all handlers to return Json directly, as the v2 keyring protocol requires.References
N/A
Checklist