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' import { TX_SERVICE_HOST, RELAY_API_URL } from 'src/config/names'
const devMainnetConfig = { const prodMainnetConfig = {
...devConfig, ...prodConfig,
[TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1/', [TX_SERVICE_HOST]: 'https://safe-transaction.mainnet.gnosis.io/api/v1/',
[RELAY_API_URL]: 'https://safe-relay.mainnet.staging.gnosisdev.com/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 logo from 'src/assets/icons/icon_etherTokens.svg'
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests' import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
import { import {
@ -55,8 +54,7 @@ export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: an
) )
} }
export const getERC721Symbol = memoize( export const getERC721Symbol = async (contractAddress: string): Promise<string> => {
async (contractAddress: string): Promise<string> => {
let tokenSymbol = 'UNKNOWN' let tokenSymbol = 'UNKNOWN'
try { try {
const ERC721token = await getERC721TokenContract() const ERC721token = await getERC721TokenContract()
@ -66,8 +64,7 @@ export const getERC721Symbol = memoize(
console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`) console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`)
} }
return tokenSymbol return tokenSymbol
}, }
)
export const getERC20DecimalsAndSymbol = async ( export const getERC20DecimalsAndSymbol = async (
tokenAddress: string, tokenAddress: string,

View File

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