From ab7fab365f98c80f62ecb34debca11b84d8befe8 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Mon, 6 Jul 2020 14:41:55 +0400 Subject: [PATCH 1/3] check if there as a pending transaction before marking transaction as a cancellation one --- .../fetchTransactions/loadOutgoingTransactions.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts b/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts index 9b2f8000..6c0f2736 100644 --- a/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts +++ b/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts @@ -79,7 +79,10 @@ export type BatchProcessTxsProps = OutgoingTxs & { const extractCancelAndOutgoingTxs = (safeAddress: string, outgoingTxs: TxServiceModel[]): OutgoingTxs => { return outgoingTxs.reduce( (acc, transaction) => { - if (isCancelTransaction(transaction, safeAddress)) { + if ( + isCancelTransaction(transaction, safeAddress) && + outgoingTxs.find((tx) => tx.nonce === transaction.nonce && !isCancelTransaction(tx, safeAddress)) + ) { if (!isNaN(Number(transaction.nonce))) { acc.cancellationTxs[transaction.nonce] = transaction } From 0f4c1325fd0ba0b131f5bfbd2ce6872c97b984a8 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Mon, 6 Jul 2020 14:42:33 +0400 Subject: [PATCH 2/3] update pkg.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4170f76..9d374de8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "2.5.0", + "version": "2.5.1", "description": "Allowing crypto users manage funds in a safer way", "website": "https://github.com/gnosis/safe-react#readme", "bugs": { From d5f05536c371b49cf77ddf6d3533f33313799189 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 6 Jul 2020 09:54:49 -0300 Subject: [PATCH 3/3] (Hotfix) Tx decoding (#1094) * Add types * Fix missing condition * Update Version --- package.json | 2 +- src/logic/tokens/store/actions/fetchTokens.ts | 4 ++-- src/logic/tokens/utils/tokenHelpers.ts | 13 +++++++++---- .../fetchTransactions/loadOutgoingTransactions.ts | 2 +- .../transactions/utils/transactionHelpers.ts | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 9d374de8..2f226d9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "2.5.1", + "version": "2.5.2", "description": "Allowing crypto users manage funds in a safer way", "website": "https://github.com/gnosis/safe-react#readme", "bugs": { diff --git a/src/logic/tokens/store/actions/fetchTokens.ts b/src/logic/tokens/store/actions/fetchTokens.ts index 83d551f2..a2156698 100644 --- a/src/logic/tokens/store/actions/fetchTokens.ts +++ b/src/logic/tokens/store/actions/fetchTokens.ts @@ -9,7 +9,7 @@ import saveTokens from './saveTokens' import generateBatchRequests from 'src/logic/contracts/generateBatchRequests' import { fetchTokenList } from 'src/logic/tokens/api' -import { makeToken } from 'src/logic/tokens/store/model/token' +import { makeToken, Token } from 'src/logic/tokens/store/model/token' import { tokensSelector } from 'src/logic/tokens/store/selectors' import { getWeb3 } from 'src/logic/wallets/getWeb3' import { store } from 'src/store' @@ -57,7 +57,7 @@ const getTokenValues = (tokenAddress) => methods: ['decimals', 'name', 'symbol'], }) -export const getTokenInfos = async (tokenAddress) => { +export const getTokenInfos = async (tokenAddress: string): Promise => { if (!tokenAddress) { return null } diff --git a/src/logic/tokens/utils/tokenHelpers.ts b/src/logic/tokens/utils/tokenHelpers.ts index 4fab2c79..24ecffe4 100644 --- a/src/logic/tokens/utils/tokenHelpers.ts +++ b/src/logic/tokens/utils/tokenHelpers.ts @@ -10,6 +10,7 @@ import { ALTERNATIVE_TOKEN_ABI } from 'src/logic/tokens/utils/alternativeAbi' import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3' import { isEmptyData } from 'src/routes/safe/store/actions/transactions/utils/transactionHelpers' import { TxServiceModel } from 'src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions' +import { Map } from 'immutable' export const ETH_ADDRESS = '0x000' export const SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH = '42842e0e' @@ -39,11 +40,15 @@ export const isAddressAToken = async (tokenAddress: string): Promise => return call !== '0x' } -export const isTokenTransfer = (tx: any): boolean => { +export const isTokenTransfer = (tx: TxServiceModel): boolean => { return !isEmptyData(tx.data) && tx.data.substring(0, 10) === '0xa9059cbb' && Number(tx.value) === 0 } -export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: any) => { +export const isSendERC721Transaction = ( + tx: TxServiceModel, + txCode: string, + knownTokens: Map, +): boolean => { // "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85" - ens token contract, includes safeTransferFrom // but no proper ERC721 standard implemented return ( @@ -79,9 +84,9 @@ export const getERC20DecimalsAndSymbol = async ( address: tokenAddress, methods: ['decimals', 'symbol'], }) - return { decimals: Number(tokenDecimals), symbol: tokenSymbol } } + return { decimals: storedTokenInfo.decimals as number, symbol: storedTokenInfo.symbol } } catch (err) { console.error(`Failed to retrieve token info for ERC20 token ${tokenAddress}`) } @@ -92,7 +97,7 @@ export const getERC20DecimalsAndSymbol = async ( export const isSendERC20Transaction = async ( tx: TxServiceModel, txCode: string, - knownTokens: any, + knownTokens: Map, ): Promise => { let isSendTokenTx = !isSendERC721Transaction(tx, txCode, knownTokens) && isTokenTransfer(tx) diff --git a/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts b/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts index 6c0f2736..b88911bc 100644 --- a/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts +++ b/src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions.ts @@ -66,7 +66,7 @@ export type OutgoingTxs = { export type BatchProcessTxsProps = OutgoingTxs & { currentUser?: string - knownTokens: Record + knownTokens: Map safe: SafeRecord } diff --git a/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts b/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts index ba8de692..6b96983d 100644 --- a/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts +++ b/src/routes/safe/store/actions/transactions/utils/transactionHelpers.ts @@ -85,7 +85,7 @@ export const isCustomTransaction = async ( tx: TxServiceModel, txCode: string, safeAddress: string, - knownTokens: Record, + knownTokens: Map, ): Promise => { return ( isOutgoingTransaction(tx, safeAddress) && @@ -340,7 +340,7 @@ export const mockTransaction = (tx: TxToMock, safeAddress: string, state): Promi ...tx, } - const knownTokens: Record = state[TOKEN_REDUCER_ID] + const knownTokens: Map = state[TOKEN_REDUCER_ID] const safe: SafeRecord = state[SAFE_REDUCER_ID].getIn([SAFE_REDUCER_ID, safeAddress]) const cancellationTxs = state[CANCELLATION_TRANSACTIONS_REDUCER_ID].get(safeAddress) || Map() const outgoingTxs = state[TRANSACTIONS_REDUCER_ID].get(safeAddress) || List()