InputEncoding
Title: Input Encoding Library
Defines the encoding of inputs added by core trustless and permissionless contracts, such as portals.
Functions
encodeEtherDeposit
Encode an Ether deposit.
function encodeEtherDeposit(
address sender,
uint256 value,
bytes calldata execLayerData
) internal pure returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The Ether sender |
value | uint256 | The amount of Wei being sent |
execLayerData | bytes | Additional data to be interpreted by the execution layer |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The encoded input payload |
decodeEtherDeposit
Decode an Ether deposit.
function decodeEtherDeposit(bytes calldata payload)
internal
pure
returns (EtherDeposit memory deposit);
Parameters
| Name | Type | Description |
|---|---|---|
payload | bytes | The encoded input payload |
Returns
| Name | Type | Description |
|---|---|---|
deposit | EtherDeposit | The decoded Ether deposit |
encodeErc20Deposit
Encode an ERC-20 token deposit.
function encodeErc20Deposit(
IERC20 token,
address sender,
uint256 value,
bytes calldata execLayerData
) internal pure returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
token | IERC20 | The token contract |
sender | address | The token sender |
value | uint256 | The amount of tokens being sent |
execLayerData | bytes | Additional data to be interpreted by the execution layer |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The encoded input payload |
decodeErc20Deposit
Decode an ERC-20 token deposit.
function decodeErc20Deposit(bytes calldata payload)
internal
pure
returns (Erc20Deposit memory deposit);
Parameters
| Name | Type | Description |
|---|---|---|
payload | bytes | The encoded input payload |
Returns
| Name | Type | Description |
|---|---|---|
deposit | Erc20Deposit | The decoded ERC-20 token deposit |
encodeErc721Deposit
Encode an ERC-721 token deposit.
baseLayerData should be forwarded to token.
function encodeErc721Deposit(
IERC721 token,
address sender,
uint256 tokenId,
bytes calldata baseLayerData,
bytes calldata execLayerData
) internal pure returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
token | IERC721 | The token contract |
sender | address | The token sender |
tokenId | uint256 | The token identifier |
baseLayerData | bytes | Additional data to be interpreted by the base layer |
execLayerData | bytes | Additional data to be interpreted by the execution layer |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The encoded input payload |
decodeErc721Deposit
Decode an ERC-721 token deposit.
function decodeErc721Deposit(bytes calldata payload)
internal
pure
returns (Erc721Deposit memory deposit);
Parameters
| Name | Type | Description |
|---|---|---|
payload | bytes | The encoded input payload |
Returns
| Name | Type | Description |
|---|---|---|
deposit | Erc721Deposit | The decoded ERC-721 token deposit |
encodeSingleErc1155Deposit
Encode an ERC-1155 single token deposit.
baseLayerData should be forwarded to token.
function encodeSingleErc1155Deposit(
IERC1155 token,
address sender,
uint256 tokenId,
uint256 value,
bytes calldata baseLayerData,
bytes calldata execLayerData
) internal pure returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
token | IERC1155 | The ERC-1155 token contract |
sender | address | The token sender |
tokenId | uint256 | The identifier of the token being transferred |
value | uint256 | Transfer amount |
baseLayerData | bytes | Additional data to be interpreted by the base layer |
execLayerData | bytes | Additional data to be interpreted by the execution layer |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The encoded input payload |
decodeErc1155SingleDeposit
Decode an ERC-1155 single token deposit.
function decodeErc1155SingleDeposit(bytes calldata payload)
internal
pure
returns (Erc1155SingleDeposit memory deposit);
Parameters
| Name | Type | Description |
|---|---|---|
payload | bytes | The encoded input payload |
Returns
| Name | Type | Description |
|---|---|---|
deposit | Erc1155SingleDeposit | The decoded ERC-1155 single token deposit |
encodeBatchErc1155Deposit
Encode an ERC-1155 batch token deposit.
baseLayerData should be forwarded to token.
function encodeBatchErc1155Deposit(
IERC1155 token,
address sender,
uint256[] calldata tokenIds,
uint256[] calldata values,
bytes calldata baseLayerData,
bytes calldata execLayerData
) internal pure returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
token | IERC1155 | The ERC-1155 token contract |
sender | address | The token sender |
tokenIds | uint256[] | The identifiers of the tokens being transferred |
values | uint256[] | Transfer amounts per token type |
baseLayerData | bytes | Additional data to be interpreted by the base layer |
execLayerData | bytes | Additional data to be interpreted by the execution layer |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The encoded input payload |
decodeErc1155BatchDeposit
Decode an ERC-1155 batch token deposit.
function decodeErc1155BatchDeposit(bytes calldata payload)
internal
pure
returns (Erc1155BatchDeposit memory deposit);
Parameters
| Name | Type | Description |
|---|---|---|
payload | bytes | The encoded input payload |
Returns
| Name | Type | Description |
|---|---|---|
deposit | Erc1155BatchDeposit | The decoded ERC-1155 batch token deposit |