Skip to content

Commit

Permalink
fix: front end if no cosmosResources
Browse files Browse the repository at this point in the history
  • Loading branch information
qperrot committed Nov 27, 2024
1 parent 70a1bc1 commit 68b7d0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 122 deletions.
14 changes: 14 additions & 0 deletions libs/ledger-live-common/src/DataModel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import BigNumber from "bignumber.js";

/**
* Interface for the end user.
* @memberof DataModel
Expand Down Expand Up @@ -38,6 +40,18 @@ export function createDataModel<R, M>(schema: DataSchema<R, M>): DataModel<R, M>
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
],
[],
[],
]
`;

0 comments on commit 68b7d0a

Please sign in to comment.