Generating nonce from safe

This commit is contained in:
apanizo 2018-09-27 16:17:55 +02:00
parent 3feece9e43
commit 3a9898c29f
3 changed files with 3 additions and 6 deletions

View File

@ -7,7 +7,6 @@ import { type Safe } from '~/routes/safe/store/model/safe'
import { type Owner, makeOwner } from '~/routes/safe/store/model/owner' import { type Owner, makeOwner } from '~/routes/safe/store/model/owner'
import { setOwners } from '~/utils/localStorage' import { setOwners } from '~/utils/localStorage'
import { getSafeEthereumInstance, createTransaction } from '~/logic/safe/safeFrontendOperations' import { getSafeEthereumInstance, createTransaction } from '~/logic/safe/safeFrontendOperations'
import { signaturesViaMetamask } from '~/config'
import AddOwnerForm, { NAME_PARAM, OWNER_ADDRESS_PARAM, INCREASE_PARAM } from './AddOwnerForm' import AddOwnerForm, { NAME_PARAM, OWNER_ADDRESS_PARAM, INCREASE_PARAM } from './AddOwnerForm'
import Review from './Review' import Review from './Review'
import selector, { type SelectorProps } from './selector' import selector, { type SelectorProps } from './selector'
@ -39,7 +38,7 @@ const getOwnerAddressesFrom = (owners: List<Owner>) => {
export const addOwner = async (values: Object, safe: Safe, threshold: number, executor: string) => { export const addOwner = async (values: Object, safe: Safe, threshold: number, executor: string) => {
const safeAddress = safe.get('address') const safeAddress = safe.get('address')
const gnosisSafe = await getSafeEthereumInstance(safeAddress) const gnosisSafe = await getSafeEthereumInstance(safeAddress)
const nonce = signaturesViaMetamask() ? await gnosisSafe.nonce() : Date.now() const nonce = await gnosisSafe.nonce()
const newThreshold = values[INCREASE_PARAM] ? threshold + 1 : threshold const newThreshold = values[INCREASE_PARAM] ? threshold + 1 : threshold
const newOwnerAddress = values[OWNER_ADDRESS_PARAM] const newOwnerAddress = values[OWNER_ADDRESS_PARAM]

View File

@ -4,7 +4,6 @@ import Stepper from '~/components/Stepper'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { type Safe } from '~/routes/safe/store/model/safe' import { type Safe } from '~/routes/safe/store/model/safe'
import { getSafeEthereumInstance, createTransaction } from '~/logic/safe/safeFrontendOperations' import { getSafeEthereumInstance, createTransaction } from '~/logic/safe/safeFrontendOperations'
import { signaturesViaMetamask } from '~/config'
import RemoveOwnerForm, { DECREASE_PARAM } from './RemoveOwnerForm' import RemoveOwnerForm, { DECREASE_PARAM } from './RemoveOwnerForm'
import Review from './Review' import Review from './Review'
import selector, { type SelectorProps } from './selector' import selector, { type SelectorProps } from './selector'
@ -44,7 +43,7 @@ export const removeOwner = async (
) => { ) => {
const safeAddress = safe.get('address') const safeAddress = safe.get('address')
const gnosisSafe = await getSafeEthereumInstance(safeAddress) const gnosisSafe = await getSafeEthereumInstance(safeAddress)
const nonce = signaturesViaMetamask() ? await gnosisSafe.nonce() : Date.now() const nonce = await gnosisSafe.nonce()
const newThreshold = values[DECREASE_PARAM] ? threshold - 1 : threshold const newThreshold = values[DECREASE_PARAM] ? threshold - 1 : threshold
const storedOwners = await gnosisSafe.getOwners() const storedOwners = await gnosisSafe.getOwners()
const index = storedOwners.findIndex(ownerAddress => ownerAddress === userToRemove) const index = storedOwners.findIndex(ownerAddress => ownerAddress === userToRemove)

View File

@ -12,7 +12,6 @@ import { promisify } from '~/utils/promisify'
import { getWeb3 } from '~/logic/wallets/getWeb3' import { getWeb3 } from '~/logic/wallets/getWeb3'
import { safeTransactionsSelector } from '~/routes/safe/store/selectors' import { safeTransactionsSelector } from '~/routes/safe/store/selectors'
import fetchSafe from '~/routes/safe/store/actions/fetchSafe' import fetchSafe from '~/routes/safe/store/actions/fetchSafe'
import { signaturesViaMetamask } from '~/config'
import { testTransactionFrom, testSizeOfTransactions } from './utils/historyServiceHelper' import { testTransactionFrom, testSizeOfTransactions } from './utils/historyServiceHelper'
@ -35,7 +34,7 @@ describe('Transactions Suite', () => {
const gnosisSafe = await getSafeEthereumInstance(safeAddress) const gnosisSafe = await getSafeEthereumInstance(safeAddress)
const firstTxData = gnosisSafe.contract.addOwnerWithThreshold.getData(accounts[1], 2) const firstTxData = gnosisSafe.contract.addOwnerWithThreshold.getData(accounts[1], 2)
const executor = accounts[0] const executor = accounts[0]
const nonce = signaturesViaMetamask() ? await gnosisSafe.nonce() : Date.now() const nonce = await gnosisSafe.nonce()
const firstTxHash = await createTransaction(safe, 'Add Owner Second account', safeAddress, 0, nonce, executor, firstTxData) const firstTxHash = await createTransaction(safe, 'Add Owner Second account', safeAddress, 0, nonce, executor, firstTxData)
await store.dispatch(fetchSafe(safe)) await store.dispatch(fetchSafe(safe))
safe = getSafeFrom(store.getState(), safeAddress) safe = getSafeFrom(store.getState(), safeAddress)