WA-238 Adding logic for withdrawing safe's funds

This commit is contained in:
apanizo 2018-05-08 13:27:22 +02:00
parent fe7a936687
commit 8d3bfa8d2a
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,26 @@
// @flow
import { getGnosisSafeContract, getCreateDailyLimitExtensionContract } from '~/wallets/safeContracts'
export const DESTINATION_PARAM = 'destination'
export const VALUE_PARAM = 'ether'
const withdrawn = async (values: Object, safeAddress: string, userAccount: string): Promise<void> => {
const gnosisSafe = getGnosisSafeContract().at(safeAddress)
const dailyLimitExtension = getCreateDailyLimitExtensionContract().at(gnosisSafe.getExtensions()[0])
if (await dailyLimitExtension.gnosisSafe() !== gnosisSafe.address) {
throw new Error('Using an extension of different safe')
}
const CALL = 0
await gnosisSafe.executeExtension(
values[DESTINATION_PARAM],
values[VALUE_PARAM],
0,
CALL,
dailyLimitExtension.address,
{ from: userAccount },
)
}
export default withdrawn

View File

@ -44,7 +44,7 @@ const createDailyLimitExtensionContract = (web3: any) => {
export const getGnosisSafeContract = ensureOnce(createGnosisSafeContract) export const getGnosisSafeContract = ensureOnce(createGnosisSafeContract)
const getCreateProxyFactoryContract = ensureOnce(createProxyFactoryContract) const getCreateProxyFactoryContract = ensureOnce(createProxyFactoryContract)
const getCreateAddExtensionContract = ensureOnce(createAddExtensionContract) const getCreateAddExtensionContract = ensureOnce(createAddExtensionContract)
const getCreateDailyLimitExtensionContract = ensureOnce(createDailyLimitExtensionContract) export const getCreateDailyLimitExtensionContract = ensureOnce(createDailyLimitExtensionContract)
const createMasterCopies = async () => { const createMasterCopies = async () => {
const web3 = getWeb3() const web3 = getWeb3()