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

Added possibility to override contract parameters for specific networ… #243

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion contracts/v1/assets/ContentAsset.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract ContentAsset is Named, Versioned, HubDependent, Initializable {
event AssetUpdatePaymentIncreased(address indexed assetContract, uint256 indexed tokenId, uint96 tokenAmount);

string private constant _NAME = "ContentAsset";
string private constant _VERSION = "1.0.2";
string private constant _VERSION = "1.0.3";

Assertion public assertionContract;
HashingProxy public hashingProxy;
Expand Down
10 changes: 5 additions & 5 deletions deployments/gnosis_chiado_dev_contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@
"deployed": true
},
"ContentAsset": {
"evmAddress": "0x84a17b70881aaDC2D7af9d6b0C84F3a354aD86D7",
"version": "1.0.2",
"evmAddress": "0x0859A16c0A46276aB645F23B3a9de64fbF23f0f7",
"version": "1.0.3",
"gitBranch": "main",
"gitCommitHash": "8877334d94d89edfa2fea5bff3cd7f367a8609ae",
"deploymentBlock": 8202448,
"deploymentTimestamp": 1707754968110,
"gitCommitHash": "a19d8d3030a292863fe2b84635f7917575952b32",
"deploymentBlock": 8868369,
"deploymentTimestamp": 1711100974304,
"deployed": true
}
}
Expand Down
13 changes: 7 additions & 6 deletions deployments/otp_devnet_contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
"deployed": true
},
"ContentAsset": {
"deployed": true,
"deploymentTimestamp": 1701163615555,
"evmAddress": "0xC13016c8E8053c482F806A4AEb1e91E045036c82",
"evmAddress": "0xC486F2F47D42fD65eC932354c39FD37F848727c6",
"substrateAddress": "5EMjsd11Z6ZhxveSJkRNWMWUfRpyojNDKu66p83W8rcLNFUQ",
"version": "1.0.3",
"gitBranch": "main",
"gitCommitHash": "7c5fb6a77323e20d2a9be46e0533c9453300db4a",
"substrateAddress": "5EMjsczztHhHRgmof318UvrkvZegnvBgCUyo3fMPurMC6uJB",
"version": "1.0.2"
"gitCommitHash": "a19d8d3030a292863fe2b84635f7917575952b32",
"deploymentBlock": 4250400,
"deploymentTimestamp": 1711100907997,
"deployed": true
},
"ContentAssetStorage": {
"deployed": true,
Expand Down
78 changes: 78 additions & 0 deletions deployments/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,84 @@
}
},
"mainnet": {
"overrides": {
"otp_mainnet": {
"ParametersStorage": {
"stakeWithdrawalDelay": "2419200",
"updateCommitWindowDuration": "3600"
}
},
"gnosis_mainnet": {
"CommitManagerV1": {
"reqs": [
{
"desiredValue": false,
"getterArgs": [0],
"setter": "setReq",
"setterArgs": [0, false]
},
{
"desiredValue": false,
"getterArgs": [1],
"setter": "setReq",
"setterArgs": [1, false]
},
{
"desiredValue": false,
"getterArgs": [2],
"setter": "setReq",
"setterArgs": [2, false]
},
{
"desiredValue": false,
"getterArgs": [3],
"setter": "setReq",
"setterArgs": [3, false]
}
]
},
"CommitManagerV1U1": {
"reqs": [
{
"desiredValue": false,
"getterArgs": [0],
"setter": "setReq",
"setterArgs": [0, false]
},
{
"desiredValue": false,
"getterArgs": [1],
"setter": "setReq",
"setterArgs": [1, false]
},
{
"desiredValue": false,
"getterArgs": [2],
"setter": "setReq",
"setterArgs": [2, false]
},
{
"desiredValue": false,
"getterArgs": [3],
"setter": "setReq",
"setterArgs": [3, false]
},
{
"desiredValue": false,
"getterArgs": [4],
"setter": "setReq",
"setterArgs": [4, false]
},
{
"desiredValue": false,
"getterArgs": [5],
"setter": "setReq",
"setterArgs": [5, false]
}
]
}
}
},
"CommitManagerV1": {
"reqs": [
{
Expand Down
21 changes: 18 additions & 3 deletions utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,20 @@ type ContractParametersConfig = {
[parameter: string]: ContractParameter | string | ContractParameter[];
};

type EnvironmentParametersConfig = {
type BaseEnvironmentParametersConfig = {
[contractName: string]: ContractParametersConfig;
};

type OverridesConfig = {
overrides?: {
[network: string]: {
[contractName: string]: ContractParametersConfig;
};
};
};

type EnvironmentParametersConfig = BaseEnvironmentParametersConfig & OverridesConfig;

type ParametersConfig = {
[environment: string]: EnvironmentParametersConfig;
};
Expand Down Expand Up @@ -230,8 +240,13 @@ export class Helpers {
}

public async updateContractParameters(contractName: string, contract: Contract) {
const parameters =
this.parametersConfig[this.hre.network.config.environment as keyof ParametersConfig]?.[contractName];
let parameters = this.parametersConfig[this.hre.network.config.environment]?.[contractName];

const overrideParameters =
this.parametersConfig[this.hre.network.config.environment]?.overrides?.[this.hre.network.name]?.[contractName];

parameters = { ...parameters, ...overrideParameters };

if (!parameters) {
return;
}
Expand Down
Loading