Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters JSON config #200

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions deploy/004_deploy_parameters_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const isDeployed = hre.helpers.isDeployed('ParametersStorage');

await hre.helpers.deploy({
const ParametersStorage = await hre.helpers.deploy({
newContractName: 'ParametersStorage',
});

if (!isDeployed && ['otp_alphanet', 'otp_devnet', 'otp_testnet'].includes(hre.network.name)) {
const variables = hre.helpers.contractDeployments.contracts['ParametersStorage'].variables ?? {};

const ParametersStorageAbi = hre.helpers.getAbi('ParametersStorage');
const ParametersStorageInterface = new hre.ethers.utils.Interface(ParametersStorageAbi);

hre.helpers.setParametersEncodedData = [['ParametersStorage', []]];

for (const variableName in variables) {
hre.helpers.setParametersEncodedData[0][1].push(
ParametersStorageInterface.encodeFunctionData(
`set${variableName.charAt(0).toUpperCase() + variableName.slice(1)}`,
[variables[variableName]],
),
);
}
}
await hre.helpers.updateContractParameters('ParametersStorage', ParametersStorage);
};

export default func;
Expand Down
4 changes: 3 additions & 1 deletion deploy/005_deploy_whitelist_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await hre.helpers.deploy({
const WhitelistStorage = await hre.helpers.deploy({
newContractName: 'WhitelistStorage',
});

await hre.helpers.updateContractParameters('WhitelistStorage', WhitelistStorage);
};

export default func;
Expand Down
2 changes: 2 additions & 0 deletions deploy/009_deploy_log2pldsf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
hre.helpers.newScoreFunctions.push(Log2PLDSF.address);
}
}

await hre.helpers.updateContractParameters('Log2PLDSF', Log2PLDSF);
};

export default func;
Expand Down
4 changes: 3 additions & 1 deletion deploy/027_deploy_commit_manager_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await hre.helpers.deploy({
const CommitManagerV1 = await hre.helpers.deploy({
newContractName: 'CommitManagerV1',
});

await hre.helpers.updateContractParameters('CommitManagerV1', CommitManagerV1);
};

export default func;
Expand Down
4 changes: 3 additions & 1 deletion deploy/028_deploy_proof_manager_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await hre.helpers.deploy({
const ProofManagerV1 = await hre.helpers.deploy({
newContractName: 'ProofManagerV1',
});

await hre.helpers.updateContractParameters('ProofManagerV1', ProofManagerV1);
};

export default func;
Expand Down
4 changes: 3 additions & 1 deletion deploy/029_deploy_commit_manager_v1_u1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await hre.helpers.deploy({
const CommitManagerV1U1 = await hre.helpers.deploy({
newContractName: 'CommitManagerV1U1',
});

await hre.helpers.updateContractParameters('CommitManagerV1U1', CommitManagerV1U1);
};

export default func;
Expand Down
4 changes: 3 additions & 1 deletion deploy/030_deploy_proof_manager_v1_u1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await hre.helpers.deploy({
const ProofManagerV1U1 = await hre.helpers.deploy({
newContractName: 'ProofManagerV1U1',
});

await hre.helpers.updateContractParameters('ProofManagerV1U1', ProofManagerV1U1);
};

export default func;
Expand Down
22 changes: 18 additions & 4 deletions deploy/998_initialize_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
Expand All @@ -27,15 +30,26 @@ 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();
]);

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();

// After that, other owners of the multisig wallet should use 'confirmTransaction' function.
// When needed confirmations amount is reached, 'executeTransaction' should be executed.
}
};

Expand Down
Loading