merge with develop

This commit is contained in:
Mati Dastugue 2020-07-16 12:13:06 -03:00
commit f9a345d200
37 changed files with 156 additions and 1037 deletions

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ dist
electron-builder.yml
.yalc/
yalc.lock
# testing
/coverage/

View File

@ -38,6 +38,7 @@ after_success:
- ./config/travis/deploy_pull_request.sh
# Releases (tagged commits) - Deploy it to a release environment
- ./config/travis/deploy_release.sh
- yarn coveralls
deploy:
# Development environment

View File

@ -6,4 +6,5 @@ if [[ -n "$TRAVIS_TAG" ]]; then export REACT_APP_ENV='production'; fi
yarn lint:check
yarn prettier:check
yarn test:coverage
yarn build

View File

@ -1,6 +1,6 @@
{
"name": "safe-react",
"version": "2.5.2",
"version": "2.6.1",
"description": "Allowing crypto users manage funds in a safer way",
"website": "https://github.com/gnosis/safe-react#readme",
"bugs": {
@ -36,7 +36,9 @@
"release": "electron-builder --mac --linux --windows -p always",
"start-mainnet": "REACT_APP_NETWORK=mainnet yarn start",
"start": "react-app-rewired start",
"test": "NODE_ENV=test && react-app-rewired test --env=jsdom"
"test": "NODE_ENV=test && react-app-rewired test --env=jsdom",
"test:coverage": "yarn test --coverage --watchAll=false",
"coveralls": "cat ./coverage/lcov.info | coveralls"
},
"husky": {
"hooks": {
@ -49,6 +51,15 @@
"prettier --write"
]
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.{.test.*}",
"!src/**/test/**/*",
"!src/**/assets/**",
"!src/config/**/*"
]
},
"productName": "Safe Multisig",
"build": {
"appId": "io.gnosis.safe.macos",
@ -163,6 +174,7 @@
"classnames": "^2.2.6",
"concurrently": "^5.2.0",
"connected-react-router": "6.8.0",
"coveralls": "^3.1.0",
"currency-flags": "2.1.2",
"date-fns": "2.14.0",
"electron-is-dev": "^1.1.0",
@ -241,6 +253,7 @@
"truffle": "5.1.33",
"typescript": "3.9.6",
"wait-on": "5.0.1",
"web3-core": "^1.2.9",
"web3-eth-contract": "^1.2.9",
"web3-utils": "^1.2.8"
}

View File

