Merge pull request #1010 from gnosis/feature/txsCollectibles
Collectibles Transactions + Add WalletLink Support
This commit is contained in:
commit
a5b4585049
|
@ -34,7 +34,6 @@ const createERC721TokenContract = async () => {
|
|||
const web3 = getWeb3()
|
||||
const erc721Token = await contract(ERC721)
|
||||
erc721Token.setProvider(web3.currentProvider)
|
||||
|
||||
return erc721Token
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import memoize from 'lodash.memoize'
|
||||
import logo from 'src/assets/icons/icon_etherTokens.svg'
|
||||
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
|
||||
import { getStandardTokenContract, getTokenInfos } from 'src/logic/tokens/store/actions/fetchTokens'
|
||||
import {
|
||||
getStandardTokenContract,
|
||||
getTokenInfos,
|
||||
getERC721TokenContract,
|
||||
} from 'src/logic/tokens/store/actions/fetchTokens'
|
||||
import { makeToken, Token } from 'src/logic/tokens/store/model/token'
|
||||
import { ALTERNATIVE_TOKEN_ABI } from 'src/logic/tokens/utils/alternativeAbi'
|
||||
import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3'
|
||||
|
@ -46,6 +51,14 @@ export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: an
|
|||
)
|
||||
}
|
||||
|
||||
export const getERC721Symbol = memoize(
|
||||
async (contractAddress: string): Promise<string> => {
|
||||
const ERC721token = await getERC721TokenContract()
|
||||
const tokenInstance = await ERC721token.at(contractAddress)
|
||||
return tokenInstance.symbol()
|
||||
},
|
||||
)
|
||||
|
||||
export const getERC20DecimalsAndSymbol = async (
|
||||
tokenAddress: string,
|
||||
): Promise<{ decimals: number; symbol: string }> => {
|
||||
|
|
|
@ -48,6 +48,7 @@ const wallets = [
|
|||
{ walletName: 'torus', desktop: true },
|
||||
{ walletName: 'unilogin', desktop: true },
|
||||
{ walletName: 'coinbase', desktop: false },
|
||||
{ walletName: 'walletLink', rpcUrl: infuraUrl, desktop: false },
|
||||
{ walletName: 'opera', desktop: false },
|
||||
{ walletName: 'operaTouch', desktop: false },
|
||||
]
|
||||
|
|
|
@ -58,7 +58,7 @@ const ReviewCollectible = ({ closeSnackbar, enqueueSnackbar, onClose, onPrev, tx
|
|||
const { fromWei, toBN } = getWeb3().utils
|
||||
|
||||
const supportsSafeTransfer = await containsMethodByHash(tx.assetAddress, SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH)
|
||||
const methodToCall = supportsSafeTransfer ? SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH : 'transfer'
|
||||
const methodToCall = supportsSafeTransfer ? `0x${SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH}` : 'transfer'
|
||||
const transferParams = [tx.recipientAddress, tx.nftTokenId]
|
||||
const params = methodToCall === 'transfer' ? transferParams : [safeAddress, ...transferParams]
|
||||
|
||||
|
|
|
@ -45,6 +45,10 @@ export const getTxAmount = (tx, formatted = true) => {
|
|||
const { decimals = 18, decodedParams, isTokenTransfer, symbol } = tx
|
||||
const { value } = isTokenTransfer && !!decodedParams && !!decodedParams.transfer ? decodedParams.transfer : tx
|
||||
|
||||
if (tx.isCollectibleTransfer) {
|
||||
return `1 ${tx.symbol}`
|
||||
}
|
||||
|
||||
if (!isTokenTransfer && !(Number(value) > 0)) {
|
||||
return NOT_AVAILABLE
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import { DecodedMethods, decodeMethods } from 'src/logic/contracts/methodIds'
|
|||
import { TOKEN_REDUCER_ID } from 'src/logic/tokens/store/reducer/tokens'
|
||||
import {
|
||||
getERC20DecimalsAndSymbol,
|
||||
getERC721Symbol,
|
||||
isSendERC20Transaction,
|
||||
isSendERC721Transaction,
|
||||
} from 'src/logic/tokens/utils/tokenHelpers'
|
||||
|
@ -285,7 +286,7 @@ export const buildTx = async ({
|
|||
safeTxGas: tx.safeTxGas,
|
||||
safeTxHash: tx.safeTxHash,
|
||||
submissionDate: tx.submissionDate,
|
||||
symbol,
|
||||
symbol: isSendERC721Tx ? await getERC721Symbol(tx.to) : symbol,
|
||||
upgradeTx: isUpgradeTx,
|
||||
value: tx.value.toString(),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue