Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix message hasher and tests #1169

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions contracts/src/v0.8/ccip/test/helpers/MessageHasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Internal} from "../../libraries/Internal.sol";

/// @notice MessageHasher is a contract that utility functions to hash an Any2EVMRampMessage
/// and encode various preimages for the final hash of the message.
/// @dev This is only deployed in tests and is not part of the production contracts.
contract MessageHasher {
function hash(Internal.Any2EVMRampMessage memory message, bytes memory onRamp) public pure returns (bytes32) {
return Internal._hash(message, onRamp);
Expand Down Expand Up @@ -48,4 +49,23 @@ contract MessageHasher {
) public pure returns (bytes memory) {
return abi.encode(leafDomainSeparator, implicitMetadataHash, fixedSizeFieldsHash, dataHash, tokenAmountsHash);
}

function encodeEVMExtraArgsV1(Client.EVMExtraArgsV1 memory extraArgs) public pure returns (bytes memory) {
return Client._argsToBytes(extraArgs);
}

function encodeEVMExtraArgsV2(Client.EVMExtraArgsV2 memory extraArgs) public pure returns (bytes memory) {
return Client._argsToBytes(extraArgs);
}

function decodeEVMExtraArgsV1(uint256 gasLimit) public pure returns (Client.EVMExtraArgsV1 memory) {
return Client.EVMExtraArgsV1(gasLimit);
}

function decodeEVMExtraArgsV2(
uint256 gasLimit,
bool allowOutOfOrderExecution
) public pure returns (Client.EVMExtraArgsV2 memory) {
return Client.EVMExtraArgsV2(gasLimit, allowOutOfOrderExecution);
}
}
Loading
Loading