Skip to content

Commit

Permalink
Added 'environment' to hardhat config, added JSON with parameters to …
Browse files Browse the repository at this point in the history
…be set in the contracts, added function to set parameters if needed used in the deployment scripts
  • Loading branch information
u-hubar committed Dec 1, 2023
1 parent 12b3293 commit 6c774c7
Show file tree
Hide file tree
Showing 12 changed files with 785 additions and 33 deletions.
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
Loading

0 comments on commit 6c774c7

Please sign in to comment.