WA-438 Fix daily limit module address

This commit is contained in:
apanizo 2018-06-21 17:01:15 +02:00
parent 26e6712a7d
commit f8e7b13095
3 changed files with 14 additions and 6 deletions

View File

@ -3,7 +3,7 @@ import * as React from 'react'
import Stepper from '~/components/Stepper' import Stepper from '~/components/Stepper'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { createTransaction } from '~/routes/safe/component/AddTransaction/createTransactions' 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 { type Safe } from '~/routes/safe/store/model/safe'
import EditDailyLimitForm, { EDIT_DAILY_LIMIT_PARAM } from './EditDailyLimitForm' import EditDailyLimitForm, { EDIT_DAILY_LIMIT_PARAM } from './EditDailyLimitForm'
import selector, { type SelectorProps } from './selector' import selector, { type SelectorProps } from './selector'
@ -24,7 +24,7 @@ type State = {
done: boolean, done: boolean,
} }
export const CHANGE_THRESHOLD_RESET_BUTTON_TEXT = 'START' export const CHANGE_THRESHOLD_RESET_BUTTON_TEXT = 'SEE TXs'
class EditDailyLimit extends React.PureComponent<Props, State> { class EditDailyLimit extends React.PureComponent<Props, State> {
state = { state = {
@ -37,8 +37,9 @@ class EditDailyLimit extends React.PureComponent<Props, State> {
const newDailyLimit = values[EDIT_DAILY_LIMIT_PARAM] const newDailyLimit = values[EDIT_DAILY_LIMIT_PARAM]
const safeAddress = safe.get('address') const safeAddress = safe.get('address')
const data = await getEditDailyLimitData(safeAddress, 0, Number(newDailyLimit)) const data = await getEditDailyLimitData(safeAddress, 0, Number(newDailyLimit))
const to = await getDailyLimitAddress(safeAddress)
const nonce = Date.now() 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() await this.props.fetchTransactions()
this.setState({ done: true }) this.setState({ done: true })
} catch (error) { } catch (error) {

View File

@ -49,7 +49,7 @@ class GnoSafe extends React.PureComponent<SafeProps, State> {
const { safe } = this.props const { safe } = this.props
const value = safe.get('dailyLimit').get('value') const value = safe.get('dailyLimit').get('value')
this.setState({ component: <EditDailyLimit safe={safe} dailyLimit={value} /> }) this.setState({ component: <EditDailyLimit safe={safe} dailyLimit={value} onReset={this.onListTransactions} /> })
} }
onWithdraw = () => { onWithdraw = () => {

View File

@ -36,10 +36,17 @@ export const getDailyLimitFrom = async (safeAddress: string, tokenAddress: numbe
return { value: Number(limit), spentToday: Number(spentToday) } 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) 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<void> => { const withdraw = async (values: Object, safeAddress: string, userAccount: string): Promise<void> => {