BridgeTransactionV2Lib

Git Source

State Variables

VERSION

uint16 internal constant VERSION = 2;

OFFSET_ORIGIN_CHAIN_ID

uint256 private constant OFFSET_ORIGIN_CHAIN_ID = 2;

OFFSET_DEST_CHAIN_ID

uint256 private constant OFFSET_DEST_CHAIN_ID = 6;

OFFSET_ORIGIN_SENDER

uint256 private constant OFFSET_ORIGIN_SENDER = 10;

OFFSET_DEST_RECIPIENT

uint256 private constant OFFSET_DEST_RECIPIENT = 30;

OFFSET_ORIGIN_TOKEN

uint256 private constant OFFSET_ORIGIN_TOKEN = 50;

OFFSET_DEST_TOKEN

uint256 private constant OFFSET_DEST_TOKEN = 70;

OFFSET_ORIGIN_AMOUNT

uint256 private constant OFFSET_ORIGIN_AMOUNT = 90;

OFFSET_DEST_AMOUNT

uint256 private constant OFFSET_DEST_AMOUNT = 122;

OFFSET_ORIGIN_FEE_AMOUNT

uint256 private constant OFFSET_ORIGIN_FEE_AMOUNT = 154;

OFFSET_DEADLINE

uint256 private constant OFFSET_DEADLINE = 186;

OFFSET_NONCE

uint256 private constant OFFSET_NONCE = 218;

OFFSET_EXCLUSIVITY_RELAYER

uint256 private constant OFFSET_EXCLUSIVITY_RELAYER = 250;

OFFSET_EXCLUSIVITY_END_TIME

uint256 private constant OFFSET_EXCLUSIVITY_END_TIME = 270;

OFFSET_ZAP_NATIVE

uint256 private constant OFFSET_ZAP_NATIVE = 302;

OFFSET_ZAP_DATA

uint256 private constant OFFSET_ZAP_DATA = 334;

Functions

validateV2

Validates that the encoded transaction is a tightly packed encoded payload for BridgeTransactionV2.

Checks the minimum length and the version, use this function before decoding any of the fields.

function validateV2(bytes calldata encodedTx) internal pure;

encodeV2

Encodes the BridgeTransactionV2 struct by tightly packing the fields.

abi.decode will not work as a result of the tightly packed fields. Use decodeV2 to decode instead.

function encodeV2(IFastBridgeV2.BridgeTransactionV2 memory bridgeTx) internal pure returns (bytes memory);

decodeV2

Decodes the BridgeTransactionV2 struct from the encoded transaction.

Encoded BridgeTransactionV2 struct must be tightly packed. Use validateV2 before decoding to ensure the encoded transaction is valid.

function decodeV2(bytes calldata encodedTx) internal pure returns (IFastBridgeV2.BridgeTransactionV2 memory bridgeTx);

version

Extracts the version from the encoded transaction.

function version(bytes calldata encodedTx) internal pure returns (uint16 version_);

originChainId

Extracts the origin chain ID from the encoded transaction.

function originChainId(bytes calldata encodedTx) internal pure returns (uint32 originChainId_);

destChainId

Extracts the destination chain ID from the encoded transaction.

function destChainId(bytes calldata encodedTx) internal pure returns (uint32 destChainId_);

originSender

Extracts the origin sender from the encoded transaction.

function originSender(bytes calldata encodedTx) internal pure returns (address originSender_);

destRecipient

Extracts the destination recipient from the encoded transaction.

function destRecipient(bytes calldata encodedTx) internal pure returns (address destRecipient_);

originToken

Extracts the origin token from the encoded transaction.

function originToken(bytes calldata encodedTx) internal pure returns (address originToken_);

destToken

Extracts the destination token from the encoded transaction.

function destToken(bytes calldata encodedTx) internal pure returns (address destToken_);

originAmount

Extracts the origin amount from the encoded transaction.

function originAmount(bytes calldata encodedTx) internal pure returns (uint256 originAmount_);

destAmount

Extracts the destination amount from the encoded transaction.

function destAmount(bytes calldata encodedTx) internal pure returns (uint256 destAmount_);

originFeeAmount

Extracts the origin fee amount from the encoded transaction.

function originFeeAmount(bytes calldata encodedTx) internal pure returns (uint256 originFeeAmount_);

deadline

Extracts the deadline from the encoded transaction.

function deadline(bytes calldata encodedTx) internal pure returns (uint256 deadline_);

nonce

Extracts the nonce from the encoded transaction.

function nonce(bytes calldata encodedTx) internal pure returns (uint256 nonce_);

exclusivityRelayer

Extracts the exclusivity relayer from the encoded transaction.

function exclusivityRelayer(bytes calldata encodedTx) internal pure returns (address exclusivityRelayer_);

exclusivityEndTime

Extracts the exclusivity end time from the encoded transaction.

function exclusivityEndTime(bytes calldata encodedTx) internal pure returns (uint256 exclusivityEndTime_);

zapNative

Extracts the Zap's native value from the encoded transaction.

function zapNative(bytes calldata encodedTx) internal pure returns (uint256 zapNative_);

zapData

Extracts the Zap's data from the encoded transaction.

function zapData(bytes calldata encodedTx) internal pure returns (bytes calldata zapData_);

Errors

BridgeTransactionV2__InvalidEncodedTx

error BridgeTransactionV2__InvalidEncodedTx();

BridgeTransactionV2__UnsupportedVersion

error BridgeTransactionV2__UnsupportedVersion(uint16 version);