Merge pull request #1067 from gnosis/bug/2.3.1-outgoing-transactions-not-showing
Bug: 2.3.1 Outgoing transactions not showing
This commit is contained in:
commit
941bed1423
|
@ -1,4 +1,3 @@
|
||||||
import memoize from 'lodash.memoize'
|
|
||||||
import logo from 'src/assets/icons/icon_etherTokens.svg'
|
import logo from 'src/assets/icons/icon_etherTokens.svg'
|
||||||
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
|
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
|
||||||
import {
|
import {
|
||||||
|
@ -26,7 +25,7 @@ export const getEthAsToken = (balance: string): Token => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isAddressAToken = async (tokenAddress): Promise<boolean> => {
|
export const isAddressAToken = async (tokenAddress: string): Promise<boolean> => {
|
||||||
// SECOND APPROACH:
|
// SECOND APPROACH:
|
||||||
// They both seem to work the same
|
// They both seem to work the same
|
||||||
// const tokenContract = await getStandardTokenContract()
|
// const tokenContract = await getStandardTokenContract()
|
||||||
|
@ -45,36 +44,49 @@ export const isTokenTransfer = (tx: any): boolean => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: any) => {
|
export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: any) => {
|
||||||
|
// "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85" - ens token contract, includes safeTransferFrom
|
||||||
|
// but no proper ERC721 standard implemented
|
||||||
return (
|
return (
|
||||||
(txCode && txCode.includes(SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH)) ||
|
(txCode &&
|
||||||
|
txCode.includes(SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH) &&
|
||||||
|
tx.to !== '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85') ||
|
||||||
(isTokenTransfer(tx) && !knownTokens.get(tx.to))
|
(isTokenTransfer(tx) && !knownTokens.get(tx.to))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getERC721Symbol = memoize(
|
export const getERC721Symbol = async (contractAddress: string): Promise<string> => {
|
||||||
async (contractAddress: string): Promise<string> => {
|
let tokenSymbol = 'UNKNOWN'
|
||||||
|
try {
|
||||||
const ERC721token = await getERC721TokenContract()
|
const ERC721token = await getERC721TokenContract()
|
||||||
const tokenInstance = await ERC721token.at(contractAddress)
|
const tokenInstance = await ERC721token.at(contractAddress)
|
||||||
return tokenInstance.symbol()
|
tokenSymbol = tokenInstance.symbol()
|
||||||
},
|
} catch (err) {
|
||||||
)
|
console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`)
|
||||||
|
}
|
||||||
|
return tokenSymbol
|
||||||
|
}
|
||||||
|
|
||||||
export const getERC20DecimalsAndSymbol = async (
|
export const getERC20DecimalsAndSymbol = async (
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
): Promise<{ decimals: number; symbol: string }> => {
|
): Promise<{ decimals: number; symbol: string }> => {
|
||||||
const tokenInfos = await getTokenInfos(tokenAddress)
|
const tokenInfo = { decimals: 18, symbol: 'UNKNOWN' }
|
||||||
|
try {
|
||||||
|
const storedTokenInfo = await getTokenInfos(tokenAddress)
|
||||||
|
|
||||||
if (tokenInfos === null) {
|
if (storedTokenInfo === null) {
|
||||||
const [tokenDecimals, tokenSymbol] = await generateBatchRequests({
|
const [tokenDecimals, tokenSymbol] = await generateBatchRequests({
|
||||||
abi: ALTERNATIVE_TOKEN_ABI,
|
abi: ALTERNATIVE_TOKEN_ABI,
|
||||||
address: tokenAddress,
|
address: tokenAddress,
|
||||||
methods: ['decimals', 'symbol'],
|
methods: ['decimals', 'symbol'],
|
||||||
})
|
})
|
||||||
|
|
||||||
return { decimals: Number(tokenDecimals), symbol: tokenSymbol }
|
return { decimals: Number(tokenDecimals), symbol: tokenSymbol }
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Failed to retrieve token info for ERC20 token ${tokenAddress}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return { decimals: Number(tokenInfos.decimals), symbol: tokenInfos.symbol }
|
return tokenInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isSendERC20Transaction = async (
|
export const isSendERC20Transaction = async (
|
||||||
|
|
|
@ -253,7 +253,20 @@ export const buildTx = async ({
|
||||||
const refundParams = await getRefundParams(tx, getERC20DecimalsAndSymbol)
|
const refundParams = await getRefundParams(tx, getERC20DecimalsAndSymbol)
|
||||||
const decodedParams = getDecodedParams(tx)
|
const decodedParams = getDecodedParams(tx)
|
||||||
const confirmations = getConfirmations(tx)
|
const confirmations = getConfirmations(tx)
|
||||||
const { decimals = 18, symbol = 'ETH' } = isSendERC20Tx ? await getERC20DecimalsAndSymbol(tx.to) : {}
|
|
||||||
|
let tokenDecimals = 18
|
||||||
|
let tokenSymbol = 'ETH'
|
||||||
|
try {
|
||||||
|
if (isSendERC20Tx) {
|
||||||
|
const { decimals, symbol } = await getERC20DecimalsAndSymbol(tx.to)
|
||||||
|
tokenDecimals = decimals
|
||||||
|
tokenSymbol = symbol
|
||||||
|
} else if (isSendERC721Tx) {
|
||||||
|
tokenSymbol = await getERC721Symbol(tx.to)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`Failed to retrieve token data from ${tx.to}`)
|
||||||
|
}
|
||||||
|
|
||||||
const txToStore = makeTransaction({
|
const txToStore = makeTransaction({
|
||||||
baseGas: tx.baseGas,
|
baseGas: tx.baseGas,
|
||||||
|
@ -263,7 +276,7 @@ export const buildTx = async ({
|
||||||
creationTx: tx.creationTx,
|
creationTx: tx.creationTx,
|
||||||
customTx: isCustomTx,
|
customTx: isCustomTx,
|
||||||
data: tx.data ? tx.data : EMPTY_DATA,
|
data: tx.data ? tx.data : EMPTY_DATA,
|
||||||
decimals,
|
decimals: tokenDecimals,
|
||||||
decodedParams,
|
decodedParams,
|
||||||
executionDate: tx.executionDate,
|
executionDate: tx.executionDate,
|
||||||
executionTxHash: tx.transactionHash,
|
executionTxHash: tx.transactionHash,
|
||||||
|
@ -286,7 +299,7 @@ export const buildTx = async ({
|
||||||
safeTxGas: tx.safeTxGas,
|
safeTxGas: tx.safeTxGas,
|
||||||
safeTxHash: tx.safeTxHash,
|
safeTxHash: tx.safeTxHash,
|
||||||
submissionDate: tx.submissionDate,
|
submissionDate: tx.submissionDate,
|
||||||
symbol: isSendERC721Tx ? await getERC721Symbol(tx.to) : symbol,
|
symbol: tokenSymbol,
|
||||||
upgradeTx: isUpgradeTx,
|
upgradeTx: isUpgradeTx,
|
||||||
value: tx.value.toString(),
|
value: tx.value.toString(),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue