Skip to content

Commit

Permalink
Avoid mutating transaction list
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Nov 6, 2024
1 parent a1132ab commit f40ecfd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/vendors/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function getNexusAPIs(url: string | 'https://nexus.oasis.io/v1/') {
)

// Temporary workaround for missing amount in staking.ReclaimEscrow
await Promise.all(
const transactionsWithFixedAmount = await Promise.all(
mergedTransactions.map(async transaction => {
if (transaction.method === ConsensusTxMethod.StakingReclaimEscrow) {
const eventsResponse = await api.consensusEventsGet({
Expand All @@ -119,17 +119,19 @@ export function getNexusAPIs(url: string | 'https://nexus.oasis.io/v1/') {
type: ConsensusEventType.StakingEscrowDebondingStart,
})
const amount = (eventsResponse.events[0].body as { amount?: number })?.amount
if (transaction.body) {
;(transaction.body as { amount?: typeof amount }).amount = amount
return {
...transaction,
body: {
...transaction.body,
amount,
},
}
return transaction
}

return transaction
return { ...transaction }
}),
)

return parseTransactionsList(mergedTransactions)
return parseTransactionsList(transactionsWithFixedAmount)
} catch (error) {
console.error('Could not fetch Nexus', error)
throw error
Expand Down

0 comments on commit f40ecfd

Please sign in to comment.