cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

signature IBC transfer is not correct.

Open liangping opened this issue 3 years ago • 2 comments

I am going to submit a IBC transfer with Ledger, but seems it not parse correctly or get a invalidate signature.

original message:

[
    {
        "typeUrl": "/ibc.applications.transfer.v1.MsgTransfer",
        "value": {
            "sourcePort": "transfer",
            "sourceChannel": "channel-141",
            "token": {
                "amount": "100000",
                "denom": "uatom"
            },
            "sender": "cosmos1jxv0u20scum4trha72c7ltfgfqef6nscj25050",
            "receiver": "osmo1ev0vtddkl7jlwfawlk06yzncapw2x9quva4wzw",
            "timeoutHeight": {
                "revisionNumber": "1",
                "revisionHeight": "2248554"
            },
            "timeoutTimestamp": "0"
        }
    }
]

signedTxBodyEncodeObject:

{
    "typeUrl": "/cosmos.tx.v1beta1.TxBody",
    "value": {
        "messages": [
            {
                "typeUrl": "/ibc.applications.transfer.v1.MsgTransfer",
                "value": {
                    "sourcePort": "transfer",
                    "sourceChannel": "channel-141",
                    "token": {
                        "amount": "100000",
                        "denom": "uatom"
                    },
                    "sender": "cosmos1jxv0u20scum4trha72c7ltfgfqef6nscj25050",
                    "receiver": "osmo1ev0vtddkl7jlwfawlk06yzncapw2x9quva4wzw",
                    "timeoutHeight": {
                        "revisionHeight": "2248625",
                        "revisionNumber": "1"
                    },
                    "timeoutTimestamp": "0"
                }
            }
        ],
        "memo": ""
    }
}
Error: message.revisionNumber.isZero

This error is throw in this.registry.encode(txbody)

liangping avatar Dec 04 '21 05:12 liangping

revisionHeight is of type Long, not string. That feeld needs to look something like { revisionHeight: Long.fromNumber(123), revisionNumber: Long.fromNumber(456) },.

webmaster128 avatar Dec 06 '21 08:12 webmaster128

Origin:

{
    "sender": "osmo1ev0vtddkl7jlwfawlk06yzncapw2x9quva4wzw",
    "routes": [
        {
            "poolId": "1", // use Long.fromString('1') got error code: 111222 
            "tokenOutDenom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
        }
    ],
    "tokenIn": {
        "denom": "uosmo",
        "amount": "100000"
    },
    "tokenOutMinAmount": "517510"
}

signedTxBodyEncodeObject:

{
    "messages": [
        {
            "typeUrl": "/osmosis.gamm.v1beta1.MsgSwapExactAmountIn",
            "value": {
                "sender": "osmo1ev0vtddkl7jlwfawlk06yzncapw2x9quva4wzw",
                "routes": [
                    {
                        "poolId": {
                            "low": 1,
                            "high": 0,
                            "unsigned": false
                        },
                        "tokenOutDenom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
                    }
                ],
                "tokenIn": {
                    "amount": {
                        "low": 100000,
                        "high": 0,
                        "unsigned": false
                    },
                    "denom": "uosmo"
                },
                "tokenOutMinAmount": {
                    "low": 517510,
                    "high": 0,
                    "unsigned": false
                }
            }
        }
    ],
    "memo": "Sent Via https://ping.pub"
}

Changed to Long, but got this error.

{
  "height": "0",
  "txhash": "E48A4E603E2862C5C1AA2F23FC273E248EB0EB52BD524ACA4D8F808242DA49BD",
  "codespace": "undefined",
  "code": 111222,
  "data": "",
  "raw_log": "panic message redacted to hide potentially sensitive system info: panic",
  "logs": [],
  "info": "",
  "gas_wanted": "0",
  "gas_used": "0",
  "tx": null,
  "timestamp": ""
}

liangping avatar Dec 06 '21 11:12 liangping