Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00
Cross-Chain Transactions
Loading...
Loading
Contract Name:
AccountSeaportBulkSigSupport
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 20 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
import {SeaportEIP1271} from "../../../extension/SeaportEIP1271.sol";
import {AccountPermissions, AccountPermissionsStorage} from "../../../extension/upgradeable/AccountPermissions.sol";
import {EnumerableSet} from "../../../external-deps/openzeppelin/utils/structs/EnumerableSet.sol";
contract AccountSeaportBulkSigSupport is SeaportEIP1271 {
using EnumerableSet for EnumerableSet.AddressSet;
constructor() {}
/// @notice Returns whether a given signer is an authorized signer for the contract.
function _isAuthorizedSigner(address _signer) internal view virtual override returns (bool authorized) {
// is signer an admin?
if (AccountPermissionsStorage.data().isAdmin[_signer]) {
return true;
}
address caller = msg.sender;
EnumerableSet.AddressSet storage approvedTargets = AccountPermissionsStorage.data().approvedTargets[_signer];
require(
approvedTargets.contains(caller) || (approvedTargets.length() == 1 && approvedTargets.at(0) == address(0)),
"Account: caller not approved target."
);
// is signer an active signer of account?
AccountPermissions.SignerPermissionsStatic memory permissions =
AccountPermissionsStorage.data().signerPermissions[_signer];
if (
permissions.startTimestamp <= block.timestamp && block.timestamp < permissions.endTimestamp
&& AccountPermissionsStorage.data().approvedTargets[_signer].length() > 0
) {
return true;
}
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
import {ECDSA} from "solady/utils/ECDSA.sol";
import {SeaportOrderParser} from "./SeaportOrderParser.sol";
import {OrderParameters} from "seaport-types/src/lib/ConsiderationStructs.sol";
abstract contract SeaportEIP1271 is SeaportOrderParser {
using ECDSA for bytes32;
/// @notice The function selector of EIP1271.isValidSignature to be returned on sucessful signature verification.
bytes4 public constant MAGICVALUE = 0x1626ba7e;
constructor() {}
/// @notice See EIP-1271: https://eips.ethereum.org/EIPS/eip-1271
function isValidSignature(bytes32 _message, bytes memory _signature)
public
view
virtual
returns (bytes4 magicValue)
{
bytes32 targetDigest;
bytes memory targetSig;
// Handle OpenSea bulk order signatures that are >65 bytes in length.
if (_signature.length > 65) {
// Decode packed signature and order parameters.
(bytes memory extractedPackedSig, OrderParameters memory orderParameters, uint256 counter) =
abi.decode(_signature, (bytes, OrderParameters, uint256));
// Verify that the original digest matches the digest built with order parameters.
bytes32 domainSeparator = _buildSeaportDomainSeparator(msg.sender);
bytes32 orderHash = _deriveOrderHash(orderParameters, counter);
require(
_deriveEIP712Digest(domainSeparator, orderHash) == _message,
"Seaport: order hash does not match the provided message."
);
// Build bulk signature digest
targetDigest = _deriveEIP712Digest(domainSeparator, _computeBulkOrderProof(extractedPackedSig, orderHash));
// Extract the signature, which is the first 65 bytes
targetSig = new bytes(65);
for (uint256 i = 0; i < 65; i++) {
targetSig[i] = extractedPackedSig[i];
}
} else {
targetDigest = _message;
targetSig = _signature;
}
address signer = targetDigest.recover(targetSig);
if (_isAuthorizedSigner(signer)) {
magicValue = MAGICVALUE;
}
}
/// @notice Returns whether a given signer is an authorized signer for the contract.
function _isAuthorizedSigner(address _signer) internal view virtual returns (bool);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/* solhint-disable */
import { OrderParameters } from "seaport-types/src/lib/ConsiderationStructs.sol";
import { EIP_712_PREFIX, EIP712_ConsiderationItem_size, EIP712_DigestPayload_size, EIP712_DomainSeparator_offset, EIP712_OfferItem_size, EIP712_Order_size, EIP712_OrderHash_offset, OneWord, OneWordShift, OrderParameters_consideration_head_offset, OrderParameters_counter_offset, OrderParameters_offer_head_offset, TwoWords, BulkOrderProof_keyShift, BulkOrderProof_keySize, BulkOrder_Typehash_Height_One, BulkOrder_Typehash_Height_Two, BulkOrder_Typehash_Height_Three, BulkOrder_Typehash_Height_Four, BulkOrder_Typehash_Height_Five, BulkOrder_Typehash_Height_Six, BulkOrder_Typehash_Height_Seven, BulkOrder_Typehash_Height_Eight, BulkOrder_Typehash_Height_Nine, BulkOrder_Typehash_Height_Ten, BulkOrder_Typehash_Height_Eleven, BulkOrder_Typehash_Height_Twelve, BulkOrder_Typehash_Height_Thirteen, BulkOrder_Typehash_Height_Fourteen, BulkOrder_Typehash_Height_Fifteen, BulkOrder_Typehash_Height_Sixteen, BulkOrder_Typehash_Height_Seventeen, BulkOrder_Typehash_Height_Eighteen, BulkOrder_Typehash_Height_Nineteen, BulkOrder_Typehash_Height_Twenty, BulkOrder_Typehash_Height_TwentyOne, BulkOrder_Typehash_Height_TwentyTwo, BulkOrder_Typehash_Height_TwentyThree, BulkOrder_Typehash_Height_TwentyFour, FreeMemoryPointerSlot } from "seaport-types/src/lib/ConsiderationConstants.sol";
contract SeaportOrderParser {
uint256 constant ECDSA_MAXLENGTH = 65;
bytes32 private immutable _NAME_HASH;
bytes32 private immutable _VERSION_HASH;
bytes32 private immutable _EIP_712_DOMAIN_TYPEHASH;
bytes32 private immutable _OFFER_ITEM_TYPEHASH;
bytes32 private immutable _CONSIDERATION_ITEM_TYPEHASH;
bytes32 private immutable _ORDER_TYPEHASH;
constructor() {
(
_NAME_HASH,
_VERSION_HASH,
_EIP_712_DOMAIN_TYPEHASH,
_OFFER_ITEM_TYPEHASH,
_CONSIDERATION_ITEM_TYPEHASH,
_ORDER_TYPEHASH
) = _deriveTypehashes();
}
function _nameString() internal pure virtual returns (string memory) {
// Return the name of the contract.
return "Seaport";
}
function _buildSeaportDomainSeparator(address _domainAddress) internal view returns (bytes32) {
return
keccak256(abi.encode(_EIP_712_DOMAIN_TYPEHASH, _NAME_HASH, _VERSION_HASH, block.chainid, _domainAddress));
}
function _deriveOrderHash(
OrderParameters memory orderParameters,
uint256 counter
) internal view returns (bytes32 orderHash) {
// Get length of original consideration array and place it on the stack.
uint256 originalConsiderationLength = (orderParameters.totalOriginalConsiderationItems);
/*
* Memory layout for an array of structs (dynamic or not) is similar
* to ABI encoding of dynamic types, with a head segment followed by
* a data segment. The main difference is that the head of an element
* is a memory pointer rather than an offset.
*/
// Declare a variable for the derived hash of the offer array.
bytes32 offerHash;
// Read offer item EIP-712 typehash from runtime code & place on stack.
bytes32 typeHash = _OFFER_ITEM_TYPEHASH;
// Utilize assembly so that memory regions can be reused across hashes.
assembly {
// Retrieve the free memory pointer and place on the stack.
let hashArrPtr := mload(FreeMemoryPointerSlot)
// Get the pointer to the offers array.
let offerArrPtr := mload(add(orderParameters, OrderParameters_offer_head_offset))
// Load the length.
let offerLength := mload(offerArrPtr)
// Set the pointer to the first offer's head.
offerArrPtr := add(offerArrPtr, OneWord)
// Iterate over the offer items.
for {
let i := 0
} lt(i, offerLength) {
i := add(i, 1)
} {
// Read the pointer to the offer data and subtract one word
// to get typeHash pointer.
let ptr := sub(mload(offerArrPtr), OneWord)
// Read the current value before the offer data.
let value := mload(ptr)
// Write the type hash to the previous word.
mstore(ptr, typeHash)
// Take the EIP712 hash and store it in the hash array.
mstore(hashArrPtr, keccak256(ptr, EIP712_OfferItem_size))
// Restore the previous word.
mstore(ptr, value)
// Increment the array pointers by one word.
offerArrPtr := add(offerArrPtr, OneWord)
hashArrPtr := add(hashArrPtr, OneWord)
}
// Derive the offer hash using the hashes of each item.
offerHash := keccak256(mload(FreeMemoryPointerSlot), shl(OneWordShift, offerLength))
}
// Declare a variable for the derived hash of the consideration array.
bytes32 considerationHash;
// Read consideration item typehash from runtime code & place on stack.
typeHash = _CONSIDERATION_ITEM_TYPEHASH;
// Utilize assembly so that memory regions can be reused across hashes.
assembly {
// Retrieve the free memory pointer and place on the stack.
let hashArrPtr := mload(FreeMemoryPointerSlot)
// Get the pointer to the consideration array.
let considerationArrPtr := add(
mload(add(orderParameters, OrderParameters_consideration_head_offset)),
OneWord
)
// Iterate over the consideration items (not including tips).
for {
let i := 0
} lt(i, originalConsiderationLength) {
i := add(i, 1)
} {
// Read the pointer to the consideration data and subtract one
// word to get typeHash pointer.
let ptr := sub(mload(considerationArrPtr), OneWord)
// Read the current value before the consideration data.
let value := mload(ptr)
// Write the type hash to the previous word.
mstore(ptr, typeHash)
// Take the EIP712 hash and store it in the hash array.
mstore(hashArrPtr, keccak256(ptr, EIP712_ConsiderationItem_size))
// Restore the previous word.
mstore(ptr, value)
// Increment the array pointers by one word.
considerationArrPtr := add(considerationArrPtr, OneWord)
hashArrPtr := add(hashArrPtr, OneWord)
}
// Derive the consideration hash using the hashes of each item.
considerationHash := keccak256(mload(FreeMemoryPointerSlot), shl(OneWordShift, originalConsiderationLength))
}
// Read order item EIP-712 typehash from runtime code & place on stack.
typeHash = _ORDER_TYPEHASH;
// Utilize assembly to access derived hashes & other arguments directly.
assembly {
// Retrieve pointer to the region located just behind parameters.
let typeHashPtr := sub(orderParameters, OneWord)
// Store the value at that pointer location to restore later.
let previousValue := mload(typeHashPtr)
// Store the order item EIP-712 typehash at the typehash location.
mstore(typeHashPtr, typeHash)
// Retrieve the pointer for the offer array head.
let offerHeadPtr := add(orderParameters, OrderParameters_offer_head_offset)
// Retrieve the data pointer referenced by the offer head.
let offerDataPtr := mload(offerHeadPtr)
// Store the offer hash at the retrieved memory location.
mstore(offerHeadPtr, offerHash)
// Retrieve the pointer for the consideration array head.
let considerationHeadPtr := add(orderParameters, OrderParameters_consideration_head_offset)
// Retrieve the data pointer referenced by the consideration head.
let considerationDataPtr := mload(considerationHeadPtr)
// Store the consideration hash at the retrieved memory location.
mstore(considerationHeadPtr, considerationHash)
// Retrieve the pointer for the counter.
let counterPtr := add(orderParameters, OrderParameters_counter_offset)
// Store the counter at the retrieved memory location.
mstore(counterPtr, counter)
// Derive the order hash using the full range of order parameters.
orderHash := keccak256(typeHashPtr, EIP712_Order_size)
// Restore the value previously held at typehash pointer location.
mstore(typeHashPtr, previousValue)
// Restore offer data pointer at the offer head pointer location.
mstore(offerHeadPtr, offerDataPtr)
// Restore consideration data pointer at the consideration head ptr.
mstore(considerationHeadPtr, considerationDataPtr)
// Restore consideration item length at the counter pointer.
mstore(counterPtr, originalConsiderationLength)
}
}
function _deriveTypehashes()
internal
pure
returns (
bytes32 nameHash,
bytes32 versionHash,
bytes32 eip712DomainTypehash,
bytes32 offerItemTypehash,
bytes32 considerationItemTypehash,
bytes32 orderTypehash
)
{
// Derive hash of the name of the contract.
nameHash = keccak256(bytes(_nameString()));
// Derive hash of the version string of the contract.
versionHash = keccak256(bytes("1.5"));
// Construct the OfferItem type string.
bytes memory offerItemTypeString = bytes(
"OfferItem("
"uint8 itemType,"
"address token,"
"uint256 identifierOrCriteria,"
"uint256 startAmount,"
"uint256 endAmount"
")"
);
// Construct the ConsiderationItem type string.
bytes memory considerationItemTypeString = bytes(
"ConsiderationItem("
"uint8 itemType,"
"address token,"
"uint256 identifierOrCriteria,"
"uint256 startAmount,"
"uint256 endAmount,"
"address recipient"
")"
);
// Construct the OrderComponents type string, not including the above.
bytes memory orderComponentsPartialTypeString = bytes(
"OrderComponents("
"address offerer,"
"address zone,"
"OfferItem[] offer,"
"ConsiderationItem[] consideration,"
"uint8 orderType,"
"uint256 startTime,"
"uint256 endTime,"
"bytes32 zoneHash,"
"uint256 salt,"
"bytes32 conduitKey,"
"uint256 counter"
")"
);
// Construct the primary EIP-712 domain type string.
eip712DomainTypehash = keccak256(
bytes(
"EIP712Domain("
"string name,"
"string version,"
"uint256 chainId,"
"address verifyingContract"
")"
)
);
// Derive the OfferItem type hash using the corresponding type string.
offerItemTypehash = keccak256(offerItemTypeString);
// Derive ConsiderationItem type hash using corresponding type string.
considerationItemTypehash = keccak256(considerationItemTypeString);
bytes memory orderTypeString = bytes.concat(
orderComponentsPartialTypeString,
considerationItemTypeString,
offerItemTypeString
);
// Derive OrderItem type hash via combination of relevant type strings.
orderTypehash = keccak256(orderTypeString);
}
function _computeBulkOrderProof(
bytes memory proofAndSignature,
bytes32 leaf
) internal pure returns (bytes32 bulkOrderHash) {
// Declare arguments for the root hash and the height of the proof.
bytes32 root;
uint256 height;
// Utilize assembly to efficiently derive the root hash using the proof.
assembly {
// Retrieve the length of the proof, key, and signature combined.
let fullLength := mload(proofAndSignature)
// If proofAndSignature has odd length, it is a compact signature
// with 64 bytes.
let signatureLength := sub(ECDSA_MAXLENGTH, and(fullLength, 1))
// Derive height (or depth of tree) with signature and proof length.
height := shr(OneWordShift, sub(fullLength, signatureLength))
// Update the length in memory to only include the signature.
mstore(proofAndSignature, signatureLength)
// Derive the pointer for the key using the signature length.
let keyPtr := add(proofAndSignature, add(OneWord, signatureLength))
// Retrieve the three-byte key using the derived pointer.
let key := shr(BulkOrderProof_keyShift, mload(keyPtr))
/// Retrieve pointer to first proof element by applying a constant
// for the key size to the derived key pointer.
let proof := add(keyPtr, BulkOrderProof_keySize)
// Compute level 1.
let scratchPtr1 := shl(OneWordShift, and(key, 1))
mstore(scratchPtr1, leaf)
mstore(xor(scratchPtr1, OneWord), mload(proof))
// Compute remaining proofs.
for {
let i := 1
} lt(i, height) {
i := add(i, 1)
} {
proof := add(proof, OneWord)
let scratchPtr := shl(OneWordShift, and(shr(i, key), 1))
mstore(scratchPtr, keccak256(0, TwoWords))
mstore(xor(scratchPtr, OneWord), mload(proof))
}
// Compute root hash.
root := keccak256(0, TwoWords)
}
// Retrieve appropriate typehash constant based on height.
bytes32 rootTypeHash = _lookupBulkOrderTypehash(height);
// Use the typehash and the root hash to derive final bulk order hash.
assembly {
mstore(0, rootTypeHash)
mstore(OneWord, root)
bulkOrderHash := keccak256(0, TwoWords)
}
}
function _lookupBulkOrderTypehash(uint256 _treeHeight) internal pure returns (bytes32 _typeHash) {
// Utilize assembly to efficiently retrieve correct bulk order typehash.
assembly {
// Use a Yul function to enable use of the `leave` keyword
// to stop searching once the appropriate type hash is found.
function lookupTypeHash(treeHeight) -> typeHash {
// Handle tree heights one through eight.
if lt(treeHeight, 9) {
// Handle tree heights one through four.
if lt(treeHeight, 5) {
// Handle tree heights one and two.
if lt(treeHeight, 3) {
// Utilize branchless logic to determine typehash.
typeHash := ternary(
eq(treeHeight, 1),
BulkOrder_Typehash_Height_One,
BulkOrder_Typehash_Height_Two
)
// Exit the function once typehash has been located.
leave
}
// Handle height three and four via branchless logic.
typeHash := ternary(
eq(treeHeight, 3),
BulkOrder_Typehash_Height_Three,
BulkOrder_Typehash_Height_Four
)
// Exit the function once typehash has been located.
leave
}
// Handle tree height five and six.
if lt(treeHeight, 7) {
// Utilize branchless logic to determine typehash.
typeHash := ternary(
eq(treeHeight, 5),
BulkOrder_Typehash_Height_Five,
BulkOrder_Typehash_Height_Six
)
// Exit the function once typehash has been located.
leave
}
// Handle height seven and eight via branchless logic.
typeHash := ternary(
eq(treeHeight, 7),
BulkOrder_Typehash_Height_Seven,
BulkOrder_Typehash_Height_Eight
)
// Exit the function once typehash has been located.
leave
}
// Handle tree height nine through sixteen.
if lt(treeHeight, 17) {
// Handle tree height nine through twelve.
if lt(treeHeight, 13) {
// Handle tree height nine and ten.
if lt(treeHeight, 11) {
// Utilize branchless logic to determine typehash.
typeHash := ternary(
eq(treeHeight, 9),
BulkOrder_Typehash_Height_Nine,
BulkOrder_Typehash_Height_Ten
)
// Exit the function once typehash has been located.
leave
}
// Handle height eleven and twelve via branchless logic.
typeHash := ternary(
eq(treeHeight, 11),
BulkOrder_Typehash_Height_Eleven,
BulkOrder_Typehash_Height_Twelve
)
// Exit the function once typehash has been located.
leave
}
// Handle tree height thirteen and fourteen.
if lt(treeHeight, 15) {
// Utilize branchless logic to determine typehash.
typeHash := ternary(
eq(treeHeight, 13),
BulkOrder_Typehash_Height_Thirteen,
BulkOrder_Typehash_Height_Fourteen
)
// Exit the function once typehash has been located.
leave
}
// Handle height fifteen and sixteen via branchless logic.
typeHash := ternary(
eq(treeHeight, 15),
BulkOrder_Typehash_Height_Fifteen,
BulkOrder_Typehash_Height_Sixteen
)
// Exit the function once typehash has been located.
leave
}
// Handle tree height seventeen through twenty.
if lt(treeHeight, 21) {
// Handle tree height seventeen and eighteen.
if lt(treeHeight, 19) {
// Utilize branchless logic to determine typehash.
typeHash := ternary(
eq(treeHeight, 17),
BulkOrder_Typehash_Height_Seventeen,
BulkOrder_Typehash_Height_Eighteen
)
// Exit the function once typehash has been located.
leave
}
// Handle height nineteen and twenty via branchless logic.
typeHash := ternary(
eq(treeHeight, 19),
BulkOrder_Typehash_Height_Nineteen,
BulkOrder_Typehash_Height_Twenty
)
// Exit the function once typehash has been located.
leave
}
// Handle tree height twenty-one and twenty-two.
if lt(treeHeight, 23) {
// Utilize branchless logic to determine typehash.
typeHash := ternary(
eq(treeHeight, 21),
BulkOrder_Typehash_Height_TwentyOne,
BulkOrder_Typehash_Height_TwentyTwo
)
// Exit the function once typehash has been located.
leave
}
// Handle height twenty-three & twenty-four w/ branchless logic.
typeHash := ternary(
eq(treeHeight, 23),
BulkOrder_Typehash_Height_TwentyThree,
BulkOrder_Typehash_Height_TwentyFour
)
// Exit the function once typehash has been located.
leave
}
// Implement ternary conditional using branchless logic.
function ternary(cond, ifTrue, ifFalse) -> c {
c := xor(ifFalse, mul(cond, xor(ifFalse, ifTrue)))
}
// Look up the typehash using the supplied tree height.
_typeHash := lookupTypeHash(_treeHeight)
}
}
function _deriveEIP712Digest(bytes32 domainSeparator, bytes32 orderHash) internal pure returns (bytes32 value) {
// Leverage scratch space to perform an efficient hash.
assembly {
// Place the EIP-712 prefix at the start of scratch space.
mstore(0, EIP_712_PREFIX)
// Place the domain separator in the next region of scratch space.
mstore(EIP712_DomainSeparator_offset, domainSeparator)
// Place the order hash in scratch space, spilling into the first
// two bytes of the free memory pointer — this should never be set
// as memory cannot be expanded to that size, and will be zeroed out
// after the hash is performed.
mstore(EIP712_OrderHash_offset, orderHash)
// Hash the relevant region (65 bytes).
value := keccak256(0, EIP712_DigestPayload_size)
// Clear out the dirtied bits in the memory pointer.
mstore(EIP712_OrderHash_offset, 0)
}
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
interface IAccountPermissions {
/*///////////////////////////////////////////////////////////////
Types
//////////////////////////////////////////////////////////////*/
/**
* @notice The payload that must be signed by an authorized wallet to set permissions for a signer to use the smart wallet.
*
* @param signer The addres of the signer to give permissions.
* @param approvedTargets The list of approved targets that a role holder can call using the smart wallet.
* @param nativeTokenLimitPerTransaction The maximum value that can be transferred by a role holder in a single transaction.
* @param permissionStartTimestamp The UNIX timestamp at and after which a signer has permission to use the smart wallet.
* @param permissionEndTimestamp The UNIX timestamp at and after which a signer no longer has permission to use the smart wallet.
* @param reqValidityStartTimestamp The UNIX timestamp at and after which a signature is valid.
* @param reqValidityEndTimestamp The UNIX timestamp at and after which a signature is invalid/expired.
* @param uid A unique non-repeatable ID for the payload.
* @param isAdmin Whether the signer should be an admin.
*/
struct SignerPermissionRequest {
address signer;
uint8 isAdmin;
address[] approvedTargets;
uint256 nativeTokenLimitPerTransaction;
uint128 permissionStartTimestamp;
uint128 permissionEndTimestamp;
uint128 reqValidityStartTimestamp;
uint128 reqValidityEndTimestamp;
bytes32 uid;
}
/**
* @notice The permissions that a signer has to use the smart wallet.
*
* @param signer The address of the signer.
* @param approvedTargets The list of approved targets that a role holder can call using the smart wallet.
* @param nativeTokenLimitPerTransaction The maximum value that can be transferred by a role holder in a single transaction.
* @param startTimestamp The UNIX timestamp at and after which a signer has permission to use the smart wallet.
* @param endTimestamp The UNIX timestamp at and after which a signer no longer has permission to use the smart wallet.
*/
struct SignerPermissions {
address signer;
address[] approvedTargets;
uint256 nativeTokenLimitPerTransaction;
uint128 startTimestamp;
uint128 endTimestamp;
}
/**
* @notice Internal struct for storing permissions for a signer (without approved targets).
*
* @param nativeTokenLimitPerTransaction The maximum value that can be transferred by a role holder in a single transaction.
* @param startTimestamp The UNIX timestamp at and after which a signer has permission to use the smart wallet.
* @param endTimestamp The UNIX timestamp at and after which a signer no longer has permission to use the smart wallet.
*/
struct SignerPermissionsStatic {
uint256 nativeTokenLimitPerTransaction;
uint128 startTimestamp;
uint128 endTimestamp;
}
/*///////////////////////////////////////////////////////////////
Events
//////////////////////////////////////////////////////////////*/
/// @notice Emitted when permissions for a signer are updated.
event SignerPermissionsUpdated(
address indexed authorizingSigner,
address indexed targetSigner,
SignerPermissionRequest permissions
);
/// @notice Emitted when an admin is set or removed.
event AdminUpdated(address indexed signer, bool isAdmin);
/*///////////////////////////////////////////////////////////////
View functions
//////////////////////////////////////////////////////////////*/
/// @notice Returns whether the given account is an admin.
function isAdmin(address signer) external view returns (bool);
/// @notice Returns whether the given account is an active signer on the account.
function isActiveSigner(address signer) external view returns (bool);
/// @notice Returns the restrictions under which a signer can use the smart wallet.
function getPermissionsForSigner(address signer) external view returns (SignerPermissions memory permissions);
/// @notice Returns all active and inactive signers of the account.
function getAllSigners() external view returns (SignerPermissions[] memory signers);
/// @notice Returns all signers with active permissions to use the account.
function getAllActiveSigners() external view returns (SignerPermissions[] memory signers);
/// @notice Returns all admins of the account.
function getAllAdmins() external view returns (address[] memory admins);
/// @dev Verifies that a request is signed by an authorized account.
function verifySignerPermissionRequest(
SignerPermissionRequest calldata req,
bytes calldata signature
) external view returns (bool success, address signer);
/*///////////////////////////////////////////////////////////////
External functions
//////////////////////////////////////////////////////////////*/
/// @notice Sets the permissions for a given signer.
function setPermissionsForSigner(SignerPermissionRequest calldata req, bytes calldata signature) external;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "../interface/IAccountPermissions.sol";
import "../../external-deps/openzeppelin/utils/cryptography/EIP712.sol";
import "../../external-deps/openzeppelin/utils/structs/EnumerableSet.sol";
library AccountPermissionsStorage {
/// @custom:storage-location account.permissions.storage
bytes32 public constant ACCOUNT_PERMISSIONS_STORAGE_POSITION =
keccak256(abi.encode(uint256(keccak256("account.permissions.storage")) - 1));
struct Data {
/// @dev The set of all admins of the wallet.
EnumerableSet.AddressSet allAdmins;
/// @dev The set of all signers with permission to use the account.
EnumerableSet.AddressSet allSigners;
/// @dev Map from address => whether the address is an admin.
mapping(address => bool) isAdmin;
/// @dev Map from signer address => active restrictions for that signer.
mapping(address => IAccountPermissions.SignerPermissionsStatic) signerPermissions;
/// @dev Map from signer address => approved target the signer can call using the account contract.
mapping(address => EnumerableSet.AddressSet) approvedTargets;
/// @dev Mapping from a signed request UID => whether the request is processed.
mapping(bytes32 => bool) executed;
}
function data() internal pure returns (Data storage data_) {
bytes32 position = ACCOUNT_PERMISSIONS_STORAGE_POSITION;
assembly {
data_.slot := position
}
}
}
abstract contract AccountPermissions is IAccountPermissions, EIP712 {
using ECDSA for bytes32;
using EnumerableSet for EnumerableSet.AddressSet;
bytes32 private constant TYPEHASH = keccak256(
"SignerPermissionRequest(address signer,uint8 isAdmin,address[] approvedTargets,uint256 nativeTokenLimitPerTransaction,uint128 permissionStartTimestamp,uint128 permissionEndTimestamp,uint128 reqValidityStartTimestamp,uint128 reqValidityEndTimestamp,bytes32 uid)"
);
function _onlyAdmin() internal virtual {
require(isAdmin(msg.sender), "!admin");
}
/*///////////////////////////////////////////////////////////////
External functions
//////////////////////////////////////////////////////////////*/
/// @notice Sets the permissions for a given signer.
function setPermissionsForSigner(SignerPermissionRequest calldata _req, bytes calldata _signature) external {
address targetSigner = _req.signer;
require(
_req.reqValidityStartTimestamp <= block.timestamp && block.timestamp < _req.reqValidityEndTimestamp,
"!period"
);
(bool success, address signer) = verifySignerPermissionRequest(_req, _signature);
require(success, "!sig");
_accountPermissionsStorage().executed[_req.uid] = true;
//isAdmin > 0, set admin or remove admin
if (_req.isAdmin > 0) {
//isAdmin = 1, set admin
//isAdmin > 1, remove admin
bool _isAdmin = _req.isAdmin == 1;
_setAdmin(targetSigner, _isAdmin);
return;
}
require(!isAdmin(targetSigner), "admin");
_accountPermissionsStorage().allSigners.add(targetSigner);
_accountPermissionsStorage().signerPermissions[targetSigner] = SignerPermissionsStatic(
_req.nativeTokenLimitPerTransaction, _req.permissionStartTimestamp, _req.permissionEndTimestamp
);
address[] memory currentTargets = _accountPermissionsStorage().approvedTargets[targetSigner].values();
uint256 len = currentTargets.length;
for (uint256 i = 0; i < len; i += 1) {
_accountPermissionsStorage().approvedTargets[targetSigner].remove(currentTargets[i]);
}
len = _req.approvedTargets.length;
for (uint256 i = 0; i < len; i += 1) {
_accountPermissionsStorage().approvedTargets[targetSigner].add(_req.approvedTargets[i]);
}
_afterSignerPermissionsUpdate(_req);
emit SignerPermissionsUpdated(signer, targetSigner, _req);
}
/*///////////////////////////////////////////////////////////////
View functions
//////////////////////////////////////////////////////////////*/
/// @notice Returns whether the given account is an admin.
function isAdmin(address _account) public view virtual returns (bool) {
return _accountPermissionsStorage().isAdmin[_account];
}
/// @notice Returns whether the given account is an active signer on the account.
function isActiveSigner(address signer) public view returns (bool) {
SignerPermissionsStatic memory permissions = _accountPermissionsStorage().signerPermissions[signer];
return permissions.startTimestamp <= block.timestamp && block.timestamp < permissions.endTimestamp
&& _accountPermissionsStorage().approvedTargets[signer].length() > 0;
}
/// @notice Returns the restrictions under which a signer can use the smart wallet.
function getPermissionsForSigner(address signer) external view returns (SignerPermissions memory) {
SignerPermissionsStatic memory permissions = _accountPermissionsStorage().signerPermissions[signer];
return SignerPermissions(
signer,
_accountPermissionsStorage().approvedTargets[signer].values(),
permissions.nativeTokenLimitPerTransaction,
permissions.startTimestamp,
permissions.endTimestamp
);
}
/// @dev Verifies that a request is signed by an authorized account.
function verifySignerPermissionRequest(SignerPermissionRequest calldata req, bytes calldata signature)
public
view
virtual
returns (bool success, address signer)
{
signer = _recoverAddress(_encodeRequest(req), signature);
success = !_accountPermissionsStorage().executed[req.uid] && isAdmin(signer);
}
/// @notice Returns all active and inactive signers of the account.
function getAllSigners() external view returns (SignerPermissions[] memory signers) {
address[] memory allSigners = _accountPermissionsStorage().allSigners.values();
uint256 len = allSigners.length;
signers = new SignerPermissions[](len);
for (uint256 i = 0; i < len; i += 1) {
address signer = allSigners[i];
SignerPermissionsStatic memory permissions = _accountPermissionsStorage().signerPermissions[signer];
signers[i] = SignerPermissions(
signer,
_accountPermissionsStorage().approvedTargets[signer].values(),
permissions.nativeTokenLimitPerTransaction,
permissions.startTimestamp,
permissions.endTimestamp
);
}
}
/// @notice Returns all signers with active permissions to use the account.
function getAllActiveSigners() external view returns (SignerPermissions[] memory signers) {
address[] memory allSigners = _accountPermissionsStorage().allSigners.values();
uint256 len = allSigners.length;
uint256 numOfActiveSigners = 0;
for (uint256 i = 0; i < len; i += 1) {
if (isActiveSigner(allSigners[i])) {
numOfActiveSigners++;
} else {
allSigners[i] = address(0);
}
}
signers = new SignerPermissions[](numOfActiveSigners);
uint256 index = 0;
for (uint256 i = 0; i < len; i += 1) {
if (allSigners[i] != address(0)) {
address signer = allSigners[i];
SignerPermissionsStatic memory permissions = _accountPermissionsStorage().signerPermissions[signer];
signers[index++] = SignerPermissions(
signer,
_accountPermissionsStorage().approvedTargets[signer].values(),
permissions.nativeTokenLimitPerTransaction,
permissions.startTimestamp,
permissions.endTimestamp
);
}
}
}
/// @notice Returns all admins of the account.
function getAllAdmins() external view returns (address[] memory) {
return _accountPermissionsStorage().allAdmins.values();
}
/*///////////////////////////////////////////////////////////////
Internal functions
//////////////////////////////////////////////////////////////*/
/// @notice Runs after every `changeRole` run.
function _afterSignerPermissionsUpdate(SignerPermissionRequest calldata _req) internal virtual;
/// @notice Makes the given account an admin.
function _setAdmin(address _account, bool _isAdmin) internal virtual {
_accountPermissionsStorage().isAdmin[_account] = _isAdmin;
if (_isAdmin) {
_accountPermissionsStorage().allAdmins.add(_account);
} else {
_accountPermissionsStorage().allAdmins.remove(_account);
}
emit AdminUpdated(_account, _isAdmin);
}
/// @dev Returns the address of the signer of the request.
function _recoverAddress(bytes memory _encoded, bytes calldata _signature)
internal
view
virtual
returns (address)
{
return _hashTypedDataV4(keccak256(_encoded)).recover(_signature);
}
/// @dev Encodes a request for recovery of the signer in `recoverAddress`.
function _encodeRequest(SignerPermissionRequest calldata _req) internal pure virtual returns (bytes memory) {
return abi.encode(
TYPEHASH,
_req.signer,
_req.isAdmin,
keccak256(abi.encodePacked(_req.approvedTargets)),
_req.nativeTokenLimitPerTransaction,
_req.permissionStartTimestamp,
_req.permissionEndTimestamp,
_req.reqValidityStartTimestamp,
_req.reqValidityEndTimestamp,
_req.uid
);
}
/// @dev Returns the AccountPermissions storage.
function _accountPermissionsStorage() internal pure returns (AccountPermissionsStorage.Data storage data) {
data = AccountPermissionsStorage.data();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../../../../lib/Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)
pragma solidity ^0.8.0;
import "./ECDSA.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
address private immutable _CACHED_THIS;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_CACHED_THIS = address(this);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(
bytes32 typeHash,
bytes32 nameHash,
bytes32 versionHash
) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte,
/// and the alphabets are capitalized conditionally according to
/// https://eips.ethereum.org/EIPS/eip-55
function toHexStringChecksummed(address value) internal pure returns (string memory str) {
str = toHexString(value);
/// @solidity memory-safe-assembly
assembly {
let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...`
let o := add(str, 0x22)
let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... `
let t := shl(240, 136) // `0b10001000 << 240`
for {
let i := 0
} 1 {
} {
mstore(add(i, i), mul(t, byte(i, hashed)))
i := add(i, 1)
if eq(i, 20) {
break
}
}
mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask)))))
o := add(o, 0x20)
mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask)))))
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte.
function toHexString(address value) internal pure returns (string memory str) {
str = toHexStringNoPrefix(value);
/// @solidity memory-safe-assembly
assembly {
let strLength := add(mload(str), 2) // Compute the length.
mstore(str, 0x3078) // Write the "0x" prefix.
str := sub(str, 2) // Move the pointer.
mstore(str, strLength) // Write the length.
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is encoded using 2 hexadecimal digits per byte.
function toHexStringNoPrefix(address value) internal pure returns (string memory str) {
/// @solidity memory-safe-assembly
assembly {
str := mload(0x40)
// Allocate the memory.
// We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,
// 0x02 bytes for the prefix, and 0x28 bytes for the digits.
// The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80.
mstore(0x40, add(str, 0x80))
// Store "0123456789abcdef" in scratch space.
mstore(0x0f, 0x30313233343536373839616263646566)
str := add(str, 2)
mstore(str, 40)
let o := add(str, 0x20)
mstore(add(o, 40), 0)
value := shl(96, value)
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
for {
let i := 0
} 1 {
} {
let p := add(o, add(i, i))
let temp := byte(i, value)
mstore8(add(p, 1), mload(and(temp, 15)))
mstore8(p, mload(shr(4, temp)))
i := add(i, 1)
if eq(i, 20) {
break
}
}
}
}
/// @dev Returns the hex encoded string from the raw bytes.
/// The output is encoded using 2 hexadecimal digits per byte.
function toHexString(bytes memory raw) internal pure returns (string memory str) {
str = toHexStringNoPrefix(raw);
/// @solidity memory-safe-assembly
assembly {
let strLength := add(mload(str), 2) // Compute the length.
mstore(str, 0x3078) // Write the "0x" prefix.
str := sub(str, 2) // Move the pointer.
mstore(str, strLength) // Write the length.
}
}
/// @dev Returns the hex encoded string from the raw bytes.
/// The output is encoded using 2 hexadecimal digits per byte.
function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) {
/// @solidity memory-safe-assembly
assembly {
let length := mload(raw)
str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix.
mstore(str, add(length, length)) // Store the length of the output.
// Store "0123456789abcdef" in scratch space.
mstore(0x0f, 0x30313233343536373839616263646566)
let o := add(str, 0x20)
let end := add(raw, length)
for {
} iszero(eq(raw, end)) {
} {
raw := add(raw, 1)
mstore8(add(o, 1), mload(and(mload(raw), 15)))
mstore8(o, mload(and(shr(4, mload(raw)), 15)))
o := add(o, 2)
}
mstore(o, 0) // Zeroize the slot after the string.
mstore(0x40, add(o, 0x20)) // Allocate the memory.
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
type CalldataPointer is uint256;
type ReturndataPointer is uint256;
type MemoryPointer is uint256;
using CalldataPointerLib for CalldataPointer global;
using MemoryPointerLib for MemoryPointer global;
using ReturndataPointerLib for ReturndataPointer global;
using CalldataReaders for CalldataPointer global;
using ReturndataReaders for ReturndataPointer global;
using MemoryReaders for MemoryPointer global;
using MemoryWriters for MemoryPointer global;
CalldataPointer constant CalldataStart = CalldataPointer.wrap(0x04);
MemoryPointer constant FreeMemoryPPtr = MemoryPointer.wrap(0x40);
MemoryPointer constant ZeroSlotPtr = MemoryPointer.wrap(0x60);
uint256 constant IdentityPrecompileAddress = 0x4;
uint256 constant OffsetOrLengthMask = 0xffffffff;
uint256 constant _OneWord = 0x20;
uint256 constant _FreeMemoryPointerSlot = 0x40;
/// @dev Allocates `size` bytes in memory by increasing the free memory pointer
/// and returns the memory pointer to the first byte of the allocated region.
// (Free functions cannot have visibility.)
// solhint-disable-next-line func-visibility
function malloc(uint256 size) pure returns (MemoryPointer mPtr) {
assembly {
mPtr := mload(_FreeMemoryPointerSlot)
mstore(_FreeMemoryPointerSlot, add(mPtr, size))
}
}
// (Free functions cannot have visibility.)
// solhint-disable-next-line func-visibility
function getFreeMemoryPointer() pure returns (MemoryPointer mPtr) {
mPtr = FreeMemoryPPtr.readMemoryPointer();
}
// (Free functions cannot have visibility.)
// solhint-disable-next-line func-visibility
function setFreeMemoryPointer(MemoryPointer mPtr) pure {
FreeMemoryPPtr.write(mPtr);
}
library CalldataPointerLib {
function lt(
CalldataPointer a,
CalldataPointer b
) internal pure returns (bool c) {
assembly {
c := lt(a, b)
}
}
function gt(
CalldataPointer a,
CalldataPointer b
) internal pure returns (bool c) {
assembly {
c := gt(a, b)
}
}
function eq(
CalldataPointer a,
CalldataPointer b
) internal pure returns (bool c) {
assembly {
c := eq(a, b)
}
}
function isNull(CalldataPointer a) internal pure returns (bool b) {
assembly {
b := iszero(a)
}
}
/// @dev Resolves an offset stored at `cdPtr + headOffset` to a calldata.
/// pointer `cdPtr` must point to some parent object with a dynamic
/// type's head stored at `cdPtr + headOffset`.
function pptrOffset(
CalldataPointer cdPtr,
uint256 headOffset
) internal pure returns (CalldataPointer cdPtrChild) {
cdPtrChild = cdPtr.offset(
cdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask
);
}
/// @dev Resolves an offset stored at `cdPtr` to a calldata pointer.
/// `cdPtr` must point to some parent object with a dynamic type as its
/// first member, e.g. `struct { bytes data; }`
function pptr(
CalldataPointer cdPtr
) internal pure returns (CalldataPointer cdPtrChild) {
cdPtrChild = cdPtr.offset(cdPtr.readUint256() & OffsetOrLengthMask);
}
/// @dev Returns the calldata pointer one word after `cdPtr`.
function next(
CalldataPointer cdPtr
) internal pure returns (CalldataPointer cdPtrNext) {
assembly {
cdPtrNext := add(cdPtr, _OneWord)
}
}
/// @dev Returns the calldata pointer `_offset` bytes after `cdPtr`.
function offset(
CalldataPointer cdPtr,
uint256 _offset
) internal pure returns (CalldataPointer cdPtrNext) {
assembly {
cdPtrNext := add(cdPtr, _offset)
}
}
/// @dev Copies `size` bytes from calldata starting at `src` to memory at
/// `dst`.
function copy(
CalldataPointer src,
MemoryPointer dst,
uint256 size
) internal pure {
assembly {
calldatacopy(dst, src, size)
}
}
}
library ReturndataPointerLib {
function lt(
ReturndataPointer a,
ReturndataPointer b
) internal pure returns (bool c) {
assembly {
c := lt(a, b)
}
}
function gt(
ReturndataPointer a,
ReturndataPointer b
) internal pure returns (bool c) {
assembly {
c := gt(a, b)
}
}
function eq(
ReturndataPointer a,
ReturndataPointer b
) internal pure returns (bool c) {
assembly {
c := eq(a, b)
}
}
function isNull(ReturndataPointer a) internal pure returns (bool b) {
assembly {
b := iszero(a)
}
}
/// @dev Resolves an offset stored at `rdPtr + headOffset` to a returndata
/// pointer. `rdPtr` must point to some parent object with a dynamic
/// type's head stored at `rdPtr + headOffset`.
function pptrOffset(
ReturndataPointer rdPtr,
uint256 headOffset
) internal pure returns (ReturndataPointer rdPtrChild) {
rdPtrChild = rdPtr.offset(
rdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask
);
}
/// @dev Resolves an offset stored at `rdPtr` to a returndata pointer.
/// `rdPtr` must point to some parent object with a dynamic type as its
/// first member, e.g. `struct { bytes data; }`
function pptr(
ReturndataPointer rdPtr
) internal pure returns (ReturndataPointer rdPtrChild) {
rdPtrChild = rdPtr.offset(rdPtr.readUint256() & OffsetOrLengthMask);
}
/// @dev Returns the returndata pointer one word after `cdPtr`.
function next(
ReturndataPointer rdPtr
) internal pure returns (ReturndataPointer rdPtrNext) {
assembly {
rdPtrNext := add(rdPtr, _OneWord)
}
}
/// @dev Returns the returndata pointer `_offset` bytes after `cdPtr`.
function offset(
ReturndataPointer rdPtr,
uint256 _offset
) internal pure returns (ReturndataPointer rdPtrNext) {
assembly {
rdPtrNext := add(rdPtr, _offset)
}
}
/// @dev Copies `size` bytes from returndata starting at `src` to memory at
/// `dst`.
function copy(
ReturndataPointer src,
MemoryPointer dst,
uint256 size
) internal pure {
assembly {
returndatacopy(dst, src, size)
}
}
}
library MemoryPointerLib {
function copy(
MemoryPointer src,
MemoryPointer dst,
uint256 size
) internal view {
assembly {
let success := staticcall(
gas(),
IdentityPrecompileAddress,
src,
size,
dst,
size
)
if or(iszero(returndatasize()), iszero(success)) {
revert(0, 0)
}
}
}
function lt(
MemoryPointer a,
MemoryPointer b
) internal pure returns (bool c) {
assembly {
c := lt(a, b)
}
}
function gt(
MemoryPointer a,
MemoryPointer b
) internal pure returns (bool c) {
assembly {
c := gt(a, b)
}
}
function eq(
MemoryPointer a,
MemoryPointer b
) internal pure returns (bool c) {
assembly {
c := eq(a, b)
}
}
function isNull(MemoryPointer a) internal pure returns (bool b) {
assembly {
b := iszero(a)
}
}
function hash(
MemoryPointer ptr,
uint256 length
) internal pure returns (bytes32 _hash) {
assembly {
_hash := keccak256(ptr, length)
}
}
/// @dev Returns the memory pointer one word after `mPtr`.
function next(
MemoryPointer mPtr
) internal pure returns (MemoryPointer mPtrNext) {
assembly {
mPtrNext := add(mPtr, _OneWord)
}
}
/// @dev Returns the memory pointer `_offset` bytes after `mPtr`.
function offset(
MemoryPointer mPtr,
uint256 _offset
) internal pure returns (MemoryPointer mPtrNext) {
assembly {
mPtrNext := add(mPtr, _offset)
}
}
/// @dev Resolves a pointer at `mPtr + headOffset` to a memory
/// pointer. `mPtr` must point to some parent object with a dynamic
/// type's pointer stored at `mPtr + headOffset`.
function pptrOffset(
MemoryPointer mPtr,
uint256 headOffset
) internal pure returns (MemoryPointer mPtrChild) {
mPtrChild = mPtr.offset(headOffset).readMemoryPointer();
}
/// @dev Resolves a pointer stored at `mPtr` to a memory pointer.
/// `mPtr` must point to some parent object with a dynamic type as its
/// first member, e.g. `struct { bytes data; }`
function pptr(
MemoryPointer mPtr
) internal pure returns (MemoryPointer mPtrChild) {
mPtrChild = mPtr.readMemoryPointer();
}
}
library CalldataReaders {
/// @dev Reads the value at `cdPtr` and applies a mask to return only the
/// last 4 bytes.
function readMaskedUint256(
CalldataPointer cdPtr
) internal pure returns (uint256 value) {
value = cdPtr.readUint256() & OffsetOrLengthMask;
}
/// @dev Reads the bool at `cdPtr` in calldata.
function readBool(
CalldataPointer cdPtr
) internal pure returns (bool value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the address at `cdPtr` in calldata.
function readAddress(
CalldataPointer cdPtr
) internal pure returns (address value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes1 at `cdPtr` in calldata.
function readBytes1(
CalldataPointer cdPtr
) internal pure returns (bytes1 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes2 at `cdPtr` in calldata.
function readBytes2(
CalldataPointer cdPtr
) internal pure returns (bytes2 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes3 at `cdPtr` in calldata.
function readBytes3(
CalldataPointer cdPtr
) internal pure returns (bytes3 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes4 at `cdPtr` in calldata.
function readBytes4(
CalldataPointer cdPtr
) internal pure returns (bytes4 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes5 at `cdPtr` in calldata.
function readBytes5(
CalldataPointer cdPtr
) internal pure returns (bytes5 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes6 at `cdPtr` in calldata.
function readBytes6(
CalldataPointer cdPtr
) internal pure returns (bytes6 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes7 at `cdPtr` in calldata.
function readBytes7(
CalldataPointer cdPtr
) internal pure returns (bytes7 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes8 at `cdPtr` in calldata.
function readBytes8(
CalldataPointer cdPtr
) internal pure returns (bytes8 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes9 at `cdPtr` in calldata.
function readBytes9(
CalldataPointer cdPtr
) internal pure returns (bytes9 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes10 at `cdPtr` in calldata.
function readBytes10(
CalldataPointer cdPtr
) internal pure returns (bytes10 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes11 at `cdPtr` in calldata.
function readBytes11(
CalldataPointer cdPtr
) internal pure returns (bytes11 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes12 at `cdPtr` in calldata.
function readBytes12(
CalldataPointer cdPtr
) internal pure returns (bytes12 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes13 at `cdPtr` in calldata.
function readBytes13(
CalldataPointer cdPtr
) internal pure returns (bytes13 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes14 at `cdPtr` in calldata.
function readBytes14(
CalldataPointer cdPtr
) internal pure returns (bytes14 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes15 at `cdPtr` in calldata.
function readBytes15(
CalldataPointer cdPtr
) internal pure returns (bytes15 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes16 at `cdPtr` in calldata.
function readBytes16(
CalldataPointer cdPtr
) internal pure returns (bytes16 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes17 at `cdPtr` in calldata.
function readBytes17(
CalldataPointer cdPtr
) internal pure returns (bytes17 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes18 at `cdPtr` in calldata.
function readBytes18(
CalldataPointer cdPtr
) internal pure returns (bytes18 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes19 at `cdPtr` in calldata.
function readBytes19(
CalldataPointer cdPtr
) internal pure returns (bytes19 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes20 at `cdPtr` in calldata.
function readBytes20(
CalldataPointer cdPtr
) internal pure returns (bytes20 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes21 at `cdPtr` in calldata.
function readBytes21(
CalldataPointer cdPtr
) internal pure returns (bytes21 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes22 at `cdPtr` in calldata.
function readBytes22(
CalldataPointer cdPtr
) internal pure returns (bytes22 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes23 at `cdPtr` in calldata.
function readBytes23(
CalldataPointer cdPtr
) internal pure returns (bytes23 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes24 at `cdPtr` in calldata.
function readBytes24(
CalldataPointer cdPtr
) internal pure returns (bytes24 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes25 at `cdPtr` in calldata.
function readBytes25(
CalldataPointer cdPtr
) internal pure returns (bytes25 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes26 at `cdPtr` in calldata.
function readBytes26(
CalldataPointer cdPtr
) internal pure returns (bytes26 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes27 at `cdPtr` in calldata.
function readBytes27(
CalldataPointer cdPtr
) internal pure returns (bytes27 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes28 at `cdPtr` in calldata.
function readBytes28(
CalldataPointer cdPtr
) internal pure returns (bytes28 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes29 at `cdPtr` in calldata.
function readBytes29(
CalldataPointer cdPtr
) internal pure returns (bytes29 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes30 at `cdPtr` in calldata.
function readBytes30(
CalldataPointer cdPtr
) internal pure returns (bytes30 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes31 at `cdPtr` in calldata.
function readBytes31(
CalldataPointer cdPtr
) internal pure returns (bytes31 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the bytes32 at `cdPtr` in calldata.
function readBytes32(
CalldataPointer cdPtr
) internal pure returns (bytes32 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint8 at `cdPtr` in calldata.
function readUint8(
CalldataPointer cdPtr
) internal pure returns (uint8 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint16 at `cdPtr` in calldata.
function readUint16(
CalldataPointer cdPtr
) internal pure returns (uint16 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint24 at `cdPtr` in calldata.
function readUint24(
CalldataPointer cdPtr
) internal pure returns (uint24 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint32 at `cdPtr` in calldata.
function readUint32(
CalldataPointer cdPtr
) internal pure returns (uint32 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint40 at `cdPtr` in calldata.
function readUint40(
CalldataPointer cdPtr
) internal pure returns (uint40 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint48 at `cdPtr` in calldata.
function readUint48(
CalldataPointer cdPtr
) internal pure returns (uint48 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint56 at `cdPtr` in calldata.
function readUint56(
CalldataPointer cdPtr
) internal pure returns (uint56 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint64 at `cdPtr` in calldata.
function readUint64(
CalldataPointer cdPtr
) internal pure returns (uint64 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint72 at `cdPtr` in calldata.
function readUint72(
CalldataPointer cdPtr
) internal pure returns (uint72 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint80 at `cdPtr` in calldata.
function readUint80(
CalldataPointer cdPtr
) internal pure returns (uint80 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint88 at `cdPtr` in calldata.
function readUint88(
CalldataPointer cdPtr
) internal pure returns (uint88 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint96 at `cdPtr` in calldata.
function readUint96(
CalldataPointer cdPtr
) internal pure returns (uint96 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint104 at `cdPtr` in calldata.
function readUint104(
CalldataPointer cdPtr
) internal pure returns (uint104 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint112 at `cdPtr` in calldata.
function readUint112(
CalldataPointer cdPtr
) internal pure returns (uint112 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint120 at `cdPtr` in calldata.
function readUint120(
CalldataPointer cdPtr
) internal pure returns (uint120 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint128 at `cdPtr` in calldata.
function readUint128(
CalldataPointer cdPtr
) internal pure returns (uint128 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint136 at `cdPtr` in calldata.
function readUint136(
CalldataPointer cdPtr
) internal pure returns (uint136 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint144 at `cdPtr` in calldata.
function readUint144(
CalldataPointer cdPtr
) internal pure returns (uint144 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint152 at `cdPtr` in calldata.
function readUint152(
CalldataPointer cdPtr
) internal pure returns (uint152 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint160 at `cdPtr` in calldata.
function readUint160(
CalldataPointer cdPtr
) internal pure returns (uint160 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint168 at `cdPtr` in calldata.
function readUint168(
CalldataPointer cdPtr
) internal pure returns (uint168 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint176 at `cdPtr` in calldata.
function readUint176(
CalldataPointer cdPtr
) internal pure returns (uint176 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint184 at `cdPtr` in calldata.
function readUint184(
CalldataPointer cdPtr
) internal pure returns (uint184 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint192 at `cdPtr` in calldata.
function readUint192(
CalldataPointer cdPtr
) internal pure returns (uint192 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint200 at `cdPtr` in calldata.
function readUint200(
CalldataPointer cdPtr
) internal pure returns (uint200 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint208 at `cdPtr` in calldata.
function readUint208(
CalldataPointer cdPtr
) internal pure returns (uint208 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint216 at `cdPtr` in calldata.
function readUint216(
CalldataPointer cdPtr
) internal pure returns (uint216 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint224 at `cdPtr` in calldata.
function readUint224(
CalldataPointer cdPtr
) internal pure returns (uint224 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint232 at `cdPtr` in calldata.
function readUint232(
CalldataPointer cdPtr
) internal pure returns (uint232 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint240 at `cdPtr` in calldata.
function readUint240(
CalldataPointer cdPtr
) internal pure returns (uint240 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint248 at `cdPtr` in calldata.
function readUint248(
CalldataPointer cdPtr
) internal pure returns (uint248 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the uint256 at `cdPtr` in calldata.
function readUint256(
CalldataPointer cdPtr
) internal pure returns (uint256 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int8 at `cdPtr` in calldata.
function readInt8(
CalldataPointer cdPtr
) internal pure returns (int8 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int16 at `cdPtr` in calldata.
function readInt16(
CalldataPointer cdPtr
) internal pure returns (int16 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int24 at `cdPtr` in calldata.
function readInt24(
CalldataPointer cdPtr
) internal pure returns (int24 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int32 at `cdPtr` in calldata.
function readInt32(
CalldataPointer cdPtr
) internal pure returns (int32 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int40 at `cdPtr` in calldata.
function readInt40(
CalldataPointer cdPtr
) internal pure returns (int40 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int48 at `cdPtr` in calldata.
function readInt48(
CalldataPointer cdPtr
) internal pure returns (int48 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int56 at `cdPtr` in calldata.
function readInt56(
CalldataPointer cdPtr
) internal pure returns (int56 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int64 at `cdPtr` in calldata.
function readInt64(
CalldataPointer cdPtr
) internal pure returns (int64 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int72 at `cdPtr` in calldata.
function readInt72(
CalldataPointer cdPtr
) internal pure returns (int72 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int80 at `cdPtr` in calldata.
function readInt80(
CalldataPointer cdPtr
) internal pure returns (int80 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int88 at `cdPtr` in calldata.
function readInt88(
CalldataPointer cdPtr
) internal pure returns (int88 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int96 at `cdPtr` in calldata.
function readInt96(
CalldataPointer cdPtr
) internal pure returns (int96 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int104 at `cdPtr` in calldata.
function readInt104(
CalldataPointer cdPtr
) internal pure returns (int104 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int112 at `cdPtr` in calldata.
function readInt112(
CalldataPointer cdPtr
) internal pure returns (int112 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int120 at `cdPtr` in calldata.
function readInt120(
CalldataPointer cdPtr
) internal pure returns (int120 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int128 at `cdPtr` in calldata.
function readInt128(
CalldataPointer cdPtr
) internal pure returns (int128 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int136 at `cdPtr` in calldata.
function readInt136(
CalldataPointer cdPtr
) internal pure returns (int136 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int144 at `cdPtr` in calldata.
function readInt144(
CalldataPointer cdPtr
) internal pure returns (int144 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int152 at `cdPtr` in calldata.
function readInt152(
CalldataPointer cdPtr
) internal pure returns (int152 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int160 at `cdPtr` in calldata.
function readInt160(
CalldataPointer cdPtr
) internal pure returns (int160 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int168 at `cdPtr` in calldata.
function readInt168(
CalldataPointer cdPtr
) internal pure returns (int168 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int176 at `cdPtr` in calldata.
function readInt176(
CalldataPointer cdPtr
) internal pure returns (int176 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int184 at `cdPtr` in calldata.
function readInt184(
CalldataPointer cdPtr
) internal pure returns (int184 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int192 at `cdPtr` in calldata.
function readInt192(
CalldataPointer cdPtr
) internal pure returns (int192 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int200 at `cdPtr` in calldata.
function readInt200(
CalldataPointer cdPtr
) internal pure returns (int200 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int208 at `cdPtr` in calldata.
function readInt208(
CalldataPointer cdPtr
) internal pure returns (int208 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int216 at `cdPtr` in calldata.
function readInt216(
CalldataPointer cdPtr
) internal pure returns (int216 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int224 at `cdPtr` in calldata.
function readInt224(
CalldataPointer cdPtr
) internal pure returns (int224 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int232 at `cdPtr` in calldata.
function readInt232(
CalldataPointer cdPtr
) internal pure returns (int232 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int240 at `cdPtr` in calldata.
function readInt240(
CalldataPointer cdPtr
) internal pure returns (int240 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int248 at `cdPtr` in calldata.
function readInt248(
CalldataPointer cdPtr
) internal pure returns (int248 value) {
assembly {
value := calldataload(cdPtr)
}
}
/// @dev Reads the int256 at `cdPtr` in calldata.
function readInt256(
CalldataPointer cdPtr
) internal pure returns (int256 value) {
assembly {
value := calldataload(cdPtr)
}
}
}
library ReturndataReaders {
/// @dev Reads value at `rdPtr` & applies a mask to return only last 4 bytes
function readMaskedUint256(
ReturndataPointer rdPtr
) internal pure returns (uint256 value) {
value = rdPtr.readUint256() & OffsetOrLengthMask;
}
/// @dev Reads the bool at `rdPtr` in returndata.
function readBool(
ReturndataPointer rdPtr
) internal pure returns (bool value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the address at `rdPtr` in returndata.
function readAddress(
ReturndataPointer rdPtr
) internal pure returns (address value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes1 at `rdPtr` in returndata.
function readBytes1(
ReturndataPointer rdPtr
) internal pure returns (bytes1 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes2 at `rdPtr` in returndata.
function readBytes2(
ReturndataPointer rdPtr
) internal pure returns (bytes2 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes3 at `rdPtr` in returndata.
function readBytes3(
ReturndataPointer rdPtr
) internal pure returns (bytes3 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes4 at `rdPtr` in returndata.
function readBytes4(
ReturndataPointer rdPtr
) internal pure returns (bytes4 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes5 at `rdPtr` in returndata.
function readBytes5(
ReturndataPointer rdPtr
) internal pure returns (bytes5 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes6 at `rdPtr` in returndata.
function readBytes6(
ReturndataPointer rdPtr
) internal pure returns (bytes6 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes7 at `rdPtr` in returndata.
function readBytes7(
ReturndataPointer rdPtr
) internal pure returns (bytes7 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes8 at `rdPtr` in returndata.
function readBytes8(
ReturndataPointer rdPtr
) internal pure returns (bytes8 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes9 at `rdPtr` in returndata.
function readBytes9(
ReturndataPointer rdPtr
) internal pure returns (bytes9 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes10 at `rdPtr` in returndata.
function readBytes10(
ReturndataPointer rdPtr
) internal pure returns (bytes10 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes11 at `rdPtr` in returndata.
function readBytes11(
ReturndataPointer rdPtr
) internal pure returns (bytes11 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes12 at `rdPtr` in returndata.
function readBytes12(
ReturndataPointer rdPtr
) internal pure returns (bytes12 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes13 at `rdPtr` in returndata.
function readBytes13(
ReturndataPointer rdPtr
) internal pure returns (bytes13 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes14 at `rdPtr` in returndata.
function readBytes14(
ReturndataPointer rdPtr
) internal pure returns (bytes14 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes15 at `rdPtr` in returndata.
function readBytes15(
ReturndataPointer rdPtr
) internal pure returns (bytes15 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes16 at `rdPtr` in returndata.
function readBytes16(
ReturndataPointer rdPtr
) internal pure returns (bytes16 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes17 at `rdPtr` in returndata.
function readBytes17(
ReturndataPointer rdPtr
) internal pure returns (bytes17 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes18 at `rdPtr` in returndata.
function readBytes18(
ReturndataPointer rdPtr
) internal pure returns (bytes18 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes19 at `rdPtr` in returndata.
function readBytes19(
ReturndataPointer rdPtr
) internal pure returns (bytes19 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes20 at `rdPtr` in returndata.
function readBytes20(
ReturndataPointer rdPtr
) internal pure returns (bytes20 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes21 at `rdPtr` in returndata.
function readBytes21(
ReturndataPointer rdPtr
) internal pure returns (bytes21 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes22 at `rdPtr` in returndata.
function readBytes22(
ReturndataPointer rdPtr
) internal pure returns (bytes22 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes23 at `rdPtr` in returndata.
function readBytes23(
ReturndataPointer rdPtr
) internal pure returns (bytes23 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes24 at `rdPtr` in returndata.
function readBytes24(
ReturndataPointer rdPtr
) internal pure returns (bytes24 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes25 at `rdPtr` in returndata.
function readBytes25(
ReturndataPointer rdPtr
) internal pure returns (bytes25 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes26 at `rdPtr` in returndata.
function readBytes26(
ReturndataPointer rdPtr
) internal pure returns (bytes26 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes27 at `rdPtr` in returndata.
function readBytes27(
ReturndataPointer rdPtr
) internal pure returns (bytes27 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes28 at `rdPtr` in returndata.
function readBytes28(
ReturndataPointer rdPtr
) internal pure returns (bytes28 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes29 at `rdPtr` in returndata.
function readBytes29(
ReturndataPointer rdPtr
) internal pure returns (bytes29 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes30 at `rdPtr` in returndata.
function readBytes30(
ReturndataPointer rdPtr
) internal pure returns (bytes30 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes31 at `rdPtr` in returndata.
function readBytes31(
ReturndataPointer rdPtr
) internal pure returns (bytes31 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the bytes32 at `rdPtr` in returndata.
function readBytes32(
ReturndataPointer rdPtr
) internal pure returns (bytes32 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint8 at `rdPtr` in returndata.
function readUint8(
ReturndataPointer rdPtr
) internal pure returns (uint8 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint16 at `rdPtr` in returndata.
function readUint16(
ReturndataPointer rdPtr
) internal pure returns (uint16 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint24 at `rdPtr` in returndata.
function readUint24(
ReturndataPointer rdPtr
) internal pure returns (uint24 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint32 at `rdPtr` in returndata.
function readUint32(
ReturndataPointer rdPtr
) internal pure returns (uint32 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint40 at `rdPtr` in returndata.
function readUint40(
ReturndataPointer rdPtr
) internal pure returns (uint40 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint48 at `rdPtr` in returndata.
function readUint48(
ReturndataPointer rdPtr
) internal pure returns (uint48 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint56 at `rdPtr` in returndata.
function readUint56(
ReturndataPointer rdPtr
) internal pure returns (uint56 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint64 at `rdPtr` in returndata.
function readUint64(
ReturndataPointer rdPtr
) internal pure returns (uint64 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint72 at `rdPtr` in returndata.
function readUint72(
ReturndataPointer rdPtr
) internal pure returns (uint72 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint80 at `rdPtr` in returndata.
function readUint80(
ReturndataPointer rdPtr
) internal pure returns (uint80 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint88 at `rdPtr` in returndata.
function readUint88(
ReturndataPointer rdPtr
) internal pure returns (uint88 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint96 at `rdPtr` in returndata.
function readUint96(
ReturndataPointer rdPtr
) internal pure returns (uint96 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint104 at `rdPtr` in returndata.
function readUint104(
ReturndataPointer rdPtr
) internal pure returns (uint104 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint112 at `rdPtr` in returndata.
function readUint112(
ReturndataPointer rdPtr
) internal pure returns (uint112 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint120 at `rdPtr` in returndata.
function readUint120(
ReturndataPointer rdPtr
) internal pure returns (uint120 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint128 at `rdPtr` in returndata.
function readUint128(
ReturndataPointer rdPtr
) internal pure returns (uint128 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint136 at `rdPtr` in returndata.
function readUint136(
ReturndataPointer rdPtr
) internal pure returns (uint136 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint144 at `rdPtr` in returndata.
function readUint144(
ReturndataPointer rdPtr
) internal pure returns (uint144 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint152 at `rdPtr` in returndata.
function readUint152(
ReturndataPointer rdPtr
) internal pure returns (uint152 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint160 at `rdPtr` in returndata.
function readUint160(
ReturndataPointer rdPtr
) internal pure returns (uint160 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint168 at `rdPtr` in returndata.
function readUint168(
ReturndataPointer rdPtr
) internal pure returns (uint168 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint176 at `rdPtr` in returndata.
function readUint176(
ReturndataPointer rdPtr
) internal pure returns (uint176 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint184 at `rdPtr` in returndata.
function readUint184(
ReturndataPointer rdPtr
) internal pure returns (uint184 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint192 at `rdPtr` in returndata.
function readUint192(
ReturndataPointer rdPtr
) internal pure returns (uint192 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint200 at `rdPtr` in returndata.
function readUint200(
ReturndataPointer rdPtr
) internal pure returns (uint200 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint208 at `rdPtr` in returndata.
function readUint208(
ReturndataPointer rdPtr
) internal pure returns (uint208 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint216 at `rdPtr` in returndata.
function readUint216(
ReturndataPointer rdPtr
) internal pure returns (uint216 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint224 at `rdPtr` in returndata.
function readUint224(
ReturndataPointer rdPtr
) internal pure returns (uint224 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint232 at `rdPtr` in returndata.
function readUint232(
ReturndataPointer rdPtr
) internal pure returns (uint232 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint240 at `rdPtr` in returndata.
function readUint240(
ReturndataPointer rdPtr
) internal pure returns (uint240 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint248 at `rdPtr` in returndata.
function readUint248(
ReturndataPointer rdPtr
) internal pure returns (uint248 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the uint256 at `rdPtr` in returndata.
function readUint256(
ReturndataPointer rdPtr
) internal pure returns (uint256 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int8 at `rdPtr` in returndata.
function readInt8(
ReturndataPointer rdPtr
) internal pure returns (int8 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int16 at `rdPtr` in returndata.
function readInt16(
ReturndataPointer rdPtr
) internal pure returns (int16 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int24 at `rdPtr` in returndata.
function readInt24(
ReturndataPointer rdPtr
) internal pure returns (int24 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int32 at `rdPtr` in returndata.
function readInt32(
ReturndataPointer rdPtr
) internal pure returns (int32 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int40 at `rdPtr` in returndata.
function readInt40(
ReturndataPointer rdPtr
) internal pure returns (int40 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int48 at `rdPtr` in returndata.
function readInt48(
ReturndataPointer rdPtr
) internal pure returns (int48 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int56 at `rdPtr` in returndata.
function readInt56(
ReturndataPointer rdPtr
) internal pure returns (int56 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int64 at `rdPtr` in returndata.
function readInt64(
ReturndataPointer rdPtr
) internal pure returns (int64 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int72 at `rdPtr` in returndata.
function readInt72(
ReturndataPointer rdPtr
) internal pure returns (int72 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int80 at `rdPtr` in returndata.
function readInt80(
ReturndataPointer rdPtr
) internal pure returns (int80 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int88 at `rdPtr` in returndata.
function readInt88(
ReturndataPointer rdPtr
) internal pure returns (int88 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int96 at `rdPtr` in returndata.
function readInt96(
ReturndataPointer rdPtr
) internal pure returns (int96 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int104 at `rdPtr` in returndata.
function readInt104(
ReturndataPointer rdPtr
) internal pure returns (int104 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int112 at `rdPtr` in returndata.
function readInt112(
ReturndataPointer rdPtr
) internal pure returns (int112 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int120 at `rdPtr` in returndata.
function readInt120(
ReturndataPointer rdPtr
) internal pure returns (int120 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int128 at `rdPtr` in returndata.
function readInt128(
ReturndataPointer rdPtr
) internal pure returns (int128 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int136 at `rdPtr` in returndata.
function readInt136(
ReturndataPointer rdPtr
) internal pure returns (int136 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int144 at `rdPtr` in returndata.
function readInt144(
ReturndataPointer rdPtr
) internal pure returns (int144 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int152 at `rdPtr` in returndata.
function readInt152(
ReturndataPointer rdPtr
) internal pure returns (int152 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int160 at `rdPtr` in returndata.
function readInt160(
ReturndataPointer rdPtr
) internal pure returns (int160 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int168 at `rdPtr` in returndata.
function readInt168(
ReturndataPointer rdPtr
) internal pure returns (int168 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int176 at `rdPtr` in returndata.
function readInt176(
ReturndataPointer rdPtr
) internal pure returns (int176 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int184 at `rdPtr` in returndata.
function readInt184(
ReturndataPointer rdPtr
) internal pure returns (int184 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int192 at `rdPtr` in returndata.
function readInt192(
ReturndataPointer rdPtr
) internal pure returns (int192 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int200 at `rdPtr` in returndata.
function readInt200(
ReturndataPointer rdPtr
) internal pure returns (int200 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int208 at `rdPtr` in returndata.
function readInt208(
ReturndataPointer rdPtr
) internal pure returns (int208 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int216 at `rdPtr` in returndata.
function readInt216(
ReturndataPointer rdPtr
) internal pure returns (int216 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int224 at `rdPtr` in returndata.
function readInt224(
ReturndataPointer rdPtr
) internal pure returns (int224 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int232 at `rdPtr` in returndata.
function readInt232(
ReturndataPointer rdPtr
) internal pure returns (int232 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int240 at `rdPtr` in returndata.
function readInt240(
ReturndataPointer rdPtr
) internal pure returns (int240 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int248 at `rdPtr` in returndata.
function readInt248(
ReturndataPointer rdPtr
) internal pure returns (int248 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
/// @dev Reads the int256 at `rdPtr` in returndata.
function readInt256(
ReturndataPointer rdPtr
) internal pure returns (int256 value) {
assembly {
returndatacopy(0, rdPtr, _OneWord)
value := mload(0)
}
}
}
library MemoryReaders {
/// @dev Reads the memory pointer at `mPtr` in memory.
function readMemoryPointer(
MemoryPointer mPtr
) internal pure returns (MemoryPointer value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads value at `mPtr` & applies a mask to return only last 4 bytes
function readMaskedUint256(
MemoryPointer mPtr
) internal pure returns (uint256 value) {
value = mPtr.readUint256() & OffsetOrLengthMask;
}
/// @dev Reads the bool at `mPtr` in memory.
function readBool(MemoryPointer mPtr) internal pure returns (bool value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the address at `mPtr` in memory.
function readAddress(
MemoryPointer mPtr
) internal pure returns (address value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes1 at `mPtr` in memory.
function readBytes1(
MemoryPointer mPtr
) internal pure returns (bytes1 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes2 at `mPtr` in memory.
function readBytes2(
MemoryPointer mPtr
) internal pure returns (bytes2 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes3 at `mPtr` in memory.
function readBytes3(
MemoryPointer mPtr
) internal pure returns (bytes3 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes4 at `mPtr` in memory.
function readBytes4(
MemoryPointer mPtr
) internal pure returns (bytes4 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes5 at `mPtr` in memory.
function readBytes5(
MemoryPointer mPtr
) internal pure returns (bytes5 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes6 at `mPtr` in memory.
function readBytes6(
MemoryPointer mPtr
) internal pure returns (bytes6 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes7 at `mPtr` in memory.
function readBytes7(
MemoryPointer mPtr
) internal pure returns (bytes7 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes8 at `mPtr` in memory.
function readBytes8(
MemoryPointer mPtr
) internal pure returns (bytes8 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes9 at `mPtr` in memory.
function readBytes9(
MemoryPointer mPtr
) internal pure returns (bytes9 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes10 at `mPtr` in memory.
function readBytes10(
MemoryPointer mPtr
) internal pure returns (bytes10 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes11 at `mPtr` in memory.
function readBytes11(
MemoryPointer mPtr
) internal pure returns (bytes11 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes12 at `mPtr` in memory.
function readBytes12(
MemoryPointer mPtr
) internal pure returns (bytes12 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes13 at `mPtr` in memory.
function readBytes13(
MemoryPointer mPtr
) internal pure returns (bytes13 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes14 at `mPtr` in memory.
function readBytes14(
MemoryPointer mPtr
) internal pure returns (bytes14 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes15 at `mPtr` in memory.
function readBytes15(
MemoryPointer mPtr
) internal pure returns (bytes15 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes16 at `mPtr` in memory.
function readBytes16(
MemoryPointer mPtr
) internal pure returns (bytes16 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes17 at `mPtr` in memory.
function readBytes17(
MemoryPointer mPtr
) internal pure returns (bytes17 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes18 at `mPtr` in memory.
function readBytes18(
MemoryPointer mPtr
) internal pure returns (bytes18 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes19 at `mPtr` in memory.
function readBytes19(
MemoryPointer mPtr
) internal pure returns (bytes19 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes20 at `mPtr` in memory.
function readBytes20(
MemoryPointer mPtr
) internal pure returns (bytes20 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes21 at `mPtr` in memory.
function readBytes21(
MemoryPointer mPtr
) internal pure returns (bytes21 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes22 at `mPtr` in memory.
function readBytes22(
MemoryPointer mPtr
) internal pure returns (bytes22 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes23 at `mPtr` in memory.
function readBytes23(
MemoryPointer mPtr
) internal pure returns (bytes23 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes24 at `mPtr` in memory.
function readBytes24(
MemoryPointer mPtr
) internal pure returns (bytes24 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes25 at `mPtr` in memory.
function readBytes25(
MemoryPointer mPtr
) internal pure returns (bytes25 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes26 at `mPtr` in memory.
function readBytes26(
MemoryPointer mPtr
) internal pure returns (bytes26 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes27 at `mPtr` in memory.
function readBytes27(
MemoryPointer mPtr
) internal pure returns (bytes27 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes28 at `mPtr` in memory.
function readBytes28(
MemoryPointer mPtr
) internal pure returns (bytes28 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes29 at `mPtr` in memory.
function readBytes29(
MemoryPointer mPtr
) internal pure returns (bytes29 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes30 at `mPtr` in memory.
function readBytes30(
MemoryPointer mPtr
) internal pure returns (bytes30 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes31 at `mPtr` in memory.
function readBytes31(
MemoryPointer mPtr
) internal pure returns (bytes31 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the bytes32 at `mPtr` in memory.
function readBytes32(
MemoryPointer mPtr
) internal pure returns (bytes32 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint8 at `mPtr` in memory.
function readUint8(MemoryPointer mPtr) internal pure returns (uint8 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint16 at `mPtr` in memory.
function readUint16(
MemoryPointer mPtr
) internal pure returns (uint16 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint24 at `mPtr` in memory.
function readUint24(
MemoryPointer mPtr
) internal pure returns (uint24 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint32 at `mPtr` in memory.
function readUint32(
MemoryPointer mPtr
) internal pure returns (uint32 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint40 at `mPtr` in memory.
function readUint40(
MemoryPointer mPtr
) internal pure returns (uint40 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint48 at `mPtr` in memory.
function readUint48(
MemoryPointer mPtr
) internal pure returns (uint48 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint56 at `mPtr` in memory.
function readUint56(
MemoryPointer mPtr
) internal pure returns (uint56 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint64 at `mPtr` in memory.
function readUint64(
MemoryPointer mPtr
) internal pure returns (uint64 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint72 at `mPtr` in memory.
function readUint72(
MemoryPointer mPtr
) internal pure returns (uint72 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint80 at `mPtr` in memory.
function readUint80(
MemoryPointer mPtr
) internal pure returns (uint80 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint88 at `mPtr` in memory.
function readUint88(
MemoryPointer mPtr
) internal pure returns (uint88 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint96 at `mPtr` in memory.
function readUint96(
MemoryPointer mPtr
) internal pure returns (uint96 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint104 at `mPtr` in memory.
function readUint104(
MemoryPointer mPtr
) internal pure returns (uint104 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint112 at `mPtr` in memory.
function readUint112(
MemoryPointer mPtr
) internal pure returns (uint112 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint120 at `mPtr` in memory.
function readUint120(
MemoryPointer mPtr
) internal pure returns (uint120 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint128 at `mPtr` in memory.
function readUint128(
MemoryPointer mPtr
) internal pure returns (uint128 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint136 at `mPtr` in memory.
function readUint136(
MemoryPointer mPtr
) internal pure returns (uint136 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint144 at `mPtr` in memory.
function readUint144(
MemoryPointer mPtr
) internal pure returns (uint144 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint152 at `mPtr` in memory.
function readUint152(
MemoryPointer mPtr
) internal pure returns (uint152 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint160 at `mPtr` in memory.
function readUint160(
MemoryPointer mPtr
) internal pure returns (uint160 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint168 at `mPtr` in memory.
function readUint168(
MemoryPointer mPtr
) internal pure returns (uint168 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint176 at `mPtr` in memory.
function readUint176(
MemoryPointer mPtr
) internal pure returns (uint176 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint184 at `mPtr` in memory.
function readUint184(
MemoryPointer mPtr
) internal pure returns (uint184 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint192 at `mPtr` in memory.
function readUint192(
MemoryPointer mPtr
) internal pure returns (uint192 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint200 at `mPtr` in memory.
function readUint200(
MemoryPointer mPtr
) internal pure returns (uint200 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint208 at `mPtr` in memory.
function readUint208(
MemoryPointer mPtr
) internal pure returns (uint208 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint216 at `mPtr` in memory.
function readUint216(
MemoryPointer mPtr
) internal pure returns (uint216 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint224 at `mPtr` in memory.
function readUint224(
MemoryPointer mPtr
) internal pure returns (uint224 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint232 at `mPtr` in memory.
function readUint232(
MemoryPointer mPtr
) internal pure returns (uint232 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint240 at `mPtr` in memory.
function readUint240(
MemoryPointer mPtr
) internal pure returns (uint240 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint248 at `mPtr` in memory.
function readUint248(
MemoryPointer mPtr
) internal pure returns (uint248 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the uint256 at `mPtr` in memory.
function readUint256(
MemoryPointer mPtr
) internal pure returns (uint256 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int8 at `mPtr` in memory.
function readInt8(MemoryPointer mPtr) internal pure returns (int8 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int16 at `mPtr` in memory.
function readInt16(MemoryPointer mPtr) internal pure returns (int16 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int24 at `mPtr` in memory.
function readInt24(MemoryPointer mPtr) internal pure returns (int24 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int32 at `mPtr` in memory.
function readInt32(MemoryPointer mPtr) internal pure returns (int32 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int40 at `mPtr` in memory.
function readInt40(MemoryPointer mPtr) internal pure returns (int40 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int48 at `mPtr` in memory.
function readInt48(MemoryPointer mPtr) internal pure returns (int48 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int56 at `mPtr` in memory.
function readInt56(MemoryPointer mPtr) internal pure returns (int56 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int64 at `mPtr` in memory.
function readInt64(MemoryPointer mPtr) internal pure returns (int64 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int72 at `mPtr` in memory.
function readInt72(MemoryPointer mPtr) internal pure returns (int72 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int80 at `mPtr` in memory.
function readInt80(MemoryPointer mPtr) internal pure returns (int80 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int88 at `mPtr` in memory.
function readInt88(MemoryPointer mPtr) internal pure returns (int88 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int96 at `mPtr` in memory.
function readInt96(MemoryPointer mPtr) internal pure returns (int96 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int104 at `mPtr` in memory.
function readInt104(
MemoryPointer mPtr
) internal pure returns (int104 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int112 at `mPtr` in memory.
function readInt112(
MemoryPointer mPtr
) internal pure returns (int112 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int120 at `mPtr` in memory.
function readInt120(
MemoryPointer mPtr
) internal pure returns (int120 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int128 at `mPtr` in memory.
function readInt128(
MemoryPointer mPtr
) internal pure returns (int128 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int136 at `mPtr` in memory.
function readInt136(
MemoryPointer mPtr
) internal pure returns (int136 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int144 at `mPtr` in memory.
function readInt144(
MemoryPointer mPtr
) internal pure returns (int144 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int152 at `mPtr` in memory.
function readInt152(
MemoryPointer mPtr
) internal pure returns (int152 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int160 at `mPtr` in memory.
function readInt160(
MemoryPointer mPtr
) internal pure returns (int160 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int168 at `mPtr` in memory.
function readInt168(
MemoryPointer mPtr
) internal pure returns (int168 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int176 at `mPtr` in memory.
function readInt176(
MemoryPointer mPtr
) internal pure returns (int176 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int184 at `mPtr` in memory.
function readInt184(
MemoryPointer mPtr
) internal pure returns (int184 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int192 at `mPtr` in memory.
function readInt192(
MemoryPointer mPtr
) internal pure returns (int192 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int200 at `mPtr` in memory.
function readInt200(
MemoryPointer mPtr
) internal pure returns (int200 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int208 at `mPtr` in memory.
function readInt208(
MemoryPointer mPtr
) internal pure returns (int208 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int216 at `mPtr` in memory.
function readInt216(
MemoryPointer mPtr
) internal pure returns (int216 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int224 at `mPtr` in memory.
function readInt224(
MemoryPointer mPtr
) internal pure returns (int224 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int232 at `mPtr` in memory.
function readInt232(
MemoryPointer mPtr
) internal pure returns (int232 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int240 at `mPtr` in memory.
function readInt240(
MemoryPointer mPtr
) internal pure returns (int240 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int248 at `mPtr` in memory.
function readInt248(
MemoryPointer mPtr
) internal pure returns (int248 value) {
assembly {
value := mload(mPtr)
}
}
/// @dev Reads the int256 at `mPtr` in memory.
function readInt256(
MemoryPointer mPtr
) internal pure returns (int256 value) {
assembly {
value := mload(mPtr)
}
}
}
library MemoryWriters {
/// @dev Writes `valuePtr` to memory at `mPtr`.
function write(MemoryPointer mPtr, MemoryPointer valuePtr) internal pure {
assembly {
mstore(mPtr, valuePtr)
}
}
/// @dev Writes a boolean `value` to `mPtr` in memory.
function write(MemoryPointer mPtr, bool value) internal pure {
assembly {
mstore(mPtr, value)
}
}
/// @dev Writes an address `value` to `mPtr` in memory.
function write(MemoryPointer mPtr, address value) internal pure {
assembly {
mstore(mPtr, value)
}
}
/// @dev Writes a bytes32 `value` to `mPtr` in memory.
/// Separate name to disambiguate literal write parameters.
function writeBytes32(MemoryPointer mPtr, bytes32 value) internal pure {
assembly {
mstore(mPtr, value)
}
}
/// @dev Writes a uint256 `value` to `mPtr` in memory.
function write(MemoryPointer mPtr, uint256 value) internal pure {
assembly {
mstore(mPtr, value)
}
}
/// @dev Writes an int256 `value` to `mPtr` in memory.
/// Separate name to disambiguate literal write parameters.
function writeInt(MemoryPointer mPtr, int256 value) internal pure {
assembly {
mstore(mPtr, value)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
/*
* -------------------------- Disambiguation & Other Notes ---------------------
* - The term "head" is used as it is in the documentation for ABI encoding,
* but only in reference to dynamic types, i.e. it always refers to the
* offset or pointer to the body of a dynamic type. In calldata, the head
* is always an offset (relative to the parent object), while in memory,
* the head is always the pointer to the body. More information found here:
* https://docs.soliditylang.org/en/v0.8.17/abi-spec.html#argument-encoding
* - Note that the length of an array is separate from and precedes the
* head of the array.
*
* - The term "body" is used in place of the term "head" used in the ABI
* documentation. It refers to the start of the data for a dynamic type,
* e.g. the first word of a struct or the first word of the first element
* in an array.
*
* - The term "pointer" is used to describe the absolute position of a value
* and never an offset relative to another value.
* - The suffix "_ptr" refers to a memory pointer.
* - The suffix "_cdPtr" refers to a calldata pointer.
*
* - The term "offset" is used to describe the position of a value relative
* to some parent value. For example, OrderParameters_conduit_offset is the
* offset to the "conduit" value in the OrderParameters struct relative to
* the start of the body.
* - Note: Offsets are used to derive pointers.
*
* - Some structs have pointers defined for all of their fields in this file.
* Lines which are commented out are fields that are not used in the
* codebase but have been left in for readability.
*/
// Declare constants for name, version, and reentrancy sentinel values.
// Name is right padded, so it touches the length which is left padded. This
// enables writing both values at once. Length goes at byte 95 in memory, and
// name fills bytes 96-109, so both values can be written left-padded to 77.
uint256 constant NameLengthPtr = 0x4D;
uint256 constant NameWithLength = 0x0d436F6E73696465726174696F6E;
uint256 constant information_version_offset = 0;
uint256 constant information_version_cd_offset = 0x60;
uint256 constant information_domainSeparator_offset = 0x20;
uint256 constant information_conduitController_offset = 0x40;
uint256 constant information_versionLengthPtr = 0x63;
uint256 constant information_versionWithLength = 0x03312e36; // 1.6
uint256 constant information_length = 0xa0;
// uint256(uint32(bytes4(keccak256("_REENTRANCY_GUARD_SLOT"))))
uint256 constant _REENTRANCY_GUARD_SLOT = 0x929eee14;
/*
*
* --------------------------------------------------------------------------+
* Opcode | Mnemonic | Stack | Memory |
* --------------------------------------------------------------------------|
* 60 0x02 | PUSH1 0x02 | 0x02 | |
* 60 0x1e | PUSH1 0x1e | 0x1e 0x02 | |
* 61 0x3d5c | PUSH2 0x3d5c | 0x3d5c 0x1e 0x02 | |
* 3d | RETURNDATASIZE | 0 0x3d5c 0x1e 0x02 | |
* |
* ::: store deployed bytecode in memory: (3d) RETURNDATASIZE (5c) TLOAD ::: |
* 52 | MSTORE | 0x1e 0x02 | [0..0x20): 0x3d5c |
* f3 | RETURN | | [0..0x20): 0x3d5c |
* --------------------------------------------------------------------------+
*/
uint256 constant _TLOAD_TEST_PAYLOAD = 0x6002_601e_613d5c_3d_52_f3;
uint256 constant _TLOAD_TEST_PAYLOAD_LENGTH = 0x0a;
uint256 constant _TLOAD_TEST_PAYLOAD_OFFSET = 0x16;
uint256 constant _NOT_ENTERED_TSTORE = 0;
uint256 constant _ENTERED_TSTORE = 1;
uint256 constant _ENTERED_AND_ACCEPTING_NATIVE_TOKENS_TSTORE = 2;
uint256 constant _TSTORE_ENABLED_SSTORE = 0;
uint256 constant _NOT_ENTERED_SSTORE = 1;
uint256 constant _ENTERED_SSTORE = 2;
uint256 constant _ENTERED_AND_ACCEPTING_NATIVE_TOKENS_SSTORE = 3;
uint256 constant Offset_fulfillAdvancedOrder_criteriaResolvers = 0x20;
uint256 constant Offset_fulfillAvailableOrders_offerFulfillments = 0x20;
uint256 constant Offset_fulfillAvailableOrders_considerationFulfillments = 0x40;
uint256 constant Offset_fulfillAvailableAdvancedOrders_criteriaResolvers = 0x20;
uint256 constant Offset_fulfillAvailableAdvancedOrders_offerFulfillments = 0x40;
uint256 constant Offset_fulfillAvailableAdvancedOrders_cnsdrationFlflmnts =
(0x60);
uint256 constant Offset_matchOrders_fulfillments = 0x20;
uint256 constant Offset_matchAdvancedOrders_criteriaResolvers = 0x20;
uint256 constant Offset_matchAdvancedOrders_fulfillments = 0x40;
// Common Offsets
// Offsets for identically positioned fields shared by:
// OfferItem, ConsiderationItem, SpentItem, ReceivedItem
uint256 constant Selector_length = 0x4;
uint256 constant Common_token_offset = 0x20;
uint256 constant Common_identifier_offset = 0x40;
uint256 constant Common_amount_offset = 0x60;
uint256 constant Common_endAmount_offset = 0x80;
uint256 constant SpentItem_size = 0x80;
uint256 constant SpentItem_size_shift = 0x7;
uint256 constant OfferItem_size = 0xa0;
uint256 constant OfferItem_size_with_head_pointer = 0xc0;
uint256 constant ReceivedItem_size_excluding_recipient = 0x80;
uint256 constant ReceivedItem_size = 0xa0;
uint256 constant ReceivedItem_amount_offset = 0x60;
uint256 constant ReceivedItem_recipient_offset = 0x80;
uint256 constant ReceivedItem_CommonParams_size = 0x60;
uint256 constant ConsiderationItem_size = 0xc0;
uint256 constant ConsiderationItem_size_with_head_pointer = 0xe0;
uint256 constant ConsiderationItem_recipient_offset = 0xa0;
// Store the same constant in an abbreviated format for a line length fix.
uint256 constant ConsiderItem_recipient_offset = 0xa0;
uint256 constant Execution_offerer_offset = 0x20;
uint256 constant Execution_conduit_offset = 0x40;
// uint256 constant OrderParameters_offerer_offset = 0x00;
uint256 constant OrderParameters_zone_offset = 0x20;
uint256 constant OrderParameters_offer_head_offset = 0x40;
uint256 constant OrderParameters_consideration_head_offset = 0x60;
// uint256 constant OrderParameters_orderType_offset = 0x80;
uint256 constant OrderParameters_startTime_offset = 0xa0;
uint256 constant OrderParameters_endTime_offset = 0xc0;
uint256 constant OrderParameters_zoneHash_offset = 0xe0;
uint256 constant OrderParameters_salt_offset = 0x100;
uint256 constant OrderParameters_conduit_offset = 0x120;
uint256 constant OrderParameters_counter_offset = 0x140;
uint256 constant Fulfillment_itemIndex_offset = 0x20;
uint256 constant AdvancedOrder_head_size = 0xa0;
uint256 constant AdvancedOrder_numerator_offset = 0x20;
uint256 constant AdvancedOrder_denominator_offset = 0x40;
uint256 constant AdvancedOrder_signature_offset = 0x60;
uint256 constant AdvancedOrder_extraData_offset = 0x80;
uint256 constant OrderStatus_ValidatedAndNotCancelled = 1;
uint256 constant OrderStatus_filledNumerator_offset = 0x10;
uint256 constant OrderStatus_filledDenominator_offset = 0x88;
uint256 constant OrderStatus_ValidatedAndNotCancelledAndFullyFilled = (
0x0000000000000000000000000000010000000000000000000000000000010001
);
uint256 constant ThirtyOneBytes = 0x1f;
uint256 constant OneWord = 0x20;
uint256 constant TwoWords = 0x40;
uint256 constant ThreeWords = 0x60;
uint256 constant FourWords = 0x80;
uint256 constant FiveWords = 0xa0;
uint256 constant OneWordShift = 0x5;
uint256 constant TwoWordsShift = 0x6;
uint256 constant SixtyThreeBytes = 0x3f;
uint256 constant OnlyFullWordMask = 0xffffffe0;
uint256 constant FreeMemoryPointerSlot = 0x40;
uint256 constant ZeroSlot = 0x60;
uint256 constant DefaultFreeMemoryPointer = 0x80;
uint256 constant Slot0x80 = 0x80;
uint256 constant Slot0xA0 = 0xa0;
uint256 constant BasicOrder_common_params_size = 0xa0;
uint256 constant BasicOrder_considerationHashesArray_ptr = 0x160;
uint256 constant BasicOrder_receivedItemByteMap =
(0x0000010102030000000000000000000000000000000000000000000000000000);
uint256 constant BasicOrder_offeredItemByteMap =
(0x0203020301010000000000000000000000000000000000000000000000000000);
uint256 constant BasicOrder_consideration_offset_from_offer = 0xa0;
bytes32 constant OrdersMatchedTopic0 =
(0x4b9f2d36e1b4c93de62cc077b00b1a91d84b6c31b4a14e012718dcca230689e7);
uint256 constant EIP712_Order_size = 0x180;
uint256 constant EIP712_OfferItem_size = 0xc0;
uint256 constant EIP712_ConsiderationItem_size = 0xe0;
uint256 constant AdditionalRecipient_size = 0x40;
uint256 constant AdditionalRecipient_size_shift = 0x6;
uint256 constant EIP712_DomainSeparator_offset = 0x02;
uint256 constant EIP712_OrderHash_offset = 0x22;
uint256 constant EIP712_DigestPayload_size = 0x42;
uint256 constant EIP712_domainData_nameHash_offset = 0x20;
uint256 constant EIP712_domainData_versionHash_offset = 0x40;
uint256 constant EIP712_domainData_chainId_offset = 0x60;
uint256 constant EIP712_domainData_verifyingContract_offset = 0x80;
uint256 constant EIP712_domainData_size = 0xa0;
// Minimum BulkOrder proof size: 64 bytes for signature + 3 for key + 32 for 1
// sibling. Maximum BulkOrder proof size: 65 bytes for signature + 3 for key +
// 768 for 24 siblings.
uint256 constant BulkOrderProof_minSize = 0x63;
uint256 constant BulkOrderProof_rangeSize = 0x2e2;
uint256 constant BulkOrderProof_lengthAdjustmentBeforeMask = 0x1d;
uint256 constant BulkOrderProof_lengthRangeAfterMask = 0x2;
uint256 constant BulkOrderProof_keyShift = 0xe8;
uint256 constant BulkOrderProof_keySize = 0x3;
uint256 constant BulkOrder_Typehash_Height_One =
(0x3ca2711d29384747a8f61d60aad3c450405f7aaff5613541dee28df2d6986d32);
uint256 constant BulkOrder_Typehash_Height_Two =
(0xbf8e29b89f29ed9b529c154a63038ffca562f8d7cd1e2545dda53a1b582dde30);
uint256 constant BulkOrder_Typehash_Height_Three =
(0x53c6f6856e13104584dd0797ca2b2779202dc2597c6066a42e0d8fe990b0024d);
uint256 constant BulkOrder_Typehash_Height_Four =
(0xa02eb7ff164c884e5e2c336dc85f81c6a93329d8e9adf214b32729b894de2af1);
uint256 constant BulkOrder_Typehash_Height_Five =
(0x39c9d33c18e050dda0aeb9a8086fb16fc12d5d64536780e1da7405a800b0b9f6);
uint256 constant BulkOrder_Typehash_Height_Six =
(0x1c19f71958cdd8f081b4c31f7caf5c010b29d12950be2fa1c95070dc47e30b55);
uint256 constant BulkOrder_Typehash_Height_Seven =
(0xca74fab2fece9a1d58234a274220ad05ca096a92ef6a1ca1750b9d90c948955c);
uint256 constant BulkOrder_Typehash_Height_Eight =
(0x7ff98d9d4e55d876c5cfac10b43c04039522f3ddfb0ea9bfe70c68cfb5c7cc14);
uint256 constant BulkOrder_Typehash_Height_Nine =
(0xbed7be92d41c56f9e59ac7a6272185299b815ddfabc3f25deb51fe55fe2f9e8a);
uint256 constant BulkOrder_Typehash_Height_Ten =
(0xd1d97d1ef5eaa37a4ee5fbf234e6f6d64eb511eb562221cd7edfbdde0848da05);
uint256 constant BulkOrder_Typehash_Height_Eleven =
(0x896c3f349c4da741c19b37fec49ed2e44d738e775a21d9c9860a69d67a3dae53);
uint256 constant BulkOrder_Typehash_Height_Twelve =
(0xbb98d87cc12922b83759626c5f07d72266da9702d19ffad6a514c73a89002f5f);
uint256 constant BulkOrder_Typehash_Height_Thirteen =
(0xe6ae19322608dd1f8a8d56aab48ed9c28be489b689f4b6c91268563efc85f20e);
uint256 constant BulkOrder_Typehash_Height_Fourteen =
(0x6b5b04cbae4fcb1a9d78e7b2dfc51a36933d023cf6e347e03d517b472a852590);
uint256 constant BulkOrder_Typehash_Height_Fifteen =
(0xd1eb68309202b7106b891e109739dbbd334a1817fe5d6202c939e75cf5e35ca9);
uint256 constant BulkOrder_Typehash_Height_Sixteen =
(0x1da3eed3ecef6ebaa6e5023c057ec2c75150693fd0dac5c90f4a142f9879fde8);
uint256 constant BulkOrder_Typehash_Height_Seventeen =
(0xeee9a1392aa395c7002308119a58f2582777a75e54e0c1d5d5437bd2e8bf6222);
uint256 constant BulkOrder_Typehash_Height_Eighteen =
(0xc3939feff011e53ab8c35ca3370aad54c5df1fc2938cd62543174fa6e7d85877);
uint256 constant BulkOrder_Typehash_Height_Nineteen =
(0x0efca7572ac20f5ae84db0e2940674f7eca0a4726fa1060ffc2d18cef54b203d);
uint256 constant BulkOrder_Typehash_Height_Twenty =
(0x5a4f867d3d458dabecad65f6201ceeaba0096df2d0c491cc32e6ea4e64350017);
uint256 constant BulkOrder_Typehash_Height_TwentyOne =
(0x80987079d291feebf21c2230e69add0f283cee0b8be492ca8050b4185a2ff719);
uint256 constant BulkOrder_Typehash_Height_TwentyTwo =
(0x3bd8cff538aba49a9c374c806d277181e9651624b3e31111bc0624574f8bca1d);
uint256 constant BulkOrder_Typehash_Height_TwentyThree =
(0x5d6a3f098a0bc373f808c619b1bb4028208721b3c4f8d6bc8a874d659814eb76);
uint256 constant BulkOrder_Typehash_Height_TwentyFour =
(0x1d51df90cba8de7637ca3e8fe1e3511d1dc2f23487d05dbdecb781860c21ac1c);
uint256 constant receivedItemsHash_ptr = 0x60;
/*
* Memory layout in _prepareBasicFulfillmentFromCalldata of
* data for OrderFulfilled
*
* event OrderFulfilled(
* bytes32 orderHash,
* address indexed offerer,
* address indexed zone,
* address fulfiller,
* SpentItem[] offer,
* > (itemType, token, id, amount)
* ReceivedItem[] consideration
* > (itemType, token, id, amount, recipient)
* )
*
* - 0x00: orderHash
* - 0x20: fulfiller
* - 0x40: offer offset (0x80)
* - 0x60: consideration offset (0x120)
* - 0x80: offer.length (1)
* - 0xa0: offerItemType
* - 0xc0: offerToken
* - 0xe0: offerIdentifier
* - 0x100: offerAmount
* - 0x120: consideration.length (1 + additionalRecipients.length)
* - 0x140: considerationItemType
* - 0x160: considerationToken
* - 0x180: considerationIdentifier
* - 0x1a0: considerationAmount
* - 0x1c0: considerationRecipient
* - ...
*/
// Minimum length of the OrderFulfilled event data.
// Must be added to the size of the ReceivedItem array for additionalRecipients
// (0xa0 * additionalRecipients.length) to calculate full size of the buffer.
uint256 constant OrderFulfilled_baseSize = 0x1e0;
uint256 constant OrderFulfilled_selector =
(0x9d9af8e38d66c62e2c12f0225249fd9d721c54b83f48d9352c97c6cacdcb6f31);
// Minimum offset in memory to OrderFulfilled event data.
// Must be added to the size of the EIP712 hash array for additionalRecipients
// (32 * additionalRecipients.length) to calculate the pointer to event data.
uint256 constant OrderFulfilled_baseOffset = 0x180;
uint256 constant OrderFulfilled_consideration_length_baseOffset = 0x2a0;
uint256 constant OrderFulfilled_offer_length_baseOffset = 0x200;
uint256 constant OrderFulfilled_offer_length_offset_relativeTo_baseOffset = (
0x80
);
uint256 constant OrderFulfilled_offer_itemType_offset_relativeTo_baseOffset = (
0xa0
);
uint256 constant OrderFulfilled_offer_token_offset_relativeTo_baseOffset = 0xc0;
// Related constants used for restricted order checks on basic orders.
uint256 constant OrderFulfilled_baseDataSize = 0x160;
// uint256 constant ValidateOrder_offerDataOffset = 0x184;
// uint256 constant RatifyOrder_offerDataOffset = 0xc4;
// uint256 constant OrderFulfilled_orderHash_offset = 0x00;
uint256 constant OrderFulfilled_fulfiller_offset = 0x20;
uint256 constant OrderFulfilled_offer_head_offset = 0x40;
uint256 constant OrderFulfilled_offer_body_offset = 0x80;
uint256 constant OrderFulfilled_consideration_head_offset = 0x60;
uint256 constant OrderFulfilled_consideration_body_offset = 0x120;
/*
* 3 memory slots/words for `authorizeOrder` and `validateOrder` calldata
* to be used for tails of extra data (length 0) and order hashes (length 1)
*/
uint256 constant OrderFulfilled_post_memory_region_reservedBytes = 0x60;
/*
* OrderFulfilled_offer_length_baseOffset - 12 * 0x20
* we back up 12 words from where the `OrderFulfilled`'s data
* for spent items start to be rewritten for `authorizeOrder`
* and `validateOrder`. Let the reference pointer be `ptr`
* pointing to the `OrderFulfilled`'s spent item array's length memory
* position then we would have:
*
* ptr - 0x0180 : zero-padded calldata selector
* ptr - 0x0160 : ZoneParameter's struct head (0x20)
* ptr - 0x0140 : order hash
* ptr - 0x0120 : fulfiller (msg.sender)
* ptr - 0x0100 : offerer
* ptr - 0x00e0 : spent items' head
* ptr - 0x00c0 : received items' head
* ptr - 0x00a0 : extra data / context head
* ptr - 0x0080 : order hashes head
* ptr - 0x0060 : start time
* ptr - 0x0040 : end time
* ptr - 0x0020 : zone hash
* ptr - 0x0000 : offer.length (1)
* ...
*
* Note that the padded calldata selector will be at minimum at the
* 0x80 memory slot.
*/
uint256 constant authorizeOrder_calldata_baseOffset = (
OrderFulfilled_offer_length_baseOffset - 0x180
);
// BasicOrderParameters
uint256 constant BasicOrder_parameters_cdPtr = 0x04;
uint256 constant BasicOrder_considerationToken_cdPtr = 0x24;
uint256 constant BasicOrder_considerationIdentifier_cdPtr = 0x44;
uint256 constant BasicOrder_considerationAmount_cdPtr = 0x64;
uint256 constant BasicOrder_offerer_cdPtr = 0x84;
uint256 constant BasicOrder_zone_cdPtr = 0xa4;
uint256 constant BasicOrder_offerToken_cdPtr = 0xc4;
uint256 constant BasicOrder_offerIdentifier_cdPtr = 0xe4;
uint256 constant BasicOrder_offerAmount_cdPtr = 0x104;
uint256 constant BasicOrder_basicOrderParameters_cd_offset = 0x24;
uint256 constant BasicOrder_basicOrderType_cdPtr = 0x124;
uint256 constant BasicOrder_startTime_cdPtr = 0x144;
uint256 constant BasicOrder_endTime_cdPtr = 0x164;
// uint256 constant BasicOrder_zoneHash_cdPtr = 0x184;
// uint256 constant BasicOrder_salt_cdPtr = 0x1a4;
uint256 constant BasicOrder_offererConduit_cdPtr = 0x1c4;
uint256 constant BasicOrder_fulfillerConduit_cdPtr = 0x1e4;
uint256 constant BasicOrder_totalOriginalAdditionalRecipients_cdPtr = 0x204;
uint256 constant BasicOrder_additionalRecipients_head_cdPtr = 0x224;
uint256 constant BasicOrder_signature_cdPtr = 0x244;
uint256 constant BasicOrder_additionalRecipients_length_cdPtr = 0x264;
uint256 constant BasicOrder_addlRecipients_length_cdPtr = 0x264;
uint256 constant BasicOrder_additionalRecipients_data_cdPtr = 0x284;
uint256 constant BasicOrder_parameters_ptr = 0x20;
uint256 constant BasicOrder_basicOrderType_range = 0x18; // 24 values
/*
* Memory layout in _prepareBasicFulfillmentFromCalldata of
* EIP712 data for ConsiderationItem
* - 0x80: ConsiderationItem EIP-712 typehash (constant)
* - 0xa0: itemType
* - 0xc0: token
* - 0xe0: identifier
* - 0x100: startAmount
* - 0x120: endAmount
* - 0x140: recipient
*/
uint256 constant BasicOrder_considerationItem_typeHash_ptr = 0x80; // memoryPtr
uint256 constant BasicOrder_considerationItem_itemType_ptr = 0xa0;
uint256 constant BasicOrder_considerationItem_token_ptr = 0xc0;
uint256 constant BasicOrder_considerationItem_identifier_ptr = 0xe0;
uint256 constant BasicOrder_considerationItem_startAmount_ptr = 0x100;
uint256 constant BasicOrder_considerationItem_endAmount_ptr = 0x120;
// uint256 constant BasicOrder_considerationItem_recipient_ptr = 0x140;
/*
* Memory layout in _prepareBasicFulfillmentFromCalldata of
* EIP712 data for OfferItem
* - 0x80: OfferItem EIP-712 typehash (constant)
* - 0xa0: itemType
* - 0xc0: token
* - 0xe0: identifier (reused for offeredItemsHash)
* - 0x100: startAmount
* - 0x120: endAmount
*/
uint256 constant BasicOrder_offerItem_typeHash_ptr = 0x80;
uint256 constant BasicOrder_offerItem_itemType_ptr = 0xa0;
uint256 constant BasicOrder_offerItem_token_ptr = 0xc0;
// uint256 constant BasicOrder_offerItem_identifier_ptr = 0xe0;
// uint256 constant BasicOrder_offerItem_startAmount_ptr = 0x100;
uint256 constant BasicOrder_offerItem_endAmount_ptr = 0x120;
/*
* Memory layout in _prepareBasicFulfillmentFromCalldata of
* EIP712 data for Order
* - 0x80: Order EIP-712 typehash (constant)
* - 0xa0: orderParameters.offerer
* - 0xc0: orderParameters.zone
* - 0xe0: keccak256(abi.encodePacked(offerHashes))
* - 0x100: keccak256(abi.encodePacked(considerationHashes))
* - 0x120: orderType
* - 0x140: startTime
* - 0x160: endTime
* - 0x180: zoneHash
* - 0x1a0: salt
* - 0x1c0: conduit
* - 0x1e0: _counters[orderParameters.offerer] (from storage)
*/
uint256 constant BasicOrder_order_typeHash_ptr = 0x80;
uint256 constant BasicOrder_order_offerer_ptr = 0xa0;
// uint256 constant BasicOrder_order_zone_ptr = 0xc0;
uint256 constant BasicOrder_order_offerHashes_ptr = 0xe0;
uint256 constant BasicOrder_order_considerationHashes_ptr = 0x100;
uint256 constant BasicOrder_order_orderType_ptr = 0x120;
uint256 constant BasicOrder_order_startTime_ptr = 0x140;
// uint256 constant BasicOrder_order_endTime_ptr = 0x160;
// uint256 constant BasicOrder_order_zoneHash_ptr = 0x180;
// uint256 constant BasicOrder_order_salt_ptr = 0x1a0;
// uint256 constant BasicOrder_order_conduitKey_ptr = 0x1c0;
uint256 constant BasicOrder_order_counter_ptr = 0x1e0;
uint256 constant BasicOrder_additionalRecipients_head_ptr = 0x240;
uint256 constant BasicOrder_signature_ptr = 0x260;
uint256 constant BasicOrder_startTimeThroughZoneHash_size = 0x60;
uint256 constant ContractOrder_orderHash_offerer_shift = 0x60;
uint256 constant Counter_blockhash_shift = 0x80;
// Signature-related
bytes32 constant EIP2098_allButHighestBitMask =
(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
bytes32 constant ECDSA_twentySeventhAndTwentyEighthBytesSet =
(0x0000000000000000000000000000000000000000000000000000000101000000);
uint256 constant ECDSA_MaxLength = 65;
uint256 constant ECDSA_signature_s_offset = 0x40;
uint256 constant ECDSA_signature_v_offset = 0x60;
bytes32 constant EIP1271_isValidSignature_selector =
(0x1626ba7e00000000000000000000000000000000000000000000000000000000);
uint256 constant EIP1271_isValidSignature_digest_negativeOffset = 0x40;
uint256 constant EIP1271_isValidSignature_selector_negativeOffset = 0x44;
uint256 constant EIP1271_isValidSignature_calldata_baseLength = 0x64;
uint256 constant EIP1271_isValidSignature_signature_head_offset = 0x40;
uint256 constant EIP_712_PREFIX =
(0x1901000000000000000000000000000000000000000000000000000000000000);
uint256 constant ExtraGasBuffer = 0x20;
uint256 constant CostPerWord = 0x3;
uint256 constant MemoryExpansionCoefficientShift = 0x9;
uint256 constant Create2AddressDerivation_ptr = 0x0b;
uint256 constant Create2AddressDerivation_length = 0x55;
uint256 constant MaskOverByteTwelve =
(0x0000000000000000000000ff0000000000000000000000000000000000000000);
uint256 constant MaskOverLastTwentyBytes =
(0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff);
uint256 constant AddressDirtyUpperBitThreshold =
(0x0000000000000000000000010000000000000000000000000000000000000000);
uint256 constant MaskOverFirstFourBytes =
(0xffffffff00000000000000000000000000000000000000000000000000000000);
uint256 constant Conduit_execute_signature =
(0x4ce34aa200000000000000000000000000000000000000000000000000000000);
uint256 constant MaxUint8 = 0xff;
uint256 constant MaxUint120 = 0xffffffffffffffffffffffffffffff;
uint256 constant Conduit_execute_ConduitTransfer_ptr = 0x20;
uint256 constant Conduit_execute_ConduitTransfer_length = 0x01;
uint256 constant Conduit_execute_ConduitTransfer_offset_ptr = 0x04;
uint256 constant Conduit_execute_ConduitTransfer_length_ptr = 0x24;
uint256 constant Conduit_execute_transferItemType_ptr = 0x44;
uint256 constant Conduit_execute_transferToken_ptr = 0x64;
uint256 constant Conduit_execute_transferFrom_ptr = 0x84;
uint256 constant Conduit_execute_transferTo_ptr = 0xa4;
uint256 constant Conduit_execute_transferIdentifier_ptr = 0xc4;
uint256 constant Conduit_execute_transferAmount_ptr = 0xe4;
uint256 constant OneConduitExecute_size = 0x104;
// Sentinel value to indicate that the conduit accumulator is not armed.
uint256 constant AccumulatorDisarmed = 0x20;
uint256 constant AccumulatorArmed = 0x40;
uint256 constant Accumulator_conduitKey_ptr = 0x20;
uint256 constant Accumulator_selector_ptr = 0x40;
uint256 constant Accumulator_array_offset_ptr = 0x44;
uint256 constant Accumulator_array_length_ptr = 0x64;
uint256 constant Accumulator_itemSizeOffsetDifference = 0x3c;
uint256 constant Accumulator_array_offset = 0x20;
uint256 constant Conduit_transferItem_size = 0xc0;
uint256 constant Conduit_transferItem_token_ptr = 0x20;
uint256 constant Conduit_transferItem_from_ptr = 0x40;
uint256 constant Conduit_transferItem_to_ptr = 0x60;
uint256 constant Conduit_transferItem_identifier_ptr = 0x80;
uint256 constant Conduit_transferItem_amount_ptr = 0xa0;
uint256 constant Ecrecover_precompile = 0x1;
uint256 constant Ecrecover_args_size = 0x80;
uint256 constant Signature_lower_v = 27;
// Bitmask that only gives a non-zero value if masked with a non-match selector.
uint256 constant NonMatchSelector_MagicMask =
(0x4000000000000000000000000000000000000000000000000000000000);
// First bit indicates that a NATIVE offer items has been used and the 231st bit
// indicates that a non match selector has been called.
uint256 constant NonMatchSelector_InvalidErrorValue =
(0x4000000000000000000000000000000000000000000000000000000001);
/**
* @dev Selector and offsets for generateOrder
*
* function generateOrder(
* address fulfiller,
* SpentItem[] calldata minimumReceived,
* SpentItem[] calldata maximumSpent,
* bytes calldata context
* )
*/
uint256 constant generateOrder_selector = 0x98919765;
uint256 constant generateOrder_selector_offset = 0x1c;
uint256 constant generateOrder_head_offset = 0x04;
uint256 constant generateOrder_minimumReceived_head_offset = 0x20;
uint256 constant generateOrder_maximumSpent_head_offset = 0x40;
uint256 constant generateOrder_context_head_offset = 0x60;
uint256 constant generateOrder_base_tail_offset = 0x80;
uint256 constant generateOrder_maximum_returned_array_length = 0xffff;
uint256 constant ratifyOrder_selector = 0xf4dd92ce;
uint256 constant ratifyOrder_selector_offset = 0x1c;
uint256 constant ratifyOrder_head_offset = 0x04;
// uint256 constant ratifyOrder_offer_head_offset = 0x00;
uint256 constant ratifyOrder_consideration_head_offset = 0x20;
uint256 constant ratifyOrder_context_head_offset = 0x40;
uint256 constant ratifyOrder_orderHashes_head_offset = 0x60;
uint256 constant ratifyOrder_contractNonce_offset = 0x80;
uint256 constant ratifyOrder_base_tail_offset = 0xa0;
uint256 constant validateOrder_selector = 0x17b1f942;
uint256 constant validateOrder_selector_offset = 0x1c;
uint256 constant validateOrder_head_offset = 0x04;
uint256 constant validateOrder_zoneParameters_offset = 0x20;
uint256 constant authorizeOrder_selector = 0x01e4d72a;
uint256 constant authorizeOrder_selector_offset = 0x1c;
uint256 constant authorizeOrder_head_offset = 0x04;
uint256 constant authorizeOrder_zoneParameters_offset = 0x20;
// uint256 constant ZoneParameters_orderHash_offset = 0x00;
uint256 constant ZoneParameters_fulfiller_offset = 0x20;
uint256 constant ZoneParameters_offerer_offset = 0x40;
uint256 constant ZoneParameters_offer_head_offset = 0x60;
uint256 constant ZoneParameters_consideration_head_offset = 0x80;
uint256 constant ZoneParameters_extraData_head_offset = 0xa0;
uint256 constant ZoneParameters_orderHashes_head_offset = 0xc0;
uint256 constant ZoneParameters_startTime_offset = 0xe0;
uint256 constant ZoneParameters_endTime_offset = 0x100;
uint256 constant ZoneParameters_zoneHash_offset = 0x120;
uint256 constant ZoneParameters_base_tail_offset = 0x140;
uint256 constant ZoneParameters_selectorAndPointer_length = 0x24;
uint256 constant ZoneParameters_basicOrderFixedElements_length = 0x44;
// ConsiderationDecoder Constants
uint256 constant OrderParameters_head_size = 0x0160;
uint256 constant OrderParameters_totalOriginalConsiderationItems_offset = (
0x0140
);
uint256 constant AdvancedOrderPlusOrderParameters_head_size = 0x0200;
uint256 constant Order_signature_offset = 0x20;
uint256 constant Order_head_size = 0x40;
uint256 constant AdvancedOrder_fixed_segment_0 = 0x40;
uint256 constant CriteriaResolver_head_size = 0xa0;
uint256 constant CriteriaResolver_fixed_segment_0 = 0x80;
uint256 constant CriteriaResolver_criteriaProof_offset = 0x80;
uint256 constant FulfillmentComponent_mem_tail_size = 0x40;
uint256 constant FulfillmentComponent_mem_tail_size_shift = 0x6;
uint256 constant Fulfillment_head_size = 0x40;
uint256 constant Fulfillment_considerationComponents_offset = 0x20;
uint256 constant OrderComponents_OrderParameters_common_head_size = 0x0140;// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
enum OrderType {
// 0: no partial fills, anyone can execute
FULL_OPEN,
// 1: partial fills supported, anyone can execute
PARTIAL_OPEN,
// 2: no partial fills, only offerer or zone can execute
FULL_RESTRICTED,
// 3: partial fills supported, only offerer or zone can execute
PARTIAL_RESTRICTED,
// 4: contract order type
CONTRACT
}
enum BasicOrderType {
// 0: no partial fills, anyone can execute
ETH_TO_ERC721_FULL_OPEN,
// 1: partial fills supported, anyone can execute
ETH_TO_ERC721_PARTIAL_OPEN,
// 2: no partial fills, only offerer or zone can execute
ETH_TO_ERC721_FULL_RESTRICTED,
// 3: partial fills supported, only offerer or zone can execute
ETH_TO_ERC721_PARTIAL_RESTRICTED,
// 4: no partial fills, anyone can execute
ETH_TO_ERC1155_FULL_OPEN,
// 5: partial fills supported, anyone can execute
ETH_TO_ERC1155_PARTIAL_OPEN,
// 6: no partial fills, only offerer or zone can execute
ETH_TO_ERC1155_FULL_RESTRICTED,
// 7: partial fills supported, only offerer or zone can execute
ETH_TO_ERC1155_PARTIAL_RESTRICTED,
// 8: no partial fills, anyone can execute
ERC20_TO_ERC721_FULL_OPEN,
// 9: partial fills supported, anyone can execute
ERC20_TO_ERC721_PARTIAL_OPEN,
// 10: no partial fills, only offerer or zone can execute
ERC20_TO_ERC721_FULL_RESTRICTED,
// 11: partial fills supported, only offerer or zone can execute
ERC20_TO_ERC721_PARTIAL_RESTRICTED,
// 12: no partial fills, anyone can execute
ERC20_TO_ERC1155_FULL_OPEN,
// 13: partial fills supported, anyone can execute
ERC20_TO_ERC1155_PARTIAL_OPEN,
// 14: no partial fills, only offerer or zone can execute
ERC20_TO_ERC1155_FULL_RESTRICTED,
// 15: partial fills supported, only offerer or zone can execute
ERC20_TO_ERC1155_PARTIAL_RESTRICTED,
// 16: no partial fills, anyone can execute
ERC721_TO_ERC20_FULL_OPEN,
// 17: partial fills supported, anyone can execute
ERC721_TO_ERC20_PARTIAL_OPEN,
// 18: no partial fills, only offerer or zone can execute
ERC721_TO_ERC20_FULL_RESTRICTED,
// 19: partial fills supported, only offerer or zone can execute
ERC721_TO_ERC20_PARTIAL_RESTRICTED,
// 20: no partial fills, anyone can execute
ERC1155_TO_ERC20_FULL_OPEN,
// 21: partial fills supported, anyone can execute
ERC1155_TO_ERC20_PARTIAL_OPEN,
// 22: no partial fills, only offerer or zone can execute
ERC1155_TO_ERC20_FULL_RESTRICTED,
// 23: partial fills supported, only offerer or zone can execute
ERC1155_TO_ERC20_PARTIAL_RESTRICTED
}
enum BasicOrderRouteType {
// 0: provide Ether (or other native token) to receive offered ERC721 item.
ETH_TO_ERC721,
// 1: provide Ether (or other native token) to receive offered ERC1155 item.
ETH_TO_ERC1155,
// 2: provide ERC20 item to receive offered ERC721 item.
ERC20_TO_ERC721,
// 3: provide ERC20 item to receive offered ERC1155 item.
ERC20_TO_ERC1155,
// 4: provide ERC721 item to receive offered ERC20 item.
ERC721_TO_ERC20,
// 5: provide ERC1155 item to receive offered ERC20 item.
ERC1155_TO_ERC20
}
enum ItemType {
// 0: ETH on mainnet, MATIC on polygon, etc.
NATIVE,
// 1: ERC20 items (ERC777 and ERC20 analogues could also technically work)
ERC20,
// 2: ERC721 items
ERC721,
// 3: ERC1155 items
ERC1155,
// 4: ERC721 items where a number of tokenIds are supported
ERC721_WITH_CRITERIA,
// 5: ERC1155 items where a number of ids are supported
ERC1155_WITH_CRITERIA
}
enum Side {
// 0: Items that can be spent
OFFER,
// 1: Items that must be received
CONSIDERATION
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {
BasicOrderType,
ItemType,
OrderType,
Side
} from "./ConsiderationEnums.sol";
import {
CalldataPointer,
MemoryPointer
} from "../helpers/PointerLibraries.sol";
/**
* @dev An order contains eleven components: an offerer, a zone (or account that
* can cancel the order or restrict who can fulfill the order depending on
* the type), the order type (specifying partial fill support as well as
* restricted order status), the start and end time, a hash that will be
* provided to the zone when validating restricted orders, a salt, a key
* corresponding to a given conduit, a counter, and an arbitrary number of
* offer items that can be spent along with consideration items that must
* be received by their respective recipient.
*/
struct OrderComponents {
address offerer;
address zone;
OfferItem[] offer;
ConsiderationItem[] consideration;
OrderType orderType;
uint256 startTime;
uint256 endTime;
bytes32 zoneHash;
uint256 salt;
bytes32 conduitKey;
uint256 counter;
}
/**
* @dev An offer item has five components: an item type (ETH or other native
* tokens, ERC20, ERC721, and ERC1155, as well as criteria-based ERC721 and
* ERC1155), a token address, a dual-purpose "identifierOrCriteria"
* component that will either represent a tokenId or a merkle root
* depending on the item type, and a start and end amount that support
* increasing or decreasing amounts over the duration of the respective
* order.
*/
struct OfferItem {
ItemType itemType;
address token;
uint256 identifierOrCriteria;
uint256 startAmount;
uint256 endAmount;
}
/**
* @dev A consideration item has the same five components as an offer item and
* an additional sixth component designating the required recipient of the
* item.
*/
struct ConsiderationItem {
ItemType itemType;
address token;
uint256 identifierOrCriteria;
uint256 startAmount;
uint256 endAmount;
address payable recipient;
}
/**
* @dev A spent item is translated from a utilized offer item and has four
* components: an item type (ETH or other native tokens, ERC20, ERC721, and
* ERC1155), a token address, a tokenId, and an amount.
*/
struct SpentItem {
ItemType itemType;
address token;
uint256 identifier;
uint256 amount;
}
/**
* @dev A received item is translated from a utilized consideration item and has
* the same four components as a spent item, as well as an additional fifth
* component designating the required recipient of the item.
*/
struct ReceivedItem {
ItemType itemType;
address token;
uint256 identifier;
uint256 amount;
address payable recipient;
}
/**
* @dev For basic orders involving ETH / native / ERC20 <=> ERC721 / ERC1155
* matching, a group of six functions may be called that only requires a
* subset of the usual order arguments. Note the use of a "basicOrderType"
* enum; this represents both the usual order type as well as the "route"
* of the basic order (a simple derivation function for the basic order
* type is `basicOrderType = orderType + (4 * basicOrderRoute)`.)
*/
struct BasicOrderParameters {
// calldata offset
address considerationToken; // 0x24
uint256 considerationIdentifier; // 0x44
uint256 considerationAmount; // 0x64
address payable offerer; // 0x84
address zone; // 0xa4
address offerToken; // 0xc4
uint256 offerIdentifier; // 0xe4
uint256 offerAmount; // 0x104
BasicOrderType basicOrderType; // 0x124
uint256 startTime; // 0x144
uint256 endTime; // 0x164
bytes32 zoneHash; // 0x184
uint256 salt; // 0x1a4
bytes32 offererConduitKey; // 0x1c4
bytes32 fulfillerConduitKey; // 0x1e4
uint256 totalOriginalAdditionalRecipients; // 0x204
AdditionalRecipient[] additionalRecipients; // 0x224
bytes signature; // 0x244
// Total length, excluding dynamic array data: 0x264 (580)
}
/**
* @dev Basic orders can supply any number of additional recipients, with the
* implied assumption that they are supplied from the offered ETH (or other
* native token) or ERC20 token for the order.
*/
struct AdditionalRecipient {
uint256 amount;
address payable recipient;
}
/**
* @dev The full set of order components, with the exception of the counter,
* must be supplied when fulfilling more sophisticated orders or groups of
* orders. The total number of original consideration items must also be
* supplied, as the caller may specify additional consideration items.
*/
struct OrderParameters {
address offerer; // 0x00
address zone; // 0x20
OfferItem[] offer; // 0x40
ConsiderationItem[] consideration; // 0x60
OrderType orderType; // 0x80
uint256 startTime; // 0xa0
uint256 endTime; // 0xc0
bytes32 zoneHash; // 0xe0
uint256 salt; // 0x100
bytes32 conduitKey; // 0x120
uint256 totalOriginalConsiderationItems; // 0x140
// offer.length // 0x160
}
/**
* @dev Orders require a signature in addition to the other order parameters.
*/
struct Order {
OrderParameters parameters;
bytes signature;
}
/**
* @dev Advanced orders include a numerator (i.e. a fraction to attempt to fill)
* and a denominator (the total size of the order) in addition to the
* signature and other order parameters. It also supports an optional field
* for supplying extra data; this data will be provided to the zone if the
* order type is restricted and the zone is not the caller, or will be
* provided to the offerer as context for contract order types.
*/
struct AdvancedOrder {
OrderParameters parameters;
uint120 numerator;
uint120 denominator;
bytes signature;
bytes extraData;
}
/**
* @dev Orders can be validated (either explicitly via `validate`, or as a
* consequence of a full or partial fill), specifically cancelled (they can
* also be cancelled in bulk via incrementing a per-zone counter), and
* partially or fully filled (with the fraction filled represented by a
* numerator and denominator).
*/
struct OrderStatus {
bool isValidated;
bool isCancelled;
uint120 numerator;
uint120 denominator;
}
/**
* @dev A criteria resolver specifies an order, side (offer vs. consideration),
* and item index. It then provides a chosen identifier (i.e. tokenId)
* alongside a merkle proof demonstrating the identifier meets the required
* criteria.
*/
struct CriteriaResolver {
uint256 orderIndex;
Side side;
uint256 index;
uint256 identifier;
bytes32[] criteriaProof;
}
/**
* @dev A fulfillment is applied to a group of orders. It decrements a series of
* offer and consideration items, then generates a single execution
* element. A given fulfillment can be applied to as many offer and
* consideration items as desired, but must contain at least one offer and
* at least one consideration that match. The fulfillment must also remain
* consistent on all key parameters across all offer items (same offerer,
* token, type, tokenId, and conduit preference) as well as across all
* consideration items (token, type, tokenId, and recipient).
*/
struct Fulfillment {
FulfillmentComponent[] offerComponents;
FulfillmentComponent[] considerationComponents;
}
/**
* @dev Each fulfillment component contains one index referencing a specific
* order and another referencing a specific offer or consideration item.
*/
struct FulfillmentComponent {
uint256 orderIndex;
uint256 itemIndex;
}
/**
* @dev An execution is triggered once all consideration items have been zeroed
* out. It sends the item in question from the offerer to the item's
* recipient, optionally sourcing approvals from either this contract
* directly or from the offerer's chosen conduit if one is specified. An
* execution is not provided as an argument, but rather is derived via
* orders, criteria resolvers, and fulfillments (where the total number of
* executions will be less than or equal to the total number of indicated
* fulfillments) and returned as part of `matchOrders`.
*/
struct Execution {
ReceivedItem item;
address offerer;
bytes32 conduitKey;
}
/**
* @dev Restricted orders are validated post-execution by calling validateOrder
* on the zone. This struct provides context about the order fulfillment
* and any supplied extraData, as well as all order hashes fulfilled in a
* call to a match or fulfillAvailable method.
*/
struct ZoneParameters {
bytes32 orderHash;
address fulfiller;
address offerer;
SpentItem[] offer;
ReceivedItem[] consideration;
bytes extraData;
bytes32[] orderHashes;
uint256 startTime;
uint256 endTime;
bytes32 zoneHash;
}
/**
* @dev Zones and contract offerers can communicate which schemas they implement
* along with any associated metadata related to each schema.
*/
struct Schema {
uint256 id;
bytes metadata;
}
using StructPointers for OrderComponents global;
using StructPointers for OfferItem global;
using StructPointers for ConsiderationItem global;
using StructPointers for SpentItem global;
using StructPointers for ReceivedItem global;
using StructPointers for BasicOrderParameters global;
using StructPointers for AdditionalRecipient global;
using StructPointers for OrderParameters global;
using StructPointers for Order global;
using StructPointers for AdvancedOrder global;
using StructPointers for OrderStatus global;
using StructPointers for CriteriaResolver global;
using StructPointers for Fulfillment global;
using StructPointers for FulfillmentComponent global;
using StructPointers for Execution global;
using StructPointers for ZoneParameters global;
/**
* @dev This library provides a set of functions for converting structs to
* pointers.
*/
library StructPointers {
/**
* @dev Get a MemoryPointer from OrderComponents.
*
* @param obj The OrderComponents object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
OrderComponents memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from OrderComponents.
*
* @param obj The OrderComponents object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
OrderComponents calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from OfferItem.
*
* @param obj The OfferItem object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
OfferItem memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from OfferItem.
*
* @param obj The OfferItem object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
OfferItem calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from ConsiderationItem.
*
* @param obj The ConsiderationItem object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
ConsiderationItem memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from ConsiderationItem.
*
* @param obj The ConsiderationItem object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
ConsiderationItem calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from SpentItem.
*
* @param obj The SpentItem object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
SpentItem memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from SpentItem.
*
* @param obj The SpentItem object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
SpentItem calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from ReceivedItem.
*
* @param obj The ReceivedItem object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
ReceivedItem memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from ReceivedItem.
*
* @param obj The ReceivedItem object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
ReceivedItem calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from BasicOrderParameters.
*
* @param obj The BasicOrderParameters object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
BasicOrderParameters memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from BasicOrderParameters.
*
* @param obj The BasicOrderParameters object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
BasicOrderParameters calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from AdditionalRecipient.
*
* @param obj The AdditionalRecipient object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
AdditionalRecipient memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from AdditionalRecipient.
*
* @param obj The AdditionalRecipient object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
AdditionalRecipient calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from OrderParameters.
*
* @param obj The OrderParameters object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
OrderParameters memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from OrderParameters.
*
* @param obj The OrderParameters object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
OrderParameters calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from Order.
*
* @param obj The Order object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
Order memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from Order.
*
* @param obj The Order object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
Order calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from AdvancedOrder.
*
* @param obj The AdvancedOrder object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
AdvancedOrder memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from AdvancedOrder.
*
* @param obj The AdvancedOrder object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
AdvancedOrder calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from OrderStatus.
*
* @param obj The OrderStatus object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
OrderStatus memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from OrderStatus.
*
* @param obj The OrderStatus object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
OrderStatus calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from CriteriaResolver.
*
* @param obj The CriteriaResolver object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
CriteriaResolver memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from CriteriaResolver.
*
* @param obj The CriteriaResolver object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
CriteriaResolver calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from Fulfillment.
*
* @param obj The Fulfillment object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
Fulfillment memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from Fulfillment.
*
* @param obj The Fulfillment object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
Fulfillment calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from FulfillmentComponent.
*
* @param obj The FulfillmentComponent object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
FulfillmentComponent memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from FulfillmentComponent.
*
* @param obj The FulfillmentComponent object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
FulfillmentComponent calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from Execution.
*
* @param obj The Execution object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
Execution memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from Execution.
*
* @param obj The Execution object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
Execution calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a MemoryPointer from ZoneParameters.
*
* @param obj The ZoneParameters object.
*
* @return ptr The MemoryPointer.
*/
function toMemoryPointer(
ZoneParameters memory obj
) internal pure returns (MemoryPointer ptr) {
assembly {
ptr := obj
}
}
/**
* @dev Get a CalldataPointer from ZoneParameters.
*
* @param obj The ZoneParameters object.
*
* @return ptr The CalldataPointer.
*/
function toCalldataPointer(
ZoneParameters calldata obj
) internal pure returns (CalldataPointer ptr) {
assembly {
ptr := obj
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Gas optimized ECDSA wrapper.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ECDSA.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ECDSA.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol)
///
/// @dev Note:
/// - The recovery functions use the ecrecover precompile (0x1).
/// - As of Solady version 0.0.68, the `recover` variants will revert upon recovery failure.
/// This is for more safety by default.
/// Use the `tryRecover` variants if you need to get the zero address back
/// upon recovery failure instead.
/// - As of Solady version 0.0.134, all `bytes signature` variants accept both
/// regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures.
/// See: https://eips.ethereum.org/EIPS/eip-2098
/// This is for calldata efficiency on smart accounts prevalent on L2s.
///
/// WARNING! Do NOT use signatures as unique identifiers:
/// - Use a nonce in the digest to prevent replay attacks on the same contract.
/// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts.
/// EIP-712 also enables readable signing of typed data for better user safety.
/// This implementation does NOT check if a signature is non-malleable.
library ECDSA {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The signature is invalid.
error InvalidSignature();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* RECOVERY OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
function recover(bytes32 hash, bytes memory signature) internal view returns (address result) {
/// @solidity memory-safe-assembly
assembly {
result := 1
let m := mload(0x40) // Cache the free memory pointer.
for {} 1 {} {
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
if eq(mload(signature), 64) {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
break
}
if eq(mload(signature), 65) {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
break
}
result := 0
break
}
result :=
mload(
staticcall(
gas(), // Amount of gas left for the transaction.
result, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x01, // Start of output.
0x20 // Size of output.
)
)
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
if iszero(returndatasize()) {
mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
revert(0x1c, 0x04)
}
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
function recoverCalldata(bytes32 hash, bytes calldata signature)
internal
view
returns (address result)
{
/// @solidity memory-safe-assembly
assembly {
result := 1
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x00, hash)
for {} 1 {} {
if eq(signature.length, 64) {
let vs := calldataload(add(signature.offset, 0x20))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, calldataload(signature.offset)) // `r`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
break
}
if eq(signature.length, 65) {
mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.
calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`.
break
}
result := 0
break
}
result :=
mload(
staticcall(
gas(), // Amount of gas left for the transaction.
result, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x01, // Start of output.
0x20 // Size of output.
)
)
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
if iszero(returndatasize()) {
mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
revert(0x1c, 0x04)
}
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Recovers the signer's address from a message digest `hash`,
/// and the EIP-2098 short form signature defined by `r` and `vs`.
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal view returns (address result) {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x00, hash)
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, r)
mstore(0x60, shr(1, shl(1, vs))) // `s`.
result :=
mload(
staticcall(
gas(), // Amount of gas left for the transaction.
1, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x01, // Start of output.
0x20 // Size of output.
)
)
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
if iszero(returndatasize()) {
mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
revert(0x1c, 0x04)
}
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Recovers the signer's address from a message digest `hash`,
/// and the signature defined by `v`, `r`, `s`.
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)
internal
view
returns (address result)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x00, hash)
mstore(0x20, and(v, 0xff))
mstore(0x40, r)
mstore(0x60, s)
result :=
mload(
staticcall(
gas(), // Amount of gas left for the transaction.
1, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x01, // Start of output.
0x20 // Size of output.
)
)
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
if iszero(returndatasize()) {
mstore(0x00, 0x8baa579f) // `InvalidSignature()`.
revert(0x1c, 0x04)
}
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* TRY-RECOVER OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// WARNING!
// These functions will NOT revert upon recovery failure.
// Instead, they will return the zero address upon recovery failure.
// It is critical that the returned address is NEVER compared against
// a zero address (e.g. an uninitialized address variable).
/// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
function tryRecover(bytes32 hash, bytes memory signature)
internal
view
returns (address result)
{
/// @solidity memory-safe-assembly
assembly {
result := 1
let m := mload(0x40) // Cache the free memory pointer.
for {} 1 {} {
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
if eq(mload(signature), 64) {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
break
}
if eq(mload(signature), 65) {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
break
}
result := 0
break
}
pop(
staticcall(
gas(), // Amount of gas left for the transaction.
result, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x40, // Start of output.
0x20 // Size of output.
)
)
mstore(0x60, 0) // Restore the zero slot.
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
result := mload(xor(0x60, returndatasize()))
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Recovers the signer's address from a message digest `hash`, and the `signature`.
function tryRecoverCalldata(bytes32 hash, bytes calldata signature)
internal
view
returns (address result)
{
/// @solidity memory-safe-assembly
assembly {
result := 1
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x00, hash)
for {} 1 {} {
if eq(signature.length, 64) {
let vs := calldataload(add(signature.offset, 0x20))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, calldataload(signature.offset)) // `r`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
break
}
if eq(signature.length, 65) {
mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.
calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`.
break
}
result := 0
break
}
pop(
staticcall(
gas(), // Amount of gas left for the transaction.
result, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x40, // Start of output.
0x20 // Size of output.
)
)
mstore(0x60, 0) // Restore the zero slot.
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
result := mload(xor(0x60, returndatasize()))
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Recovers the signer's address from a message digest `hash`,
/// and the EIP-2098 short form signature defined by `r` and `vs`.
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs)
internal
view
returns (address result)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x00, hash)
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, r)
mstore(0x60, shr(1, shl(1, vs))) // `s`.
pop(
staticcall(
gas(), // Amount of gas left for the transaction.
1, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x40, // Start of output.
0x20 // Size of output.
)
)
mstore(0x60, 0) // Restore the zero slot.
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
result := mload(xor(0x60, returndatasize()))
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Recovers the signer's address from a message digest `hash`,
/// and the signature defined by `v`, `r`, `s`.
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)
internal
view
returns (address result)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x00, hash)
mstore(0x20, and(v, 0xff))
mstore(0x40, r)
mstore(0x60, s)
pop(
staticcall(
gas(), // Amount of gas left for the transaction.
1, // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x40, // Start of output.
0x20 // Size of output.
)
)
mstore(0x60, 0) // Restore the zero slot.
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
result := mload(xor(0x60, returndatasize()))
mstore(0x40, m) // Restore the free memory pointer.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* HASHING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns an Ethereum Signed Message, created from a `hash`.
/// This produces a hash corresponding to the one signed with the
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
/// JSON-RPC method as part of EIP-191.
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x20, hash) // Store into scratch space for keccak256.
mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32") // 28 bytes.
result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`.
}
}
/// @dev Returns an Ethereum Signed Message, created from `s`.
/// This produces a hash corresponding to the one signed with the
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
/// JSON-RPC method as part of EIP-191.
/// Note: Supports lengths of `s` up to 999999 bytes.
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
let sLength := mload(s)
let o := 0x20
mstore(o, "\x19Ethereum Signed Message:\n") // 26 bytes, zero-right-padded.
mstore(0x00, 0x00)
// Convert the `s.length` to ASCII decimal representation: `base10(s.length)`.
for { let temp := sLength } 1 {} {
o := sub(o, 1)
mstore8(o, add(48, mod(temp, 10)))
temp := div(temp, 10)
if iszero(temp) { break }
}
let n := sub(0x3a, o) // Header length: `26 + 32 - o`.
// Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes.
returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20))
mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header.
result := keccak256(add(s, sub(0x20, n)), add(n, sLength))
mstore(s, sLength) // Restore the length.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EMPTY CALLDATA HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns an empty calldata bytes.
function emptySignature() internal pure returns (bytes calldata signature) {
/// @solidity memory-safe-assembly
assembly {
signature.length := 0
}
}
}{
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"remappings": [
":@chainlink/=lib/chainlink/",
":@ds-test/=lib/ds-test/src/",
":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":@rari-capital/solmate/=lib/seaport/lib/solmate/",
":@seaport/=lib/seaport/contracts/",
":@solady/=lib/solady/",
":@std/=lib/forge-std/src/",
":@thirdweb-dev/dynamic-contracts/=lib/dynamic-contracts/",
":ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
":ERC721A/=lib/ERC721A/contracts/",
":chainlink/=lib/chainlink/contracts/",
":contracts/=contracts/",
":ds-test/=lib/ds-test/src/",
":dynamic-contracts/=lib/dynamic-contracts/src/",
":erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
":erc721a-upgradeable/=lib/ERC721A-Upgradeable/",
":erc721a/=lib/ERC721A/",
":forge-std/=lib/forge-std/src/",
":lib/sstore2/=lib/dynamic-contracts/lib/sstore2/",
":murky/=lib/murky/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/",
":seaport-core/=lib/seaport/lib/seaport-core/",
":seaport-sol/=lib/seaport-sol/src/",
":seaport-types/=lib/seaport/lib/seaport-types/",
":seaport/=lib/seaport/",
":solady/=lib/solady/src/",
":solarray/=lib/seaport/lib/solarray/src/",
":solmate/=lib/seaport/lib/solmate/src/",
":sstore2/=lib/dynamic-contracts/lib/sstore2/contracts/"
],
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"MAGICVALUE","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_message","type":"bytes32"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"magicValue","type":"bytes4"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6101406040523480156200001257600080fd5b506200001d62000037565b610120526101005260e05260c05260a052608052620001c2565b600080808080806200006360408051808201909152600781526614d9585c1bdc9d60ca1b602082015290565b80519060200120955060405180604001604052806003815260200162312e3560e81b81525080519060200120945060006040518060a00160405280606a8152602001620014eb606a9139905060006040518060c001604052806084815260200162001341608491399050600060405180610100016040528060d481526020016200141760d491399050604051806080016040528060528152602001620013c560529139805190602001209650828051906020012095508180519060200120945060008183856040516020016200013c9392919062000195565b60405160208183030381529060405290508080519060200120945050505050909192939495565b6000815160005b818110156200018657602081850181015186830152016200016a565b50600093019283525090919050565b6000620001b9620001b2620001ab848862000163565b8662000163565b8462000163565b95945050505050565b60805160a05160c05160e05161010051610120516111316200021060003960006103ac0152600061033a015260006102d30152600060b3015260006101010152600060d901526111316000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80631626ba7e1461003b578063ff2188231461006b575b600080fd5b61004e610049366004610cb6565b610079565b6040516001600160e01b0319909116815260200160405180910390f35b61004e630b135d3f60e11b81565b6000806060604184511115610285576000806000868060200190518101906100a19190611002565b925092509250600061015d33604080517f000000000000000000000000000000000000000000000000000000000000000060208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201526001600160a01b03821660a082015260009060c001604051602081830303815290604052805190602001209050919050565b9050600061016b84846102bb565b9050896101788383610402565b146101eb5760405162461bcd60e51b815260206004820152603860248201527f536561706f72743a206f72646572206861736820646f6573206e6f74206d617460448201527731b4103a343290383937bb34b232b21036b2b9b9b0b3b29760411b60648201526084015b60405180910390fd5b6101fe826101f98784610422565b610402565b6040805160418082526080820190925291985060208201818036833701905050955060005b604181101561027a5785818151811061023e5761023e6110c4565b602001015160f81c60f81b87828151811061025b5761025b6110c4565b60200101906001600160f81b031916908160001a905350600101610223565b50505050505061028b565b50839050825b600061029783836104be565b90506102a28161054f565b156102b257630b135d3f60e11b93505b50505092915050565b610140820151604080519084015180516000939284927f000000000000000000000000000000000000000000000000000000000000000092602090910190845b81811015610328578251601f1901805186825260c0822086529052602093840193909201916001016102fb565b508060051b60405120945050505060007f00000000000000000000000000000000000000000000000000000000000000009150604051602060608901510160005b86811015610396578151601f1901805186825260e082208552905260209283019290910190600101610369565b505060408051600587901b9020601f198a0180517f00000000000000000000000000000000000000000000000000000000000000008252928b01805197815260608c018051938152610140909c019a8b5261018082209390915295909552939097525050925250919050565b61190160f01b600090815260029290925260229081526042822091905290565b600080600084516001811660410380820360051c9250808752806020018701915050805160e81c6003820191506001811660051b868152825160208218525060015b8381101561049157604060002082821c60051b602090811691825293840180519190941852600101610464565b5050506040600020915060006104a68261070b565b60009081526020939093525050604090209392505050565b60405160019083600052602083015160405260408351036104fa57604083015160ff81901c601b016020526001600160ff1b0316606052610520565b604183510361051b57606083015160001a6020526040830151606052610520565b600091505b6020600160806000855afa5191503d61054157638baa579f6000526004601cfd5b600060605260405292915050565b6000610559610b1e565b6001600160a01b0383166000908152600491909101602052604090205460ff161561058657506001919050565b336000610591610b1e565b6001600160a01b03851660009081526006919091016020526040902090506105b98183610b7c565b806105e957506105c881610ba1565b60011480156105e9575060006105de8282610bab565b6001600160a01b0316145b6106415760405162461bcd60e51b8152602060048201526024808201527f4163636f756e743a2063616c6c6572206e6f7420617070726f7665642074617260448201526333b2ba1760e11b60648201526084016101e2565b600061064b610b1e565b6001600160a01b038616600090815260059190910160209081526040918290208251606081018452815481526001909101546001600160801b03808216938301849052600160801b909104169281019290925290915042108015906106bc575080604001516001600160801b031642105b80156106f3575060006106f16106d0610b1e565b6001600160a01b038816600090815260069190910160205260409020610ba1565b115b1561070357506001949350505050565b505050919050565b6000610b15565b6000600982101561086e5760058210156107cb57600382101561077e577f832c58a5b611aadcfa6a082ac9d04bace53d8278387f10040347b7e98eb5b30260018314027fbf8e29b89f29ed9b529c154a63038ffca562f8d7cd1e2545dda53a1b582dde30185b92915050565b7ff3e8417a785f980bdaf134fa0274a6bf891eeb8195cd94b09d2aa651046e28bc60038314027fa02eb7ff164c884e5e2c336dc85f81c6a93329d8e9adf214b32729b894de2af118610778565b6007821015610821577f25d02425402d882d211a7ab774c0ed6eca048c4d03d9af40132475744753b2a360058314027f1c19f71958cdd8f081b4c31f7caf5c010b29d12950be2fa1c95070dc47e30b5518610778565b7fb58d772fb09b426b9dece637f61ca9065f2b994f1464b51e9207f55f7c8f594860078314027f7ff98d9d4e55d876c5cfac10b43c04039522f3ddfb0ea9bfe70c68cfb5c7cc1418610778565b60118210156109c657600d82101561092357600b8210156108d6577f6f0ec38c21f6f583ab7f3c5413c773ffd5344c34fde1d390958e438bf667448f60098314027fd1d97d1ef5eaa37a4ee5fbf234e6f6d64eb511eb562221cd7edfbdde0848da0518610778565b7f32f4e7485d6485f9f6c255929b9905c62ba919758bbe231f231eaeecf33d810c600b8314027fbb98d87cc12922b83759626c5f07d72266da9702d19ffad6a514c73a89002f5f18610778565b600f821015610979577f8df51df98847160517f5b1186b4bc3f418d98b8a7f17f1292f392d79d600d79e600d8314027f6b5b04cbae4fcb1a9d78e7b2dfc51a36933d023cf6e347e03d517b472a85259018610778565b7fcc4886e37eedd9aacd6c1c2c9247197a621a71282e87a7cbc673f3736d9aa141600f8314027f1da3eed3ecef6ebaa6e5023c057ec2c75150693fd0dac5c90f4a142f9879fde818610778565b6015821015610a72576013821015610a25577f2d7a3ed6dab270fdb8e054b2ad525f0ce2a8b89cc76c17f0965434740f673a5560118314027fc3939feff011e53ab8c35ca3370aad54c5df1fc2938cd62543174fa6e7d8587718610778565b7f54b3212a178782f104e0d514b41a9a5c4ca9c980bf6597c3cecbf280917e202a60138314027f5a4f867d3d458dabecad65f6201ceeaba0096df2d0c491cc32e6ea4e6435001718610778565b6017821015610ac8577fbb40bf8cea3a5a716e2b6eb08bbdac8ec159f82f380783db3c56904f15a43d0460158314027f3bd8cff538aba49a9c374c806d277181e9651624b3e31111bc0624574f8bca1d18610778565b7f403be09941a31d05cfc2f896505811353d45d38743288b016630cce39435476a60178314027f1d51df90cba8de7637ca3e8fe1e3511d1dc2f23487d05dbdecb781860c21ac1c18610778565b61077882610712565b600080610b4c60017ff2776159535489b2c8217c06dac58993e45cb245272f968642d4d3ef6aa761506110da565b604051602001610b5e91815260200190565b60408051601f19818403018152919052805160209091012092915050565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6000610778825490565b6000610b9a83836000826000018281548110610bc957610bc96110c4565b9060005260206000200154905092915050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b0381118282101715610c1457610c14610bdc565b60405290565b60405160c081016001600160401b0381118282101715610c1457610c14610bdc565b60405161016081016001600160401b0381118282101715610c1457610c14610bdc565b604051601f8201601f191681016001600160401b0381118282101715610c8757610c87610bdc565b604052919050565b60006001600160401b03821115610ca857610ca8610bdc565b50601f01601f191660200190565b60008060408385031215610cc957600080fd5b8235915060208301356001600160401b03811115610ce657600080fd5b8301601f81018513610cf757600080fd5b8035610d0a610d0582610c8f565b610c5f565b818152866020838501011115610d1f57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6001600160a01b0381168114610d5457600080fd5b50565b8051610d6281610d3f565b919050565b60006001600160401b03821115610d8057610d80610bdc565b5060051b60200190565b805160068110610d6257600080fd5b600082601f830112610daa57600080fd5b81516020610dba610d0583610d67565b82815260a09283028501820192828201919087851115610dd957600080fd5b8387015b85811015610e445781818a031215610df55760008081fd5b610dfd610bf2565b610e0682610d8a565b815285820151610e1581610d3f565b818701526040828101519082015260608083015190820152608080830151908201528452928401928101610ddd565b5090979650505050505050565b600082601f830112610e6257600080fd5b81516020610e72610d0583610d67565b82815260c09283028501820192828201919087851115610e9157600080fd5b8387015b85811015610e445781818a031215610ead5760008081fd5b610eb5610c1a565b610ebe82610d8a565b815285820151610ecd81610d3f565b8187015260408281015190820152606080830151908201526080808301519082015260a080830151610efe81610d3f565b908201528452928401928101610e95565b805160058110610d6257600080fd5b60006101608284031215610f3157600080fd5b610f39610c3c565b9050610f4482610d57565b8152610f5260208301610d57565b602082015260408201516001600160401b0380821115610f7157600080fd5b610f7d85838601610d99565b60408401526060840151915080821115610f9657600080fd5b50610fa384828501610e51565b606083015250610fb560808301610f0f565b608082015260a082015160a082015260c082015160c082015260e082015160e082015261010080830151818301525061012080830151818301525061014080830151818301525092915050565b60008060006060848603121561101757600080fd5b83516001600160401b038082111561102e57600080fd5b818601915086601f83011261104257600080fd5b8151611050610d0582610c8f565b8181526020898184870101111561106657600080fd5b60005b83811015611084578581018201518382018301528101611069565b506000818484010152819750808901519450505050808211156110a657600080fd5b506110b386828701610f1e565b925050604084015190509250925092565b634e487b7160e01b600052603260045260246000fd5b8181038181111561077857634e487b7160e01b600052601160045260246000fdfea2646970667358221220bf1f5fe030bdfe7681a7a41f8cac7da6561866a7ab63e24531fa21b7eeea425664736f6c63430008170033436f6e73696465726174696f6e4974656d2875696e7438206974656d547970652c6164647265737320746f6b656e2c75696e74323536206964656e7469666965724f7243726974657269612c75696e74323536207374617274416d6f756e742c75696e7432353620656e64416d6f756e742c6164647265737320726563697069656e7429454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e7472616374294f72646572436f6d706f6e656e74732861646472657373206f6666657265722c61646472657373207a6f6e652c4f666665724974656d5b5d206f666665722c436f6e73696465726174696f6e4974656d5b5d20636f6e73696465726174696f6e2c75696e7438206f72646572547970652c75696e7432353620737461727454696d652c75696e7432353620656e6454696d652c62797465733332207a6f6e65486173682c75696e743235362073616c742c6279746573333220636f6e647569744b65792c75696e7432353620636f756e746572294f666665724974656d2875696e7438206974656d547970652c6164647265737320746f6b656e2c75696e74323536206964656e7469666965724f7243726974657269612c75696e74323536207374617274416d6f756e742c75696e7432353620656e64416d6f756e7429
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80631626ba7e1461003b578063ff2188231461006b575b600080fd5b61004e610049366004610cb6565b610079565b6040516001600160e01b0319909116815260200160405180910390f35b61004e630b135d3f60e11b81565b6000806060604184511115610285576000806000868060200190518101906100a19190611002565b925092509250600061015d33604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f32b5c112df393a49218d7552f96b2eeb829dfb4272f4f24eef510a586b85feef918101919091527f65f792c4319563f3a8f1ce154ef783f165de90334a87a1918514e159542a735a60608201524660808201526001600160a01b03821660a082015260009060c001604051602081830303815290604052805190602001209050919050565b9050600061016b84846102bb565b9050896101788383610402565b146101eb5760405162461bcd60e51b815260206004820152603860248201527f536561706f72743a206f72646572206861736820646f6573206e6f74206d617460448201527731b4103a343290383937bb34b232b21036b2b9b9b0b3b29760411b60648201526084015b60405180910390fd5b6101fe826101f98784610422565b610402565b6040805160418082526080820190925291985060208201818036833701905050955060005b604181101561027a5785818151811061023e5761023e6110c4565b602001015160f81c60f81b87828151811061025b5761025b6110c4565b60200101906001600160f81b031916908160001a905350600101610223565b50505050505061028b565b50839050825b600061029783836104be565b90506102a28161054f565b156102b257630b135d3f60e11b93505b50505092915050565b610140820151604080519084015180516000939284927fa66999307ad1bb4fde44d13a5d710bd7718e0c87c1eef68a571629fbf5b93d0292602090910190845b81811015610328578251601f1901805186825260c0822086529052602093840193909201916001016102fb565b508060051b60405120945050505060007f42d81c6929ffdc4eb27a0808e40e82516ad42296c166065de7f812492304ff6e9150604051602060608901510160005b86811015610396578151601f1901805186825260e082208552905260209283019290910190600101610369565b505060408051600587901b9020601f198a0180517ffa445660b7e21515a59617fcd68910b487aa5808b8abda3d78bc85df364b2c2f8252928b01805197815260608c018051938152610140909c019a8b5261018082209390915295909552939097525050925250919050565b61190160f01b600090815260029290925260229081526042822091905290565b600080600084516001811660410380820360051c9250808752806020018701915050805160e81c6003820191506001811660051b868152825160208218525060015b8381101561049157604060002082821c60051b602090811691825293840180519190941852600101610464565b5050506040600020915060006104a68261070b565b60009081526020939093525050604090209392505050565b60405160019083600052602083015160405260408351036104fa57604083015160ff81901c601b016020526001600160ff1b0316606052610520565b604183510361051b57606083015160001a6020526040830151606052610520565b600091505b6020600160806000855afa5191503d61054157638baa579f6000526004601cfd5b600060605260405292915050565b6000610559610b1e565b6001600160a01b0383166000908152600491909101602052604090205460ff161561058657506001919050565b336000610591610b1e565b6001600160a01b03851660009081526006919091016020526040902090506105b98183610b7c565b806105e957506105c881610ba1565b60011480156105e9575060006105de8282610bab565b6001600160a01b0316145b6106415760405162461bcd60e51b8152602060048201526024808201527f4163636f756e743a2063616c6c6572206e6f7420617070726f7665642074617260448201526333b2ba1760e11b60648201526084016101e2565b600061064b610b1e565b6001600160a01b038616600090815260059190910160209081526040918290208251606081018452815481526001909101546001600160801b03808216938301849052600160801b909104169281019290925290915042108015906106bc575080604001516001600160801b031642105b80156106f3575060006106f16106d0610b1e565b6001600160a01b038816600090815260069190910160205260409020610ba1565b115b1561070357506001949350505050565b505050919050565b6000610b15565b6000600982101561086e5760058210156107cb57600382101561077e577f832c58a5b611aadcfa6a082ac9d04bace53d8278387f10040347b7e98eb5b30260018314027fbf8e29b89f29ed9b529c154a63038ffca562f8d7cd1e2545dda53a1b582dde30185b92915050565b7ff3e8417a785f980bdaf134fa0274a6bf891eeb8195cd94b09d2aa651046e28bc60038314027fa02eb7ff164c884e5e2c336dc85f81c6a93329d8e9adf214b32729b894de2af118610778565b6007821015610821577f25d02425402d882d211a7ab774c0ed6eca048c4d03d9af40132475744753b2a360058314027f1c19f71958cdd8f081b4c31f7caf5c010b29d12950be2fa1c95070dc47e30b5518610778565b7fb58d772fb09b426b9dece637f61ca9065f2b994f1464b51e9207f55f7c8f594860078314027f7ff98d9d4e55d876c5cfac10b43c04039522f3ddfb0ea9bfe70c68cfb5c7cc1418610778565b60118210156109c657600d82101561092357600b8210156108d6577f6f0ec38c21f6f583ab7f3c5413c773ffd5344c34fde1d390958e438bf667448f60098314027fd1d97d1ef5eaa37a4ee5fbf234e6f6d64eb511eb562221cd7edfbdde0848da0518610778565b7f32f4e7485d6485f9f6c255929b9905c62ba919758bbe231f231eaeecf33d810c600b8314027fbb98d87cc12922b83759626c5f07d72266da9702d19ffad6a514c73a89002f5f18610778565b600f821015610979577f8df51df98847160517f5b1186b4bc3f418d98b8a7f17f1292f392d79d600d79e600d8314027f6b5b04cbae4fcb1a9d78e7b2dfc51a36933d023cf6e347e03d517b472a85259018610778565b7fcc4886e37eedd9aacd6c1c2c9247197a621a71282e87a7cbc673f3736d9aa141600f8314027f1da3eed3ecef6ebaa6e5023c057ec2c75150693fd0dac5c90f4a142f9879fde818610778565b6015821015610a72576013821015610a25577f2d7a3ed6dab270fdb8e054b2ad525f0ce2a8b89cc76c17f0965434740f673a5560118314027fc3939feff011e53ab8c35ca3370aad54c5df1fc2938cd62543174fa6e7d8587718610778565b7f54b3212a178782f104e0d514b41a9a5c4ca9c980bf6597c3cecbf280917e202a60138314027f5a4f867d3d458dabecad65f6201ceeaba0096df2d0c491cc32e6ea4e6435001718610778565b6017821015610ac8577fbb40bf8cea3a5a716e2b6eb08bbdac8ec159f82f380783db3c56904f15a43d0460158314027f3bd8cff538aba49a9c374c806d277181e9651624b3e31111bc0624574f8bca1d18610778565b7f403be09941a31d05cfc2f896505811353d45d38743288b016630cce39435476a60178314027f1d51df90cba8de7637ca3e8fe1e3511d1dc2f23487d05dbdecb781860c21ac1c18610778565b61077882610712565b600080610b4c60017ff2776159535489b2c8217c06dac58993e45cb245272f968642d4d3ef6aa761506110da565b604051602001610b5e91815260200190565b60408051601f19818403018152919052805160209091012092915050565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6000610778825490565b6000610b9a83836000826000018281548110610bc957610bc96110c4565b9060005260206000200154905092915050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b0381118282101715610c1457610c14610bdc565b60405290565b60405160c081016001600160401b0381118282101715610c1457610c14610bdc565b60405161016081016001600160401b0381118282101715610c1457610c14610bdc565b604051601f8201601f191681016001600160401b0381118282101715610c8757610c87610bdc565b604052919050565b60006001600160401b03821115610ca857610ca8610bdc565b50601f01601f191660200190565b60008060408385031215610cc957600080fd5b8235915060208301356001600160401b03811115610ce657600080fd5b8301601f81018513610cf757600080fd5b8035610d0a610d0582610c8f565b610c5f565b818152866020838501011115610d1f57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6001600160a01b0381168114610d5457600080fd5b50565b8051610d6281610d3f565b919050565b60006001600160401b03821115610d8057610d80610bdc565b5060051b60200190565b805160068110610d6257600080fd5b600082601f830112610daa57600080fd5b81516020610dba610d0583610d67565b82815260a09283028501820192828201919087851115610dd957600080fd5b8387015b85811015610e445781818a031215610df55760008081fd5b610dfd610bf2565b610e0682610d8a565b815285820151610e1581610d3f565b818701526040828101519082015260608083015190820152608080830151908201528452928401928101610ddd565b5090979650505050505050565b600082601f830112610e6257600080fd5b81516020610e72610d0583610d67565b82815260c09283028501820192828201919087851115610e9157600080fd5b8387015b85811015610e445781818a031215610ead5760008081fd5b610eb5610c1a565b610ebe82610d8a565b815285820151610ecd81610d3f565b8187015260408281015190820152606080830151908201526080808301519082015260a080830151610efe81610d3f565b908201528452928401928101610e95565b805160058110610d6257600080fd5b60006101608284031215610f3157600080fd5b610f39610c3c565b9050610f4482610d57565b8152610f5260208301610d57565b602082015260408201516001600160401b0380821115610f7157600080fd5b610f7d85838601610d99565b60408401526060840151915080821115610f9657600080fd5b50610fa384828501610e51565b606083015250610fb560808301610f0f565b608082015260a082015160a082015260c082015160c082015260e082015160e082015261010080830151818301525061012080830151818301525061014080830151818301525092915050565b60008060006060848603121561101757600080fd5b83516001600160401b038082111561102e57600080fd5b818601915086601f83011261104257600080fd5b8151611050610d0582610c8f565b8181526020898184870101111561106657600080fd5b60005b83811015611084578581018201518382018301528101611069565b506000818484010152819750808901519450505050808211156110a657600080fd5b506110b386828701610f1e565b925050604084015190509250925092565b634e487b7160e01b600052603260045260246000fd5b8181038181111561077857634e487b7160e01b600052601160045260246000fdfea2646970667358221220bf1f5fe030bdfe7681a7a41f8cac7da6561866a7ab63e24531fa21b7eeea425664736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.