From 3330e517812b099df66d53bd648ac724ca977633 Mon Sep 17 00:00:00 2001 From: Michal Zielenkiewicz Date: Wed, 6 Nov 2024 08:44:21 +0100 Subject: [PATCH] Avoid mutating transaction list --- src/vendors/nexus.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/vendors/nexus.ts b/src/vendors/nexus.ts index ae9f6c6ffa..0f4c597bc3 100644 --- a/src/vendors/nexus.ts +++ b/src/vendors/nexus.ts @@ -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({ @@ -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