Skip to content

Commit 1366b74

Browse files
committed
undo msg hasher
1 parent 60f7b9a commit 1366b74

File tree

5 files changed

+128
-163
lines changed

5 files changed

+128
-163
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.4;
3+
4+
import {Client} from "../../libraries/Client.sol";
5+
import {Internal} from "../../libraries/Internal.sol";
6+
7+
contract MessageHasher {
8+
function encodeEVMExtraArgsV1(
9+
Client.EVMExtraArgsV1 memory extraArgs
10+
) public pure returns (bytes memory) {
11+
return Client._argsToBytes(extraArgs);
12+
}
13+
14+
function encodeEVMExtraArgsV2(
15+
Client.GenericExtraArgsV2 memory extraArgs
16+
) public pure returns (bytes memory) {
17+
return Client._argsToBytes(extraArgs);
18+
}
19+
20+
function encodeGenericExtraArgsV2(
21+
Client.GenericExtraArgsV2 memory extraArgs
22+
) public pure returns (bytes memory) {
23+
return Client._argsToBytes(extraArgs);
24+
}
25+
26+
function encodeGenericExtraArgsV3(
27+
Client.EVMExtraArgsV3 memory extraArgs
28+
) public pure returns (bytes memory) {
29+
return Client._argsToBytes(extraArgs);
30+
}
31+
32+
function decodeEVMExtraArgsV1(
33+
uint256 gasLimit
34+
) public pure returns (Client.EVMExtraArgsV1 memory) {
35+
return Client.EVMExtraArgsV1(gasLimit);
36+
}
37+
38+
function decodeGenericExtraArgsV2(
39+
uint256 gasLimit,
40+
bool allowOutOfOrderExecution
41+
) public pure returns (Client.GenericExtraArgsV2 memory) {
42+
return Client.GenericExtraArgsV2({gasLimit: gasLimit, allowOutOfOrderExecution: allowOutOfOrderExecution});
43+
}
44+
45+
function decodeEVMExtraArgsV2(
46+
uint256 gasLimit,
47+
bool allowOutOfOrderExecution
48+
) public pure returns (Client.GenericExtraArgsV2 memory) {
49+
return Client.GenericExtraArgsV2({gasLimit: gasLimit, allowOutOfOrderExecution: allowOutOfOrderExecution});
50+
}
51+
52+
function encodeSVMExtraArgsV1(
53+
Client.SVMExtraArgsV1 memory extraArgs
54+
) public pure returns (bytes memory) {
55+
return Client._svmArgsToBytes(extraArgs);
56+
}
57+
58+
function encodeSUIExtraArgsV1(
59+
Client.SuiExtraArgsV1 memory extraArgs
60+
) public pure returns (bytes memory) {
61+
return Client._suiArgsToBytes(extraArgs);
62+
}
63+
64+
/// @notice used offchain to decode an encoded SVMExtraArgsV1 struct.
65+
/// @dev The unrolled version fails due to differences in encoding when the accounts[] array
66+
/// is empty or not.
67+
function decodeSVMExtraArgsStruct(
68+
Client.SVMExtraArgsV1 memory extraArgs
69+
)
70+
public
71+
pure
72+
returns (
73+
uint32 computeUnits,
74+
uint64 accountIsWritableBitmap,
75+
bool allowOutOfOrderExecution,
76+
bytes32 tokenReceiver,
77+
bytes32[] memory accounts
78+
)
79+
{
80+
return (
81+
extraArgs.computeUnits,
82+
extraArgs.accountIsWritableBitmap,
83+
extraArgs.allowOutOfOrderExecution,
84+
extraArgs.tokenReceiver,
85+
extraArgs.accounts
86+
);
87+
}
88+
89+
/// @notice Used offchain to decode an encoded SuiExtraArgsV1 struct.
90+
function decodeSuiExtraArgsStruct(
91+
Client.SuiExtraArgsV1 memory extraArgs
92+
)
93+
public
94+
pure
95+
returns (uint256 gasLimit, bool allowOutOfOrderExecution, bytes32 tokenReceiver, bytes32[] memory receiverObjectIds)
96+
{
97+
return
98+
(extraArgs.gasLimit, extraArgs.allowOutOfOrderExecution, extraArgs.tokenReceiver, extraArgs.receiverObjectIds);
99+
}
100+
}

0 commit comments

Comments
 (0)