Merge branch 'development' into dependabot/npm_and_yarn/electron-7.2.4

This commit is contained in:
Mikhail Mikheev 2020-07-07 11:57:34 +04:00 committed by GitHub
commit 9f16375d71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "safe-react", "name": "safe-react",
"version": "2.5.1", "version": "2.5.2",
"description": "Allowing crypto users manage funds in a safer way", "description": "Allowing crypto users manage funds in a safer way",
"website": "https://github.com/gnosis/safe-react#readme", "website": "https://github.com/gnosis/safe-react#readme",
"bugs": { "bugs": {

View File

@ -9,7 +9,7 @@ import saveTokens from './saveTokens'
import generateBatchRequests from 'src/logic/contracts/generateBatchRequests' import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
import { fetchTokenList } from 'src/logic/tokens/api' import { fetchTokenList } from 'src/logic/tokens/api'
import { makeToken } from 'src/logic/tokens/store/model/token' import { makeToken, Token } from 'src/logic/tokens/store/model/token'
import { tokensSelector } from 'src/logic/tokens/store/selectors' import { tokensSelector } from 'src/logic/tokens/store/selectors'
import { getWeb3 } from 'src/logic/wallets/getWeb3' import { getWeb3 } from 'src/logic/wallets/getWeb3'
import { store } from 'src/store' import { store } from 'src/store'
@ -57,7 +57,7 @@ const getTokenValues = (tokenAddress) =>
methods: ['decimals', 'name', 'symbol'], methods: ['decimals', 'name', 'symbol'],
}) })
export const getTokenInfos = async (tokenAddress) => { export const getTokenInfos = async (tokenAddress: string): Promise<Token> => {
if (!tokenAddress) { if (!tokenAddress) {
return null return null
} }

View File

@ -10,6 +10,7 @@ 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'
import { isEmptyData } from 'src/routes/safe/store/actions/transactions/utils/transactionHelpers' import { isEmptyData } from 'src/routes/safe/store/actions/transactions/utils/transactionHelpers'
import { TxServiceModel } from 'src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions' import { TxServiceModel } from 'src/routes/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions'
import { Map } from 'immutable'
export const ETH_ADDRESS = '0x000' export const ETH_ADDRESS = '0x000'
export const SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH = '42842e0e' export const SAFE_TRANSFER_FROM_WITHOUT_DATA_HASH = '42842e0e'
@ -39,11 +40,15 @@ export const isAddressAToken = async (tokenAddress: string): Promise<boolean> =>
return call !== '0x' return call !== '0x'
} }
export const isTokenTransfer = (tx: any): boolean => { export const isTokenTransfer = (tx: TxServiceModel): boolean => {
return !isEmptyData(tx.data) && tx.data.substring(0, 10) === '0xa9059cbb' && Number(tx.value) === 0 return !isEmptyData(tx.data) && tx.data.substring(0, 10) === '0xa9059cbb' && Number(tx.value) === 0
} }
export const isSendERC721Transaction = (tx: any, txCode: string, knownTokens: any) => { export const isSendERC721Transaction = (
tx: TxServiceModel,
txCode: string,
knownTokens: Map<string, Token>,
): boolean => {
// "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85" - ens token contract, includes safeTransferFrom // "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85" - ens token contract, includes safeTransferFrom
// but no proper ERC721 standard implemented // but no proper ERC721 standard implemented
return ( return (
@ -79,9 +84,9 @@ export const getERC20DecimalsAndSymbol = async (
address: tokenAddress, address: tokenAddress,
methods: ['decimals', 'symbol'], methods: ['decimals', 'symbol'],
}) })
return { decimals: Number(tokenDecimals), symbol: tokenSymbol } return { decimals: Number(tokenDecimals), symbol: tokenSymbol }
} }
return { decimals: storedTokenInfo.decimals as number, symbol: storedTokenInfo.symbol }
} catch (err) { } catch (err) {
console.error(`Failed to retrieve token info for ERC20 token ${tokenAddress}`) console.error(`Failed to retrieve token info for ERC20 token ${tokenAddress}`)
} }
@ -92,7 +97,7 @@ export const getERC20DecimalsAndSymbol = async (
export const isSendERC20Transaction = async ( export const isSendERC20Transaction = async (
tx: TxServiceModel, tx: TxServiceModel,
txCode: string, txCode: string,
knownTokens: any, knownTokens: Map<string, Token>,
): Promise<boolean> => { ): Promise<boolean> => {
let isSendTokenTx = !isSendERC721Transaction(tx, txCode, knownTokens) && isTokenTransfer(tx) let isSendTokenTx = !isSendERC721Transaction(tx, txCode, knownTokens) && isTokenTransfer(tx)

View File

@ -66,7 +66,7 @@ export type OutgoingTxs = {
export type BatchProcessTxsProps = OutgoingTxs & { export type BatchProcessTxsProps = OutgoingTxs & {
currentUser?: string currentUser?: string
knownTokens: Record<string, Token> knownTokens: Map<string, Token>
safe: SafeRecord safe: SafeRecord
} }

View File

@ -85,7 +85,7 @@ export const isCustomTransaction = async (
tx: TxServiceModel, tx: TxServiceModel,
txCode: string, txCode: string,
safeAddress: string, safeAddress: string,
knownTokens: Record<string, Token>, knownTokens: Map<string, Token>,
): Promise<boolean> => { ): Promise<boolean> => {
return ( return (
isOutgoingTransaction(tx, safeAddress) && isOutgoingTransaction(tx, safeAddress) &&
@ -340,7 +340,7 @@ export const mockTransaction = (tx: TxToMock, safeAddress: string, state): Promi
...tx, ...tx,
} }
const knownTokens: Record<string, Token> = state[TOKEN_REDUCER_ID] const knownTokens: Map<string, Token> = state[TOKEN_REDUCER_ID]
const safe: SafeRecord = state[SAFE_REDUCER_ID].getIn([SAFE_REDUCER_ID, safeAddress]) const safe: SafeRecord = state[SAFE_REDUCER_ID].getIn([SAFE_REDUCER_ID, safeAddress])
const cancellationTxs = state[CANCELLATION_TRANSACTIONS_REDUCER_ID].get(safeAddress) || Map() const cancellationTxs = state[CANCELLATION_TRANSACTIONS_REDUCER_ID].get(safeAddress) || Map()
const outgoingTxs = state[TRANSACTIONS_REDUCER_ID].get(safeAddress) || List() const outgoingTxs = state[TRANSACTIONS_REDUCER_ID].get(safeAddress) || List()