From 60ebb1e3b8d0e0dda2fab3f2a2037f53bc5b71ee Mon Sep 17 00:00:00 2001 From: devbest555 Date: Thu, 30 May 2024 16:09:53 +0800 Subject: [PATCH] add - when GnosisSafeL2 is already deployed, skip it --- deploy/deploy_gnosis_safe.js | 22 +++++++++++------- deploy/deploy_ownablee.js | 17 ++++++++------ deploy/setup.js | 44 +++++++++++++++++++----------------- scripts/utils.js | 2 +- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/deploy/deploy_gnosis_safe.js b/deploy/deploy_gnosis_safe.js index 4b6db6be..19ec98ea 100644 --- a/deploy/deploy_gnosis_safe.js +++ b/deploy/deploy_gnosis_safe.js @@ -2,17 +2,23 @@ module.exports = async function ({ getNamedAccounts, deployments }) { const { deploy } = deployments; const { deployer } = await getNamedAccounts(); + const { getConfig } = require('../scripts/utils'); + const network = await ethers.provider.getNetwork(); const chainId = network.chainId; console.log("Chain ID: ", chainId); - - await deploy('GnosisSafeL2', { - from: deployer, - args: [], - log: true, - deterministicDeployment: false, - skipIfAlreadyDeployed: true, - }); + + const {GnosisSafeL2} = getConfig(chainId); + + if (GnosisSafeL2 == "") { + await deploy('GnosisSafeL2', { + from: deployer, + args: [], + log: true, + deterministicDeployment: false, + skipIfAlreadyDeployed: true, + }); + } }; module.exports.id = 'deploy_gnosis_safe' diff --git a/deploy/deploy_ownablee.js b/deploy/deploy_ownablee.js index ef9799af..364ef83e 100644 --- a/deploy/deploy_ownablee.js +++ b/deploy/deploy_ownablee.js @@ -7,21 +7,24 @@ module.exports = async function ({ getNamedAccounts, deployments }) { const network = await ethers.provider.getNetwork(); const chainId = network.chainId; - const {vabToken, usdcAdress, walletAddress} = getConfig(chainId); + let GnosisSafeAddress = GnosisSafeL2; + if (GnosisSafeAddress == "") { + this.GnosisSafe = await deployments.get('GnosisSafeL2'); + GnosisSafeAddress = this.GnosisSafe.address; + } - console.log("------------- Ownablee Deployment -----------------"); - console.log({vabToken, usdcAdress, walletAddress}); + const {vabToken, usdcAdress, walletAddress, GnosisSafeL2} = getConfig(chainId); - this.GnosisSafe = await deployments.get('GnosisSafeL2'); - + console.log("------------- Ownablee Deployment -----------------"); + console.log({vabToken, usdcAdress, walletAddress, GnosisSafeL2}); + await deploy('Ownablee', { from: deployer, args: [ walletAddress, vabToken, usdcAdress, - // this.GnosisSafe.address - "0x170341dfFAD907f9695Dc1C17De622A5A2F28259", + GnosisSafeAddress, // "0xe0536a4D730a78DB8B4c4605D73e107201d9543e" // "0x3E5e853d1784cDB519DB1eB175B374FB53FE285C" ], diff --git a/deploy/setup.js b/deploy/setup.js index 03abd7f9..1a0c778b 100644 --- a/deploy/setup.js +++ b/deploy/setup.js @@ -35,28 +35,30 @@ module.exports = async function ({ deployments }) { console.log("Private Signers Address", {user1: signer1.address, user2: signer2.address}); // console.log("Private Signers", signer1, signer2); - const GnosisSafeContract = await ethers.getContractAt('GnosisSafeL2', this.GnosisSafeL2.address) - const threshold = await GnosisSafeContract.getThreshold(); - try { - if (threshold == 0) { - await GnosisSafeContract.connect(deployer).setup( - [signer1.address, signer2.address], - 2, - addressZero, - "0x", - addressZero, - addressZero, - 0, - addressZero, - {from: deployer.address} - ) - } - console.log('complete => GnosisSafeL2 setup') - } catch (ex) { - console.log('error => GnosisSafeL2 setup', ex) + const {GnosisSafeL2} = getConfig(chainId); + + if (GnosisSafeL2 == "") { + const GnosisSafeContract = await ethers.getContractAt('GnosisSafeL2', this.GnosisSafeL2.address) + const threshold = await GnosisSafeContract.getThreshold(); + try { + if (threshold == 0) { + await GnosisSafeContract.connect(deployer).setup( + [signer1.address, signer2.address], + 2, + addressZero, + "0x", + addressZero, + addressZero, + 0, + addressZero, + {from: deployer.address} + ) + } + console.log('complete => GnosisSafeL2 setup') + } catch (ex) { + console.log('error => GnosisSafeL2 setup', ex) + } } - - const FactoryFilmNFTContract = await ethers.getContractAt('FactoryFilmNFT', this.FactoryFilmNFT.address) diff --git a/scripts/utils.js b/scripts/utils.js index 962d3036..cf880869 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -179,7 +179,7 @@ const CONFIG = { FactoryFilmNFT: "", FactorySubNFT: "", FactoryTierNFT: "", - GnosisSafeL2: "", + GnosisSafeL2: "0x170341dffad907f9695dc1c17de622a5a2f28259", Ownablee: "", Property: "", StakingPool: "",