Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aureliusbtc committed Feb 17, 2024
1 parent d61063e commit 29ba989
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/contracts-communication/contracts/libs/Options.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title OptionsLib
/// @notice A library for encoding and decoding Interchain options related to interchain messages.
library OptionsLib {
/// @dev Struct to hold V1 of options data.
/// @param version The version of the options.
/// @param gasLimit The gas limit for the transaction.
/// @param gasAirdrop The amount of gas to airdrop.
struct Options {
uint8 version;
uint256 gasLimit;
// uint256 msgValue;
uint256 gasAirdrop;
}

/// @notice Encodes options into a bytes format.
/// @param options The Options to encode.
/// @return The encoded options as bytes.
function encodeOptions(Options memory options) internal pure returns (bytes memory) {
return abi.encode(options.version, options.gasLimit, options.gasAirdrop);
}

/// @notice Decodes options from a bytes format back into an Options struct.
/// @param data The options data in bytes format.
/// @return The decoded options as an Options struct.
function decodeOptions(bytes memory data) internal pure returns (Options memory) {
(uint8 version, uint256 gasLimit, uint256 gasAirdrop) = abi.decode(data, (uint8, uint256, uint256));
return Options(version, gasLimit, gasAirdrop);
}
}

0 comments on commit 29ba989

Please sign in to comment.