Skip to content

Commit

Permalink
Add option to override to payable
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Aug 31, 2024
1 parent c0417f4 commit 2243682
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
22 changes: 11 additions & 11 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -1040,18 +1040,18 @@ MinHeapLibTest:testMemHeapSmallestGas() (gas: 2985537)
MinHeapLibTest:testMemHeapWriteAndReadFromStorage() (gas: 67756)
MinHeapLibTest:testMemHeapWriteAndReadFromStorage2() (gas: 67774)
MinHeapLibTest:test__codesize() (gas: 14576)
MulticallableTest:testMulticallableBenchmark() (gas: 30291)
MulticallableTest:testMulticallableBenchmark() (gas: 30286)
MulticallableTest:testMulticallableOriginalBenchmark() (gas: 38715)
MulticallableTest:testMulticallablePreservesMsgSender() (gas: 11413)
MulticallableTest:testMulticallableReturnDataIsProperlyEncoded() (gas: 398368)
MulticallableTest:testMulticallableReturnDataIsProperlyEncoded(string,string,uint256) (runs: 317, μ: 250587, ~: 390621)
MulticallableTest:testMulticallableReturnDataIsProperlyEncoded(uint256,uint256,uint256,uint256) (runs: 317, μ: 249928, ~: 34427)
MulticallableTest:testMulticallableRevertWithCustomError() (gas: 11859)
MulticallableTest:testMulticallableRevertWithMessage() (gas: 13509)
MulticallableTest:testMulticallableRevertWithMessage(string) (runs: 317, μ: 14121, ~: 13970)
MulticallableTest:testMulticallableRevertWithNothing() (gas: 11766)
MulticallableTest:testMulticallableWithNoData() (gas: 6361)
MulticallableTest:test__codesize() (gas: 9857)
MulticallableTest:testMulticallablePreservesMsgSender() (gas: 11408)
MulticallableTest:testMulticallableReturnDataIsProperlyEncoded() (gas: 397972)
MulticallableTest:testMulticallableReturnDataIsProperlyEncoded(string,string,uint256) (runs: 317, μ: 234394, ~: 43539)
MulticallableTest:testMulticallableReturnDataIsProperlyEncoded(uint256,uint256,uint256,uint256) (runs: 317, μ: 245730, ~: 394794)
MulticallableTest:testMulticallableRevertWithCustomError() (gas: 11854)
MulticallableTest:testMulticallableRevertWithMessage() (gas: 13504)
MulticallableTest:testMulticallableRevertWithMessage(string) (runs: 317, μ: 14116, ~: 13965)
MulticallableTest:testMulticallableRevertWithNothing() (gas: 11761)
MulticallableTest:testMulticallableWithNoData() (gas: 6356)
MulticallableTest:test__codesize() (gas: 9855)
OwnableRolesTest:testBytecodeSize() (gas: 350635)
OwnableRolesTest:testGrantAndRemoveRolesDirect(address,uint256,uint256) (runs: 317, μ: 41493, ~: 42162)
OwnableRolesTest:testGrantAndRevokeOrRenounceRoles(address,bool,bool,bool,uint256,uint256) (runs: 317, μ: 27815, ~: 20899)
Expand Down
12 changes: 8 additions & 4 deletions src/utils/Multicallable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ abstract contract Multicallable {
/// If any of the `delegatecall`s reverts, the entire context is reverted,
/// and the error is bubbled up.
///
/// This function is deliberately made non-payable to guard against double-spending.
/// (See: https://www.paradigm.xyz/2021/08/two-rights-might-make-a-wrong)
///
/// By default, this function directly returns the results and terminates the call context.
/// If you need to add before and after actions to the multicall, please override this function.
function multicall(bytes[] calldata data) public virtual returns (bytes[] memory) {
function multicall(bytes[] calldata data) public payable virtual returns (bytes[] memory) {
// Revert if `msg.value` is non-zero by default to guard against double-spending.
// (See: https://www.paradigm.xyz/2021/08/two-rights-might-make-a-wrong)
//
// If you really need to pass in a `msg.value`, then you will have to
// override this function and add in any relevant before and after checks.
if (msg.value != 0) revert();

_multicallDirectReturn(_multicallInner(data));
}

Expand Down

0 comments on commit 2243682

Please sign in to comment.