RequestLib
Library for formatting the request part of the base messages.
- Request represents a message sender requirements for the message execution on the destination chain.
- Request occupies a single storage word, and thus is stored on stack instead of being stored in memory.
gasDrop field is included for future compatibility and is ignored at the moment.
Request stack layout (from highest bits to lowest)
Position | Field | Type | Bytes | Description |
---|---|---|---|---|
(024..012] | gasDrop | uint96 | 12 | Minimum amount of gas token to drop to the recipient |
(012..004] | gasLimit | uint64 | 8 | Minimum amount of gas units to supply for execution |
(004..000] | version | uint32 | 4 | Base message version to pass to the recipient |
State Variables
SHIFT_GAS_DROP
Amount of bits to shift to gasDrop field
uint192 private constant SHIFT_GAS_DROP = 12 * 8;
SHIFT_GAS_LIMIT
Amount of bits to shift to gasLimit field
uint192 private constant SHIFT_GAS_LIMIT = 4 * 8;
Functions
encodeRequest
Returns an encoded request with the given fields
function encodeRequest(uint96 gasDrop_, uint64 gasLimit_, uint32 version_) internal pure returns (Request);
Parameters
Name | Type | Description |
---|---|---|
gasDrop_ | uint96 | Minimum amount of gas token to drop to the recipient (ignored at the moment) |
gasLimit_ | uint64 | Minimum amount of gas units to supply for execution |
version_ | uint32 | Base message version to pass to the recipient |
wrapPadded
Wraps the padded encoded request into a Request-typed value.
The "padded" request is simply an encoded request casted to uint256 (highest bits are set to zero). Casting to uint256 is done automatically in Solidity, so no extra actions from consumers are needed. The highest bits are discarded, so that the contracts dealing with encoded requests don't need to be updated, if a new field is added.
function wrapPadded(uint256 paddedRequest) internal pure returns (Request);
gasDrop
Returns the requested of gas token to drop to the recipient.
function gasDrop(Request request) internal pure returns (uint96);
gasLimit
Returns the requested minimum amount of gas units to supply for execution.
function gasLimit(Request request) internal pure returns (uint64);
version
Returns the requested base message version to pass to the recipient.
function version(Request request) internal pure returns (uint32);