LibDataTransfer

This is a Solidity smart contract library that provides functions related to data transfer between different blockchain networks or layers.

getOriginalPayload()

this function is responsible for extracting the original payload from the extended payload by slicing the extendedPayload from the 42nd byte to the end. It removes the extended part of the payload and returns the original payload.

Input

FieldTypeDescription

extendedPayload

bytes

Payload + extra information like which data transfer type has been used

Output

FieldTypeDescription

payload

bytes

the original payload

dataTransfer()

this function is responsible for executing data transfer operations based on the specified protocols. It increments the core sequence, creates a transfer key, generates the extended payload, and processes each protocol in dataTransferInArgs.protocols. Depending on the protocol's dataTransferType, either the Wormhole or LayerZero data transfer function is called. If an unrecognised dataTransferType is encountered, the function reverts with an error.

Input

FieldTypeDescription

dataTransferInArgs

DataTransferInArgs

struct DataTransferInArgs {
    DataTransferInProtocol protocol;
    TransferKey transferKey;
    bytes payload;
}

Output

FieldTypeDescription

transferKey

TransferKey

struct TransferKey {
    uint16 networkId;
    bytes32 senderAddress;
    uint64 swapSequence;
}

getPayload()

this function is responsible for obtaining the transfer key and payload based on the specified data transfer type. Depending on the dataTransferType in dataTransferOutArgs, either the Wormhole or LayerZero library functions are called to obtain the payload.

Input

FieldTypeDescription

dataTransferOutArgs

DataTransferOutArgs

struct DataTransferOutArgs {
    DataTransferType dataTransferType;
    bytes payload;
}

Output

FieldTypeDescription

transferKey

TransferKey

struct TransferKey {
    uint16 networkId;
    bytes32 senderAddress;
    uint64 swapSequence;
}

payload

bytes

The data necessary for swapping.

Last updated