mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-28 10:25:17 +00:00
* Fix fetch symbol for incoming txs * Fix getting symbol promise from erc721 * Adda ens contract addresses for different networks
This commit is contained in:
parent
3c795462b7
commit
9f1dc37bbb
@ -1,4 +1,4 @@
|
|||||||
import { getNetworkId } from 'src/config'
|
import { getNetworkId, getNetworkInfo } from 'src/config'
|
||||||
import { ETHEREUM_NETWORK } from 'src/config/networks/network.d'
|
import { ETHEREUM_NETWORK } from 'src/config/networks/network.d'
|
||||||
import { nftAssetsListAddressesSelector } from 'src/logic/collectibles/store/selectors'
|
import { nftAssetsListAddressesSelector } from 'src/logic/collectibles/store/selectors'
|
||||||
import { TxServiceModel } from 'src/logic/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions'
|
import { TxServiceModel } from 'src/logic/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions'
|
||||||
@ -18,6 +18,14 @@ export const CK_ADDRESS = {
|
|||||||
[ETHEREUM_NETWORK.RINKEBY]: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf',
|
[ETHEREUM_NETWORK.RINKEBY]: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: xDAI ENS is missing, once we have it we need to add it here
|
||||||
|
const ENS_CONTRACT_ADDRESS = {
|
||||||
|
[ETHEREUM_NETWORK.MAINNET]: '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85',
|
||||||
|
[ETHEREUM_NETWORK.RINKEBY]: '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85',
|
||||||
|
[ETHEREUM_NETWORK.ENERGY_WEB_CHAIN]: '0x0A6d64413c07E10E890220BBE1c49170080C6Ca0',
|
||||||
|
[ETHEREUM_NETWORK.VOLTA]: '0xd7CeF70Ba7efc2035256d828d5287e2D285CD1ac',
|
||||||
|
}
|
||||||
|
|
||||||
// safeTransferFrom(address,address,uint256)
|
// safeTransferFrom(address,address,uint256)
|
||||||
export const SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH = '42842e0e'
|
export const SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH = '42842e0e'
|
||||||
|
|
||||||
@ -50,12 +58,11 @@ export const getERC721Symbol = async (contractAddress: string): Promise<string>
|
|||||||
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 = await tokenInstance.symbol()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// If the contract address is an ENS token contract, we know that the ERC721 standard is not proper implemented
|
// If the contract address is an ENS token contract, we know that the ERC721 standard is not proper implemented
|
||||||
// The method symbol() is missing
|
// The method symbol() is missing
|
||||||
const ENS_TOKEN_CONTRACT = '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85'
|
if (isENSContract(contractAddress)) {
|
||||||
if (sameAddress(contractAddress, ENS_TOKEN_CONTRACT)) {
|
|
||||||
return 'ENS'
|
return 'ENS'
|
||||||
}
|
}
|
||||||
console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`)
|
console.error(`Failed to retrieve token symbol for ERC721 token ${contractAddress}`)
|
||||||
@ -64,6 +71,11 @@ export const getERC721Symbol = async (contractAddress: string): Promise<string>
|
|||||||
return tokenSymbol
|
return tokenSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isENSContract = (contractAddress: string): boolean => {
|
||||||
|
const { id } = getNetworkInfo()
|
||||||
|
return sameAddress(contractAddress, ENS_CONTRACT_ADDRESS[id])
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies if the provided contract is a valid ERC721
|
* Verifies if the provided contract is a valid ERC721
|
||||||
* @param {string} contractAddress
|
* @param {string} contractAddress
|
||||||
|
@ -10,6 +10,7 @@ import { web3ReadOnly } from 'src/logic/wallets/getWeb3'
|
|||||||
import { makeIncomingTransaction } from 'src/logic/safe/store/models/incomingTransaction'
|
import { makeIncomingTransaction } from 'src/logic/safe/store/models/incomingTransaction'
|
||||||
import fetchTransactions from 'src/logic/safe/store/actions/transactions/fetchTransactions/fetchTransactions'
|
import fetchTransactions from 'src/logic/safe/store/actions/transactions/fetchTransactions/fetchTransactions'
|
||||||
import { TransactionTypes } from 'src/logic/safe/store/models/types/transaction'
|
import { TransactionTypes } from 'src/logic/safe/store/models/types/transaction'
|
||||||
|
import { isENSContract } from 'src/logic/collectibles/utils'
|
||||||
|
|
||||||
export type IncomingTxServiceModel = {
|
export type IncomingTxServiceModel = {
|
||||||
blockNumber: number
|
blockNumber: number
|
||||||
@ -76,12 +77,18 @@ const batchIncomingTxsTokenDataRequest = (txs: IncomingTxServiceModel[]) => {
|
|||||||
batch.execute()
|
batch.execute()
|
||||||
|
|
||||||
return Promise.all(whenTxsValues).then((txsValues) =>
|
return Promise.all(whenTxsValues).then((txsValues) =>
|
||||||
txsValues.map(([tx, symbol, decimals, ethTx, ethTxReceipt]) => [
|
txsValues.map(([tx, symbolFetched, decimals, ethTx, ethTxReceipt]) => {
|
||||||
tx,
|
let symbol = symbolFetched
|
||||||
symbol ? symbol : nativeCoin.symbol,
|
if (!symbolFetched) {
|
||||||
decimals ? decimals : nativeCoin.decimals,
|
symbol = isENSContract(tx.tokenAddress) ? 'ENS' : nativeCoin.symbol
|
||||||
new bn(ethTx?.gasPrice ?? 0).times(ethTxReceipt?.gasUsed ?? 0),
|
}
|
||||||
]),
|
return [
|
||||||
|
tx,
|
||||||
|
symbol,
|
||||||
|
decimals ? decimals : nativeCoin.decimals,
|
||||||
|
new bn(ethTx?.gasPrice ?? 0).times(ethTxReceipt?.gasUsed ?? 0),
|
||||||
|
]
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user