diff --git a/app/Makefile.version b/app/Makefile.version index 8268a85e..9a0f20c4 100644 --- a/app/Makefile.version +++ b/app/Makefile.version @@ -3,4 +3,4 @@ APPVERSION_M=2 # This is the `spec_version` field of `Runtime` APPVERSION_N=34 # This is the patch version of this release -APPVERSION_P=2 +APPVERSION_P=3 diff --git a/app/src/coin.h b/app/src/coin.h index 6cfe4cfd..dfc61e83 100644 --- a/app/src/coin.h +++ b/app/src/coin.h @@ -50,7 +50,10 @@ typedef enum { #define COIN_DEFAULT_DENOM_FACTOR 6 #define COIN_DEFAULT_DENOM_TRIMMING 6 -#define COIN_DENOM_MAXSIZE 50 +// Coin denoms may be up to 128 characters long +// https://github.com/cosmos/cosmos-sdk/blob/master/types/coin.go#L780 +// https://github.com/cosmos/ibc-go/blob/main/docs/architecture/adr-001-coin-source-tracing.md +#define COIN_DENOM_MAXSIZE 129 #define COIN_AMOUNT_MAXSIZE 50 #define COIN_MAX_CHAINID_LEN 20 diff --git a/tests/testcases/manual.json b/tests/testcases/manual.json index 1cea43e5..b8da8e41 100644 --- a/tests/testcases/manual.json +++ b/tests/testcases/manual.json @@ -1878,5 +1878,66 @@ "5 | Gas : V3" ], "expert": true + }, + { + "name": "ibc_denoms", + "tx": { + "account_number": "0", + "chain_id": "cosmoshub-4", + "fee": { + "amount": [ + { + "amount": "5", + "denom": "uatom" + } + ], + "gas": "10000" + }, + "memo": "testmemo", + "msgs": [ + { + "inputs": [ + { + "address": "cosmosaccaddr1d9h8qat5e4ehc5", + "coins": [ + { + "amount": "10", + "denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2" + } + ] + } + ], + "outputs": [ + { + "address": "cosmosaccaddr1da6hgur4wse3jx32", + "coins": [ + { + "amount": "10", + "denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2" + } + ] + } + ] + } + ], + "sequence": "1" + }, + "parsingErr": "No error", + "validationErr": "No error", + "expected": [ + "0 | Chain ID : cosmoshub-4", + "1 | Account : 0", + "2 | Sequence : 1", + "3 | Source Address : cosmosaccaddr1d9h8qat5e4ehc5", + "4 | Source Coins [1/2] : 10 ibc/27394FB092D2ECCD56123C74F36E4C1F", + "4 | Source Coins [2/2] : 926001CEADA9CA97EA622B25F41E5EB2", + "5 | Dest Address : cosmosaccaddr1da6hgur4wse3jx32", + "6 | Dest Coins [1/2] : 10 ibc/27394FB092D2ECCD56123C74F36E4C1F", + "6 | Dest Coins [2/2] : 926001CEADA9CA97EA622B25F41E5EB2", + "7 | Memo : testmemo", + "8 | Fee : 5 uatom", + "9 | Gas : 10000" + ], + "expert": true } ] diff --git a/tests_zemu/package.json b/tests_zemu/package.json index 29671cd8..85d84d34 100644 --- a/tests_zemu/package.json +++ b/tests_zemu/package.json @@ -18,7 +18,7 @@ "testSR25519": "jest --detectOpenHandles --runInBand tests/sr25519.test.ts" }, "dependencies": { - "@zondax/zemu": "^0.27.4", + "@zondax/zemu": "^0.29.0", "ledger-cosmos-js": "^2.1.8" }, "devDependencies": { diff --git a/tests_zemu/snapshots/s-ibc_denoms/00000.png b/tests_zemu/snapshots/s-ibc_denoms/00000.png new file mode 100644 index 00000000..a3f6466f Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00000.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00001.png b/tests_zemu/snapshots/s-ibc_denoms/00001.png new file mode 100644 index 00000000..04f0c145 Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00001.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00002.png b/tests_zemu/snapshots/s-ibc_denoms/00002.png new file mode 100644 index 00000000..a1f2ec1d Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00002.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00003.png b/tests_zemu/snapshots/s-ibc_denoms/00003.png new file mode 100644 index 00000000..b0b0090a Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00003.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00004.png b/tests_zemu/snapshots/s-ibc_denoms/00004.png new file mode 100644 index 00000000..75e3e0c0 Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00004.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00005.png b/tests_zemu/snapshots/s-ibc_denoms/00005.png new file mode 100644 index 00000000..0759e66d Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00005.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00006.png b/tests_zemu/snapshots/s-ibc_denoms/00006.png new file mode 100644 index 00000000..893bf19a Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00006.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00007.png b/tests_zemu/snapshots/s-ibc_denoms/00007.png new file mode 100644 index 00000000..89a6d2f5 Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00007.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00008.png b/tests_zemu/snapshots/s-ibc_denoms/00008.png new file mode 100644 index 00000000..c3bc9c05 Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00008.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00009.png b/tests_zemu/snapshots/s-ibc_denoms/00009.png new file mode 100644 index 00000000..8af7ed67 Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00009.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00010.png b/tests_zemu/snapshots/s-ibc_denoms/00010.png new file mode 100644 index 00000000..006c26ab Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00010.png differ diff --git a/tests_zemu/snapshots/s-ibc_denoms/00011.png b/tests_zemu/snapshots/s-ibc_denoms/00011.png new file mode 100644 index 00000000..131855e2 Binary files /dev/null and b/tests_zemu/snapshots/s-ibc_denoms/00011.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00004.png b/tests_zemu/snapshots/s-mainmenu/00004.png index 0fac4278..76f93ddc 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00004.png and b/tests_zemu/snapshots/s-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00010.png b/tests_zemu/snapshots/s-mainmenu/00010.png index 0fac4278..76f93ddc 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00010.png and b/tests_zemu/snapshots/s-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00000.png b/tests_zemu/snapshots/sp-ibc_denoms/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00000.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00001.png b/tests_zemu/snapshots/sp-ibc_denoms/00001.png new file mode 100644 index 00000000..70772708 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00001.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00002.png b/tests_zemu/snapshots/sp-ibc_denoms/00002.png new file mode 100644 index 00000000..46ba8198 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00002.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00003.png b/tests_zemu/snapshots/sp-ibc_denoms/00003.png new file mode 100644 index 00000000..e42e6ee7 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00003.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00004.png b/tests_zemu/snapshots/sp-ibc_denoms/00004.png new file mode 100644 index 00000000..19374588 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00004.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00005.png b/tests_zemu/snapshots/sp-ibc_denoms/00005.png new file mode 100644 index 00000000..e234dbb0 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00005.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00006.png b/tests_zemu/snapshots/sp-ibc_denoms/00006.png new file mode 100644 index 00000000..a1980245 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00006.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00007.png b/tests_zemu/snapshots/sp-ibc_denoms/00007.png new file mode 100644 index 00000000..1c1128d5 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00007.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00008.png b/tests_zemu/snapshots/sp-ibc_denoms/00008.png new file mode 100644 index 00000000..709fbea8 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00008.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00009.png b/tests_zemu/snapshots/sp-ibc_denoms/00009.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00009.png differ diff --git a/tests_zemu/snapshots/sp-ibc_denoms/00010.png b/tests_zemu/snapshots/sp-ibc_denoms/00010.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/sp-ibc_denoms/00010.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00004.png b/tests_zemu/snapshots/sp-mainmenu/00004.png index c0ce7660..75bfa467 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00004.png and b/tests_zemu/snapshots/sp-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00010.png b/tests_zemu/snapshots/sp-mainmenu/00010.png index c0ce7660..75bfa467 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00010.png and b/tests_zemu/snapshots/sp-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00000.png b/tests_zemu/snapshots/x-ibc_denoms/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00000.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00001.png b/tests_zemu/snapshots/x-ibc_denoms/00001.png new file mode 100644 index 00000000..70772708 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00001.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00002.png b/tests_zemu/snapshots/x-ibc_denoms/00002.png new file mode 100644 index 00000000..46ba8198 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00002.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00003.png b/tests_zemu/snapshots/x-ibc_denoms/00003.png new file mode 100644 index 00000000..e42e6ee7 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00003.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00004.png b/tests_zemu/snapshots/x-ibc_denoms/00004.png new file mode 100644 index 00000000..19374588 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00004.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00005.png b/tests_zemu/snapshots/x-ibc_denoms/00005.png new file mode 100644 index 00000000..e234dbb0 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00005.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00006.png b/tests_zemu/snapshots/x-ibc_denoms/00006.png new file mode 100644 index 00000000..a1980245 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00006.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00007.png b/tests_zemu/snapshots/x-ibc_denoms/00007.png new file mode 100644 index 00000000..1c1128d5 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00007.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00008.png b/tests_zemu/snapshots/x-ibc_denoms/00008.png new file mode 100644 index 00000000..709fbea8 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00008.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00009.png b/tests_zemu/snapshots/x-ibc_denoms/00009.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00009.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00010.png b/tests_zemu/snapshots/x-ibc_denoms/00010.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/x-ibc_denoms/00010.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00004.png b/tests_zemu/snapshots/x-mainmenu/00004.png index c0ce7660..75bfa467 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00004.png and b/tests_zemu/snapshots/x-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00010.png b/tests_zemu/snapshots/x-mainmenu/00010.png index c0ce7660..75bfa467 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00010.png and b/tests_zemu/snapshots/x-mainmenu/00010.png differ diff --git a/tests_zemu/tests/common.ts b/tests_zemu/tests/common.ts index cd283595..5bcf1137 100644 --- a/tests_zemu/tests/common.ts +++ b/tests_zemu/tests/common.ts @@ -198,3 +198,45 @@ export const example_tx_str_basic_extra_fields = { sequence: '106', unknown_field: 123456 } + +export const ibc_denoms = { + account_number: "0", + chain_id: "cosmoshub-4", + fee: { + amount: [ + { + "amount": '5', + "denom": 'uatom', + } + ], + gas: '10000', + }, + memo: "testmemo", + msgs: [ + { + inputs: [ + { + address: "cosmosaccaddr1d9h8qat5e4ehc5", + coins: [ + { + amount: '10', + denom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' + } + ] + } + ], + outputs: [ + { + address: 'cosmosaccaddr1da6hgur4wse3jx32', + coins: [ + { + amount: '10', + denom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' + } + ] + } + ] + } + ], + sequence: '1' +} diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index e9436a85..21784928 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -17,7 +17,7 @@ import Zemu from '@zondax/zemu' // @ts-ignore import CosmosApp from 'ledger-cosmos-js' -import { DEFAULT_OPTIONS, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2 } from './common' +import { DEFAULT_OPTIONS, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2, ibc_denoms } from './common' // @ts-ignore import secp256k1 from 'secp256k1/elliptic' @@ -311,4 +311,49 @@ describe('Standard', function () { await sim.close() } }) + + test.each(DEVICE_MODELS)('ibc denoms', async function (m) { + const sim = new Zemu(m.path) + try { + await sim.start({ ...DEFAULT_OPTIONS, model: m.name }) + const app = new CosmosApp(sim.getTransport()) + + const path = [44, 118, 0, 0, 0] + const tx = JSON.stringify(ibc_denoms) + + // get address / publickey + const respPk = await app.getAddressAndPubKey(path, 'cosmos') + expect(respPk.return_code).toEqual(0x9000) + expect(respPk.error_message).toEqual('No errors') + console.log(respPk) + + // do not wait here.. + const signatureRequest = app.sign(path, tx) + + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-ibc_denoms`) + + const resp = await signatureRequest + console.log(resp) + + expect(resp.return_code).toEqual(0x9000) + expect(resp.error_message).toEqual('No errors') + expect(resp).toHaveProperty('signature') + + // Now verify the signature + const hash = crypto.createHash('sha256') + const msgHash = Uint8Array.from(hash.update(tx).digest()) + + const signatureDER = resp.signature + const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER)) + + const pk = Uint8Array.from(respPk.compressed_pk) + + const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk) + expect(signatureOk).toEqual(true) + } finally { + await sim.close() + } + }) })