From 7f53e43fe9e40d3fe9fb644cb10d45768d360f7c Mon Sep 17 00:00:00 2001 From: apanizo Date: Wed, 2 May 2018 16:43:16 +0200 Subject: [PATCH] WA-238 FIX creating master copy if contract has not been deployed --- src/wallets/safeContracts.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/wallets/safeContracts.js b/src/wallets/safeContracts.js index d3a344b7..fc4521db 100644 --- a/src/wallets/safeContracts.js +++ b/src/wallets/safeContracts.js @@ -53,30 +53,34 @@ const createMasterCopies = async () => { // Create ProxyFactory Master Copy const ProxyFactory = getCreateProxyFactoryContract(web3) - proxyFactoryMaster = await ProxyFactory.deployed() - if (!proxyFactoryMaster) { + try { + proxyFactoryMaster = await ProxyFactory.deployed() + } catch (err) { proxyFactoryMaster = await ProxyFactory.new({ from: userAccount, gas: '5000000' }) } // Create AddExtension Master Copy const CreateAndAddExtension = getCreateAddExtensionContract(web3) - createAndAddExtensionMaster = await CreateAndAddExtension.deployed() - if (!createAndAddExtensionMaster) { + try { + createAndAddExtensionMaster = await CreateAndAddExtension.deployed() + } catch (err) { createAndAddExtensionMaster = await CreateAndAddExtension.new({ from: userAccount, gas: '5000000' }) } // Initialize safe master copy const GnosisSafe = getGnosisSafeContract(web3) - safeMaster = await GnosisSafe.deployed() - if (!safeMaster) { + try { + safeMaster = await GnosisSafe.deployed() + } catch (err) { safeMaster = await GnosisSafe.new({ from: userAccount, gas: '5000000' }) safeMaster.setup([userAccount], 1, 0, 0, { from: userAccount, gas: '5000000' }) } // Initialize extension master copy const DailyLimitExtension = getCreateDailyLimitExtensionContract(web3) - dailyLimitMaster = await DailyLimitExtension.deployed() - if (!dailyLimitMaster) { + try { + dailyLimitMaster = await DailyLimitExtension.deployed() + } catch (err) { dailyLimitMaster = await DailyLimitExtension.new({ from: userAccount, gas: '5000000' }) dailyLimitMaster.setup([], [], { from: userAccount, gas: '5000000' }) }