From 22d75d014c14d1acae26464c9b1e99c270b6c39b Mon Sep 17 00:00:00 2001 From: MrDeadCe11 <84342118+MrDeadCe11@users.noreply.github.com> Date: Wed, 22 May 2024 14:33:36 -0500 Subject: [PATCH] 691 allow script gen (#705) * made generate run on a fork of mainnet or sepolia. should no longer require a private key to generate a proposal * linted * added an open proposal generation script * linted * removed loading of private key from generator scripts * removed generated test file * Format output json --------- Co-authored-by: Patrick Gallagher --- gov-input/anvil/new-AddCollateral.json | 39 +--------- gov-input/mainnet/new-AddCollateral.json | 74 +++++++++---------- gov-input/mainnet/new-TargetsAndCalldata.json | 22 ++++++ gov-input/mainnet/new-UpdateDelay.json | 18 ++--- gov-input/sepolia/new-AddCollateral.json | 39 +--------- package.json | 4 +- .../GenerateAddCollateralProposal.s.sol | 4 - .../GenerateAddNitroRewardsProposal.s.sol | 4 - .../GenerateERC20TransferProposal.s.sol | 4 - ...odifyParametersPerCollateralProposal.s.sol | 4 - .../GenerateModifyParametersProposal.s.sol | 4 - .../GenerateTargetsAndCalldataProposal.s.sol | 62 ++++++++++++++++ .../GenerateUpdateDelayProposal.s.sol | 4 - script/gov/Generator.s.sol | 9 ++- tasks/governanceManager.sh | 7 +- tasks/parseProposalOutputs.js | 2 +- tasks/parseProposalPath.js | 10 ++- 17 files changed, 150 insertions(+), 160 deletions(-) create mode 100644 gov-input/mainnet/new-TargetsAndCalldata.json create mode 100644 script/gov/Generate/GenerateTargetsAndCalldataProposal.s.sol diff --git a/gov-input/anvil/new-AddCollateral.json b/gov-input/anvil/new-AddCollateral.json index bf109b24..bf6444e6 100644 --- a/gov-input/anvil/new-AddCollateral.json +++ b/gov-input/anvil/new-AddCollateral.json @@ -1,38 +1 @@ -{ - "chainid": "31337", - "description": "add NEWADD as a collateral type", - "network": "anvil", - "newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853", - "newCollateralType": "NEWADD", - "proposalType": "AddCollateral", - "ProtocolToken_Address": "", - "ODGovernor_Address": "", - "SAFEEngine_Address": "", - "OracleRelayer_Address": "", - "LiquidationEngine_Address": "", - "TaxCollector_Address": "", - "GlobalSettlement_Address": "", - "SAFEEngineCollateralParams": { - "collateralDebtCeiling": "500000000000000000000000000000000000000000000000", - "collateralDebtFloor": "100000000000000000000000000000000000000000000000" - }, - "TaxCollectorCollateralParams": { - "stabilityFee": "1000000000000000000000000000" - }, - "LiquidationEngineCollateralParams": { - "newCAHChild": "0xd468bF477c0c99095D508c3B0A60f39348d91ac0", - "liquidationPenalty": "1000000000000000000", - "liquidationQuantity": "1000000000000000000000000000000000000000000000" - }, - "OracleRelayerCollateralParams": { - "delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9", - "safetyCRatio": "1000000000000000000000000000", - "liquidationCRatio": "1000000000000000000000000000" - }, - "CollateralAuctionHouseParams": { - "maximumDiscount": "1", - "minimumBid": "2", - "minimumDiscount": "3", - "perSecondDiscountUpdateRate": "999998607628240538157433861" - } -} \ No newline at end of file +{"chainid":"31337","description":"add NEWADDed as a collateral type","network":"anvil","newCollateralAddress":"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853","newCollateralType":"NEWADD","proposalType":"AddCollateral","ProtocolToken_Address":"0xc6e7DF5E7b4f2A278906862b61205850344D4e7d","ODGovernor_Address":"0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f","SAFEEngine_Address":"0x67d269191c92Caf3cD7723F116c85e6E9bf55933","OracleRelayer_Address":"0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E","LiquidationEngine_Address":"0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9","TaxCollector_Address":"0x95401dc811bb5740090279Ba06cfA8fcF6113778","GlobalSettlement_Address":"0x5f3f1dBD7B74C6B46e8c44f98792A1dAf8d69154","SAFEEngineCollateralParams":{"collateralDebtCeiling":"500000000000000000000000000000000000000000000000","collateralDebtFloor":"100000000000000000000000000000000000000000000000"},"TaxCollectorCollateralParams":{"stabilityFee":"1000000000000000000000000000"},"LiquidationEngineCollateralParams":{"liquidationPenalty":"1000000000000000000","liquidationQuantity":"1000000000000000000000000000000000000000000000","newCAHChild":"0xf9b42E09Fd787d6864D6b2Cd8E1350fc93E6683D"},"OracleRelayerCollateralParams":{"delayedOracle":"0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9","safetyCRatio":"1000000000000000000000000000","liquidationCRatio":"1000000000000000000000000000"},"CollateralAuctionHouseParams":{"maximumDiscount":"1","minimumBid":"2","minimumDiscount":"3","perSecondDiscountUpdateRate":"999998607628240538157433861"}} \ No newline at end of file diff --git a/gov-input/mainnet/new-AddCollateral.json b/gov-input/mainnet/new-AddCollateral.json index 2fe7f42a..eff06ba0 100644 --- a/gov-input/mainnet/new-AddCollateral.json +++ b/gov-input/mainnet/new-AddCollateral.json @@ -1,38 +1,38 @@ { - "chainid": "42161", - "description": "add NEWADD as a collateral type", - "network": "mainnet", - "newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853", - "newCollateralType": "NEWADD", - "proposalType": "AddCollateral", - "ProtocolToken_Address": "", - "ODGovernor_Address": "", - "SAFEEngine_Address": "", - "OracleRelayer_Address": "", - "LiquidationEngine_Address": "", - "TaxCollector_Address": "", - "GlobalSettlement_Address": "", - "SAFEEngineCollateralParams": { - "collateralDebtCeiling": "500000000000000000000000000000000000000000000000", - "collateralDebtFloor": "100000000000000000000000000000000000000000000000" - }, - "TaxCollectorCollateralParams": { - "stabilityFee": "1000000000000000000000000000" - }, - "LiquidationEngineCollateralParams": { - "newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263", - "liquidationPenalty": "1000000000000000000", - "liquidationQuantity": "1000000000000000000000000000000000000000000000" - }, - "OracleRelayerCollateralParams": { - "delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9", - "safetyCRatio": "1000000000000000000000000000", - "liquidationCRatio": "1000000000000000000000000000" - }, - "CollateralAuctionHouseParams": { - "maximumDiscount": "1", - "minimumBid": "2", - "minimumDiscount": "3", - "perSecondDiscountUpdateRate": "999998607628240538157433861" - } -} \ No newline at end of file + "chainid": "42161", + "description": "add NEWADD as a collateral type", + "network": "mainnet", + "newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853", + "newCollateralType": "NEWADD", + "proposalType": "AddCollateral", + "ProtocolToken_Address": "", + "ODGovernor_Address": "", + "SAFEEngine_Address": "", + "OracleRelayer_Address": "", + "LiquidationEngine_Address": "", + "TaxCollector_Address": "", + "GlobalSettlement_Address": "", + "SAFEEngineCollateralParams": { + "collateralDebtCeiling": "500000000000000000000000000000000000000000000000", + "collateralDebtFloor": "100000000000000000000000000000000000000000000000" + }, + "TaxCollectorCollateralParams": { + "stabilityFee": "1000000000000000000000000000" + }, + "LiquidationEngineCollateralParams": { + "newCAHChild": "0x293b702362918e990Dd5f48a80fB139FeAd64263", + "liquidationPenalty": "1000000000000000000", + "liquidationQuantity": "1000000000000000000000000000000000000000000000" + }, + "OracleRelayerCollateralParams": { + "delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9", + "safetyCRatio": "1000000000000000000000000000", + "liquidationCRatio": "1000000000000000000000000000" + }, + "CollateralAuctionHouseParams": { + "maximumDiscount": "1", + "minimumBid": "2", + "minimumDiscount": "3", + "perSecondDiscountUpdateRate": "999998607628240538157433861" + } +} diff --git a/gov-input/mainnet/new-TargetsAndCalldata.json b/gov-input/mainnet/new-TargetsAndCalldata.json new file mode 100644 index 00000000..3f1fb412 --- /dev/null +++ b/gov-input/mainnet/new-TargetsAndCalldata.json @@ -0,0 +1,22 @@ +{ + "chainid": 42161, + "description": "Random calldatas", + "network": "mainnet", + "proposalType": "TargetsAndCalldata", + "ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F", + "objectArray": [ + { + "target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70", + "calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15" + }, + { + "target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70", + "calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15" + }, + { + "target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70", + "calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15" + } + ], + "arrayLength": "3" +} \ No newline at end of file diff --git a/gov-input/mainnet/new-UpdateDelay.json b/gov-input/mainnet/new-UpdateDelay.json index bde24e5f..87a39518 100644 --- a/gov-input/mainnet/new-UpdateDelay.json +++ b/gov-input/mainnet/new-UpdateDelay.json @@ -1,10 +1,10 @@ { -"chainid": 42161, -"description": "update timelock controller delay", -"network": "mainnet", -"TimelockController_Address": "", -"ProtocolToken_Address": "", -"ODGovernor_Address": "", -"proposalType": "UpdateDelay", -"newDelay": 86400 -} \ No newline at end of file + "chainid": 42161, + "description": "update timelock controller delay", + "network": "mainnet", + "TimelockController_Address": "", + "ProtocolToken_Address": "", + "ODGovernor_Address": "", + "proposalType": "UpdateDelay", + "newDelay": 86400 +} diff --git a/gov-input/sepolia/new-AddCollateral.json b/gov-input/sepolia/new-AddCollateral.json index de42025e..97b55161 100644 --- a/gov-input/sepolia/new-AddCollateral.json +++ b/gov-input/sepolia/new-AddCollateral.json @@ -1,38 +1 @@ -{ - "chainid": "421614", - "network": "sepolia", - "newCollateralAddress": "", - "newCollateralType": "", - "proposalType": "AddCollateral", - "description": "", - "ProtocolToken_Address": "", - "ODGovernor_Address": "", - "SAFEEngine_Address": "", - "OracleRelayer_Address": "", - "LiquidationEngine_Address": "", - "TaxCollector_Address": "", - "GlobalSettlement_Address": "", - "SAFEEngineCollateralParams": { - "collateralDebtCeiling": "", - "collateralDebtFloor": "" - }, - "TaxCollectorCollateralParams": { - "stabilityFee": "" - }, - "LiquidationEngineCollateralParams": { - "newCAHChild": "", - "liquidationPenalty": "", - "liquidationQuantity": "" - }, - "OracleRelayerCollateralParams": { - "delayedOracle": "", - "safetyCRatio": "", - "liquidationCRatio": "" - }, - "CollateralAuctionHouseParams": { - "maximumDiscount": "", - "minimumBid": "", - "minimumDiscount": "", - "perSecondDiscountUpdateRate": "" - } -} \ No newline at end of file +{"chainid":"421614","network":"sepolia","newCollateralAddress":"0x1ebFA3a5074f74C1dE3d1bfd1e981ab89475Ef14","newCollateralType":"NEWEY","proposalType":"AddCollateral","description":"it's a new collateratl!","ProtocolToken_Address":"","ODGovernor_Address":"","SAFEEngine_Address":"","OracleRelayer_Address":"","LiquidationEngine_Address":"","TaxCollector_Address":"","GlobalSettlement_Address":"","SAFEEngineCollateralParams":{"collateralDebtCeiling":"1","collateralDebtFloor":"2"},"TaxCollectorCollateralParams":{"stabilityFee":"3"},"LiquidationEngineCollateralParams":{"newCAHChild":"0x1ebFA3a5074f74C1dE3d1bfd1e981ab89475Ef14","liquidationPenalty":"4","liquidationQuantity":"5"},"OracleRelayerCollateralParams":{"delayedOracle":"0x1ebFA3a5074f74C1dE3d1bfd1e981ab89475Ef14","safetyCRatio":"6","liquidationCRatio":"7"},"CollateralAuctionHouseParams":{"maximumDiscount":"8","minimumBid":"9","minimumDiscount":"10","perSecondDiscountUpdateRate":"11"}} \ No newline at end of file diff --git a/package.json b/package.json index 9ae62d37..03ddb91a 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,13 @@ "name": "@opendollar/contracts", "version": "1.7.1", "private": true, - "description": "Multicollateral ETH backed stablecoin", + "description": "Contracts for the Open Dollar protocol", "homepage": "https://www.opendollar.com/", "repository": { "type": "git", "url": "https://github.com/open-dollar/od-contracts" }, - "license": "MIT", + "license": "GNU AGPL", "author": "OpenFi Foundation", "contributors": [ "cupOJoseph (https://github.com/cupOJoseph)", diff --git a/script/gov/Generate/GenerateAddCollateralProposal.s.sol b/script/gov/Generate/GenerateAddCollateralProposal.s.sol index 93d11781..a0e50066 100644 --- a/script/gov/Generate/GenerateAddCollateralProposal.s.sol +++ b/script/gov/Generate/GenerateAddCollateralProposal.s.sol @@ -174,8 +174,6 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { // Get the descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); - vm.startBroadcast(_privateKey); - // Propose the action to add the collateral type uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); string memory stringProposalId = vm.toString(proposalId / 10 ** 69); @@ -187,8 +185,6 @@ contract GenerateAddCollateralProposal is Generator, JSONScript { _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/', stringProposalId, '-add-collateral.json')); } - - vm.stopBroadcast(); } function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) { diff --git a/script/gov/Generate/GenerateAddNitroRewardsProposal.s.sol b/script/gov/Generate/GenerateAddNitroRewardsProposal.s.sol index c2db3af2..71d51026 100644 --- a/script/gov/Generate/GenerateAddNitroRewardsProposal.s.sol +++ b/script/gov/Generate/GenerateAddNitroRewardsProposal.s.sol @@ -71,8 +71,6 @@ contract GenerateAddNitroRewardsProposal is Generator, JSONScript { // Get the description and descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); - vm.startBroadcast(_privateKey); - // Propose the action to add rewards to NitroPool uint256 proposalId = gov.propose(targets, values, calldatas, description); string memory stringProposalId = vm.toString(proposalId / 10 ** 69); @@ -88,8 +86,6 @@ contract GenerateAddNitroRewardsProposal is Generator, JSONScript { jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-add-nitro-rewards.json') ); } - - vm.stopBroadcast(); } function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) { diff --git a/script/gov/Generate/GenerateERC20TransferProposal.s.sol b/script/gov/Generate/GenerateERC20TransferProposal.s.sol index ddb4bd8c..f40d2fd3 100644 --- a/script/gov/Generate/GenerateERC20TransferProposal.s.sol +++ b/script/gov/Generate/GenerateERC20TransferProposal.s.sol @@ -57,8 +57,6 @@ contract GenerateERC20TransferProposal is Generator, JSONScript { // Get the descriptionHash bytes32 descriptionHash = keccak256(bytes(description)); - vm.startBroadcast(_privateKey); - // Propose the action to add transfer the ERC20 token to the receiver uint256 proposalId = gov.propose(targets, values, calldatas, description); string memory stringProposalId = vm.toString(proposalId / 10 ** 69); @@ -72,8 +70,6 @@ contract GenerateERC20TransferProposal is Generator, JSONScript { _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash); vm.writeJson(jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-transfer-erc20.json')); } - - vm.stopBroadcast(); } function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) { diff --git a/script/gov/Generate/GenerateModifyParametersPerCollateralProposal.s.sol b/script/gov/Generate/GenerateModifyParametersPerCollateralProposal.s.sol index a47780da..232f4b04 100644 --- a/script/gov/Generate/GenerateModifyParametersPerCollateralProposal.s.sol +++ b/script/gov/Generate/GenerateModifyParametersPerCollateralProposal.s.sol @@ -64,8 +64,6 @@ contract GenerateModifyParametersPerCollateralProposal is Generator, JSONScript bytes32 descriptionHash = keccak256(bytes(_description)); - vm.startBroadcast(_privateKey); - // Propose the action to add the collateral type uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); string memory stringProposalId = vm.toString(proposalId / 10 ** 69); @@ -77,8 +75,6 @@ contract GenerateModifyParametersPerCollateralProposal is Generator, JSONScript _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/', stringProposalId, '-modifyParameters.json')); } - - vm.stopBroadcast(); } function _readData( diff --git a/script/gov/Generate/GenerateModifyParametersProposal.s.sol b/script/gov/Generate/GenerateModifyParametersProposal.s.sol index 24cb4dc2..93f6c5d0 100644 --- a/script/gov/Generate/GenerateModifyParametersProposal.s.sol +++ b/script/gov/Generate/GenerateModifyParametersProposal.s.sol @@ -62,8 +62,6 @@ contract GenerateModifyParametersProposal is Generator, JSONScript { bytes32 descriptionHash = keccak256(bytes(_description)); - vm.startBroadcast(_privateKey); - // Propose the action to add the collateral type uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); string memory stringProposalId = vm.toString(proposalId / 10 ** 69); @@ -75,8 +73,6 @@ contract GenerateModifyParametersProposal is Generator, JSONScript { _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/', stringProposalId, '-modifyParameters.json')); } - - vm.stopBroadcast(); } function _readData( diff --git a/script/gov/Generate/GenerateTargetsAndCalldataProposal.s.sol b/script/gov/Generate/GenerateTargetsAndCalldataProposal.s.sol new file mode 100644 index 00000000..abf51003 --- /dev/null +++ b/script/gov/Generate/GenerateTargetsAndCalldataProposal.s.sol @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity 0.8.20; + +import {JSONScript} from '@script/gov/helpers/JSONScript.s.sol'; +import {ODGovernor} from '@contracts/gov/ODGovernor.sol'; +import {TimelockController} from '@openzeppelin/governance/TimelockController.sol'; +import {Generator} from '@script/gov/Generator.s.sol'; +import {Strings} from '@openzeppelin/utils/Strings.sol'; +import 'forge-std/StdJson.sol'; + +contract GenerateTargetsAndCalldataProposal is Generator, JSONScript { + using stdJson for string; + + address public _odGovernor; + string public _description; + address[] public targets; + bytes[] public calldatas; + + function _loadBaseData(string memory json) internal override { + _description = json.readString(string(abi.encodePacked('.description'))); + _odGovernor = json.readAddress(string(abi.encodePacked('.ODGovernor_Address:'))); + uint256 len = json.readUint(string(abi.encodePacked('.arrayLength'))); + for (uint256 i; i < len; i++) { + string memory index = Strings.toString(i); + address target = json.readAddress(string(abi.encodePacked('.objectArray[', index, '].target'))); + bytes memory callData = json.readBytes(string(abi.encodePacked('.objectArray[', index, '].calldata'))); + targets.push(target); + calldatas.push(callData); + } + } + + function _generateProposal() internal override { + ODGovernor gov = ODGovernor(payable(_odGovernor)); + + uint256[] memory values = new uint256[](targets.length); + for (uint256 i; i < targets.length; i++) { + values[i] = 0; + } + + bytes32 descriptionHash = keccak256(bytes(_description)); + + uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); + + // Propose the action to add the collateral type + + string memory stringProposalId = vm.toString(proposalId / 10 ** 69); + + { + string memory objectKey = 'TARGETS-CALLDATA'; + // Build the JSON output + string memory jsonOutput = + _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); + vm.writeJson( + jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-targetsAndCalldata.json') + ); + } + } + + function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) { + _serializedInput = vm.serializeJson(_objectKey, json); + } +} diff --git a/script/gov/Generate/GenerateUpdateDelayProposal.s.sol b/script/gov/Generate/GenerateUpdateDelayProposal.s.sol index 90947f92..a1592473 100644 --- a/script/gov/Generate/GenerateUpdateDelayProposal.s.sol +++ b/script/gov/Generate/GenerateUpdateDelayProposal.s.sol @@ -39,8 +39,6 @@ contract GenerateUpdateDelayProposal is Generator, JSONScript { bytes32 descriptionHash = keccak256(bytes(_description)); - vm.startBroadcast(_privateKey); - uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash); // Propose the action to add the collateral type @@ -54,8 +52,6 @@ contract GenerateUpdateDelayProposal is Generator, JSONScript { _buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, _description, descriptionHash); vm.writeJson(jsonOutput, string.concat('./gov-output/', _network, '/', stringProposalId, '-updateTimeDelay.json')); } - - vm.stopBroadcast(); } function _serializeCurrentJson(string memory _objectKey) internal override returns (string memory _serializedInput) { diff --git a/script/gov/Generator.s.sol b/script/gov/Generator.s.sol index 3ba497ae..912dabbd 100644 --- a/script/gov/Generator.s.sol +++ b/script/gov/Generator.s.sol @@ -5,6 +5,7 @@ pragma solidity 0.8.20; import 'forge-std/Script.sol'; import {ForkManagement} from '@script/gov/helpers/ForkManagement.s.sol'; +import 'forge-std/console2.sol'; contract Generator is ForkManagement { using stdJson for string; @@ -17,9 +18,13 @@ contract Generator is ForkManagement { function run(string memory _filePath) public { _loadJson(_filePath); - _checkNetworkParams(); - _loadPrivateKeys(); _loadBaseData(json); + _network = json.readString(string(abi.encodePacked('.network'))); + if (json.readUint(string(abi.encodePacked('.chainid'))) == 421_614) { + vm.createSelectFork(vm.rpcUrl('sepolia')); + } else { + vm.createSelectFork(vm.rpcUrl('mainnet')); + } _generateProposal(); } diff --git a/tasks/governanceManager.sh b/tasks/governanceManager.sh index 06b51d98..b5cf70b8 100755 --- a/tasks/governanceManager.sh +++ b/tasks/governanceManager.sh @@ -67,14 +67,11 @@ function generateProposal() { getRpcAndPk $NETWORK - - CALLDATA=$(cast calldata "run(string)" $CAST_PATH) - COMMAND_PATH=$(node tasks/parseProposalPath.js $1) CALLDATA=$(cast calldata "run(string)" $CAST_PATH) - - simulate $COMMAND_PATH $CALLDATA $RPC_ENDPOINT $PRIVATE_KEY + forge script $COMMAND_PATH -s $CALLDATA --fork-url $ARB_MAINNET_RPC --unlocked + # simulate $COMMAND_PATH $CALLDATA $RPC_ENDPOINT $PRIVATE_KEY } diff --git a/tasks/parseProposalOutputs.js b/tasks/parseProposalOutputs.js index 23286efc..c6e09d11 100644 --- a/tasks/parseProposalOutputs.js +++ b/tasks/parseProposalOutputs.js @@ -10,5 +10,5 @@ const inputPath = path.join(__dirname, `../gov-input/${targetEnv}/new-${proposal const currentProp = require(inputPath); -currentProp ? console.log(JSON.stringify(currentProp)) : console.log(''); +currentProp ? console.log(JSON.stringify(currentProp, null, 2)) : console.log(''); return; diff --git a/tasks/parseProposalPath.js b/tasks/parseProposalPath.js index 0379c4fe..2f47580f 100644 --- a/tasks/parseProposalPath.js +++ b/tasks/parseProposalPath.js @@ -14,7 +14,7 @@ if (currentJson.objectArray != undefined) { // create correct number of modifications currentJson["arrayLength"] = currentJson.objectArray.length.toString(); - fs.writeFile(basePath, JSON.stringify(currentJson), (err) => { + fs.writeFile(basePath, JSON.stringify(currentJson, null, 2), (err) => { if (err) { console.error(err); return; @@ -35,8 +35,10 @@ function getNetwork(network) { let signer; //ethers.getCreateAddress(from: , nonce: 1) let provider; if (network == "anvil") { - provider = new ethers.JsonRpcProvider("http://localhost:8545"); - signer = new ethers.Wallet(process.env.ANVIL_ONE, provider); + let anvilRpc = process.env.ANVIL_RPC; + let anvilPK = process.env.ANVIL_ONE; + provider = new ethers.JsonRpcProvider(anvilRpc, provider); + signer = new ethers.Wallet(anvilPK, provider); } else if (network == "sepolia" || network == "arb-sepolia") { const rpc_endpoint = process.env.ARB_SEPOLIA_RPC; provider = new ethers.JsonRpcProvider(rpc_endpoint); @@ -78,7 +80,7 @@ async function predictAddress(currentJson, provider) { async function predictAddressAndWriteToFile(currentJson, provider) { const predictedAddress = await predictAddress(currentJson, provider); currentJson["LiquidationEngineCollateralParams"]["newCAHChild"] = predictedAddress; - fs.writeFileSync(basePath, JSON.stringify(currentJson), (err) => { + fs.writeFileSync(basePath, JSON.stringify(currentJson, null, 2), (err) => { if (err) { console.error(err); return;