fix catching errors during retrieving token symbols/decimals

This commit is contained in:
Mikhail Mikheev 2020-06-26 13:34:12 +04:00
parent 46c227881a
commit 728bcc3f8e
3 changed files with 27 additions and 27 deletions

View File

@ -1,11 +1,11 @@
//
import devConfig from './development'
import prodConfig from './production'
import { TX_SERVICE_HOST, RELAY_API_URL } from 'src/config/names'
const devMainnetConfig = {
...devConfig,
[TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1/',
[RELAY_API_URL]: 'https://safe-relay.mainnet.staging.gnosisdev.com/api/v1/',
const prodMainnetConfig = {
...prodConfig,
[TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.gnosis.io/api/v1/',
[RELAY_API_URL]: 'https://safe-relay.gnosis.io/api/v1/',
}
export default devMainnetConfig
export default prodMainnetConfig

View File

@ -1,4 +1,3 @@
import memoize from 'lodash.memoize'
import logo from 'src/assets/icons/icon_etherTokens.svg'
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
import {
@ -55,8 +54,7 @@ export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: an
)
}
export const getERC721Symbol = memoize(
async (contractAddress: string): Promise<string> => {
export const getERC721Symbol = async (contractAddress: string): Promise<string> => {
let tokenSymbol = 'UNKNOWN'
try {
const ERC721token = await getERC721TokenContract()
@ -66,8 +64,7 @@ export const getERC721Symbol = memoize(
console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`)
}
return tokenSymbol
},
)
}
export const getERC20DecimalsAndSymbol = async (
tokenAddress: string,

View File

@ -256,13 +256,16 @@ export const buildTx = async ({
let tokenDecimals = 18
let tokenSymbol = 'ETH'
try {
if (isSendERC20Tx) {
const { decimals, symbol } = await getERC20DecimalsAndSymbol(tx.to)
tokenDecimals = decimals
tokenSymbol = symbol
} else if (isSendERC721Tx) {
const { symbol } = await getERC721Symbol(tx.to)
tokenSymbol = symbol
tokenSymbol = await getERC721Symbol(tx.to)
}
} catch (err) {
console.log(`Failed to retrieve token data from ${tx.to}`)
}
const txToStore = makeTransaction({