WA-238 Updating code to new safe-contracts version

This commit is contained in:
apanizo 2018-05-10 15:06:34 +02:00
parent 7b969675d7
commit 3c740c0dbb
4 changed files with 39 additions and 29 deletions

View File

@ -87,7 +87,7 @@
"storybook-host": "^4.1.5", "storybook-host": "^4.1.5",
"storybook-router": "^0.3.3", "storybook-router": "^0.3.3",
"style-loader": "^0.20.2", "style-loader": "^0.20.2",
"truffle": "4.1.5", "truffle": "4.1.8",
"truffle-contract": "^1.1.8", "truffle-contract": "^1.1.8",
"truffle-solidity-loader": "0.0.8", "truffle-solidity-loader": "0.0.8",
"uglifyjs-webpack-plugin": "^1.2.2", "uglifyjs-webpack-plugin": "^1.2.2",

View File

@ -9,24 +9,21 @@ const withdrawn = async (values: Object, safeAddress: string, userAccount: strin
const web3 = getWeb3() const web3 = getWeb3()
const gnosisSafe = getGnosisSafeContract(web3).at(safeAddress) const gnosisSafe = getGnosisSafeContract(web3).at(safeAddress)
const extensions = await gnosisSafe.getExtensions() const modules = await gnosisSafe.getModules()
const dailyAddress = extensions[0] const dailyAddress = modules[0]
const dailyLimitExtension = getCreateDailyLimitExtensionContract(web3).at(dailyAddress)
if (await dailyLimitExtension.gnosisSafe() !== gnosisSafe.address) { const dailyLimitModule = getCreateDailyLimitExtensionContract(web3).at(dailyAddress)
if (await dailyLimitModule.manager.call() !== gnosisSafe.address) {
throw new Error('Using an extension of different safe') throw new Error('Using an extension of different safe')
} }
const destination = values[DESTINATION_PARAM] const destination = values[DESTINATION_PARAM]
const value = web3.toWei(values[VALUE_PARAM], 'ether') const value = web3.toWei(values[VALUE_PARAM], 'ether')
const CALL = 0 await dailyLimitModule.executeDailyLimit(
await gnosisSafe.executeExtension(
destination, destination,
value, value,
0, 0,
CALL,
dailyLimitExtension.address,
{ from: userAccount, gas: '5000000' }, { from: userAccount, gas: '5000000' },
) )
} }

View File

