-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from base-org/jack/interface-updates
Adjust Inbox & Outbox interfaces for improved efficiency
- Loading branch information
Showing
18 changed files
with
575 additions
and
885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
/// @title ERC7786Base | ||
/// | ||
/// @author Coinbase (https://github.com/base-org/RIP-7755-poc) | ||
/// | ||
/// @notice This contract contains the selectors for the RIP-7755-supported attributes of the ERC7786 standard | ||
contract RIP7755Base { | ||
/// @notice Low-level call specs representing the desired transaction on destination chain | ||
struct Call { | ||
/// @dev The address to call | ||
bytes32 to; | ||
/// @dev The calldata to call with | ||
bytes data; | ||
/// @dev The native asset value of the call | ||
uint256 value; | ||
} | ||
|
||
/// @notice The selector for the precheck attribute | ||
bytes4 internal constant _PRECHECK_ATTRIBUTE_SELECTOR = 0xfa1e5831; // precheck(address) | ||
|
||
/// @notice The selector for the isUserOp attribute. Used to designate a request designated to be a destination | ||
/// chain ERC-4337 User Operation | ||
bytes4 internal constant _USER_OP_ATTRIBUTE_SELECTOR = 0xd45448dd; // isUserOp(bool) | ||
|
||
/// @notice This error is thrown if an attribute is not found in the attributes array | ||
/// | ||
/// @param selector The selector of the attribute that was not found | ||
error AttributeNotFound(bytes4 selector); | ||
|
||
/// @notice Returns the keccak256 hash of a message request | ||
/// | ||
/// @dev Filters out the fulfiller attribute from the attributes array | ||
/// | ||
/// @param sourceChain The source chain identifier | ||
/// @param sender The account address of the sender | ||
/// @param destinationChain The destination chain identifier | ||
/// @param receiver The account address of the receiver | ||
/// @param payload The encoded calls to be included in the request | ||
/// @param attributes The attributes to be included in the message | ||
/// | ||
/// @return _ The keccak256 hash of the message request | ||
function getRequestId( | ||
bytes32 sourceChain, | ||
bytes32 sender, | ||
bytes32 destinationChain, | ||
bytes32 receiver, | ||
bytes calldata payload, | ||
bytes[] calldata attributes | ||
) public pure returns (bytes32) { | ||
return keccak256(abi.encode(sourceChain, sender, destinationChain, receiver, payload, attributes)); | ||
} | ||
|
||
/// @notice Locates an attribute in the attributes array | ||
/// | ||
/// @custom:reverts If the attribute is not found | ||
/// | ||
/// @param attributes The attributes array to search | ||
/// @param selector The selector of the attribute to find | ||
/// | ||
/// @return attribute The attribute found | ||
function _locateAttribute(bytes[] calldata attributes, bytes4 selector) internal pure returns (bytes calldata) { | ||
(bool found, bytes calldata attribute) = _locateAttributeUnchecked(attributes, selector); | ||
|
||
if (!found) { | ||
revert AttributeNotFound(selector); | ||
} | ||
|
||
return attribute; | ||
} | ||
|
||
/// @notice Locates an attribute in the attributes array without checking if the attribute is found | ||
/// | ||
/// @param attributes The attributes array to search | ||
/// @param selector The selector of the attribute to find | ||
/// | ||
/// @return found Whether the attribute was found | ||
/// @return attribute The attribute found | ||
function _locateAttributeUnchecked(bytes[] calldata attributes, bytes4 selector) | ||
internal | ||
pure | ||
returns (bool found, bytes calldata attribute) | ||
{ | ||
for (uint256 i; i < attributes.length; i++) { | ||
if (bytes4(attributes[i]) == selector) { | ||
return (true, attributes[i]); | ||
} | ||
} | ||
return (false, attributes[0]); | ||
} | ||
} |
Oops, something went wrong.