@evvm/testnet-contracts 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,25 +3,54 @@
3
3
 
4
4
  pragma solidity ^0.8.0;
5
5
 
6
+ /**
7
+ * @title ExternalChainStationStructs
8
+ * @author Mate labs
9
+ * @notice Shared data structures for External Chain Station cross-chain treasury operations
10
+ * @dev Defines all structural types used by TreasuryExternalChainStation contract
11
+ * These structures ensure type safety and consistency for cross-chain operations
12
+ * from external chains to the host chain in the EVVM ecosystem
13
+ */
6
14
  abstract contract ExternalChainStationStructs {
15
+ /// @notice Time-delayed address change proposal structure for governance
16
+ /// @dev Used for admin and Fisher executor address changes with 1-day delay
17
+ /// @param current Currently active address with full privileges
18
+ /// @param proposal Proposed new address waiting for acceptance
19
+ /// @param timeToAccept Timestamp when the proposal becomes acceptable
7
20
  struct AddressTypeProposal {
8
21
  address current;
9
22
  address proposal;
10
23
  uint256 timeToAccept;
11
24
  }
12
25
 
26
+ /// @notice Hyperlane protocol configuration for cross-chain messaging
27
+ /// @dev Configuration for reliable cross-chain communication via Hyperlane
28
+ /// @param hostChainStationDomainId Hyperlane domain identifier for the host chain
29
+ /// @param hostChainStationAddress Host chain station address in bytes32 format
30
+ /// @param mailboxAddress Hyperlane mailbox contract address on this chain
13
31
  struct HyperlaneConfig {
14
32
  uint32 hostChainStationDomainId;
15
33
  bytes32 hostChainStationAddress;
16
34
  address mailboxAddress;
17
35
  }
18
36
 
37
+ /// @notice LayerZero protocol configuration for omnichain messaging
38
+ /// @dev Configuration for omnichain interoperability via LayerZero V2
39
+ /// @param hostChainStationEid LayerZero endpoint identifier for the host chain
40
+ /// @param hostChainStationAddress Host chain station address in bytes32 format
41
+ /// @param endpointAddress LayerZero V2 endpoint contract address on this chain
19
42
  struct LayerZeroConfig {
20
43
  uint32 hostChainStationEid;
21
44
  bytes32 hostChainStationAddress;
22
45
  address endpointAddress;
23
46
  }
24
47
 
48
+ /// @notice Axelar protocol configuration for cross-chain communication
49
+ /// @dev Configuration for secure cross-chain transfers via Axelar Network
50
+ /// @param hostChainStationChainName Axelar chain identifier for the host chain
51
+ /// @param hostChainStationAddress Host chain station address in string format
52
+ /// @param gasServiceAddress Axelar gas service contract address for fee payments
53
+ /// @param gatewayAddress Axelar gateway contract address for message routing
25
54
  struct AxelarConfig {
26
55
  string hostChainStationChainName;
27
56
  string hostChainStationAddress;
@@ -29,6 +58,15 @@ abstract contract ExternalChainStationStructs {
29
58
  address gatewayAddress;
30
59
  }
31
60
 
61
+ /// @notice Unified cross-chain configuration for all supported protocols
62
+ /// @dev Single structure containing all protocol configurations for deployment
63
+ /// @param hostChainStationDomainId Hyperlane domain ID for host chain
64
+ /// @param mailboxAddress Hyperlane mailbox contract address
65
+ /// @param hostChainStationEid LayerZero endpoint ID for host chain
66
+ /// @param endpointAddress LayerZero V2 endpoint contract address
67
+ /// @param hostChainStationChainName Axelar chain name for host chain
68
+ /// @param gasServiceAddress Axelar gas service contract address
69
+ /// @param gatewayAddress Axelar gateway contract address
32
70
  struct CrosschainConfig {
33
71
  uint32 hostChainStationDomainId;
34
72
  address mailboxAddress;
@@ -38,4 +76,16 @@ abstract contract ExternalChainStationStructs {
38
76
  address gasServiceAddress;
39
77
  address gatewayAddress;
40
78
  }
79
+
80
+ /// @notice Parameters for coordinated host chain address changes across all protocols
81
+ /// @dev Used to propose and execute synchronized address updates with time delay
82
+ /// @param porposeAddress_AddressType Address format for Hyperlane and LayerZero protocols
83
+ /// @param porposeAddress_StringType String format for Axelar protocol compatibility
84
+ /// @param timeToAccept Timestamp when the address change proposal can be executed
85
+ struct ChangeHostChainAddressParams {
86
+ address porposeAddress_AddressType;
87
+ string porposeAddress_StringType;
88
+ uint256 timeToAccept;
89
+ }
41
90
  }
91
+
@@ -4,35 +4,54 @@
4
4
  pragma solidity ^0.8.0;
5
5
 
6
6
  /**
7
- * @title TreasuryStructs
8
- * @dev Library of common structures used across TreasuryTwoChains.
9
- * This contract serves as a shared type system for the entire ecosystem,
10
- * ensuring consistency in data structures between the core TreasuryTwoChains and
11
- * external service contracts.
12
- *
13
- * @notice This contract should be inherited by both TreasuryTwoChains contracts
14
- * that need to interact with these data structures.
7
+ * @title HostChainStationStructs
8
+ * @author Mate labs
9
+ * @notice Shared data structures for Host Chain Station cross-chain treasury operations
10
+ * @dev Defines all structural types used by TreasuryHostChainStation contract
11
+ * These structures ensure type safety and consistency for cross-chain operations
12
+ * from the host chain to external chains in the EVVM ecosystem
15
13
  */
16
14
 
17
15
  abstract contract HostChainStationStructs {
16
+ /// @notice Time-delayed address change proposal structure for governance
17
+ /// @dev Used for admin and Fisher executor address changes with 1-day delay
18
+ /// @param current Currently active address with full privileges
19
+ /// @param proposal Proposed new address waiting for acceptance
20
+ /// @param timeToAccept Timestamp when the proposal becomes acceptable
18
21
  struct AddressTypeProposal {
19
22
  address current;
20
23
  address proposal;
21
24
  uint256 timeToAccept;
22
25
  }
23
26
 
27
+ /// @notice Hyperlane protocol configuration for cross-chain messaging
28
+ /// @dev Configuration for reliable cross-chain communication via Hyperlane
29
+ /// @param externalChainStationDomainId Hyperlane domain identifier for the external chain
30
+ /// @param externalChainStationAddress External chain station address in bytes32 format
31
+ /// @param mailboxAddress Hyperlane mailbox contract address on this host chain
24
32
  struct HyperlaneConfig {
25
33
  uint32 externalChainStationDomainId;
26
34
  bytes32 externalChainStationAddress;
27
35
  address mailboxAddress;
28
36
  }
29
37
 
38
+ /// @notice LayerZero protocol configuration for omnichain messaging
39
+ /// @dev Configuration for omnichain interoperability via LayerZero V2
40
+ /// @param externalChainStationEid LayerZero endpoint identifier for the external chain
41
+ /// @param externalChainStationAddress External chain station address in bytes32 format
42
+ /// @param endpointAddress LayerZero V2 endpoint contract address on this host chain
30
43
  struct LayerZeroConfig {
31
44
  uint32 externalChainStationEid;
32
45
  bytes32 externalChainStationAddress;
33
46
  address endpointAddress;
34
47
  }
35
48
 
49
+ /// @notice Axelar protocol configuration for cross-chain communication
50
+ /// @dev Configuration for secure cross-chain transfers via Axelar Network
51
+ /// @param externalChainStationChainName Axelar chain identifier for the external chain
52
+ /// @param externalChainStationAddress External chain station address in string format
53
+ /// @param gasServiceAddress Axelar gas service contract address for fee payments
54
+ /// @param gatewayAddress Axelar gateway contract address for message routing
36
55
  struct AxelarConfig {
37
56
  string externalChainStationChainName;
38
57
  string externalChainStationAddress;
@@ -40,6 +59,15 @@ abstract contract HostChainStationStructs {
40
59
  address gatewayAddress;
41
60
  }
42
61
 
62
+ /// @notice Unified cross-chain configuration for all supported protocols
63
+ /// @dev Single structure containing all protocol configurations for deployment
64
+ /// @param externalChainStationDomainId Hyperlane domain ID for external chain
65
+ /// @param mailboxAddress Hyperlane mailbox contract address
66
+ /// @param externalChainStationEid LayerZero endpoint ID for external chain
67
+ /// @param endpointAddress LayerZero V2 endpoint contract address
68
+ /// @param externalChainStationChainName Axelar chain name for external chain
69
+ /// @param gasServiceAddress Axelar gas service contract address
70
+ /// @param gatewayAddress Axelar gateway contract address
43
71
  struct CrosschainConfig {
44
72
  uint32 externalChainStationDomainId;
45
73
  address mailboxAddress;
@@ -49,4 +77,15 @@ abstract contract HostChainStationStructs {
49
77
  address gasServiceAddress;
50
78
  address gatewayAddress;
51
79
  }
80
+
81
+ /// @notice Parameters for coordinated external chain address changes across all protocols
82
+ /// @dev Used to propose and execute synchronized address updates with time delay
83
+ /// @param porposeAddress_AddressType Address format for Hyperlane and LayerZero protocols
84
+ /// @param porposeAddress_StringType String format for Axelar protocol compatibility
85
+ /// @param timeToAccept Timestamp when the address change proposal can be executed
86
+ struct ChangeExternalChainAddressParams {
87
+ address porposeAddress_AddressType;
88
+ string porposeAddress_StringType;
89
+ uint256 timeToAccept;
90
+ }
52
91
  }
@@ -0,0 +1,42 @@
1
+ // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
+ // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
+ pragma solidity ^0.8.0;
4
+
5
+ /**
6
+ * @title PayloadUtils Library
7
+ * @author Mate labs
8
+ * @notice Utility library for encoding and decoding cross-chain transfer payloads
9
+ * @dev Provides standardized payload format for cross-chain treasury operations
10
+ * Used by both TreasuryHostChainStation and TreasuryExternalChainStation
11
+ * to ensure consistent data format across Hyperlane, LayerZero, and Axelar protocols
12
+ */
13
+ library PayloadUtils {
14
+ /// @notice Encodes transfer data into a standardized cross-chain payload
15
+ /// @dev Uses ABI encoding for reliable cross-chain data transmission
16
+ /// @param token Token contract address (address(0) for native ETH)
17
+ /// @param toAddress Recipient address on the destination chain
18
+ /// @param amount Amount of tokens to transfer (in token's native decimals)
19
+ /// @return payload Encoded bytes containing the transfer parameters
20
+ function encodePayload(
21
+ address token,
22
+ address toAddress,
23
+ uint256 amount
24
+ ) internal pure returns (bytes memory payload) {
25
+ payload = abi.encode(token, toAddress, amount);
26
+ }
27
+
28
+ /// @notice Decodes a cross-chain payload back into transfer parameters
29
+ /// @dev Uses ABI decoding to extract the original transfer data safely
30
+ /// @param payload Encoded bytes received from cross-chain protocols
31
+ /// @return token Token contract address (address(0) indicates native ETH)
32
+ /// @return toAddress Recipient address extracted from the payload
33
+ /// @return amount Amount of tokens to transfer in token's native decimals
34
+ function decodePayload(
35
+ bytes memory payload
36
+ ) internal pure returns (address token, address toAddress, uint256 amount) {
37
+ (token, toAddress, amount) = abi.decode(
38
+ payload,
39
+ (address, address, uint256)
40
+ );
41
+ }
42
+ }
@@ -7,14 +7,48 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
7
7
 
8
8
  pragma solidity ^0.8.0;
9
9
 
10
+ /**
11
+ * @title SignatureUtils
12
+ * @author Mate labs
13
+ * @notice Signature verification utilities for Treasury Cross-Chain Fisher Bridge operations
14
+ * @dev Specialized signature verification for Fisher Bridge transactions in the EVVM cross-chain treasury system
15
+ * Provides EIP-191 compliant signature verification with structured message format for enhanced security
16
+ *
17
+ * Key Features:
18
+ * - EIP-191 standard message signing format for wallet compatibility
19
+ * - Fisher Bridge specific message structure for transaction authenticity
20
+ * - Nonce-based replay attack prevention
21
+ * - EVVM ID integration for cross-instance security
22
+ * - Support for both ETH and ERC20 token bridge operations
23
+ *
24
+ * Security Model:
25
+ * - Structured message format: "{evvmID},fisherBridge,{parameters}"
26
+ * - Nonce validation prevents replay attacks across chains
27
+ * - EVVM ID ensures signatures are valid only for specific EVVM instances
28
+ * - Address and amount validation through signature verification
29
+ */
10
30
  library SignatureUtils {
11
- /**
12
- * @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
13
- * verify messages, the next functions are used to verify the messages signed
14
- * by the users
15
- */
16
-
17
-
31
+ /// @notice Verifies Fisher Bridge transaction signatures using EIP-191 standard
32
+ /// @dev Constructs and verifies structured message for Fisher Bridge cross-chain operations
33
+ /// Message format: "{evvmID},fisherBridge,{addressToReceive},{nonce},{tokenAddress},{priorityFee},{amount}"
34
+ /// This ensures each signature is unique and prevents cross-chain replay attacks
35
+ ///
36
+ /// @param evvmID Unique identifier of the EVVM instance (prevents cross-instance replay)
37
+ /// @param signer Address that should have signed the message (transaction originator)
38
+ /// @param addressToReceive Destination address on the target chain for the bridged tokens
39
+ /// @param nonce Sequential nonce for the user to prevent replay attacks
40
+ /// @param tokenAddress Contract address of the token being bridged (address(0) for ETH)
41
+ /// @param priorityFee Fee amount paid to Fisher executor for priority processing
42
+ /// @param amount Total amount of tokens being bridged across chains
43
+ /// @param signature ECDSA signature (65 bytes) created by the signer using their private key
44
+ /// @return bool True if the signature is valid and matches the expected signer, false otherwise
45
+ ///
46
+ /// @dev Security Features:
47
+ /// - EIP-191 compliance ensures wallet compatibility (MetaMask, WalletConnect, etc.)
48
+ /// - Structured message prevents parameter manipulation
49
+ /// - EVVM ID binding prevents cross-instance attacks
50
+ /// - Nonce inclusion prevents replay attacks
51
+ /// - All parameters are included in signature for integrity verification
18
52
  function verifyMessageSignedForFisherBridge(
19
53
  uint256 evvmID,
20
54
  address signer,
@@ -1,7 +1,5 @@
1
- // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
- // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
-
4
- pragma solidity ^0.8.0;
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.4;
5
3
 
6
4
  library ExternalChainStationStructs {
7
5
  struct AddressTypeProposal {
@@ -40,7 +38,7 @@ library ExternalChainStationStructs {
40
38
  }
41
39
  }
42
40
 
43
- interface ITreasuryExternalChainStation {
41
+ interface TreasuryExternalChainStation {
44
42
  struct EnforcedOptionParam {
45
43
  uint32 eid;
46
44
  uint16 msgType;
@@ -86,53 +84,27 @@ interface ITreasuryExternalChainStation {
86
84
  uint256 amount,
87
85
  uint256 nonce
88
86
  );
89
- event OwnershipTransferred(
90
- address indexed previousOwner,
91
- address indexed newOwner
92
- );
87
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
93
88
  event PeerSet(uint32 eid, bytes32 peer);
94
89
 
90
+ function _setHostChainAddress(address hostChainStationAddress, string memory hostChainStationAddressString)
91
+ external;
95
92
  function acceptAdmin() external;
96
-
97
93
  function acceptFisherExecutor() external;
98
-
99
- function allowInitializePath(
100
- Origin memory origin
101
- ) external view returns (bool);
102
-
103
- function combineOptions(
104
- uint32 _eid,
105
- uint16 _msgType,
106
- bytes memory _extraOptions
107
- ) external view returns (bytes memory);
108
-
109
- function depositCoin(
110
- address toAddress,
111
- uint256 amount,
112
- bytes1 protocolToExecute
113
- ) external payable;
114
-
115
- function depositERC20(
116
- address toAddress,
117
- address token,
118
- uint256 amount,
119
- bytes1 protocolToExecute
120
- ) external payable;
121
-
94
+ function acceptHostChainAddress() external;
95
+ function allowInitializePath(Origin memory origin) external view returns (bool);
96
+ function combineOptions(uint32 _eid, uint16 _msgType, bytes memory _extraOptions)
97
+ external
98
+ view
99
+ returns (bytes memory);
100
+ function depositCoin(address toAddress, uint256 amount, bytes1 protocolToExecute) external payable;
101
+ function depositERC20(address toAddress, address token, uint256 amount, bytes1 protocolToExecute)
102
+ external
103
+ payable;
122
104
  function endpoint() external view returns (address);
123
-
124
- function enforcedOptions(
125
- uint32 eid,
126
- uint16 msgType
127
- ) external view returns (bytes memory enforcedOption);
128
-
129
- function execute(
130
- bytes32 commandId,
131
- string memory sourceChain,
132
- string memory sourceAddress,
133
- bytes memory payload
134
- ) external;
135
-
105
+ function enforcedOptions(uint32 eid, uint16 msgType) external view returns (bytes memory enforcedOption);
106
+ function execute(bytes32 commandId, string memory sourceChain, string memory sourceAddress, bytes memory payload)
107
+ external;
136
108
  function fisherBridgeReceive(
137
109
  address from,
138
110
  address addressToReceive,
@@ -141,7 +113,6 @@ interface ITreasuryExternalChainStation {
141
113
  uint256 amount,
142
114
  bytes memory signature
143
115
  ) external;
144
-
145
116
  function fisherBridgeSendCoin(
146
117
  address from,
147
118
  address addressToReceive,
@@ -149,7 +120,6 @@ interface ITreasuryExternalChainStation {
149
120
  uint256 amount,
150
121
  bytes memory signature
151
122
  ) external payable;
152
-
153
123
  function fisherBridgeSendERC20(
154
124
  address from,
155
125
  address addressToReceive,
@@ -158,58 +128,17 @@ interface ITreasuryExternalChainStation {
158
128
  uint256 amount,
159
129
  bytes memory signature
160
130
  ) external;
161
-
162
131
  function gateway() external view returns (address);
163
-
164
- function getAdmin()
165
- external
166
- view
167
- returns (ExternalChainStationStructs.AddressTypeProposal memory);
168
-
169
- function getAxelarConfig()
170
- external
171
- view
172
- returns (ExternalChainStationStructs.AxelarConfig memory);
173
-
174
- function getFisherExecutor()
175
- external
176
- view
177
- returns (ExternalChainStationStructs.AddressTypeProposal memory);
178
-
179
- function getHyperlaneConfig()
180
- external
181
- view
182
- returns (ExternalChainStationStructs.HyperlaneConfig memory);
183
-
184
- function getLayerZeroConfig()
185
- external
186
- view
187
- returns (ExternalChainStationStructs.LayerZeroConfig memory);
188
-
189
- function getNextFisherExecutionNonce(
190
- address user
191
- ) external view returns (uint256);
192
-
132
+ function getAdmin() external view returns (ExternalChainStationStructs.AddressTypeProposal memory);
133
+ function getAxelarConfig() external view returns (ExternalChainStationStructs.AxelarConfig memory);
134
+ function getFisherExecutor() external view returns (ExternalChainStationStructs.AddressTypeProposal memory);
135
+ function getHyperlaneConfig() external view returns (ExternalChainStationStructs.HyperlaneConfig memory);
136
+ function getLayerZeroConfig() external view returns (ExternalChainStationStructs.LayerZeroConfig memory);
137
+ function getNextFisherExecutionNonce(address user) external view returns (uint256);
193
138
  function getOptions() external view returns (bytes memory);
194
-
195
- function getQuoteHyperlane(
196
- address toAddress,
197
- address token,
198
- uint256 amount
199
- ) external view returns (uint256);
200
-
201
- function handle(
202
- uint32 _origin,
203
- bytes32 _sender,
204
- bytes memory _data
205
- ) external payable;
206
-
207
- function isComposeMsgSender(
208
- Origin memory,
209
- bytes memory,
210
- address _sender
211
- ) external view returns (bool);
212
-
139
+ function getQuoteHyperlane(address toAddress, address token, uint256 amount) external view returns (uint256);
140
+ function handle(uint32 _origin, bytes32 _sender, bytes memory _data) external payable;
141
+ function isComposeMsgSender(Origin memory, bytes memory, address _sender) external view returns (bool);
213
142
  function lzReceive(
214
143
  Origin memory _origin,
215
144
  bytes32 _guid,
@@ -217,46 +146,21 @@ interface ITreasuryExternalChainStation {
217
146
  address _executor,
218
147
  bytes memory _extraData
219
148
  ) external payable;
220
-
221
149
  function nextNonce(uint32, bytes32) external view returns (uint64 nonce);
222
-
223
- function oAppVersion()
224
- external
225
- pure
226
- returns (uint64 senderVersion, uint64 receiverVersion);
227
-
150
+ function oAppVersion() external pure returns (uint64 senderVersion, uint64 receiverVersion);
228
151
  function owner() external view returns (address);
229
-
230
152
  function peers(uint32 eid) external view returns (bytes32 peer);
231
-
232
153
  function proposeAdmin(address _newOwner) external;
233
-
234
154
  function proposeFisherExecutor(address _newFisherExecutor) external;
235
-
236
- function quoteLayerZero(
237
- address toAddress,
238
- address token,
239
- uint256 amount
240
- ) external view returns (uint256);
241
-
155
+ function proposeHostChainAddress(address hostChainStationAddress, string memory hostChainStationAddressString)
156
+ external;
157
+ function quoteLayerZero(address toAddress, address token, uint256 amount) external view returns (uint256);
242
158
  function rejectProposalAdmin() external;
243
-
244
159
  function rejectProposalFisherExecutor() external;
245
-
160
+ function rejectProposalHostChainAddress() external;
246
161
  function renounceOwnership() external;
247
-
248
162
  function setDelegate(address _delegate) external;
249
-
250
- function setEnforcedOptions(
251
- EnforcedOptionParam[] memory _enforcedOptions
252
- ) external;
253
-
254
- function setHostChainAddress(
255
- address hostChainStationAddress,
256
- string memory hostChainStationAddressString
257
- ) external;
258
-
163
+ function setEnforcedOptions(EnforcedOptionParam[] memory _enforcedOptions) external;
259
164
  function setPeer(uint32 _eid, bytes32 _peer) external;
260
-
261
165
  function transferOwnership(address newOwner) external;
262
166
  }