Skip to content

Commit

Permalink
Move _toArray helper to NestedMultisigBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Oct 20, 2024
1 parent 1168e6d commit 582e4fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 0 additions & 6 deletions script/universal/MultisigBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ abstract contract MultisigBase is CommonBase {
});
}

function toArray(IMulticall3.Call3 memory call) internal pure returns (IMulticall3.Call3[] memory) {
IMulticall3.Call3[] memory calls = new IMulticall3.Call3[](1);
calls[0] = call;
return calls;
}

// The state change simulation can set the threshold, owner address and/or nonce.
// This allows simulation of the final transaction by overriding the threshold to 1.
// State changes reflected in the simulation as a result of these overrides will
Expand Down
14 changes: 10 additions & 4 deletions script/universal/NestedMultisigBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ abstract contract NestedMultisigBuilder is MultisigBase {
vm.store(address(nestedSafe), SAFE_NONCE_SLOT, bytes32(originalNonce));
vm.store(address(_signerSafe), SAFE_NONCE_SLOT, bytes32(originalSignerNonce));

_printDataToSign(_signerSafe, toArray(call));
_printDataToSign(_signerSafe, _toArray(call));
}

/**
Expand All @@ -98,7 +98,7 @@ abstract contract NestedMultisigBuilder is MultisigBase {
IGnosisSafe nestedSafe = IGnosisSafe(_ownerSafe());
IMulticall3.Call3[] memory nestedCalls = _buildCalls();
IMulticall3.Call3 memory call = _generateApproveCall(nestedSafe, nestedCalls);
_checkSignatures(_signerSafe, toArray(call), _signatures);
_checkSignatures(_signerSafe, _toArray(call), _signatures);
}

/**
Expand All @@ -114,7 +114,7 @@ abstract contract NestedMultisigBuilder is MultisigBase {
IMulticall3.Call3 memory call = _generateApproveCall(nestedSafe, nestedCalls);

vm.startBroadcast();
(Vm.AccountAccess[] memory accesses, Simulation.Payload memory simPayload) = _executeTransaction(_signerSafe, toArray(call), _signatures);
(Vm.AccountAccess[] memory accesses, Simulation.Payload memory simPayload) = _executeTransaction(_signerSafe, _toArray(call), _signatures);
vm.stopBroadcast();

_postApprove(accesses, simPayload);
Expand Down Expand Up @@ -197,7 +197,7 @@ abstract contract NestedMultisigBuilder is MultisigBase {
bytes32 hash = _getTransactionHash(_safe, _data);

// simulate an approveHash, so that signer can verify the data they are signing
bytes memory approveHashData = abi.encodeCall(IMulticall3.aggregate3, (toArray(
bytes memory approveHashData = abi.encodeCall(IMulticall3.aggregate3, (_toArray(
IMulticall3.Call3({
target: address(_safe),
allowFailure: false,
Expand Down Expand Up @@ -232,4 +232,10 @@ abstract contract NestedMultisigBuilder is MultisigBase {
}
return overrides;
}

function _toArray(IMulticall3.Call3 memory call) internal pure returns (IMulticall3.Call3[] memory) {
IMulticall3.Call3[] memory calls = new IMulticall3.Call3[](1);
calls[0] = call;
return calls;
}
}

0 comments on commit 582e4fe

Please sign in to comment.