From c0f9db99d42b67223841cb1c40a467cd9c0a59ec Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 9 Jun 2021 18:21:52 +0800 Subject: [PATCH] add withdrawals to transaction amount --- .../app/domain/CardanoShelleyTransaction.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js b/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js index 821b4515e7..0c4669d7d6 100644 --- a/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js +++ b/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js @@ -73,6 +73,17 @@ export default class CardanoShelleyTransaction extends WalletTransaction { throw new Error(`${nameof(CardanoShelleyTransaction)}::${this.constructor.fromAnnotatedTx} missing extra data`); } + const withdrawals = toAddr({ + rows: tx.accountingInputs, + addressLookupMap, + tokens: tx.tokens, + defaultToken, + }); + const amount = tx.amount.joinAddCopy(tx.fee); + for (const {value} of withdrawals) { + amount.joinAddMutable(value); + } + return new CardanoShelleyTransaction({ txid: tx.transaction.Hash, block: tx.block, @@ -89,7 +100,7 @@ export default class CardanoShelleyTransaction extends WalletTransaction { ), ttl: Extra.Ttl != null ? new BigNumber(Extra.Ttl) : undefined, metadata: Extra.Metadata, - amount: tx.amount.joinAddCopy(tx.fee), + amount, date: tx.block != null ? tx.block.BlockTime : new Date(tx.transaction.LastUpdateTime), @@ -97,12 +108,7 @@ export default class CardanoShelleyTransaction extends WalletTransaction { from: toAddr({ rows: tx.utxoInputs, addressLookupMap, tokens: tx.tokens, defaultToken, }), to: toAddr({ rows: tx.utxoOutputs, addressLookupMap, tokens: tx.tokens, defaultToken, }), }, - withdrawals: toAddr({ - rows: tx.accountingInputs, - addressLookupMap, - tokens: tx.tokens, - defaultToken, - }), + withdrawals, certificates: tx.certificates, state: tx.transaction.Status, errorMsg: tx.transaction.ErrorMessage,