From f8e7b1309547cdf8a08df44f70439830a3c92d26 Mon Sep 17 00:00:00 2001 From: apanizo Date: Thu, 21 Jun 2018 17:01:15 +0200 Subject: [PATCH] WA-438 Fix daily limit module address --- src/routes/safe/component/EditDailyLimit/index.jsx | 7 ++++--- src/routes/safe/component/Safe/index.jsx | 2 +- src/routes/safe/component/Withdraw/withdraw.js | 11 +++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/routes/safe/component/EditDailyLimit/index.jsx b/src/routes/safe/component/EditDailyLimit/index.jsx index 04246d4c..d5e9f587 100644 --- a/src/routes/safe/component/EditDailyLimit/index.jsx +++ b/src/routes/safe/component/EditDailyLimit/index.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import Stepper from '~/components/Stepper' import { connect } from 'react-redux' import { createTransaction } from '~/routes/safe/component/AddTransaction/createTransactions' -import { getEditDailyLimitData } from '~/routes/safe/component/Withdraw/withdraw' +import { getEditDailyLimitData, getDailyLimitAddress } from '~/routes/safe/component/Withdraw/withdraw' import { type Safe } from '~/routes/safe/store/model/safe' import EditDailyLimitForm, { EDIT_DAILY_LIMIT_PARAM } from './EditDailyLimitForm' import selector, { type SelectorProps } from './selector' @@ -24,7 +24,7 @@ type State = { done: boolean, } -export const CHANGE_THRESHOLD_RESET_BUTTON_TEXT = 'START' +export const CHANGE_THRESHOLD_RESET_BUTTON_TEXT = 'SEE TXs' class EditDailyLimit extends React.PureComponent { state = { @@ -37,8 +37,9 @@ class EditDailyLimit extends React.PureComponent { const newDailyLimit = values[EDIT_DAILY_LIMIT_PARAM] const safeAddress = safe.get('address') const data = await getEditDailyLimitData(safeAddress, 0, Number(newDailyLimit)) + const to = await getDailyLimitAddress(safeAddress) const nonce = Date.now() - await createTransaction(safe, `Change Safe's daily limit to ${newDailyLimit} [${nonce}]`, safeAddress, 0, nonce, userAddress, data) + await createTransaction(safe, `Change Safe's daily limit to ${newDailyLimit} [${nonce}]`, to, 0, nonce, userAddress, data) await this.props.fetchTransactions() this.setState({ done: true }) } catch (error) { diff --git a/src/routes/safe/component/Safe/index.jsx b/src/routes/safe/component/Safe/index.jsx index 6db44255..e1b3be06 100644 --- a/src/routes/safe/component/Safe/index.jsx +++ b/src/routes/safe/component/Safe/index.jsx @@ -49,7 +49,7 @@ class GnoSafe extends React.PureComponent { const { safe } = this.props const value = safe.get('dailyLimit').get('value') - this.setState({ component: }) + this.setState({ component: }) } onWithdraw = () => { diff --git a/src/routes/safe/component/Withdraw/withdraw.js b/src/routes/safe/component/Withdraw/withdraw.js index 8a51156d..eda37787 100644 --- a/src/routes/safe/component/Withdraw/withdraw.js +++ b/src/routes/safe/component/Withdraw/withdraw.js @@ -36,10 +36,17 @@ export const getDailyLimitFrom = async (safeAddress: string, tokenAddress: numbe return { value: Number(limit), spentToday: Number(spentToday) } } -export const getEditDailyLimitData = async (safeAddress: string, token: string, dailyLimit: number) => { +export const getDailyLimitAddress = async (safeAddress: string) => { const dailyLimitModule = await getDailyLimitModuleFrom(safeAddress) - return dailyLimitModule.contract.changeDailyLimit.getData(token, dailyLimit) + return dailyLimitModule.address +} + +export const getEditDailyLimitData = async (safeAddress: string, token: string, dailyLimit: string) => { + const web3 = getWeb3() + const dailyLimitModule = await getDailyLimitModuleFrom(safeAddress) + const dailyLimitInWei = web3.toWei(dailyLimit, 'ether') + return dailyLimitModule.contract.changeDailyLimit.getData(token, dailyLimitInWei) } const withdraw = async (values: Object, safeAddress: string, userAccount: string): Promise => {