fix catching errors during retrieving token symbols/decimals
This commit is contained in:
parent
46c227881a
commit
728bcc3f8e
|
@ -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
|
||||||
|
|
|
@ -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,19 +54,17 @@ 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()
|
const tokenInstance = await ERC721token.at(contractAddress)
|
||||||
const tokenInstance = await ERC721token.at(contractAddress)
|
tokenSymbol = tokenInstance.symbol()
|
||||||
tokenSymbol = tokenInstance.symbol()
|
} catch (err) {
|
||||||
} catch (err) {
|
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,
|
||||||
|
|
|
@ -256,13 +256,16 @@ export const buildTx = async ({
|
||||||
|
|
||||||
let tokenDecimals = 18
|
let tokenDecimals = 18
|
||||||
let tokenSymbol = 'ETH'
|
let tokenSymbol = 'ETH'
|
||||||
if (isSendERC20Tx) {
|
try {
|
||||||
const { decimals, symbol } = await getERC20DecimalsAndSymbol(tx.to)
|
if (isSendERC20Tx) {
|
||||||
tokenDecimals = decimals
|
const { decimals, symbol } = await getERC20DecimalsAndSymbol(tx.to)
|
||||||
tokenSymbol = symbol
|
tokenDecimals = decimals
|
||||||
} else if (isSendERC721Tx) {
|
tokenSymbol = symbol
|
||||||
const { symbol } = await getERC721Symbol(tx.to)
|
} else if (isSendERC721Tx) {
|
||||||
tokenSymbol = symbol
|
tokenSymbol = await getERC721Symbol(tx.to)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`Failed to retrieve token data from ${tx.to}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const txToStore = makeTransaction({
|
const txToStore = makeTransaction({
|
||||||
|
|
Loading…
Reference in New Issue