web-examples
web-examples copied to clipboard
bug: Cosmos signDirect signature validation fails
Summary: When calling signDirect action after connecting to CosmosHub, the example fails to validate the signature returned due to checking the wrong field.
Description:
According to WalletConnect Cosmos RPC reference after signing the payload, the response should have a signature property containing both a pub_key property and an additional signature field which contains the actual signature string that should be validated.
When returning such response the example dApp tries to validate the signature returned and fails to do so, throwing a match is not a function error, which originates from cosmjs function fromBase64 used internally during the verification process.
From further inspection I believe this error is a result of trying to verify the initial signature field (containing the pub_key & signature object) instead of the actual signature string sent inside it (as match is a method on String type).
Steps to reproduce:
- When connecting, choose 'Cosmos Hub'
- Click cosmos_signDirect
- Sign the message in the wallet
Expected Result: The signature will be verified with no errors thrown in the console.
Actual Result:
The verification fails instantly and a match is not a function error is thrown in the console tab