Skip to content

Commit

Permalink
add multicall3
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed Dec 26, 2024
1 parent 3c15212 commit 996445b
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contracts/src/PBHEntryPointImplV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl {
/// World ID in a given month.
uint8 public numPbhPerMonth;

/// @notice Address of the Multicall3 implementation.
address immutable multicall3;

/// @dev Whether a nullifier hash has been used already. Used to guarantee an action is only performed once by a single person
mapping(uint256 => bool) public nullifierHashes;

Expand Down Expand Up @@ -230,7 +233,9 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl {
function pbhMulticall(
IMulticall3.Call3[] calldata calls,
PBHPayload calldata pbhPayload
) external {}
) external {
IMulticall3(multicall3).aggregate3(calls);
}

// TODO: consider making this internal
/// @param sender The sender of this particular transaction or UserOp.
Expand Down
97 changes: 97 additions & 0 deletions contracts/src/interfaces/IMulticall3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.12 <0.9.0;

interface IMulticall3 {
struct Call {
address target;
bytes callData;
}

struct Call3 {
address target;
bool allowFailure;
bytes callData;
}

struct Call3Value {
address target;
bool allowFailure;
uint256 value;
bytes callData;
}

struct Result {
bool success;
bytes returnData;
}

function aggregate(
Call[] calldata calls
) external payable returns (uint256 blockNumber, bytes[] memory returnData);

function aggregate3(
Call3[] calldata calls
) external payable returns (Result[] memory returnData);

function aggregate3Value(
Call3Value[] calldata calls
) external payable returns (Result[] memory returnData);

function blockAndAggregate(
Call[] calldata calls
)
external
payable
returns (
uint256 blockNumber,
bytes32 blockHash,
Result[] memory returnData
);

function getBasefee() external view returns (uint256 basefee);

function getBlockHash(
uint256 blockNumber
) external view returns (bytes32 blockHash);

function getBlockNumber() external view returns (uint256 blockNumber);

function getChainId() external view returns (uint256 chainid);

function getCurrentBlockCoinbase() external view returns (address coinbase);

function getCurrentBlockDifficulty()
external
view
returns (uint256 difficulty);

function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);

function getCurrentBlockTimestamp()
external
view
returns (uint256 timestamp);

function getEthBalance(
address addr
) external view returns (uint256 balance);

function getLastBlockHash() external view returns (bytes32 blockHash);

function tryAggregate(
bool requireSuccess,
Call[] calldata calls
) external payable returns (Result[] memory returnData);

function tryBlockAndAggregate(
bool requireSuccess,
Call[] calldata calls
)
external
payable
returns (
uint256 blockNumber,
bytes32 blockHash,
Result[] memory returnData
);
}

0 comments on commit 996445b

Please sign in to comment.