diff --git a/src/routes/safe/component/Withdrawn/withdrawn.js b/src/routes/safe/component/Withdrawn/withdrawn.js new file mode 100644 index 00000000..9981bc23 --- /dev/null +++ b/src/routes/safe/component/Withdrawn/withdrawn.js @@ -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 => { + 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 diff --git a/src/wallets/safeContracts.js b/src/wallets/safeContracts.js index 547ab9cb..f2879e0b 100644 --- a/src/wallets/safeContracts.js +++ b/src/wallets/safeContracts.js @@ -44,7 +44,7 @@ const createDailyLimitExtensionContract = (web3: any) => { export const getGnosisSafeContract = ensureOnce(createGnosisSafeContract) const getCreateProxyFactoryContract = ensureOnce(createProxyFactoryContract) const getCreateAddExtensionContract = ensureOnce(createAddExtensionContract) -const getCreateDailyLimitExtensionContract = ensureOnce(createDailyLimitExtensionContract) +export const getCreateDailyLimitExtensionContract = ensureOnce(createDailyLimitExtensionContract) const createMasterCopies = async () => { const web3 = getWeb3()