Skip to content
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
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion script/SignFromJson.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
25 changes: 13 additions & 12 deletions src/JsonTxBuilderBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down