execution of the transaction

This commit is contained in:
Mikhail Mikheev 2019-07-05 20:04:46 +04:00
parent 87c41e4d78
commit 6b6d6cc3c9
4 changed files with 19 additions and 9 deletions

View File

@ -1,9 +1,9 @@
// @flow
import contract from 'truffle-contract'
import ProxyFactorySol from '@gnosis.pm/safe-contracts/build/contracts/ProxyFactory.json'
import GnosisSafeSol from '@gnosis.pm/safe-contracts/build/contracts/GnosisSafe.json'
import { ensureOnce } from '~/utils/singleton'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import GnosisSafeSol from '@gnosis.pm/safe-contracts/build/contracts/GnosisSafe.json'
import ProxyFactorySol from '@gnosis.pm/safe-contracts/build/contracts/ProxyFactory.json'
import { calculateGasOf, calculateGasPrice } from '~/logic/wallets/ethTransactions'
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'

View File

@ -7,6 +7,7 @@ import { type Token } from '~/logic/tokens/store/model/token'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import { type Operation, saveTxToHistory } from '~/logic/safe/transactions'
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
import { getErrorMessage } from '~/test/utils/ethereumErrors'
export const CALL = 0
export const TX_TYPE_EXECUTION = 'execution'
@ -83,6 +84,13 @@ export const executeTransaction = async (
)}000000000000000000000000000000000000000000000000000000000000000001`
}
// debug
const executeDataUsedSignatures = safeInstance.contract.methods
.execTransaction(to, valueInWei, data, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs)
.encodeABI()
console.log(await getErrorMessage(safeInstance.address, 0, executeDataUsedSignatures, sender))
// debug end
const receipt = await safeInstance.execTransaction(
to,
valueInWei,

View File

@ -10,13 +10,15 @@ import { approveTransaction, executeTransaction, CALL } from '~/logic/safe/trans
// https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures
// https://github.com/gnosis/safe-contracts/blob/master/test/gnosisSafeTeamEdition.js#L26
const generateSignaturesFromTxConfirmations = (tx: Transaction) => {
// The constant parts need to be sorted so that the recovered signers are sorted ascending (natural order) by address (not checksummed).
const confirmedAdresses = tx.confirmations.map(conf => conf.owner.address).sort()
let sigs = '0x'
tx.confirmations.forEach((conf) => {
sigs
+= `000000000000000000000000${
conf.owner.address.replace('0x', '')
}0000000000000000000000000000000000000000000000000000000000000000`
+ '01'
confirmedAdresses.forEach((addr) => {
sigs += `000000000000000000000000${addr.replace(
'0x',
'',
)}000000000000000000000000000000000000000000000000000000000000000001`
})
return sigs
}

View File

@ -1,6 +1,6 @@
// @flow
import { getWeb3 } from '~/logic/wallets/getWeb3'
import abi from 'ethereumjs-abi'
import { getWeb3 } from '~/logic/wallets/getWeb3'
/*
console.log(`to[${to}] \n\n valieInWei[${valueInWei}] \n\n