LibTransferKey
The LibTransferKey
library provides functionality for encoding, decoding, and validating TransferKey
structs, which are used to represent transfer keys in the application.
Field | Type | Description |
---|---|---|
networkId of the current chain in Magpie protocol, it is different from the actual networkId ethereum: 1 polygon: 2 bsc: 3 avalanche: 4 arbitrum: 5 optimism: 6 | ||
The address who initiated the transfer. | ||
The magpie sequence for the current swap. |
encode():
In the encode
function, a new bytes array (payload
) of size 42 is created to store the encoded transfer key.
Input:
Field | Type | Description |
---|---|---|
Output:
Field | Type | Description |
---|---|---|
The transferKey concatenated and converted to bytes |
decode():
In the decode
function, the assembly block is used to extract the values of each field from the payload
array and store them in the transferKey
struct.
Input:
Field | Type | Description |
---|---|---|
The data which contains the transferKey. |
Output:
Field | Type | Description |
---|---|---|
validate():
The validate
function checks if the networkId
, senderAddress
, and swapSequence
fields of both TransferKey
structs are equal. If any of the fields differ, indicating an invalid transfer key, the function reverts with an InvalidTransferKey
error.
Input:
Field | Type | Description |
---|---|---|
Last updated