diff --git a/.circleci/config.yml b/.circleci/config.yml index 9dffcdb43f..bef6cc43a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -235,6 +235,16 @@ jobs: command: | just install forge test + forge_fmt: + docker: + - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.35.0 + steps: + - checkout + - run: + name: forge fmt + command: | + just install + forge fmt --check workflows: version: 2 diff --git a/script/SignFromJson.s.sol b/script/SignFromJson.s.sol index 857caa2cba..0be6c3a9d6 100644 --- a/script/SignFromJson.s.sol +++ b/script/SignFromJson.s.sol @@ -8,7 +8,6 @@ import {stdJson} from "forge-std/StdJson.sol"; import {console} from "forge-std/console.sol"; contract SignFromJson is MultisigBuilder, JsonTxBuilderBase { - function signJson(string memory _path) public { _loadJson(_path); sign(); diff --git a/src/JsonTxBuilderBase.sol b/src/JsonTxBuilderBase.sol index 4f41c2abad..413fa24866 100644 --- a/src/JsonTxBuilderBase.sol +++ b/src/JsonTxBuilderBase.sol @@ -6,7 +6,6 @@ import {stdJson} from "forge-std/StdJson.sol"; import {console} from "forge-std/console.sol"; import {CommonBase} from "forge-std/Base.sol"; - abstract contract JsonTxBuilderBase is CommonBase { string json; @@ -18,27 +17,29 @@ abstract contract JsonTxBuilderBase is CommonBase { function _buildCallsFromJson() internal view returns (IMulticall3.Call3[] memory) { // A hacky way to get the total number of elements in a JSON // object array because Forge does not support this natively. - uint MAX_LENGTH_SUPPORTED = 999; - uint transaction_count = MAX_LENGTH_SUPPORTED; - for(uint i = 0; transaction_count == MAX_LENGTH_SUPPORTED; i++) { - require(i < MAX_LENGTH_SUPPORTED, - "Transaction list longer than MAX_LENGTH_SUPPORTED is not " - "supported, to support it, simply bump the value of " - "MAX_LENGTH_SUPPORTED to a bigger one."); - try vm.parseJsonAddress(json, string(abi.encodePacked("$.transactions[", vm.toString(i), "].to"))) returns (address) { - } catch { + uint256 MAX_LENGTH_SUPPORTED = 999; + uint256 transaction_count = MAX_LENGTH_SUPPORTED; + for (uint256 i = 0; transaction_count == MAX_LENGTH_SUPPORTED; i++) { + require( + i < MAX_LENGTH_SUPPORTED, + "Transaction list longer than MAX_LENGTH_SUPPORTED is not " + "supported, to support it, simply bump the value of " "MAX_LENGTH_SUPPORTED to a bigger one." + ); + try vm.parseJsonAddress(json, string(abi.encodePacked("$.transactions[", vm.toString(i), "].to"))) returns ( + address + ) {} catch { transaction_count = i; } } IMulticall3.Call3[] memory calls = new IMulticall3.Call3[](transaction_count); - for (uint i = 0; i < transaction_count; i++) { + for (uint256 i = 0; i < transaction_count; i++) { calls[i] = IMulticall3.Call3({ target: stdJson.readAddress(json, string(abi.encodePacked("$.transactions[", vm.toString(i), "].to"))), allowFailure: false, callData: stdJson.readBytes(json, string(abi.encodePacked("$.transactions[", vm.toString(i), "].data"))) - }); + }); } return calls;