From 68b7d0a3917d36c67862da26bc8e763c6ab9a5cf Mon Sep 17 00:00:00 2001 From: qperrot Date: Tue, 26 Nov 2024 11:49:52 +0100 Subject: [PATCH] fix: front end if no cosmosResources --- libs/ledger-live-common/src/DataModel.ts | 14 ++ .../mantra.integration.test.ts.snap | 123 +----------------- 2 files changed, 15 insertions(+), 122 deletions(-) diff --git a/libs/ledger-live-common/src/DataModel.ts b/libs/ledger-live-common/src/DataModel.ts index 7988a48aef0e..4906673b867e 100644 --- a/libs/ledger-live-common/src/DataModel.ts +++ b/libs/ledger-live-common/src/DataModel.ts @@ -1,3 +1,5 @@ +import BigNumber from "bignumber.js"; + /** * Interface for the end user. * @memberof DataModel @@ -38,6 +40,18 @@ export function createDataModel(schema: DataSchema): DataModel function decodeModel(raw) { let { data } = raw; + if (data.currencyId == "crypto_org" && !data.cosmosResources) { + data.cosmosResources = { + delegations: [], + redelegations: [], + unbondings: [], + delegatedBalance: new BigNumber(0), + pendingRewardsBalance: new BigNumber(0), + unbondingBalance: new BigNumber(0), + withdrawAddress: data.freshAddress, + sequence: 0, + }; + } for (let i = raw.version; i < version; i++) { data = migrations[i](data); } diff --git a/libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap b/libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap index 6c5a83e56382..bb879e4cbb75 100644 --- a/libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap +++ b/libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap @@ -39,128 +39,7 @@ exports[`mantra currency bridge scanAccounts mantra seed 1 1`] = ` exports[`mantra currency bridge scanAccounts mantra seed 1 2`] = ` [ - [ - { - "accountId": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:", - "blockHash": null, - "blockHeight": 446099, - "extra": {}, - "fee": "1950", - "hasFailed": false, - "hash": "4855629335DD67EEB42CC089311697D7F5FAE587CD7E33F81E0AAE5227B4FB8F", - "id": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:-4855629335DD67EEB42CC089311697D7F5FAE587CD7E33F81E0AAE5227B4FB8F-IN", - "recipients": [ - "mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn", - ], - "senders": [ - "mantra1g84934jpu3v5de5yqukkkhxmcvsw3u2aedx9w9", - ], - "transactionSequenceNumber": 6, - "type": "IN", - "value": "1000000", - }, - { - "accountId": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:", - "blockHash": null, - "blockHeight": 446137, - "extra": {}, - "fee": "1949", - "hasFailed": false, - "hash": "8F9934B90FC0006941F24FA783970CCC6480F991725E8D7A0BFDB3E917DECCB0", - "id": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:-8F9934B90FC0006941F24FA783970CCC6480F991725E8D7A0BFDB3E917DECCB0-OUT", - "recipients": [ - "mantra1g84934jpu3v5de5yqukkkhxmcvsw3u2aedx9w9", - ], - "senders": [ - "mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn", - ], - "transactionSequenceNumber": 1, - "type": "OUT", - "value": "301949", - }, - { - "accountId": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:", - "blockHash": null, - "blockHeight": 446147, - "extra": { - "memo": "Ledger Live", - }, - "fee": "2385", - "hasFailed": false, - "hash": "AAC85BCAA8EB83298CABABB6A6574082C056092C7139FD8C8ED8849A207B8C8A", - "id": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:-AAC85BCAA8EB83298CABABB6A6574082C056092C7139FD8C8ED8849A207B8C8A-REWARD", - "recipients": [], - "senders": [], - "transactionSequenceNumber": 2, - "type": "REWARD", - "value": "0", - }, - { - "accountId": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:", - "blockHash": null, - "blockHeight": 446122, - "extra": { - "memo": "Ledger Live", - "validators": [ - { - "address": "mantravaloper1y8hxa8q0qk6h2fxtugkx67re38k03888eeqmpd", - "amount": "500000", - }, - ], - }, - "fee": "2906", - "hasFailed": false, - "hash": "B1FE340869D47C458F2B6CCD6029E9996B3CC957BE01E8426A7686E50B2987B4", - "id": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:-B1FE340869D47C458F2B6CCD6029E9996B3CC957BE01E8426A7686E50B2987B4-DELEGATE", - "recipients": [], - "senders": [], - "transactionSequenceNumber": 0, - "type": "DELEGATE", - "value": "2906", - }, - { - "accountId": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:", - "blockHash": null, - "blockHeight": 445531, - "extra": {}, - "fee": "2125", - "hasFailed": false, - "hash": "E6FA7ACE758FE1C371CDE0503651D07D3F25F65BE2A57B642CC5F3B3D6A3A5F7", - "id": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:-E6FA7ACE758FE1C371CDE0503651D07D3F25F65BE2A57B642CC5F3B3D6A3A5F7-IN", - "recipients": [ - "mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn", - ], - "senders": [ - "mantra1g84934jpu3v5de5yqukkkhxmcvsw3u2aedx9w9", - ], - "transactionSequenceNumber": 5, - "type": "IN", - "value": "20000", - }, - { - "accountId": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:", - "blockHash": null, - "blockHeight": 620191, - "extra": { - "memo": "Ledger Live", - "validators": [ - { - "address": "mantravaloper1y8hxa8q0qk6h2fxtugkx67re38k03888eeqmpd", - "amount": "10000", - }, - ], - }, - "fee": "3331", - "hasFailed": false, - "hash": "FD8D25ECA06DC0EB86864C40BB445A52919C7D12C2957BB74F7FA0122E0A4DFD", - "id": "js:2:mantra:mantra1gyauvl44q2apn3u3aujm36q8zrj74vry7n5nvn:-FD8D25ECA06DC0EB86864C40BB445A52919C7D12C2957BB74F7FA0122E0A4DFD-DELEGATE", - "recipients": [], - "senders": [], - "transactionSequenceNumber": 3, - "type": "DELEGATE", - "value": "3331", - }, - ], + [], [], ] `;