Merge pull request #1010 from gnosis/feature/txsCollectibles

Collectibles Transactions + Add WalletLink Support
This commit is contained in:
Mati Dastugue 2020-06-18 11:33:21 -03:00 committed by GitHub
commit a5b4585049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 4 deletions

View File

@ -34,7 +34,6 @@ const createERC721TokenContract = async () => {
const web3 = getWeb3() const web3 = getWeb3()
const erc721Token = await contract(ERC721) const erc721Token = await contract(ERC721)
erc721Token.setProvider(web3.currentProvider) erc721Token.setProvider(web3.currentProvider)
return erc721Token return erc721Token
} }

View File

@ -1,6 +1,11 @@
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 { 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 { makeToken, Token } from 'src/logic/tokens/store/model/token'
import { ALTERNATIVE_TOKEN_ABI } from 'src/logic/tokens/utils/alternativeAbi' import { ALTERNATIVE_TOKEN_ABI } from 'src/logic/tokens/utils/alternativeAbi'
import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3' 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 ( export const getERC20DecimalsAndSymbol = async (
tokenAddress: string, tokenAddress: string,
): Promise<{ decimals: number; symbol: string }> => { ): Promise<{ decimals: number; symbol: string }> => {

View File

@ -48,6 +48,7 @@ const wallets = [
{ walletName: 'torus', desktop: true }, { walletName: 'torus', desktop: true },
{ walletName: 'unilogin', desktop: true }, { walletName: 'unilogin', desktop: true },
{ walletName: 'coinbase', desktop: false }, { walletName: 'coinbase', desktop: false },
{ walletName: 'walletLink', rpcUrl: infuraUrl, desktop: false },
{ walletName: 'opera', desktop: false }, { walletName: 'opera', desktop: false },
{ walletName: 'operaTouch', desktop: false }, { walletName: 'operaTouch', desktop: false },
] ]

View File

@ -58,7 +58,7 @@ const ReviewCollectible = ({ closeSnackbar, enqueueSnackbar, onClose, onPrev, tx
const { fromWei, toBN } = getWeb3().utils const { fromWei, toBN } = getWeb3().utils
const supportsSafeTransfer = await containsMethodByHash(tx.assetAddress, SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH) 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 transferParams = [tx.recipientAddress, tx.nftTokenId]
const params = methodToCall === 'transfer' ? transferParams : [safeAddress, ...transferParams] const params = methodToCall === 'transfer' ? transferParams : [safeAddress, ...transferParams]

View File

@ -45,6 +45,10 @@ export const getTxAmount = (tx, formatted = true) => {
const { decimals = 18, decodedParams, isTokenTransfer, symbol } = tx const { decimals = 18, decodedParams, isTokenTransfer, symbol } = tx
const { value } = isTokenTransfer && !!decodedParams && !!decodedParams.transfer ? decodedParams.transfer : tx const { value } = isTokenTransfer && !!decodedParams && !!decodedParams.transfer ? decodedParams.transfer : tx
if (tx.isCollectibleTransfer) {
return `1 ${tx.symbol}`
}
if (!isTokenTransfer && !(Number(value) > 0)) { if (!isTokenTransfer && !(Number(value) > 0)) {
return NOT_AVAILABLE return NOT_AVAILABLE
} }

View File

@ -4,6 +4,7 @@ import { DecodedMethods, decodeMethods } from 'src/logic/contracts/methodIds'
import { TOKEN_REDUCER_ID } from 'src/logic/tokens/store/reducer/tokens' import { TOKEN_REDUCER_ID } from 'src/logic/tokens/store/reducer/tokens'
import { import {
getERC20DecimalsAndSymbol, getERC20DecimalsAndSymbol,
getERC721Symbol,
isSendERC20Transaction, isSendERC20Transaction,
isSendERC721Transaction, isSendERC721Transaction,
} from 'src/logic/tokens/utils/tokenHelpers' } from 'src/logic/tokens/utils/tokenHelpers'
@ -285,7 +286,7 @@ export const buildTx = async ({
safeTxGas: tx.safeTxGas, safeTxGas: tx.safeTxGas,
safeTxHash: tx.safeTxHash, safeTxHash: tx.safeTxHash,
submissionDate: tx.submissionDate, submissionDate: tx.submissionDate,
symbol, symbol: isSendERC721Tx ? await getERC721Symbol(tx.to) : symbol,
upgradeTx: isUpgradeTx, upgradeTx: isUpgradeTx,
value: tx.value.toString(), value: tx.value.toString(),
}) })