mTokenProofDecoderLib

Git Source

Title: mTokenProofDecoderLib

Author: Merge Layers Inc.

Utility library for encoding and decoding mToken journals

State Variables

ENTRY_SIZE

Encoded journal entry size in bytes

uint256 public constant ENTRY_SIZE = 113

Functions

decodeJournal

Decodes encoded journal data into fields

function decodeJournal(bytes memory journalData)
    internal
    pure
    returns (
        address sender,
        address market,
        uint256 accAmountIn,
        uint256 accAmountOut,
        uint32 chainId,
        uint32 dstChainId,
        bool l1Inclusion
    );

Parameters

NameTypeDescription
journalDatabytesPacked journal bytes

Returns

NameTypeDescription
senderaddressJournal sender
marketaddressMarket address
accAmountInuint256Accumulated amount in
accAmountOutuint256Accumulated amount out
chainIduint32Source chain id
dstChainIduint32Destination chain id
l1InclusionboolWhether L1 inclusion is required

encodeJournal

Encodes journal fields into packed bytes

function encodeJournal(
    address sender,
    address market,
    uint256 accAmountIn,
    uint256 accAmountOut,
    uint32 chainId,
    uint32 dstChainId,
    bool l1Inclusion
) internal pure returns (bytes memory);

Parameters

NameTypeDescription
senderaddressJournal sender
marketaddressMarket address
accAmountInuint256Accumulated amount in
accAmountOutuint256Accumulated amount out
chainIduint32Source chain id
dstChainIduint32Destination chain id
l1InclusionboolWhether L1 inclusion is required

Returns

NameTypeDescription
<none>bytesPacked journal bytes

Errors

mTokenProofDecoderLib_ChainNotFound

Thrown when chain is not found

error mTokenProofDecoderLib_ChainNotFound();

mTokenProofDecoderLib_InvalidLength

Thrown when journal length is invalid

error mTokenProofDecoderLib_InvalidLength();

mTokenProofDecoderLib_InvalidInclusion

Thrown when L1 inclusion flag is invalid

error mTokenProofDecoderLib_InvalidInclusion();