From 08a406761399f88519e5a70bcf30796595e27880 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 12 Sep 2024 06:58:50 +0200 Subject: [PATCH 1/4] Fix parsing amount decimals in Pontus-X events using TEST denomination --- src/oasis-nexus/api.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/oasis-nexus/api.ts b/src/oasis-nexus/api.ts index be7991161..4a36ee691 100644 --- a/src/oasis-nexus/api.ts +++ b/src/oasis-nexus/api.ts @@ -845,20 +845,13 @@ export const useGetRuntimeEvents: typeof generated.useGetRuntimeEvents = ( eth_tx_hash: adjustedHash, body: { ...event.body, - amount: + amount: { // If there's no denomination then use runtime's native. Otherwise unknown (would have to get by token name?). - event.body.amount.Denomination === '' - ? { - ...event.body.amount, - Amount: fromBaseUnits( - event.body.amount.Amount, - paraTimesConfig[runtime].decimals, - ), - Denomination: - event.body?.Denomination ?? - getTokensForScope({ network, layer: runtime })[0].ticker, - } - : event.body.amount, + ...event.body.amount, + Amount: fromBaseUnits(event.body.amount.Amount, paraTimesConfig[runtime].decimals), + Denomination: + event.body?.Denomination ?? getTokensForScope({ network, layer: runtime })[0].ticker, + }, }, layer: runtime, network, From 263ed4febdd951bce66bd9b993ed042d7e0cb7d6 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 12 Sep 2024 07:00:55 +0200 Subject: [PATCH 2/4] Fix denomination in Pontus-X events using TEST denomination --- src/oasis-nexus/api.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/oasis-nexus/api.ts b/src/oasis-nexus/api.ts index 4a36ee691..64e8cfb8f 100644 --- a/src/oasis-nexus/api.ts +++ b/src/oasis-nexus/api.ts @@ -850,7 +850,8 @@ export const useGetRuntimeEvents: typeof generated.useGetRuntimeEvents = ( ...event.body.amount, Amount: fromBaseUnits(event.body.amount.Amount, paraTimesConfig[runtime].decimals), Denomination: - event.body?.Denomination ?? getTokensForScope({ network, layer: runtime })[0].ticker, + event.body.amount.Denomination ?? + getTokensForScope({ network, layer: runtime })[0].ticker, }, }, layer: runtime, From 07cbb7e84e0f81564d6c89270091c51c2a3bdd72 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 12 Sep 2024 07:04:55 +0200 Subject: [PATCH 3/4] Fix native denomination fallback (Pontus-X events using EUROe) Until ba7990d36cf78b75cd5c1ea0666ce67fe41f04d5 all denominations were overwritten with native denomination. After it native denomination="" were displayed as "". --- src/oasis-nexus/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/oasis-nexus/api.ts b/src/oasis-nexus/api.ts index 64e8cfb8f..8a29cb0b4 100644 --- a/src/oasis-nexus/api.ts +++ b/src/oasis-nexus/api.ts @@ -846,11 +846,11 @@ export const useGetRuntimeEvents: typeof generated.useGetRuntimeEvents = ( body: { ...event.body, amount: { - // If there's no denomination then use runtime's native. Otherwise unknown (would have to get by token name?). + // If denomination="" or missing then use runtime's native. Otherwise unknown (would have to get by token name?). ...event.body.amount, Amount: fromBaseUnits(event.body.amount.Amount, paraTimesConfig[runtime].decimals), Denomination: - event.body.amount.Denomination ?? + event.body.amount.Denomination || getTokensForScope({ network, layer: runtime })[0].ticker, }, }, From 392b4e2ed39d48e9de8eea276cb084aac7b28419 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 12 Sep 2024 07:12:03 +0200 Subject: [PATCH 4/4] Add changelog --- .changelog/1539.bugfix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .changelog/1539.bugfix.md diff --git a/.changelog/1539.bugfix.md b/.changelog/1539.bugfix.md new file mode 100644 index 000000000..4e9c2680d --- /dev/null +++ b/.changelog/1539.bugfix.md @@ -0,0 +1 @@ +Fix non-native event denominations