tests fix wip commit

This commit is contained in:
mmv 2019-03-14 17:02:04 +04:00
parent d4c6fda203
commit 122be46934
32 changed files with 177 additions and 134 deletions

View File

@ -135,7 +135,7 @@
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"setupTestFrameworkScriptFile": "<rootDir>/config/jest/jest.setup.js",
"setupFilesAfterEnv": ["<rootDir>/config/jest/jest.setup.js"],
"setupFiles": [
"<rootDir>/config/webpack.config.test.js",
"<rootDir>/config/polyfills.js",

View File

@ -2,7 +2,6 @@
import contract from 'truffle-contract'
import { ensureOnce } from '~/utils/singleton'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import GnosisSafeSol from '#/GnosisSafe.json'
import ProxyFactorySol from '#/ProxyFactory.json'
import { calculateGasOf, calculateGasPrice } from '~/logic/wallets/ethTransactions'
@ -42,7 +41,7 @@ const instanciateMasterCopies = async () => {
// ONLY USED IN TEST ENVIRONMENT
const createMasterCopies = async () => {
const web3 = getWeb3()
const accounts = await promisify(cb => web3.eth.getAccounts(cb))
const accounts = await web3.eth.getAccounts()
const userAccount = accounts[0]
const ProxyFactory = getCreateProxyFactoryContract(web3)

View File

@ -23,8 +23,17 @@ export const approveTransaction = async (
// return executeTransaction(safeAddress, to, valueInWei, data, operation, nonce, sender)
const safe = await getSafeEthereumInstance(safeAddress)
const txGasEstimate = await generateTxGasEstimateFrom(safe, safeAddress, data, to, valueInWei, operation)
const signature =
await generateMetamaskSignature(safe, safeAddress, sender, to, valueInWei, nonce, data, operation, txGasEstimate)
const signature = await generateMetamaskSignature(
safe,
safeAddress,
sender,
to,
valueInWei,
nonce,
data,
operation,
txGasEstimate,
)
storeSignature(safeAddress, nonce, signature)
return undefined
@ -33,7 +42,7 @@ export const approveTransaction = async (
const gnosisSafe = await getSafeEthereumInstance(safeAddress)
const contractTxHash = await gnosisSafe.getTransactionHash(to, valueInWei, data, operation, 0, 0, 0, 0, 0, nonce)
const approveData = gnosisSafe.contract.approveHash.getData(contractTxHash)
const approveData = gnosisSafe.contract.methods.approveHash(contractTxHash).encodeABI()
const gas = await calculateGasOf(approveData, sender, safeAddress)
const txReceipt = await gnosisSafe.approveHash(contractTxHash, { from: sender, gas, gasPrice })
@ -60,16 +69,35 @@ export const executeTransaction = async (
if (signaturesViaMetamask()) {
const safe = await getSafeEthereumInstance(safeAddress)
const txGasEstimate = await generateTxGasEstimateFrom(safe, safeAddress, data, to, valueInWei, operation)
const signature =
await generateMetamaskSignature(safe, safeAddress, sender, to, valueInWei, nonce, data, operation, txGasEstimate)
const signature = await generateMetamaskSignature(
safe,
safeAddress,
sender,
to,
valueInWei,
nonce,
data,
operation,
txGasEstimate,
)
storeSignature(safeAddress, nonce, signature)
const sigs = getSignaturesFrom(safeAddress, nonce)
const threshold = await safe.getThreshold()
const gas =
await estimateDataGas(safe, to, valueInWei, data, operation, txGasEstimate, 0, nonce, Number(threshold), 0)
const gas = await estimateDataGas(
safe,
to,
valueInWei,
data,
operation,
txGasEstimate,
0,
nonce,
Number(threshold),
0,
)
const numOwners = await safe.getOwners()
const gasIncludingRemovingStoreUpfront = gas + txGasEstimate + (numOwners.length * 15000)
const gasIncludingRemovingStoreUpfront = gas + txGasEstimate + numOwners.length * 15000
const txReceipt = await safe.execTransaction(
to,
@ -94,24 +122,17 @@ export const executeTransaction = async (
const gnosisSafe = await getSafeEthereumInstance(safeAddress)
const signatures = buildSignaturesFrom(ownersWhoHasSigned, sender)
const txExecutionData =
gnosisSafe.contract.execTransaction.getData(to, valueInWei, data, operation, 0, 0, 0, 0, 0, signatures)
const txExecutionData = gnosisSafe.contract.methods
.execTransaction(to, valueInWei, data, operation, 0, 0, 0, 0, 0, signatures)
.encodeABI()
const gas = await calculateGasOf(txExecutionData, sender, safeAddress)
const numOwners = await gnosisSafe.getOwners()
const gasIncludingRemovingStoreUpfront = gas + (numOwners.length * 15000)
const txReceipt = await gnosisSafe.execTransaction(
to,
valueInWei,
data,
operation,
0,
0,
0,
0,
0,
signatures,
{ from: sender, gas: gasIncludingRemovingStoreUpfront, gasPrice },
)
const gasIncludingRemovingStoreUpfront = gas + numOwners.length * 15000
const txReceipt = await gnosisSafe.execTransaction(to, valueInWei, data, operation, 0, 0, 0, 0, 0, signatures, {
from: sender,
gas: gasIncludingRemovingStoreUpfront,
gasPrice,
})
const txHash = txReceipt.tx
await checkReceiptStatus(txHash)

View File

@ -42,7 +42,7 @@ export const createTransaction = async (
const web3 = getWeb3()
const safeAddress = safe.get('address')
const threshold = safe.get('threshold')
const valueInWei = web3.toWei(value, 'ether')
const valueInWei = web3.utils.toWei(value, 'ether')
const CALL = 0
const isExecution = hasOneOwner(safe) || threshold === 1

View File

@ -1,6 +1,5 @@
// @flow
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { BigNumber } from 'bignumber.js'
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
import { getSignaturesFrom } from '~/utils/localStorage/signatures'
@ -21,7 +20,6 @@ const estimateDataGasCosts = (data) => {
return data.match(/.{2}/g).reduce(reducer, 0)
}
export const estimateDataGas = (
safe: any,
to: string,
@ -42,8 +40,9 @@ export const estimateDataGas = (
const signatureCost = signatureCount * (68 + 2176 + 2176) // array count (3 -> r, s, v) * signature count
const sigs = getSignaturesFrom(safe.address, nonce)
const payload = safe.contract.execTransaction
.getData(to, valueInWei, data, operation, txGasEstimate, 0, gasPrice, gasToken, refundReceiver, sigs)
const payload = safe.contract.methods
.execTransaction(to, valueInWei, data, operation, txGasEstimate, 0, gasPrice, gasToken, refundReceiver, sigs)
.encodeABI()
let dataGasEstimate = estimateDataGasCosts(payload) + signatureCost
if (dataGasEstimate > 65536) {
@ -64,19 +63,19 @@ export const generateTxGasEstimateFrom = async (
operation: number,
) => {
try {
const estimateData = safe.contract.requiredTxGas.getData(to, valueInWei, data, operation)
const estimateResponse = await promisify(cb => getWeb3().eth.call({
const estimateData = safe.contract.methods.requiredTxGas(to, valueInWei, data, operation).encodeABI()
const estimateResponse = await getWeb3().eth.call({
to: safeAddress,
from: safeAddress,
data: estimateData,
}, cb))
})
const txGasEstimate = new BigNumber(estimateResponse.substring(138), 16)
// Add 10k else we will fail in case of nested calls
return Promise.resolve(txGasEstimate.toNumber() + 10000)
} catch (error) {
// eslint-disable-next-line
console.log("Error calculating tx gas estimation " + error)
console.log('Error calculating tx gas estimation ' + error)
return Promise.resolve(0)
}
}
@ -151,8 +150,16 @@ export const generateMetamaskSignature = async (
txGasEstimate: number,
) => {
const web3 = getWeb3()
const typedData =
await generateTypedDataFrom(safe, safeAddress, to, valueInWei, nonce, data, operation, txGasEstimate)
const typedData = await generateTypedDataFrom(
safe,
safeAddress,
to,
valueInWei,
nonce,
data,
operation,
txGasEstimate,
)
const jsonTypedData = JSON.stringify(typedData)
const signedTypedData = {
@ -163,7 +170,7 @@ export const generateMetamaskSignature = async (
params: [jsonTypedData, sender],
from: sender,
}
const txSignedResponse = await promisify(cb => web3.currentProvider.sendAsync(signedTypedData, cb))
const txSignedResponse = await web3.currentProvider.sendAsync(signedTypedData)
return txSignedResponse.result.replace(EMPTY_DATA, '')
}

View File

@ -1,7 +1,6 @@
// @flow
import { BigNumber } from 'bignumber.js'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { enhancedFetch } from '~/utils/fetch'
// const MAINNET_NETWORK = 1
@ -13,7 +12,7 @@ export const checkReceiptStatus = async (hash: string) => {
}
const web3 = getWeb3()
const txReceipt = await promisify(cb => web3.eth.getTransactionReceipt(hash, cb))
const txReceipt = await web3.eth.getTransactionReceipt(hash)
const { status } = txReceipt
if (!status) {
@ -53,7 +52,7 @@ export const calculateGasPrice = async () => {
export const calculateGasOf = async (data: Object, from: string, to: string) => {
const web3 = getWeb3()
try {
const gas = await promisify(cb => web3.eth.estimateGas({ data, from, to }, cb))
const gas = await web3.eth.estimateGas({ data, from, to })
return gas * 2
} catch (err) {

View File

@ -5,5 +5,5 @@ import { BigNumber } from 'bignumber.js'
export const toNative = async (amt: string | number | BigNumber, decimal: number): Promise<BigNumber> => {
const web3 = getWeb3()
return web3.toBigNumber(amt).mul(10 ** decimal)
return web3.utils.BN(amt).mul(10 ** decimal)
}

View File

@ -12,11 +12,10 @@ import Review from './Review'
import selector, { type SelectorProps } from './selector'
import actions, { type Actions } from './actions'
const getSteps = () => [
'Fill Owner Form', 'Review Add order operation',
]
const getSteps = () => ['Fill Owner Form', 'Review Add order operation']
type Props = SelectorProps & Actions & {
type Props = SelectorProps &
Actions & {
safe: Safe,
threshold: number,
}
@ -44,7 +43,7 @@ export const addOwner = async (values: Object, safe: Safe, threshold: number, ex
const newOwnerAddress = values[OWNER_ADDRESS_PARAM]
const newOwnerName = values[NAME_PARAM]
const data = gnosisSafe.contract.addOwnerWithThreshold.getData(newOwnerAddress, newThreshold)
const data = gnosisSafe.contract.methods.addOwnerWithThreshold(newOwnerAddress, newThreshold).encodeABI()
await createTransaction(safe, `Add Owner ${newOwnerName}`, safeAddress, 0, nonce, executor, data)
setOwners(safeAddress, safe.get('owners').push(makeOwner({ name: newOwnerName, address: newOwnerAddress })))
}
@ -92,13 +91,14 @@ class AddOwner extends React.Component<Props, State> {
<Stepper.Page numOwners={safe.get('owners').count()} threshold={safe.get('threshold')} addresses={addresses}>
{AddOwnerForm}
</Stepper.Page>
<Stepper.Page>
{ Review }
</Stepper.Page>
<Stepper.Page>{Review}</Stepper.Page>
</Stepper>
</React.Fragment>
)
}
}
export default connect(selector, actions)(AddOwner)
export default connect(
selector,
actions,
)(AddOwner)

View File

@ -37,10 +37,9 @@ type State = {
filter: string,
}
const filterBy = (filter: string, tokens: List<Token>): List<Token> =>
tokens.filter((token: Token) => !filter ||
token.get('symbol').toLowerCase().includes(filter.toLowerCase()) ||
token.get('name').toLowerCase().includes(filter.toLowerCase()))
const filterBy = (filter: string, tokens: List<Token>): List<Token> => tokens.filter((token: Token) => !filter
|| token.get('symbol').toLowerCase().includes(filter.toLowerCase())
|| token.get('name').toLowerCase().includes(filter.toLowerCase()))
class Tokens extends React.Component<Props, State> {
@ -132,4 +131,3 @@ class Tokens extends React.Component<Props, State> {
const TokenComponent = withStyles(styles)(Tokens)
export default connect(undefined, actions)(TokenComponent)

View File

@ -16,7 +16,9 @@ import Paragraph from '~/components/layout/Paragraph'
import Modal from '~/components/Modal'
import { type Column, cellWidth } from '~/components/Table/TableHead'
import Table from '~/components/Table'
import { getBalanceData, generateColumns, BALANCE_TABLE_ASSET_ID, type BalanceRow, filterByZero } from './dataFetcher'
import {
getBalanceData, generateColumns, BALANCE_TABLE_ASSET_ID, type BalanceRow, filterByZero,
} from './dataFetcher'
import Tokens from './Tokens'
import Send from './Send'
import Receive from './Receive'
@ -115,31 +117,49 @@ class Balances extends React.Component<Props, State> {
{(sortedData: Array<BalanceRow>) => sortedData.map((row: any, index: number) => (
<TableRow tabIndex={-1} key={index} className={classes.hide}>
{autoColumns.map((column: Column) => (
<TableCell key={column.id} style={cellWidth(column.width)} numeric={column.numeric} component="td">
<TableCell key={column.id} style={cellWidth(column.width)} align={column.align} component="td">
{row[column.id]}
</TableCell>
))}
<TableCell component="td">
<Row align="end" className={classes.actions}>
{ granted &&
<Button variant="contained" size="small" color="secondary" className={classes.send} onClick={this.onShow('Send')}>
{granted && (
<Button
variant="contained"
size="small"
color="secondary"
className={classes.send}
onClick={this.onShow('Send')}
>
<CallMade className={classNames(classes.leftIcon, classes.iconSmall)} />
Send
</Button>
}
<Button variant="contained" size="small" color="secondary" className={classes.receive} onClick={this.onShow('Receive')}>
)}
<Button
variant="contained"
size="small"
color="secondary"
className={classes.receive}
onClick={this.onShow('Receive')}
>
<CallReceived className={classNames(classes.leftIcon, classes.iconSmall)} />
Receive
</Button>
</Row>
</TableCell>
</TableRow>
))}
))
}
</Table>
<Modal title="Send Tokens" description="Send Tokens Form" handleClose={this.onHide('Send')} open={showSend}>
<Send onClose={this.onHide('Send')} />
</Modal>
<Modal title="Receive Tokens" description="Receive Tokens Form" handleClose={this.onHide('Receive')} open={showReceive}>
<Modal
title="Receive Tokens"
description="Receive Tokens Form"
handleClose={this.onHide('Receive')}
open={showReceive}
>
<Receive onClose={this.onHide('Receive')} />
</Modal>
</React.Fragment>

View File

@ -48,7 +48,7 @@ export const removeOwner = async (
const storedOwners = await gnosisSafe.getOwners()
const index = storedOwners.findIndex(ownerAddress => ownerAddress === userToRemove)
const prevAddress = index === 0 ? SENTINEL_ADDRESS : storedOwners[index - 1]
const data = gnosisSafe.contract.removeOwner.getData(prevAddress, userToRemove, newThreshold)
const data = gnosisSafe.contract.removeOwner(prevAddress, userToRemove, newThreshold).encodeABI()
const text = name || userToRemove
return createTransaction(safe, `Remove Owner ${text}`, safeAddress, 0, nonce, executor, data)

View File

@ -36,7 +36,7 @@ const getTransferData = async (tokenAddress: string, to: string, amount: BigNumb
const StandardToken = await getStandardTokenContract()
const myToken = await StandardToken.at(tokenAddress)
return myToken.contract.transfer.getData(to, amount)
return myToken.contract.transfer(to, amount).encodeABI()
}
const processTokenTransfer = async (safe: Safe, token: Token, to: string, amount: number, userAddress: string) => {

View File

@ -32,14 +32,14 @@ class Threshold extends React.PureComponent<Props, State> {
onThreshold = async (values: Object) => {
try {
const { safe, userAddress } = this.props // , fetchThreshold } = this.props
const { safe, userAddress, fetchTransactions } = this.props // , fetchThreshold } = this.props
const newThreshold = values[THRESHOLD_PARAM]
const safeAddress = safe.get('address')
const gnosisSafe = await getSafeEthereumInstance(safeAddress)
const nonce = await gnosisSafe.nonce()
const data = gnosisSafe.contract.changeThreshold.getData(newThreshold)
const data = gnosisSafe.contract.changeThreshold(newThreshold).encodeABI()
await createTransaction(safe, `Change Safe's threshold [${nonce}]`, safeAddress, 0, nonce, userAddress, data)
await this.props.fetchTransactions(safeAddress)
await fetchTransactions(safeAddress)
this.setState({ done: true })
} catch (error) {
this.setState({ done: false })
@ -49,8 +49,10 @@ class Threshold extends React.PureComponent<Props, State> {
}
onReset = () => {
const { onReset } = this.props
this.setState({ done: false })
this.props.onReset()
onReset()
}
render() {

View File

@ -5,7 +5,6 @@ import TextField from '~/components/forms/TextField'
import { composeValidators, required, mustBeEthereumAddress, uniqueAddress } from '~/components/forms/validator'
import Block from '~/components/layout/Block'
import Heading from '~/components/layout/Heading'
import { promisify } from '~/utils/promisify'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
import { getStandardTokenContract } from '~/routes/tokens/store/actions/fetchTokens'
@ -17,7 +16,7 @@ type Props = {
export const TOKEN_ADRESS_PARAM = 'tokenAddress'
export const token = async (tokenAddress: string) => {
const code = await promisify(cb => getWeb3().eth.getCode(tokenAddress, cb))
const code = await getWeb3().eth.getCode(tokenAddress)
const isDeployed = code !== EMPTY_DATA
if (!isDeployed) {

View File

@ -3,11 +3,12 @@ import * as React from 'react'
import Stepper from '~/components/Stepper'
import { getHumanFriendlyToken } from '~/routes/tokens/store/actions/fetchTokens'
import FirstPage, { TOKEN_ADRESS_PARAM } from '~/routes/tokens/component/AddToken/FirstPage'
import SecondPage, { TOKEN_SYMBOL_PARAM, TOKEN_DECIMALS_PARAM, TOKEN_LOGO_URL_PARAM, TOKEN_NAME_PARAM } from '~/routes/tokens/component/AddToken/SecondPage'
import SecondPage, {
TOKEN_SYMBOL_PARAM, TOKEN_DECIMALS_PARAM, TOKEN_LOGO_URL_PARAM, TOKEN_NAME_PARAM,
} from '~/routes/tokens/component/AddToken/SecondPage'
import { makeToken, type Token } from '~/routes/tokens/store/model/token'
import addTokenAction from '~/routes/tokens/store/actions/addToken'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
import Review from './Review'
@ -69,17 +70,18 @@ class AddToken extends React.Component<Props, State> {
const tokenAddress = values[TOKEN_ADRESS_PARAM]
const erc20Token = await getHumanFriendlyToken()
const instance = await erc20Token.at(tokenAddress)
const web3 = getWeb3()
const dataName = await instance.contract.name.getData()
const nameResult = await promisify(cb => getWeb3().eth.call({ to: tokenAddress, data: dataName }, cb))
const dataName = await instance.contract.methods.name().encodeABI()
const nameResult = await web3.eth.call({ to: tokenAddress, data: dataName })
const hasName = nameResult !== EMPTY_DATA
const dataSymbol = await instance.contract.symbol.getData()
const symbolResult = await promisify(cb => getWeb3().eth.call({ to: tokenAddress, data: dataSymbol }, cb))
const dataSymbol = await instance.contract.methods.symbol().encodeABI()
const symbolResult = await web3.eth.call({ to: tokenAddress, data: dataSymbol })
const hasSymbol = symbolResult !== EMPTY_DATA
const dataDecimals = await instance.contract.decimals.getData()
const decimalsResult = await promisify(cb => getWeb3().eth.call({ to: tokenAddress, data: dataDecimals }, cb))
const dataDecimals = await instance.contract.methods.decimals().encodeABI()
const decimalsResult = await web3.eth.call({ to: tokenAddress, data: dataDecimals })
const hasDecimals = decimalsResult !== EMPTY_DATA

View File

@ -76,10 +76,12 @@ class TokenComponent extends React.PureComponent<Props, State> {
color="primary"
/>
{symbol}
{ token.get('removable') &&
{ token.get('removable')
&& (
<IconButton aria-label="Delete" onClick={this.onRemoveClick}>
<Delete />
</IconButton>
)
}
</Typography>
</CardContent>

View File

@ -5,7 +5,6 @@ import SafeView from '~/routes/safe/component/Safe'
import { aNewStore, type GlobalState } from '~/store'
import { sleep } from '~/utils/timer'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { addEtherTo } from '~/test/utils/tokenMovements'
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
import { travelToSafe } from '~/test/builder/safe.dom.utils'
@ -31,7 +30,7 @@ export const renderSafeInDom = async (
// deploy safe updating store
const address = await aMinedSafe(store, owners, threshold)
// have available accounts
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await getWeb3().eth.getAccounts()
// navigate to SAFE route
const SafeDom = travelToSafe(store, address)

View File

@ -6,7 +6,7 @@ import { SEE_MULTISIG_BUTTON_TEXT } from '~/routes/safe/component/Safe/MultisigT
import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
import { sleep } from '~/utils/timer'
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import { ConnectedRouter } from 'connected-react-router'
import AppRoutes from '~/routes'
import { SAFELIST_ADDRESS, SETTINS_ADDRESS } from '~/routes/routes'
import { history, type GlobalState } from '~/store'

View File

@ -3,7 +3,6 @@ import { makeSafe, type Safe } from '~/routes/safe/store/model/safe'
import addSafe, { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
import { FIELD_NAME, FIELD_CONFIRMATIONS, FIELD_OWNERS, getOwnerNameBy, getOwnerAddressBy } from '~/routes/open/components/fields'
import { getWeb3, getProviderInfo } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { createSafe, type OpenState } from '~/routes/open/container/Open'
import { type GlobalState } from '~/store/index'
import { makeProvider } from '~/logic/wallets/store/model/provider'
@ -72,7 +71,7 @@ export const aMinedSafe = async (
const walletRecord = makeProvider(provider)
store.dispatch(addProvider(walletRecord))
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await getWeb3().eth.getAccounts()
const form = {
[FIELD_NAME]: 'Safe Name',
[FIELD_CONFIRMATIONS]: `${threshold}`,

View File

@ -4,7 +4,7 @@ import { type Store } from 'redux'
import TestUtils from 'react-dom/test-utils'
import Select from '@material-ui/core/Select'
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import { ConnectedRouter } from 'connected-react-router'
import { ADD_OWNER_BUTTON } from '~/routes/open/components/SafeOwnersForm'
import Open from '~/routes/open/container/Open'
import { aNewStore, history, type GlobalState } from '~/store'
@ -12,7 +12,6 @@ import { sleep } from '~/utils/timer'
import { getProviderInfo, getWeb3 } from '~/logic/wallets/getWeb3'
import addProvider from '~/logic/wallets/store/actions/addProvider'
import { makeProvider } from '~/logic/wallets/store/model/provider'
import { promisify } from '~/utils/promisify'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import { whenSafeDeployed } from './builder/safe.dom.utils'
@ -34,7 +33,7 @@ const fillOpenSafeForm = async (localStore: Store<GlobalState>) => {
const deploySafe = async (safe: React$Component<{}>, threshold: number, numOwners: number) => {
const web3 = getWeb3()
const accounts = await promisify(cb => web3.eth.getAccounts(cb))
const accounts = await web3.eth.getAccounts()
expect(threshold).toBeLessThanOrEqual(numOwners)
const form = TestUtils.findRenderedDOMComponentWithTag(safe, 'form')

View File

@ -3,7 +3,7 @@ import * as React from 'react'
import { type Store } from 'redux'
import TestUtils from 'react-dom/test-utils'
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import { ConnectedRouter } from 'connected-react-router'
import Load from '~/routes/load/container/Load'
import { aNewStore, history, type GlobalState } from '~/store'
import { sleep } from '~/utils/timer'

View File

@ -6,7 +6,6 @@ import { aNewStore } from '~/store'
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
import { addTknTo, getFirstTokenContract } from '~/test/utils/tokenMovements'
import { EXPAND_BALANCE_INDEX, travelToSafe } from '~/test/builder/safe.dom.utils'
import { promisify } from '~/utils/promisify'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { sendMoveTokensForm, dispatchTknBalance } from '~/test/utils/transactions/moveTokens.helper'
import { sleep } from '~/utils/timer'
@ -18,7 +17,7 @@ describe('DOM > Feature > SAFE ERC20 TOKENS', () => {
beforeEach(async () => {
store = aNewStore()
safeAddress = await aMinedSafe(store)
accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
accounts = await getWeb3().eth.getAccounts()
})
it('sends ERC20 tokens', async () => {

View File

@ -8,7 +8,6 @@ import { loadSafe } from '~/routes/load/container/Load'
import { safesMapSelector } from '~/routes/safeList/store/selectors'
import { makeOwner, type Owner } from '~/routes/safe/store/model/owner'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { safesInitialState } from '~/routes/safe/store/reducer/safe'
import { setOwners, OWNERS_KEY } from '~/utils/localStorage'
@ -20,7 +19,7 @@ describe('Safe - redux load safe', () => {
store = aNewStore()
address = await aMinedSafe(store)
localStorage.clear()
accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
accounts = await getWeb3().eth.getAccounts()
})
it('if safe is not present, store and persist it with default names', async () => {

View File

@ -2,7 +2,6 @@
import { List } from 'immutable'
import { aNewStore } from '~/store'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { confirmationsTransactionSelector, safeTransactionsSelector } from '~/routes/safe/store/selectors'
import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
import { type Safe } from '~/routes/safe/store/model/safe'
@ -103,7 +102,7 @@ describe('React DOM TESTS > Add and remove owners', () => {
const threshold = 1
const store = aNewStore()
const address = await aMinedSafe(store, numOwners, threshold)
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await getWeb3().eth.getAccounts()
const gnosisSafe = await getGnosisSafeInstanceAt(address)
const values = {
@ -132,7 +131,7 @@ describe('React DOM TESTS > Add and remove owners', () => {
const threshold = 1
const store = aNewStore()
const address = await aMinedSafe(store, numOwners, threshold)
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await getWeb3().eth.getAccounts()
const gnosisSafe = await getGnosisSafeInstanceAt(address)
const values = {
@ -164,7 +163,7 @@ describe('React DOM TESTS > Add and remove owners', () => {
const threshold = 2
const store = aNewStore()
const address = await aMinedSafe(store, numOwners, threshold)
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await getWeb3().eth.getAccounts()
const gnosisSafe = await getGnosisSafeInstanceAt(address)
const decrease = shouldDecrease(numOwners, threshold)
@ -190,7 +189,7 @@ describe('React DOM TESTS > Add and remove owners', () => {
const threshold = 2
const store = aNewStore()
const address = await aMinedSafe(store, numOwners, threshold)
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await getWeb3().eth.getAccounts()
const gnosisSafe = await getGnosisSafeInstanceAt(address)
const decrease = true
@ -215,7 +214,7 @@ describe('React DOM TESTS > Add and remove owners', () => {
const threshold = 2
const store = aNewStore()
const address = await aMinedSafe(store, numOwners, threshold)
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await getWeb3().eth.getAccounts()
const gnosisSafe = await getGnosisSafeInstanceAt(address)
const decrease = shouldDecrease(numOwners, threshold)

View File

@ -8,7 +8,6 @@ import { makeConfirmation } from '~/routes/safe/store/model/confirmation'
import { aNewStore } from '~/store'
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
import { getSafeFrom } from '~/test/utils/safeHelper'
import { promisify } from '~/utils/promisify'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { safeTransactionsSelector } from '~/routes/safe/store/selectors'
import fetchSafe from '~/routes/safe/store/actions/fetchSafe'
@ -20,7 +19,7 @@ describe('Transactions Suite', () => {
let safeAddress: string
let accounts: string[]
beforeAll(async () => {
accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
accounts = await getWeb3().eth.getAccounts()
})
beforeEach(async () => {
localStorage.clear()

View File

@ -2,7 +2,6 @@
import * as TestUtils from 'react-dom/test-utils'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { type Match } from 'react-router-dom'
import { promisify } from '~/utils/promisify'
import TokenComponent from '~/routes/tokens/component/Token'
import { getFirstTokenContract, getSecondTokenContract } from '~/test/utils/tokenMovements'
import { aNewStore } from '~/store'
@ -24,7 +23,7 @@ describe('DOM > Feature > Add new ERC 20 Tokens', () => {
beforeAll(async () => {
web3 = getWeb3()
accounts = await promisify(cb => web3.eth.getAccounts(cb))
accounts = await web3.eth.getAccounts()
firstErc20Token = await getFirstTokenContract(web3, accounts[0])
secondErc20Token = await getSecondTokenContract(web3, accounts[0])

View File

@ -3,7 +3,6 @@ import * as TestUtils from 'react-dom/test-utils'
import { List } from 'immutable'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { type Match } from 'react-router-dom'
import { promisify } from '~/utils/promisify'
import TokenComponent from '~/routes/tokens/component/Token'
import Checkbox from '@material-ui/core/Checkbox'
import { getFirstTokenContract, getSecondTokenContract, addTknTo } from '~/test/utils/tokenMovements'
@ -26,7 +25,7 @@ describe('DOM > Feature > Enable and disable default tokens', () => {
beforeAll(async () => {
web3 = getWeb3()
accounts = await promisify(cb => web3.eth.getAccounts(cb))
accounts = await web3.eth.getAccounts()
firstErc20Token = await getFirstTokenContract(web3, accounts[0])
secondErc20Token = await getSecondTokenContract(web3, accounts[0])
// $FlowFixMe

View File

@ -1,7 +1,6 @@
// @flow
import * as TestUtils from 'react-dom/test-utils'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import { getFirstTokenContract, getSecondTokenContract } from '~/test/utils/tokenMovements'
import { aNewStore } from '~/store'
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
@ -24,7 +23,7 @@ describe('DOM > Feature > Add new ERC 20 Tokens', () => {
beforeAll(async () => {
web3 = getWeb3()
accounts = await promisify(cb => web3.eth.getAccounts(cb))
accounts = await web3.eth.getAccounts()
firstErc20Token = await getFirstTokenContract(web3, accounts[0])
secondErc20Token = await getSecondTokenContract(web3, accounts[0])

View File

@ -1,7 +1,6 @@
// @flow
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { type Match } from 'react-router-dom'
import { promisify } from '~/utils/promisify'
import { getFirstTokenContract, getSecondTokenContract } from '~/test/utils/tokenMovements'
import { aNewStore } from '~/store'
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
@ -24,7 +23,7 @@ describe('DOM > Feature > Add new ERC 20 Tokens', () => {
beforeAll(async () => {
web3 = getWeb3()
accounts = await promisify(cb => web3.eth.getAccounts(cb))
accounts = await web3.eth.getAccounts()
firstErc20Token = await getFirstTokenContract(web3, accounts[0])
secondErc20Token = await getSecondTokenContract(web3, accounts[0])

View File

@ -1,7 +1,6 @@
// @flow
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { type Match } from 'react-router-dom'
import { promisify } from '~/utils/promisify'
import { getFirstTokenContract, getSecondTokenContract } from '~/test/utils/tokenMovements'
import { aNewStore } from '~/store'
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
@ -11,7 +10,12 @@ import { testToken } from '~/test/builder/tokens.dom.utils'
import * as fetchTokensModule from '~/routes/tokens/store/actions/fetchTokens'
import * as enhancedFetchModule from '~/utils/fetch'
import { TOKEN_ADRESS_PARAM } from '~/routes/tokens/component/AddToken/FirstPage'
import { TOKEN_NAME_PARAM, TOKEN_DECIMALS_PARAM, TOKEN_SYMBOL_PARAM, TOKEN_LOGO_URL_PARAM } from '~/routes/tokens/component/AddToken/SecondPage'
import {
TOKEN_NAME_PARAM,
TOKEN_DECIMALS_PARAM,
TOKEN_SYMBOL_PARAM,
TOKEN_LOGO_URL_PARAM,
} from '~/routes/tokens/component/AddToken/SecondPage'
import addToken from '~/routes/tokens/store/actions/addToken'
import { addTokenFnc } from '~/routes/tokens/component/AddToken'
import { activeTokensSelector, tokenListSelector } from '~/routes/tokens/store/selectors'
@ -27,7 +31,7 @@ describe('DOM > Feature > Add new ERC 20 Tokens', () => {
beforeAll(async () => {
web3 = getWeb3()
accounts = await promisify(cb => web3.eth.getAccounts(cb))
accounts = await web3.eth.getAccounts()
firstErc20Token = await getFirstTokenContract(web3, accounts[0])
secondErc20Token = await getSecondTokenContract(web3, accounts[0])

View File

@ -1,7 +1,6 @@
// @flow
import { getWeb3 } from '~/logic/wallets/getWeb3'
import abi from 'ethereumjs-abi'
import { promisify } from '~/utils/promisify'
/*
console.log(`to[${to}] \n\n valieInWei[${valueInWei}] \n\n
@ -15,9 +14,12 @@ const err = await getErrorMessage(address, 0, txData, accounts[2])
*/
export const getErrorMessage = async (to: string, value: number, data: string, from: string) => {
const web3 = getWeb3()
const returnData = await promisify(cb => web3.eth.call({
to, from, value, data,
}, cb))
const returnData = await web3.eth.call({
to,
from,
value,
data,
})
const returnBuffer = Buffer.from(returnData.slice(2), 'hex')
return abi.rawDecode(['string'], returnBuffer.slice(4))[0]

View File

@ -1,16 +1,15 @@
// @flow
import contract from 'truffle-contract'
import { getBalanceInEtherOf, getWeb3 } from '~/logic/wallets/getWeb3'
import { promisify } from '~/utils/promisify'
import Token from '#/test/TestToken.json'
import { ensureOnce } from '~/utils/singleton'
import { toNative } from '~/logic/wallets/tokens'
export const addEtherTo = async (address: string, eth: string) => {
const web3 = getWeb3()
const accounts = await promisify(cb => web3.eth.getAccounts(cb))
const txData = { from: accounts[0], to: address, value: web3.toWei(eth, 'ether') }
return promisify(cb => web3.eth.sendTransaction(txData, cb))
const accounts = await web3.eth.getAccounts()
const txData = { from: accounts[0], to: address, value: web3.utils.toWei(eth, 'ether') }
return web3.eth.sendTransaction(txData)
}
export const checkBalanceOf = async (addressToTest: string, value: string) => {
@ -30,7 +29,7 @@ export const getSecondTokenContract = ensureOnce(createTokenContract)
export const addTknTo = async (safe: string, value: number, tokenContract?: any) => {
const web3 = getWeb3()
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
const accounts = await web3.eth.getAccounts()
const myToken = tokenContract || await getFirstTokenContract(web3, accounts[0])
const nativeValue = await toNative(value, 18)