From 9310fe298fe4f65e37b7cb5c96fe93f4b1f109f6 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Wed, 2 Sep 2020 17:55:25 +0200 Subject: [PATCH 1/3] Fix fees not showing in transaction details --- .../store/actions/transactions/utils/transactionHelpers.ts | 3 +++ src/logic/safe/transactions/incomingTxHistory.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts b/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts index 5349d7b669..8a7b395369 100644 --- a/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts +++ b/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts @@ -7,6 +7,7 @@ import { isSendERC20Transaction, isSendERC721Transaction, } from 'src/logic/tokens/utils/tokenHelpers' +import { getWeb3 } from 'src/logic/wallets/getWeb3' import { sameAddress, ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses' import { EMPTY_DATA } from 'src/logic/wallets/ethTransactions' import { makeConfirmation } from 'src/logic/safe/store/models/confirmation' @@ -241,6 +242,7 @@ export const buildTx = async ({ tx, txCode, }: BuildTx): Promise => { + const { fromWei, toBN } = getWeb3().utils const safeAddress = safe.address const isModifySettingsTx = isModifySettingsTransaction(tx, safeAddress) const isTxCancelled = isTransactionCancelled(tx, outgoingTxs, cancellationTxs) @@ -282,6 +284,7 @@ export const buildTx = async ({ executionDate: tx.executionDate, executionTxHash: tx.transactionHash, executor: tx.executor, + fee: tx.fee ? fromWei(toBN(tx.fee)) : null, gasPrice: tx.gasPrice, gasToken: tx.gasToken || ZERO_ADDRESS, isCancellationTx, diff --git a/src/logic/safe/transactions/incomingTxHistory.ts b/src/logic/safe/transactions/incomingTxHistory.ts index 6e6b19cbe1..c7d78e5476 100644 --- a/src/logic/safe/transactions/incomingTxHistory.ts +++ b/src/logic/safe/transactions/incomingTxHistory.ts @@ -1,7 +1,7 @@ import { getIncomingTxServiceUriTo, getTxServiceHost } from 'src/config' import { checksumAddress } from 'src/utils/checksumAddress' -export const buildIncomingTxServiceUrl = (safeAddress) => { +export const buildIncomingTxServiceUrl = (safeAddress: string): string => { const host = getTxServiceHost() const address = checksumAddress(safeAddress) const base = getIncomingTxServiceUriTo(address) From 5e9acb29cc15cc55c561a958583c1b7c99b00fdb Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 7 Sep 2020 12:09:21 +0200 Subject: [PATCH 2/3] Convert fee from wei only when showing extended transaction Fix incoming transactions fee value to display correct value --- src/logic/contracts/generateBatchRequests.ts | 5 +++++ .../fetchTransactions/loadIncomingTransactions.ts | 11 ++++++++--- .../actions/transactions/utils/transactionHelpers.ts | 4 +--- .../Transactions/TxsTable/ExpandedTx/index.tsx | 5 ++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/logic/contracts/generateBatchRequests.ts b/src/logic/contracts/generateBatchRequests.ts index 7ad47d92e2..2d48979bd8 100644 --- a/src/logic/contracts/generateBatchRequests.ts +++ b/src/logic/contracts/generateBatchRequests.ts @@ -40,6 +40,7 @@ const generateBatchRequests = ({ abi, address, batch, context, methods }: any): request = contractInstance.methods[method](...args).call.request(resolver) } + // If batch was provided add to external batch batch ? batch.add(request) : localBatch.add(request) } catch (e) { resolve(null) @@ -47,6 +48,10 @@ const generateBatchRequests = ({ abi, address, batch, context, methods }: any): }) }) + // TODO fix this so all batch.execute() are handled here + // If batch was created locally we can already execute it + // If batch was provided we should execute once we finish to generate the batch, + // in the outside function where the batch object is created. !batch && localBatch.execute() const returnValues = context ? [context, ...values] : values diff --git a/src/logic/safe/store/actions/transactions/fetchTransactions/loadIncomingTransactions.ts b/src/logic/safe/store/actions/transactions/fetchTransactions/loadIncomingTransactions.ts index f2e5acda2b..ec79aa234a 100644 --- a/src/logic/safe/store/actions/transactions/fetchTransactions/loadIncomingTransactions.ts +++ b/src/logic/safe/store/actions/transactions/fetchTransactions/loadIncomingTransactions.ts @@ -45,7 +45,12 @@ const batchIncomingTxsTokenDataRequest = (txs: IncomingTxServiceModel[]) => { const batch = new web3ReadOnly.BatchRequest() const whenTxsValues = txs.map((tx) => { - const methods = ['symbol', 'decimals', { method: 'getTransaction', args: [tx.transactionHash], type: 'eth' }] + const methods = [ + 'symbol', + 'decimals', + { method: 'getTransaction', args: [tx.transactionHash], type: 'eth' }, + { method: 'getTransactionReceipt', args: [tx.transactionHash], type: 'eth' }, + ] return generateBatchRequests({ abi: ALTERNATIVE_TOKEN_ABI, @@ -59,11 +64,11 @@ const batchIncomingTxsTokenDataRequest = (txs: IncomingTxServiceModel[]) => { batch.execute() return Promise.all(whenTxsValues).then((txsValues) => - txsValues.map(([tx, symbol, decimals, { gas, gasPrice }]) => [ + txsValues.map(([tx, symbol, decimals, { gasPrice }, { gasUsed }]) => [ tx, symbol === null ? 'ETH' : symbol, decimals === null ? '18' : decimals, - new bn(gas).div(gasPrice).toFixed(), + new bn(gasPrice).times(gasUsed), ]), ) } diff --git a/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts b/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts index e3eab1f65e..db80263277 100644 --- a/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts +++ b/src/logic/safe/store/actions/transactions/utils/transactionHelpers.ts @@ -7,7 +7,6 @@ import { isSendERC20Transaction, isSendERC721Transaction, } from 'src/logic/tokens/utils/tokenHelpers' -import { getWeb3 } from 'src/logic/wallets/getWeb3' import { sameAddress, ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses' import { EMPTY_DATA } from 'src/logic/wallets/ethTransactions' import { makeConfirmation } from 'src/logic/safe/store/models/confirmation' @@ -243,7 +242,6 @@ export const buildTx = async ({ tx, txCode, }: BuildTx): Promise => { - const { fromWei, toBN } = getWeb3().utils const safeAddress = safe.address const isModifySettingsTx = isModifySettingsTransaction(tx, safeAddress) const isTxCancelled = isTransactionCancelled(tx, outgoingTxs, cancellationTxs) @@ -284,7 +282,7 @@ export const buildTx = async ({ executionDate: tx.executionDate, executionTxHash: tx.transactionHash, executor: tx.executor, - fee: tx.fee ? fromWei(toBN(tx.fee)) : null, + fee: tx.fee, gasPrice: tx.gasPrice, gasToken: tx.gasToken || ZERO_ADDRESS, isCancellationTx, diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx index 82697cb2b8..60fdf6213a 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx @@ -21,6 +21,7 @@ import Hairline from 'src/components/layout/Hairline' import Paragraph from 'src/components/layout/Paragraph' import Row from 'src/components/layout/Row' import Span from 'src/components/layout/Span' +import { getWeb3 } from 'src/logic/wallets/getWeb3' import { INCOMING_TX_TYPES } from 'src/logic/safe/store/models/incomingTransaction' import { safeNonceSelector, safeThresholdSelector } from 'src/logic/safe/store/selectors' import { Transaction, TransactionTypes } from 'src/logic/safe/store/models/types/transaction' @@ -34,6 +35,8 @@ interface ExpandedTxProps { } const ExpandedTx = ({ cancelTx, tx }: ExpandedTxProps): React.ReactElement => { + const { fromWei, toBN } = getWeb3().utils + const classes = useStyles() const nonce = useSelector(safeNonceSelector) const threshold = useSelector(safeThresholdSelector) as number @@ -85,7 +88,7 @@ const ExpandedTx = ({ cancelTx, tx }: ExpandedTxProps): React.ReactElement => { {!isCreationTx ? ( Fee: - {tx.fee ? tx.fee : 'n/a'} + {tx.fee ? fromWei(toBN(tx.fee)) : 'n/a'} ) : null} From 73b982dbe70b2f8418f0849ee8da01bfc7b416a4 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 7 Sep 2020 12:21:46 +0200 Subject: [PATCH 3/3] Add ETH symbol to fee on details --- .../safe/components/Transactions/TxsTable/ExpandedTx/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx index 60fdf6213a..7bd08ad8c7 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.tsx @@ -88,7 +88,7 @@ const ExpandedTx = ({ cancelTx, tx }: ExpandedTxProps): React.ReactElement => { {!isCreationTx ? ( Fee: - {tx.fee ? fromWei(toBN(tx.fee)) : 'n/a'} + {tx.fee ? fromWei(toBN(tx.fee)) + ' ETH' : 'n/a'} ) : null}