Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MetaIntentTransmitter

Git Source

Inherits: Transmitter, ReentrancyGuard, OwnableRoles, Pausable, EIP712

Title: MetaIntentTransmitter

One-way order issuer that:

  1. Pulls inputs from user
  2. Executes protocol calls in order
  3. Emits event and exits

Constants

OPERATOR_ROLE

Operator role identifier

uint256 public constant OPERATOR_ROLE = _ROLE_0

AUTHORITY_ROLE

Authority role identifier

uint256 public constant AUTHORITY_ROLE = _ROLE_1

TOKEN_STACK_SLOT

Note: storage-location: erc7201:metaintenttransmitter.tokens

bytes32 constant TOKEN_STACK_SLOT = 0x1b08c89f51b1decc132fa8988a44ec87df810cdce8fa337e2d1606c8b95fe100

State Variables

_nonces

Prevent nonce reuse per user

mapping(address user => mapping(uint256 nonce => bytes32 orderId)) _nonces

_executedOrders

Track order execution for analytics

mapping(bytes32 orderId => uint256 nonce) _executedOrders

routeAuthority

Address for authorizing routes

address public routeAuthority

Functions

constructor

constructor(address owner, address operator, address authorizer, address initialRouteAuthority) EIP712();

execute

Execute a meta-intent order by pulling inputs and executing protocol calls

function execute(Order calldata order) external payable whenNotPaused nonReentrant returns (bytes32 orderId);

Parameters

NameTypeDescription
orderOrderThe order to execute

Returns

NameTypeDescription
orderIdbytes32Unique identifier for the executed order

pause

Pause the contract, preventing state change calls

Can only be called by an administrator

function pause() external onlyRoles(OPERATOR_ROLE);

unpause

Unpause the contract, allowing state change calls

Can only be called by an administrator

function unpause() external onlyRoles(OPERATOR_ROLE);

setRouteAuthority

Update the route authority address

Can only be called by an administrator

function setRouteAuthority(address newRouteAuthority) external onlyRoles(AUTHORITY_ROLE);

Parameters

NameTypeDescription
newRouteAuthorityaddressThe new Mure signer address

previewOrderId

Compute orderId without executing (for front-end)

function previewOrderId(Order calldata order) external view returns (bytes32);

orderConsumed

Check if an order has been consumed

function orderConsumed(bytes32 orderId) public view returns (bool);

nonceConsumed

Check if nonce has been used

function nonceConsumed(address user, uint256 nonce) public view returns (bool);

_consumeNonce

Consume a nonce for user and associate it with orderId

function _consumeNonce(address user, uint256 nonce, bytes32 orderId) internal;

_refundExcess

If return any current balance to msg.sender

function _refundExcess(address to) internal;

_verifyCallSignature

Verifies that the call signature is valid for the given order

Uses EIP712 domain hashing and SignatureCheckerLib for verification

function _verifyCallSignature(Order calldata order) internal view;

Parameters

NameTypeDescription
orderOrderThe order to verify signature for

_domainNameAndVersion

function _domainNameAndVersion() internal pure override returns (string memory name, string memory version);

_tokens

function _tokens() internal pure returns (LibTransient.TStack storage ptr);

_pushAddr

function _pushAddr(LibTransient.TStack storage tokens, address addr) internal;

_popAddr

function _popAddr(LibTransient.TStack storage tokens) internal returns (address addr);

_setRouteAuthority

function _setRouteAuthority(address newRouteAuthority) internal;

Events

OrderInitiated

Emitted when order is successfully initialized

Off-chain systems index this to track order lifecycle

event OrderInitiated(bytes32 indexed orderId, address indexed user, uint256 timestamp);

RouteAuthorityUpdated

Emitted when the route authority address is rotated

Off-chain systems index this to track signer changes

event RouteAuthorityUpdated(address indexed oldAuthority, address indexed newAuthority);