@ -3,10 +3,10 @@ import contract from 'truffle-contract'
import { promisify } from '~/utils/promisify' import { promisify } from '~/utils/promisify'
import { ensureOnce } from '~/utils/singleton' import { ensureOnce } from '~/utils/singleton'
import { getWeb3 } from '~/wallets/getWeb3' import { getWeb3 } from '~/wallets/getWeb3'
import GnosisSafeSol from '#/GnosisSafe.json' import GnosisSafeSol from '#/GnosisSafeTeamEdition.json'
import ProxyFactorySol from '#/ProxyFactory.json' import ProxyFactorySol from '#/ProxyFactory.json'
import CreateAndAddExtensionSol from '#/CreateAndAddExtension.json' import CreateAndAddModule from '#/CreateAndAddModule.json'
import DailyLimitExtensionSol from '#/DailyLimitExtension.json' import DailyLimitModule from '#/DailyLimitModule.json'
let proxyFactoryMaster let proxyFactoryMaster
let createAndAddExtensionMaster let createAndAddExtensionMaster
@ -28,17 +28,17 @@ const createProxyFactoryContract = (web3: any) => {
} }
const createAddExtensionContract = (web3: any) => { const createAddExtensionContract = (web3: any) => {
const createAndAddExtension = contract(CreateAndAddExtensionSol) const createAndAddModule = contract(CreateAndAddModule)
createAndAddExtension.setProvider(web3.currentProvider) createAndAddModule.setProvider(web3.currentProvider)
return createAndAddExtension return createAndAddModule
} }
const createDailyLimitExtensionContract = (web3: any) => { const createDailyLimitExtensionContract = (web3: any) => {
const dailyLimitExtension = contract(DailyLimitExtensionSol) const dailyLimitModule = contract(DailyLimitModule)
dailyLimitExtension.setProvider(web3.currentProvider) dailyLimitModule.setProvider(web3.currentProvider)
return dailyLimitExtension return dailyLimitModule
} }
export const getGnosisSafeContract = ensureOnce(createGnosisSafeContract) export const getGnosisSafeContract = ensureOnce(createGnosisSafeContract)
@ -88,11 +88,14 @@ export const initContracts = ensureOnce(createMasterCopies)
const getSafeDataBasedOn = async (accounts, numConfirmations, dailyLimitInEth) => { const getSafeDataBasedOn = async (accounts, numConfirmations, dailyLimitInEth) => {
const web3 = getWeb3() const web3 = getWeb3()
const extensionData = await dailyLimitMaster.contract.setup
const moduleData = await dailyLimitMaster.contract.setup
.getData([0], [web3.toWei(dailyLimitInEth, 'ether')]) .getData([0], [web3.toWei(dailyLimitInEth, 'ether')])
const proxyFactoryData = await proxyFactoryMaster.contract.createProxy const proxyFactoryData = await proxyFactoryMaster.contract.createProxy
.getData(dailyLimitMaster.address, extensionData) .getData(dailyLimitMaster.address, moduleData)
const createAndAddExtensionData = createAndAddExtensionMaster.contract.createAndAddExtension
const createAndAddExtensionData = createAndAddExtensionMaster.contract.createAndAddModule
.getData(proxyFactoryMaster.address, proxyFactoryData) .getData(proxyFactoryMaster.address, proxyFactoryData)
return safeMaster.contract.setup return safeMaster.contract.setup

View File

@ -10477,9 +10477,9 @@ sockjs@0.3.19:
faye-websocket "^0.10.0" faye-websocket "^0.10.0"
uuid "^3.0.1" uuid "^3.0.1"
solc@0.4.21, solc@^0.4.2: solc@0.4.23:
version "0.4.21" version "0.4.23"
resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.21.tgz#6a7ecd505bfa0fc268330d5de6b9ae65c8c68264" resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.23.tgz#54a0ff4015827b32fddb62c0a418b5247310a58e"
dependencies: dependencies:
fs-extra "^0.30.0" fs-extra "^0.30.0"
memorystream "^0.3.1" memorystream "^0.3.1"
@ -10505,6 +10505,16 @@ solc@^0.3.6:
require-from-string "^1.1.0" require-from-string "^1.1.0"
yargs "^4.7.1" yargs "^4.7.1"
solc@^0.4.2:
version "0.4.21"
resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.21.tgz#6a7ecd505bfa0fc268330d5de6b9ae65c8c68264"
dependencies:
fs-extra "^0.30.0"
memorystream "^0.3.1"
require-from-string "^1.1.0"
semver "^5.3.0"
yargs "^4.7.1"
solidity-parser@^0.1.0, solidity-parser@^0.1.1: solidity-parser@^0.1.0, solidity-parser@^0.1.1:
version "0.1.1" version "0.1.1"
resolved "https://registry.yarnpkg.com/solidity-parser/-/solidity-parser-0.1.1.tgz#0fb3b665ed7041bef4575962ee426e7cd9d0a90a" resolved "https://registry.yarnpkg.com/solidity-parser/-/solidity-parser-0.1.1.tgz#0fb3b665ed7041bef4575962ee426e7cd9d0a90a"
@ -11252,13 +11262,13 @@ truffle-solidity-loader@0.0.8:
truffle "^2.0.8" truffle "^2.0.8"
web3 "^0.17.0-alpha" web3 "^0.17.0-alpha"
truffle@4.1.5: truffle@4.1.8:
version "4.1.5" version "4.1.8"
resolved "https://registry.yarnpkg.com/truffle/-/truffle-4.1.5.tgz#763c8175fe5ea1ada92aa7a02eff84b4ab272f72" resolved "https://registry.yarnpkg.com/truffle/-/truffle-4.1.8.tgz#b0b9175e0270145999567a3f0a2337c914a23a9c"
dependencies: dependencies:
mocha "^3.4.2" mocha "^3.4.2"
original-require "^1.0.1" original-require "^1.0.1"
solc "0.4.21" solc "0.4.23"
truffle@^2.0.8: truffle@^2.0.8:
version "2.1.2" version "2.1.2"