From decc4c90a108e72dc0a2d23349b8c0e615cf3c53 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Tue, 5 Dec 2023 14:24:46 +0100 Subject: [PATCH 1/2] Added possibility to set new contracts in the Hub using multisig --- deploy/998_initialize_contracts.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/deploy/998_initialize_contracts.ts b/deploy/998_initialize_contracts.ts index 543bdb57..1f3f87bf 100644 --- a/deploy/998_initialize_contracts.ts +++ b/deploy/998_initialize_contracts.ts @@ -13,12 +13,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { newScoreFunctions, } = hre.helpers; - if (hre.network.name !== 'hardhat') { + if (hre.network.config.environment === 'testnet' || hre.network.config.environment == 'mainnet') { const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; + const multiSigWalletAddress = hre.helpers.contractDeployments.contracts['Multisig'].evmAddress; console.log(`HubController: ${hubControllerAddress}`); + console.log(`MultiSigWallet: ${multiSigWalletAddress}`); const HubController = await hre.ethers.getContractAt('HubController', hubControllerAddress, deployer); + const MultiSigWallet = await hre.ethers.getContractAt('MultiSigWallet', multiSigWalletAddress, deployer); console.log(`New or redeployed contracts: ${JSON.stringify(newContracts)}`); console.log(`New or redeployed Asset Storage contracts: ${JSON.stringify(newAssetStorageContracts)}`); @@ -27,15 +30,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log(`New or redeployed hash functions set in the proxy: ${JSON.stringify(newHashFunctions)}`); console.log(`New or redeployed score functions set in the proxy: ${JSON.stringify(newScoreFunctions)}`); - const setAndReinitializeContractsTx = await HubController.setAndReinitializeContracts( + // Prepare the data for the setAndReinitializeContracts function call + const encodedData = HubController.interface.encodeFunctionData('setAndReinitializeContracts', [ newContracts, newAssetStorageContracts, newHashFunctions, newScoreFunctions, contractsForReinitialization, setParametersEncodedData, - ); - await setAndReinitializeContractsTx.wait(); + ]); + + // Submit the transaction to the multisig wallet + const submitTx = await MultiSigWallet.submitTransaction(hubControllerAddress, 0, encodedData); + await submitTx.wait(); + + // After that, other owners of the multisig wallet should use 'confirmTransaction' function. + // When needed confirmations amount is reached, 'executeTransaction' should be executed. } }; From 6968285a7da387ca33ccb4f8317c16a4b51cd010 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Tue, 5 Dec 2023 14:32:38 +0100 Subject: [PATCH 2/2] Added logging for submitted multisig transaction id --- deploy/998_initialize_contracts.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deploy/998_initialize_contracts.ts b/deploy/998_initialize_contracts.ts index 1f3f87bf..fff28e18 100644 --- a/deploy/998_initialize_contracts.ts +++ b/deploy/998_initialize_contracts.ts @@ -40,6 +40,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { setParametersEncodedData, ]); + MultiSigWallet.on('Submission', (transactionId) => { + console.log(`[Multisig] HubController.setAndReinitializeContracts Transaction ID: ${transactionId}`); + }); + // Submit the transaction to the multisig wallet const submitTx = await MultiSigWallet.submitTransaction(hubControllerAddress, 0, encodedData); await submitTx.wait();