paritytech / txwrapper-core

Tools for FRAME chain builders to publish chain specific offline transaction generation libraries.
https://paritytech.github.io/txwrapper-core/
Apache License 2.0
77 stars 28 forks source link

Filter out error message from `decode` when decoding a signed tx #20

Closed emostov closed 3 years ago

emostov commented 3 years ago

Here: https://github.com/paritytech/txwrapper-core/blob/95825c73890c04fa8f4a767b885b22e6776cd1d9/packages/txwrapper-core/src/core/decode/decode.ts#L48-L60

We first try to decode as a signing payload, and if that fails we assume it needs to be decoded as a signed TX. With recent updates to polkadot-js error messages this results in the following being logged while decode is executing successful on signed TX:

2020-11-25 22:19:10        REGISTRY: Error: findMetaCall: Unable to find Call with index 0x84d4/[132,212]
    at assert (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/util/assert.js:34:11)
    at assertReturn (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/util/assert.js:44:3)
    at TypeRegistry.findMetaCall (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/create/registry.js:263:35)
    at decodeCallViaU8a (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/generic/Call.js:72:34)
    at decodeCall (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/generic/Call.js:96:12)
    at new GenericCall (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/generic/Call.js:127:21)
    at new Type (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/create/registry.js:300:16)
    at initType (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/create/createType.js:49:19)
    at createTypeUnsafe (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/create/createType.js:68:12)
    at createType (/Users/zeke/Documents/parity/txwrapper-core/node_modules/@polkadot/types/create/createType.js:83:10)

This message should not show up to the user. The solution may involve changing the try/catch or maybe try to suppress polkadot-js logging.

emostov commented 3 years ago

Given https://github.com/polkadot-js/api/pull/2952, this can now be updated.