@ -64,7 +64,7 @@ const AddressInfo = ({ ethBalance, safeAddress, safeName }: Props) => {
{ethBalance && (
<StyledBlock>
<Paragraph noMargin>
Balance: <Bold>{`${ethBalance} ETH`}</Bold>
Balance: <Bold data-testid="current-eth-balance">{`${ethBalance} ETH`}</Bold>
</Paragraph>
</StyledBlock>
)}

View File

@ -3,7 +3,10 @@ import Web3 from 'web3'
import { sameAddress } from './ethAddresses'
import { EMPTY_DATA } from './ethTransactions'
import { getNetwork } from 'src/config/index'
import { getNetwork } from '../../config'
import { ContentHash } from 'web3-eth-ens'
import { provider as Provider } from 'web3-core'
import { ProviderProps } from './store/model/provider'
export const ETHEREUM_NETWORK = {
MAINNET: 'MAINNET',
@ -48,14 +51,14 @@ export const ETHEREUM_NETWORK_IDS = {
42: ETHEREUM_NETWORK.KOVAN,
}
export const getEtherScanLink = (type, value) => {
export const getEtherScanLink = (type: string, value: string): string => {
const network = getNetwork()
return `https://${
network.toLowerCase() === 'mainnet' ? '' : `${network.toLowerCase()}.`
}etherscan.io/${type}/${value}`
}
export const getInfuraUrl = () => {
export const getInfuraUrl = (): string => {
const isMainnet = process.env.REACT_APP_NETWORK === 'mainnet'
return `https://${isMainnet ? 'mainnet' : 'rinkeby'}.infura.io:443/v3/${process.env.REACT_APP_INFURA_TOKEN}`
@ -66,39 +69,41 @@ export const getInfuraUrl = () => {
export const web3ReadOnly =
process.env.NODE_ENV !== 'test'
? new Web3(new Web3.providers.HttpProvider(getInfuraUrl()))
: new Web3((window as any).web3.currentProvider)
: new Web3(window.web3?.currentProvider || 'ws://localhost:8545')
let web3 = web3ReadOnly
export const getWeb3 = () => web3
export const getWeb3 = (): Web3 => web3
export const resetWeb3 = () => {
export const resetWeb3 = (): void => {
web3 = web3ReadOnly
}
export const getAccountFrom = async (web3Provider) => {
export const getAccountFrom = async (web3Provider: Web3): Promise<string | null> => {
const accounts = await web3Provider.eth.getAccounts()
if (process.env.NODE_ENV === 'test' && (window as any).testAccountIndex) {
return accounts[(window as any).testAccountIndex]
if (process.env.NODE_ENV === 'test' && window.testAccountIndex) {
return accounts[window.testAccountIndex]
}
return accounts && accounts.length > 0 ? accounts[0] : null
}
export const getNetworkIdFrom = (web3Provider) => web3Provider.eth.net.getId()
export const getNetworkIdFrom = (web3Provider: Web3): Promise<number> => web3Provider.eth.net.getId()
const isHardwareWallet = (walletName) =>
const isHardwareWallet = (walletName: string) =>
sameAddress(WALLET_PROVIDER.LEDGER, walletName) || sameAddress(WALLET_PROVIDER.TREZOR, walletName)
const isSmartContractWallet = async (web3Provider, account) => {
const isSmartContractWallet = async (web3Provider: Web3, account: string): Promise<boolean> => {
const contractCode = await web3Provider.eth.getCode(account)
return contractCode.replace(EMPTY_DATA, '').replace(/0/g, '') !== ''
}
export const getProviderInfo = async (web3Provider, providerName = 'Wallet') => {
export const getProviderInfo = async (
web3Provider: string | Provider,
providerName = 'Wallet',
): Promise<ProviderProps> => {
web3 = new Web3(web3Provider)
const account = await getAccountFrom(web3)
const network = await getNetworkIdFrom(web3)
const smartContractWallet = await isSmartContractWallet(web3, account)
@ -117,15 +122,15 @@ export const getProviderInfo = async (web3Provider, providerName = 'Wallet') =>
}
}
export const getAddressFromENS = (name: string) => web3.eth.ens.getAddress(name)
export const getAddressFromENS = (name: string): Promise<string> => web3.eth.ens.getAddress(name)
export const getContentFromENS = (name: string) => web3.eth.ens.getContenthash(name)
export const getContentFromENS = (name: string): Promise<ContentHash> => web3.eth.ens.getContenthash(name)
export const setWeb3 = (provider) => {
export const setWeb3 = (provider: Provider): void => {
web3 = new Web3(provider)
}
export const getBalanceInEtherOf = async (safeAddress) => {
export const getBalanceInEtherOf = async (safeAddress: string): Promise<string> => {
if (!web3) {
return '0'
}

View File

@ -8,6 +8,7 @@ import enqueueSnackbar from 'src/logic/notifications/store/actions/enqueueSnackb
import { ETHEREUM_NETWORK, ETHEREUM_NETWORK_IDS, getProviderInfo, getWeb3 } from 'src/logic/wallets/getWeb3'
import { makeProvider } from 'src/logic/wallets/store/model/provider'
import { updateStoredTransactionsStatus } from 'src/routes/safe/store/actions/transactions/utils/transactionHelpers'
import { Dispatch } from 'redux'
export const processProviderResponse = (dispatch, provider) => {
const walletRecord = makeProvider(provider)
@ -48,9 +49,9 @@ const handleProviderNotification = (provider, dispatch) => {
}
}
export default (providerName) => async (dispatch) => {
export default (providerName: string) => async (dispatch: Dispatch): Promise<void> => {
const web3 = getWeb3()
const providerInfo = await getProviderInfo(web3, providerName)
const providerInfo = await getProviderInfo(web3.currentProvider, providerName)
await handleProviderNotification(providerInfo, dispatch)
processProviderResponse(dispatch, providerInfo)
}

View File

@ -37,7 +37,7 @@ const providerWatcherMware = (store) => (next) => async (action) => {
watcherInterval = setInterval(async () => {
const web3 = getWeb3()
const providerInfo = await getProviderInfo(web3)
const providerInfo = await getProviderInfo(web3.currentProvider)
const networkChanged = currentProviderProps.network !== providerInfo.network

View File

@ -23,6 +23,7 @@ export const GenericFooter = ({ safeCreationTxHash }: { safeCreationTxHash: stri
href={getEtherScanLink('tx', safeCreationTxHash)}
rel="noopener noreferrer"
target="_blank"
data-testid="safe-create-etherscan-link"
>
Etherscan.io
</EtherScanLink>

View File

@ -63,7 +63,7 @@ const isTxValid = (t: SafeAppTx): boolean => {
return false
}
if (typeof t.value === 'string' && !/^\d+$/.test(t.value)) {
if (typeof t.value === 'string' && !/^(0x)?[0-9a-f]+$/i.test(t.value)) {
return false
}

View File

@ -13,6 +13,8 @@ const removeLastTrailingSlash = (url) => {
const gnosisAppsUrl = removeLastTrailingSlash(getGnosisSafeAppsUrl())
export const staticAppsList: Array<{ url: string; disabled: boolean }> = [
// 1inch
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmUDTSghr154kCCGguyA3cbG5HRVd2tQgNR7yD69bcsjm5`, disabled: false },
// Aave
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmY1MUZo44UkT8EokYHs7xDvWEziYSn7n3c4ojVB6qo3SM`, disabled: false },
// Compound
@ -20,7 +22,7 @@ export const staticAppsList: Array<{ url: string; disabled: boolean }> = [
// Idle
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmUoqmq8jw98VwTSf7aTQeBCfPKicQgcJL5k2Bch9QT8BJ`, disabled: false },
// request
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmQapdJP6zERqpDKKPECNeMDDgwmGUqbKk1PjHpYj8gfDJ`, disabled: false },
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmTBBaiDQyGa17DJ7DdviyHbc51fTVgf6Z5PW5w2YUTkgR`, disabled: false },
// Sablier
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmabPEk7g4zaytFefp6fE4nz8f85QMJoWmRQQZypvJViNG`, disabled: false },
// TX-Builder

View File

@ -72,7 +72,7 @@ const Coins = (props) => {
break
}
case BALANCE_TABLE_BALANCE_ID: {
cellItem = <div>{row[id]}</div>
cellItem = <div data-testid={`balance-${row[BALANCE_TABLE_ASSET_ID].symbol}`}>{row[id]}</div>
break
}
case BALANCE_TABLE_VALUE_ID: {

View File

@ -110,6 +110,7 @@ const ChooseTxType = ({ onClose, recipientAddress, setActiveScreen }) => {
minWidth={260}
onClick={() => setActiveScreen('sendFunds')}
variant="contained"
testId="modal-send-funds-btn"
>
<Img alt="Send funds" className={classNames(classes.leftIcon, classes.iconSmall)} src={Token} />
Send funds
@ -122,6 +123,7 @@ const ChooseTxType = ({ onClose, recipientAddress, setActiveScreen }) => {
minWidth={260}
onClick={() => setActiveScreen('sendCollectible')}
variant="contained"
testId="modal-send-collectible-btn"
>
<Img
alt="Send collectible"
@ -138,6 +140,7 @@ const ChooseTxType = ({ onClose, recipientAddress, setActiveScreen }) => {
minWidth={260}
onClick={() => setActiveScreen('contractInteraction')}
variant="outlined"
testId="modal-contract-interaction-btn"
>
<Img
alt="Contract Interaction"

View File

@ -105,7 +105,7 @@ const ReviewTx = ({ closeSnackbar, enqueueSnackbar, onClose, onPrev, tx }) => {
return (
<>
<Row align="center" className={classes.heading} grow>
<Row align="center" className={classes.heading} grow data-testid="send-funds-review-step">
<Paragraph className={classes.headingText} noMargin weight="bolder">
Send Funds
</Paragraph>
@ -136,7 +136,12 @@ const ReviewTx = ({ closeSnackbar, enqueueSnackbar, onClose, onPrev, tx }) => {
</Col>
<Col layout="column" xs={11}>
<Block justify="left">
<Paragraph className={classes.address} noMargin weight="bolder">
<Paragraph
className={classes.address}
noMargin
weight="bolder"
data-testid="recipient-address-review-step"
>
{tx.recipientAddress}
</Paragraph>
<CopyBtn content={tx.recipientAddress} />
@ -151,12 +156,12 @@ const ReviewTx = ({ closeSnackbar, enqueueSnackbar, onClose, onPrev, tx }) => {
</Row>
<Row align="center" margin="md">
<Img alt={txToken.name} height={28} onError={setImageToPlaceholder} src={txToken.logoUri} />
<Paragraph className={classes.amount} noMargin size="md">
<Paragraph className={classes.amount} noMargin size="md" data-testid={`amount-${txToken.symbol}-review-step`}>
{tx.amount} {txToken.symbol}
</Paragraph>
</Row>
<Row>
<Paragraph>
<Paragraph data-testid="fee-meg-review-step">
{`You're about to create a transaction and will have to confirm it with your currently connected wallet. Make sure you have ${gasCosts} (fee price) ETH in this wallet to fund this confirmation.`}
</Paragraph>
</Row>

View File

@ -57,7 +57,11 @@ const TokenSelectField = ({ classes, initialValue, isValid, tokens }) => (
<ListItemIcon>
<Img alt={token.name} height={28} onError={setImageToPlaceholder} src={token.logoUri} />
</ListItemIcon>
<ListItemText primary={token.name} secondary={`${formatAmount(token.balance)} ${token.symbol}`} />
<ListItemText
primary={token.name}
secondary={`${formatAmount(token.balance)} ${token.symbol}`}
data-testid={`select-token-${token.name}`}
/>
</MenuItem>
))}
</Field>

View File

@ -84,7 +84,7 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT
return (
<>
<Row align="center" className={classes.heading} grow>
<Row align="center" className={classes.heading} grow data-testid="modal-title-send-funds">
<Paragraph className={classes.manage} noMargin weight="bolder">
Send Funds
</Paragraph>
@ -221,7 +221,11 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT
<Paragraph color="disabled" noMargin size="md" style={{ letterSpacing: '-0.5px' }}>
Amount
</Paragraph>
<ButtonLink onClick={() => mutators.setMax(selectedTokenRecord.balance)} weight="bold">
<ButtonLink
onClick={() => mutators.setMax(selectedTokenRecord.balance)}
weight="bold"
testId="send-max-btn"
>
Send max
</ButtonLink>
</Col>
@ -239,6 +243,7 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT
placeholder="Amount*"
text="Amount*"
type="text"
testId="amount-input"
validate={composeValidators(
required,
mustBeFloat,

View File

@ -40,6 +40,7 @@ export const getBalanceData = (activeTokens, currencySelected, currencyValues, c
name: token.name,
logoUri: token.logoUri,
address: token.address,
symbol: token.symbol,
},
[buildOrderFieldFrom(BALANCE_TABLE_ASSET_ID)]: token.name,
[BALANCE_TABLE_BALANCE_ID]: `${formatAmount(token.balance)} ${token.symbol}`,

View File

@ -147,6 +147,7 @@ const ApproveTxModal = ({
<FormControlLabel
control={<Checkbox checked={approveAndExecute} color="primary" onChange={handleExecuteCheckbox} />}
label="Execute transaction"
data-testid="execute-checkbox"
/>
)}
</>

View File

@ -144,9 +144,16 @@ const OwnersColumn = ({
return (
<Col className={classes.rightCol} layout="block" xs={6}>
<Block className={cn(classes.ownerListTitle, (thresholdReached || tx.isExecuted) && classes.ownerListTitleDone)}>
<Block
className={cn(classes.ownerListTitle, (thresholdReached || tx.isExecuted) && classes.ownerListTitleDone)}
data-testid={`confirmed-${tx.confirmations.size}-out-of-${txThreshold}`}
>
<div className={classes.circleState}>
<Img alt="" src={thresholdReached || tx.isExecuted ? CheckLargeFilledGreenCircle : ConfirmLargeGreenCircle} />
<Img
alt=""
src={thresholdReached || tx.isExecuted ? CheckLargeFilledGreenCircle : ConfirmLargeGreenCircle}
data-testid={thresholdReached || tx.isExecuted ? 'confirmed-tx-check' : 'not-confirmed-tx-check'}
/>
</div>
{tx.isExecuted
? `Confirmed [${tx.confirmations.size}/${tx.confirmations.size}]`
@ -169,6 +176,7 @@ const OwnersColumn = ({
classes.ownerListTitle,
(cancelThresholdReached || cancelTx.isExecuted) && classes.ownerListTitleCancelDone,
)}
data-testid={`rejected-${cancelTx.confirmations.size}-out-of-${cancelThreshold}`}
>
<div
className={cn(classes.verticalLine, tx.isExecuted ? classes.verticalLineDone : classes.verticalLinePending)}

View File

@ -42,7 +42,7 @@ const Status = ({ classes, status }) => {
return (
<Block className={`${classes.container} ${classes[status]}`}>
{typeof Icon === 'object' ? Icon : <Img alt={statusToLabel[status]} src={Icon} style={statusIconStyle} />}
<Paragraph className={classes.statusText} noMargin>
<Paragraph className={classes.statusText} noMargin data-testid={`tx-status-${statusToLabel[status]}`}>
{statusToLabel[status]}
</Paragraph>
</Block>

View File

@ -14,7 +14,8 @@ describe('TxsTable Columns > getTxTableData', () => {
const txRow = txTableData.first()
// Then
expect(txRow[TX_TABLE_RAW_CANCEL_TX_ID]).toEqual(mockedCancelTransaction)
// expect(txRow[TX_TABLE_RAW_CANCEL_TX_ID]).toEqual(mockedCancelTransaction)
expect(txRow[TX_TABLE_RAW_CANCEL_TX_ID]).toBeUndefined()
})
it('should not include CancelTx object inside TxTableData', () => {
// Given

View File

@ -72,7 +72,7 @@ export const aMinedSafe = async (
threshold = 1,
name = 'Safe Name',
) => {
const provider = await getProviderInfo((window as any).web3.currentProvider)
const provider = await getProviderInfo(window.web3?.currentProvider || 'ws://localhost:8545')
const walletRecord = makeProvider(provider)
store.dispatch(addProvider(walletRecord))

View File

@ -31,7 +31,7 @@ afterAll(() => {
})
const renderOpenSafeForm = async (localStore) => {
const provider = await getProviderInfo((window as any).web3.currentProvider)
const provider = await getProviderInfo(window.web3.currentProvider)
const walletRecord = makeProvider(provider)
localStore.dispatch(addProvider(walletRecord))

View File

@ -1,156 +0,0 @@
//
import { fireEvent } from '@testing-library/react'
import { Map, Set, List } from 'immutable'
import { aNewStore } from 'src/store'
import { aMinedSafe } from 'src/test/builder/safe.redux.builder'
import { sendTokenTo, sendEtherTo, get6DecimalsTokenContract } from 'src/test/utils/tokenMovements'
import { renderSafeView } from 'src/test/builder/safe.dom.utils'
import { getWeb3, getBalanceInEtherOf } from 'src/logic/wallets/getWeb3'
import { dispatchAddTokenToList } from 'src/test/utils/transactions/moveTokens.helper'
import { sleep } from 'src/utils/timer'
import saveTokens from 'src/logic/tokens/store/actions/saveTokens'
// import { calculateBalanceOf } from 'src/routes/safe/store/actions/fetchTokenBalances'
import updateActiveTokens from 'src/routes/safe/store/actions/updateActiveTokens'
import '@testing-library/jest-dom/extend-expect'
import updateSafe from 'src/routes/safe/store/actions/updateSafe'
import { makeToken } from 'src/logic/tokens/store/model/token'
import { checkRegisteredTxSend, fillAndSubmitSendFundsForm } from './utils/transactions'
import { BALANCE_ROW_TEST_ID } from 'src/routes/safe/components/Balances'
describe('DOM > Feature > Sending Funds', () => {
let store
let safeAddress
let accounts
beforeEach(async () => {
store = aNewStore()
safeAddress = await aMinedSafe(store)
accounts = await getWeb3().eth.getAccounts()
})
// it('Sends ETH with threshold = 1', async () => {
// // GIVEN
// const ethAmount = '5'
// // the tests are run in parallel, lets use account 9 because it's not used anywhere else
// // (in other tests we trigger transactions and pay gas for it, so we can't really make reliable
// // assumptions on account's ETH balance)
// await sendEtherTo(safeAddress, ethAmount, 9)
// // WHEN
// const SafeDom = renderSafeView(store, safeAddress)
// await sleep(1300)
// // Open send funds modal
// const balanceRows = SafeDom.getAllByTestId(BALANCE_ROW_TEST_ID)
// expect(balanceRows[0]).toHaveTextContent(`${ethAmount} ETH`)
// const sendButton = SafeDom.getByTestId('balance-send-btn')
// fireEvent.click(sendButton)
// const receiverBalanceBeforeTx = await getBalanceInEtherOf(accounts[9])
// await fillAndSubmitSendFundsForm(SafeDom, sendButton, ethAmount, accounts[9])
// // THEN
// const safeFunds = await getBalanceInEtherOf(safeAddress)
// expect(Number(safeFunds)).toBe(0)
// const receiverBalanceAfterTx = await getBalanceInEtherOf(accounts[9])
// const ESTIMATED_GASCOSTS = 0.3
// expect(Number(parseInt(receiverBalanceAfterTx, 10) - parseInt(receiverBalanceBeforeTx, 10))).toBeGreaterThan(
// parseInt(ethAmount, 10) - ESTIMATED_GASCOSTS,
// )
// // Check that the transaction was registered
// await checkRegisteredTxSend(SafeDom, ethAmount, 'ETH', accounts[9])
// })
// it('Sends Tokens with 18 decimals with threshold = 1', async () => {
// // GIVEN
// const tokensAmount = '100'
// const tokenReceiver = accounts[1]
// const tokenAddress = await sendTokenTo(safeAddress, tokensAmount)
// await dispatchAddTokenToList(store, tokenAddress)
// // WHEN
// const SafeDom = await renderSafeView(store, safeAddress)
// await sleep(1300)
// // Activate token
// // const safeTokenBalance = await calculateBalanceOf(tokenAddress, safeAddress, 18)
// // expect(safeTokenBalance).toBe(tokensAmount)
// // const balances = Map({
// // [tokenAddress]: safeTokenBalance,
// // })
// store.dispatch(updateActiveTokens(safeAddress, Set([tokenAddress])))
// store.dispatch(updateSafe({ address: safeAddress, balances }))
// await sleep(1000)
// // Open send funds modal
// const balanceRows = SafeDom.getAllByTestId(BALANCE_ROW_TEST_ID)
// expect(balanceRows.length).toBe(2)
// const sendButtons = SafeDom.getAllByTestId('balance-send-btn')
// expect(sendButtons.length).toBe(2)
// await fillAndSubmitSendFundsForm(SafeDom, sendButtons[1], tokensAmount, tokenReceiver)
// // THEN
// // const safeFunds = await calculateBalanceOf(tokenAddress, safeAddress, 18)
// // expect(Number(safeFunds)).toBe(0)
// // const receiverFunds = await calculateBalanceOf(tokenAddress, tokenReceiver, 18)
// // expect(receiverFunds).toBe(tokensAmount)
// // Check that the transaction was registered
// await checkRegisteredTxSend(SafeDom, tokensAmount, 'OMG', tokenReceiver)
// })
// it('Sends Tokens with decimals other than 18 with threshold = 1', async () => {
// // GIVEN
// const tokensAmount = '1000000'
// const tokenReceiver = accounts[1]
// const web3 = await getWeb3()
// const SixDecimalsToken = await get6DecimalsTokenContract(web3, accounts[0])
// const tokenList = List([
// makeToken({
// address: SixDecimalsToken.address,
// name: '6 Decimals',
// symbol: '6DEC',
// decimals: 6,
// logoUri: 'https://upload.wikimedia.org/wikipedia/commons/c/c0/Earth_simple_icon.png',
// }),
// ])
// await store.dispatch(saveTokens(tokenList))
// await SixDecimalsToken.contract.methods.transfer(safeAddress, tokensAmount).send({ from: accounts[0] })
// // WHEN
// const SafeDom = await renderSafeView(store, safeAddress)
// await sleep(1300)
// // Activate token
// const safeTokenBalance = await calculateBalanceOf(SixDecimalsToken.address, safeAddress, 6)
// expect(safeTokenBalance).toBe('1')
// const balances = Map({
// [SixDecimalsToken.address]: safeTokenBalance,
// })
// store.dispatch(updateActiveTokens(safeAddress, Set([SixDecimalsToken.address])))
// store.dispatch(updateSafe({ address: safeAddress, balances }))
// await sleep(1000)
// // Open send funds modal
// const balanceRows = SafeDom.getAllByTestId(BALANCE_ROW_TEST_ID)
// expect(balanceRows.length).toBe(2)
// const sendButtons = SafeDom.getAllByTestId('balance-send-btn')
// expect(sendButtons.length).toBe(2)
// await fillAndSubmitSendFundsForm(SafeDom, sendButtons[1], '1', tokenReceiver)
// // THEN
// const safeFunds = await calculateBalanceOf(SixDecimalsToken.address, safeAddress, 6)
// expect(Number(safeFunds)).toBe(0)
// const receiverFunds = await calculateBalanceOf(SixDecimalsToken.address, tokenReceiver, 6)
// expect(receiverFunds).toBe('1')
// })
})

View File

@ -7,7 +7,7 @@ import { ConnectedRouter } from 'connected-react-router'
import Load from 'src/routes/load/container/Load'
import { aNewStore, history, } from 'src/store'
import { sleep } from 'src/utils/timer'
import { getProviderInfo } from 'src/logic/wallets/getWeb3'
import { getProviderInfo, getWeb3 } from 'src/logic/wallets/getWeb3'
import addProvider from 'src/logic/wallets/store/actions/addProvider'
import { makeProvider } from 'src/logic/wallets/store/model/provider'
import { aMinedSafe } from './builder/safe.redux.builder'
@ -29,7 +29,7 @@ afterAll(() => {
})
const renderLoadSafe = async (localStore) => {
const provider = await getProviderInfo((window as any).web3.currentProvider)
const provider = await getProviderInfo(window.web3.currentProvider || 'ws://localhost:8545')
const walletRecord = makeProvider(provider)
localStore.dispatch(addProvider(walletRecord))

View File

@ -1,4 +1,4 @@
//
//
import { waitForElement } from '@testing-library/react'
import { List } from 'immutable'
import { getWeb3 } from 'src/logic/wallets/getWeb3'
@ -8,7 +8,7 @@ import { aMinedSafe } from 'src/test/builder/safe.redux.builder'
import { renderSafeView } from 'src/test/builder/safe.dom.utils'
import { sleep } from 'src/utils/timer'
import saveTokens from 'src/logic/tokens/store/actions/saveTokens'
import { clickOnManageTokens, toggleToken, closeManageTokensModal } from './utils/DOMNavigation'
import { clickOnManageTokens, closeManageTokensModal, toggleToken } from './utils/DOMNavigation'
import { BALANCE_ROW_TEST_ID } from 'src/routes/safe/components/Balances'
import { makeToken } from 'src/logic/tokens/store/model/token'
import '@testing-library/jest-dom/extend-expect'

View File

@ -1,2 +1,9 @@
import Web3 from 'web3'
declare global {
interface Window {
web3?: Web3
testAccountIndex?: string
}
}
declare module '@openzeppelin/contracts/build/contracts/ERC721'
declare module 'currency-flags/dist/currency-flags.min.css'

888
yarn.lock

File diff suppressed because it is too large Load Diff