Skip to content

Commit

Permalink
Merge pull request #1539 from oasisprotocol/lw/fix-nonnative-event-de…
Browse files Browse the repository at this point in the history
…nominations

Fix non-native event denominations
  • Loading branch information
lukaw3d authored Sep 12, 2024
2 parents 9b82575 + 392b4e2 commit 1386a1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions .changelog/1539.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix non-native event denominations
22 changes: 8 additions & 14 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,20 +845,14 @@ export const useGetRuntimeEvents: typeof generated.useGetRuntimeEvents = (
eth_tx_hash: adjustedHash,
body: {
...event.body,
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,
amount: {
// 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 ||
getTokensForScope({ network, layer: runtime })[0].ticker,
},
},
layer: runtime,
network,
Expand Down

0 comments on commit 1386a1b

Please sign in to comment.