@evvm/testnet-contracts 2.2.3 → 3.0.0

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.
Files changed (71) hide show
  1. package/LICENSE +145 -118
  2. package/README.md +162 -39
  3. package/contracts/core/Core.sol +1394 -0
  4. package/contracts/core/lib/CoreStorage.sol +171 -0
  5. package/contracts/nameService/NameService.sol +666 -586
  6. package/contracts/nameService/lib/IdentityValidation.sol +18 -3
  7. package/contracts/p2pSwap/P2PSwap.sol +439 -285
  8. package/contracts/staking/Estimator.sol +128 -40
  9. package/contracts/staking/Staking.sol +329 -322
  10. package/contracts/treasury/Treasury.sol +48 -37
  11. package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +585 -198
  12. package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +425 -174
  13. package/contracts/treasuryTwoChains/lib/PayloadUtils.sol +2 -4
  14. package/interfaces/{IEvvm.sol → ICore.sol} +67 -29
  15. package/interfaces/IEstimator.sol +1 -1
  16. package/interfaces/INameService.sol +58 -52
  17. package/interfaces/IP2PSwap.sol +18 -17
  18. package/interfaces/IStaking.sol +22 -17
  19. package/interfaces/ITreasury.sol +2 -1
  20. package/interfaces/ITreasuryExternalChainStation.sol +15 -9
  21. package/interfaces/ITreasuryHostChainStation.sol +14 -11
  22. package/interfaces/IUserValidator.sol +6 -0
  23. package/library/Erc191TestBuilder.sol +350 -297
  24. package/library/EvvmService.sol +38 -27
  25. package/library/errors/CoreError.sol +116 -0
  26. package/library/errors/CrossChainTreasuryError.sol +36 -0
  27. package/library/errors/NameServiceError.sol +79 -0
  28. package/library/errors/StakingError.sol +79 -0
  29. package/library/errors/TreasuryError.sol +33 -0
  30. package/library/primitives/SignatureRecover.sol +33 -0
  31. package/library/structs/CoreStructs.sol +146 -0
  32. package/library/structs/ExternalChainStationStructs.sol +92 -0
  33. package/library/structs/HostChainStationStructs.sol +77 -0
  34. package/library/structs/NameServiceStructs.sol +47 -0
  35. package/library/structs/P2PSwapStructs.sol +127 -0
  36. package/library/structs/StakingStructs.sol +67 -0
  37. package/library/utils/AdvancedStrings.sol +84 -5
  38. package/library/utils/CAUtils.sol +29 -0
  39. package/library/utils/SignatureUtil.sol +34 -0
  40. package/library/utils/governance/Admin.sol +66 -0
  41. package/library/utils/governance/ProposalStructs.sol +49 -0
  42. package/library/utils/service/CoreExecution.sol +177 -0
  43. package/library/utils/service/StakingServiceUtils.sol +30 -3
  44. package/library/utils/signature/CoreHashUtils.sol +73 -0
  45. package/library/utils/signature/NameServiceHashUtils.sol +156 -0
  46. package/library/utils/signature/P2PSwapHashUtils.sol +65 -0
  47. package/library/utils/signature/StakingHashUtils.sol +41 -0
  48. package/library/utils/signature/TreasuryCrossChainHashUtils.sol +40 -0
  49. package/package.json +2 -1
  50. package/contracts/evvm/Evvm.sol +0 -1327
  51. package/contracts/evvm/lib/ErrorsLib.sol +0 -18
  52. package/contracts/evvm/lib/EvvmStorage.sol +0 -62
  53. package/contracts/evvm/lib/EvvmStructs.sol +0 -90
  54. package/contracts/evvm/lib/SignatureUtils.sol +0 -120
  55. package/contracts/nameService/lib/ErrorsLib.sol +0 -21
  56. package/contracts/nameService/lib/NameServiceStructs.sol +0 -69
  57. package/contracts/nameService/lib/SignatureUtils.sol +0 -245
  58. package/contracts/p2pSwap/lib/P2PSwapStructs.sol +0 -59
  59. package/contracts/p2pSwap/lib/SignatureUtils.sol +0 -98
  60. package/contracts/staking/lib/ErrorsLib.sol +0 -22
  61. package/contracts/staking/lib/SignatureUtils.sol +0 -39
  62. package/contracts/staking/lib/StakingStructs.sol +0 -94
  63. package/contracts/treasury/lib/ErrorsLib.sol +0 -11
  64. package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +0 -48
  65. package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +0 -80
  66. package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +0 -87
  67. package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +0 -79
  68. package/library/utils/GovernanceUtils.sol +0 -81
  69. package/library/utils/nonces/AsyncNonce.sol +0 -32
  70. package/library/utils/nonces/SyncNonce.sol +0 -27
  71. package/library/utils/service/EvvmPayments.sol +0 -79
@@ -11,77 +11,86 @@ pragma solidity ^0.8.0;
11
11
  * https://book.getfoundry.sh/cheatcodes/sign
12
12
  */
13
13
 
14
- import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
14
+ import {
15
+ CoreStructs
16
+ } from "@evvm/testnet-contracts/library/structs/CoreStructs.sol";
17
+ import {
18
+ AdvancedStrings
19
+ } from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
20
+ import {
21
+ CoreHashUtils
22
+ } from "@evvm/testnet-contracts/library/utils/signature/CoreHashUtils.sol";
23
+ import {
24
+ NameServiceHashUtils
25
+ } from "@evvm/testnet-contracts/library/utils/signature/NameServiceHashUtils.sol";
26
+ import {
27
+ P2PSwapHashUtils
28
+ } from "@evvm/testnet-contracts/library/utils/signature/P2PSwapHashUtils.sol";
29
+ import {
30
+ StakingHashUtils
31
+ } from "@evvm/testnet-contracts/library/utils/signature/StakingHashUtils.sol";
15
32
 
16
33
  library Erc191TestBuilder {
17
34
  //-----------------------------------------------------------------------------------
18
35
  // EVVM
19
36
  //-----------------------------------------------------------------------------------
37
+
20
38
  function buildMessageSignedForPay(
21
39
  uint256 evvmID,
22
- address _receiverAddress,
23
- string memory _receiverIdentity,
24
- address _token,
25
- uint256 _amount,
26
- uint256 _priorityFee,
27
- uint256 _nonce,
28
- bool _priority_boolean,
29
- address _executor
30
- ) internal pure returns (bytes32 messageHash) {
31
- string memory messageToSign = string.concat(
32
- AdvancedStrings.uintToString(evvmID),
33
- ",",
34
- "pay",
35
- ",",
36
- _receiverAddress == address(0)
37
- ? _receiverIdentity
38
- : AdvancedStrings.addressToString(_receiverAddress),
39
- ",",
40
- AdvancedStrings.addressToString(_token),
41
- ",",
42
- AdvancedStrings.uintToString(_amount),
43
- ",",
44
- AdvancedStrings.uintToString(_priorityFee),
45
- ",",
46
- AdvancedStrings.uintToString(_nonce),
47
- ",",
48
- _priority_boolean ? "true" : "false",
49
- ",",
50
- AdvancedStrings.addressToString(_executor)
51
- );
52
- messageHash = buildHashForSign(messageToSign);
40
+ address servicePointer,
41
+ address to_address,
42
+ string memory to_identity,
43
+ address token,
44
+ uint256 amount,
45
+ uint256 priorityFee,
46
+ address senderExecutor,
47
+ uint256 nonce,
48
+ bool isAsyncExec
49
+ ) internal pure returns (bytes32) {
50
+ return
51
+ buildHashForSign(
52
+ AdvancedStrings.buildSignaturePayload(
53
+ evvmID,
54
+ servicePointer,
55
+ CoreHashUtils.hashDataForPay(
56
+ to_address,
57
+ to_identity,
58
+ token,
59
+ amount,
60
+ priorityFee
61
+ ),
62
+ senderExecutor,
63
+ nonce,
64
+ isAsyncExec
65
+ )
66
+ );
53
67
  }
54
68
 
55
69
  function buildMessageSignedForDispersePay(
56
70
  uint256 evvmID,
57
- bytes32 hashList,
58
- address _token,
59
- uint256 _amount,
60
- uint256 _priorityFee,
61
- uint256 _nonce,
62
- bool _priority_boolean,
63
- address _executor
64
- ) public pure returns (bytes32 messageHash) {
71
+ address servicePointer,
72
+ CoreStructs.DispersePayMetadata[] memory toData,
73
+ address token,
74
+ uint256 amount,
75
+ uint256 priorityFee,
76
+ address senderExecutor,
77
+ uint256 nonce,
78
+ bool isAsyncExec
79
+ ) public pure returns (bytes32) {
65
80
  return
66
81
  buildHashForSign(
67
- string.concat(
68
- AdvancedStrings.uintToString(evvmID),
69
- ",",
70
- "dispersePay",
71
- ",",
72
- AdvancedStrings.bytes32ToString(hashList),
73
- ",",
74
- AdvancedStrings.addressToString(_token),
75
- ",",
76
- AdvancedStrings.uintToString(_amount),
77
- ",",
78
- AdvancedStrings.uintToString(_priorityFee),
79
- ",",
80
- AdvancedStrings.uintToString(_nonce),
81
- ",",
82
- _priority_boolean ? "true" : "false",
83
- ",",
84
- AdvancedStrings.addressToString(_executor)
82
+ AdvancedStrings.buildSignaturePayload(
83
+ evvmID,
84
+ servicePointer,
85
+ CoreHashUtils.hashDataForDispersePay(
86
+ toData,
87
+ token,
88
+ amount,
89
+ priorityFee
90
+ ),
91
+ senderExecutor,
92
+ nonce,
93
+ isAsyncExec
85
94
  )
86
95
  );
87
96
  }
@@ -92,211 +101,230 @@ library Erc191TestBuilder {
92
101
 
93
102
  function buildMessageSignedForPreRegistrationUsername(
94
103
  uint256 evvmID,
95
- bytes32 _hashUsername,
96
- uint256 _nameServiceNonce
97
- ) internal pure returns (bytes32 messageHash) {
104
+ address servicePointer,
105
+ bytes32 hashPreRegisteredUsername,
106
+ address originExecutor,
107
+ uint256 nonce
108
+ ) internal pure returns (bytes32) {
98
109
  return
99
110
  buildHashForSign(
100
- string.concat(
101
- AdvancedStrings.uintToString(evvmID),
102
- ",",
103
- "preRegistrationUsername",
104
- ",",
105
- AdvancedStrings.bytes32ToString(_hashUsername),
106
- ",",
107
- AdvancedStrings.uintToString(_nameServiceNonce)
111
+ AdvancedStrings.buildSignaturePayload(
112
+ evvmID,
113
+ servicePointer,
114
+ NameServiceHashUtils.hashDataForPreRegistrationUsername(
115
+ hashPreRegisteredUsername
116
+ ),
117
+ originExecutor,
118
+ nonce,
119
+ true
108
120
  )
109
121
  );
110
122
  }
111
123
 
112
124
  function buildMessageSignedForRegistrationUsername(
113
125
  uint256 evvmID,
114
- string memory _username,
115
- uint256 _clowNumber,
116
- uint256 _nameServiceNonce
117
- ) internal pure returns (bytes32 messageHash) {
126
+ address servicePointer,
127
+ string memory username,
128
+ uint256 lockNumber,
129
+ address originExecutor,
130
+ uint256 nonce
131
+ ) internal pure returns (bytes32) {
118
132
  return
119
133
  buildHashForSign(
120
- string.concat(
121
- AdvancedStrings.uintToString(evvmID),
122
- ",",
123
- "registrationUsername",
124
- ",",
125
- _username,
126
- ",",
127
- AdvancedStrings.uintToString(_clowNumber),
128
- ",",
129
- AdvancedStrings.uintToString(_nameServiceNonce)
134
+ AdvancedStrings.buildSignaturePayload(
135
+ evvmID,
136
+ servicePointer,
137
+ NameServiceHashUtils.hashDataForRegistrationUsername(
138
+ username,
139
+ lockNumber
140
+ ),
141
+ originExecutor,
142
+ nonce,
143
+ true
130
144
  )
131
145
  );
132
146
  }
133
147
 
134
148
  function buildMessageSignedForMakeOffer(
135
149
  uint256 evvmID,
136
- string memory _username,
137
- uint256 _dateExpire,
138
- uint256 _amount,
139
- uint256 _nameServiceNonce
140
- ) internal pure returns (bytes32 messageHash) {
150
+ address servicePointer,
151
+ string memory username,
152
+ uint256 amount,
153
+ uint256 expirationDate,
154
+ address originExecutor,
155
+ uint256 nonce
156
+ ) internal pure returns (bytes32) {
141
157
  return
142
158
  buildHashForSign(
143
- string.concat(
144
- AdvancedStrings.uintToString(evvmID),
145
- ",",
146
- "makeOffer",
147
- ",",
148
- _username,
149
- ",",
150
- AdvancedStrings.uintToString(_dateExpire),
151
- ",",
152
- AdvancedStrings.uintToString(_amount),
153
- ",",
154
- AdvancedStrings.uintToString(_nameServiceNonce)
159
+ AdvancedStrings.buildSignaturePayload(
160
+ evvmID,
161
+ servicePointer,
162
+ NameServiceHashUtils.hashDataForMakeOffer(
163
+ username,
164
+ amount,
165
+ expirationDate
166
+ ),
167
+ originExecutor,
168
+ nonce,
169
+ true
155
170
  )
156
171
  );
157
172
  }
158
173
 
159
174
  function buildMessageSignedForWithdrawOffer(
160
175
  uint256 evvmID,
161
- string memory _username,
162
- uint256 _offerId,
163
- uint256 _nameServiceNonce
164
- ) internal pure returns (bytes32 messageHash) {
176
+ address servicePointer,
177
+ string memory username,
178
+ uint256 offerId,
179
+ address originExecutor,
180
+ uint256 nonce
181
+ ) internal pure returns (bytes32) {
165
182
  return
166
183
  buildHashForSign(
167
- string.concat(
168
- AdvancedStrings.uintToString(evvmID),
169
- ",",
170
- "withdrawOffer",
171
- ",",
172
- _username,
173
- ",",
174
- AdvancedStrings.uintToString(_offerId),
175
- ",",
176
- AdvancedStrings.uintToString(_nameServiceNonce)
184
+ AdvancedStrings.buildSignaturePayload(
185
+ evvmID,
186
+ servicePointer,
187
+ NameServiceHashUtils.hashDataForWithdrawOffer(
188
+ username,
189
+ offerId
190
+ ),
191
+ originExecutor,
192
+ nonce,
193
+ true
177
194
  )
178
195
  );
179
196
  }
180
197
 
181
198
  function buildMessageSignedForAcceptOffer(
182
199
  uint256 evvmID,
183
- string memory _username,
184
- uint256 _offerId,
185
- uint256 _nameServiceNonce
186
- ) internal pure returns (bytes32 messageHash) {
200
+ address servicePointer,
201
+ string memory username,
202
+ uint256 offerId,
203
+ address originExecutor,
204
+ uint256 nonce
205
+ ) internal pure returns (bytes32) {
187
206
  return
188
207
  buildHashForSign(
189
- string.concat(
190
- AdvancedStrings.uintToString(evvmID),
191
- ",",
192
- "acceptOffer",
193
- ",",
194
- _username,
195
- ",",
196
- AdvancedStrings.uintToString(_offerId),
197
- ",",
198
- AdvancedStrings.uintToString(_nameServiceNonce)
208
+ AdvancedStrings.buildSignaturePayload(
209
+ evvmID,
210
+ servicePointer,
211
+ NameServiceHashUtils.hashDataForAcceptOffer(
212
+ username,
213
+ offerId
214
+ ),
215
+ originExecutor,
216
+ nonce,
217
+ true
199
218
  )
200
219
  );
201
220
  }
202
221
 
203
222
  function buildMessageSignedForRenewUsername(
204
223
  uint256 evvmID,
205
- string memory _username,
206
- uint256 _nameServiceNonce
207
- ) internal pure returns (bytes32 messageHash) {
224
+ address servicePointer,
225
+ string memory username,
226
+ address originExecutor,
227
+ uint256 nonce
228
+ ) internal pure returns (bytes32) {
208
229
  return
209
230
  buildHashForSign(
210
- string.concat(
211
- AdvancedStrings.uintToString(evvmID),
212
- ",",
213
- "renewUsername",
214
- ",",
215
- _username,
216
- ",",
217
- AdvancedStrings.uintToString(_nameServiceNonce)
231
+ AdvancedStrings.buildSignaturePayload(
232
+ evvmID,
233
+ servicePointer,
234
+ NameServiceHashUtils.hashDataForRenewUsername(username),
235
+ originExecutor,
236
+ nonce,
237
+ true
218
238
  )
219
239
  );
220
240
  }
221
241
 
222
242
  function buildMessageSignedForAddCustomMetadata(
223
243
  uint256 evvmID,
224
- string memory _username,
225
- string memory _value,
226
- uint256 _nameServiceNonce
227
- ) internal pure returns (bytes32 messageHash) {
244
+ address servicePointer,
245
+ string memory username,
246
+ string memory value,
247
+ address originExecutor,
248
+ uint256 nonce
249
+ ) internal pure returns (bytes32) {
228
250
  return
229
251
  buildHashForSign(
230
- string.concat(
231
- AdvancedStrings.uintToString(evvmID),
232
- ",",
233
- "addCustomMetadata",
234
- ",",
235
- _username,
236
- ",",
237
- _value,
238
- ",",
239
- AdvancedStrings.uintToString(_nameServiceNonce)
252
+ AdvancedStrings.buildSignaturePayload(
253
+ evvmID,
254
+ servicePointer,
255
+ NameServiceHashUtils.hashDataForAddCustomMetadata(
256
+ username,
257
+ value
258
+ ),
259
+ originExecutor,
260
+ nonce,
261
+ true
240
262
  )
241
263
  );
242
264
  }
243
265
 
244
266
  function buildMessageSignedForRemoveCustomMetadata(
245
267
  uint256 evvmID,
246
- string memory _username,
247
- uint256 _key,
248
- uint256 _nonce
249
- ) internal pure returns (bytes32 messageHash) {
268
+ address servicePointer,
269
+ string memory username,
270
+ uint256 key,
271
+ address originExecutor,
272
+ uint256 nonce
273
+ ) internal pure returns (bytes32) {
250
274
  return
251
275
  buildHashForSign(
252
- string.concat(
253
- AdvancedStrings.uintToString(evvmID),
254
- ",",
255
- "removeCustomMetadata",
256
- ",",
257
- _username,
258
- ",",
259
- AdvancedStrings.uintToString(_key),
260
- ",",
261
- AdvancedStrings.uintToString(_nonce)
276
+ AdvancedStrings.buildSignaturePayload(
277
+ evvmID,
278
+ servicePointer,
279
+ NameServiceHashUtils.hashDataForRemoveCustomMetadata(
280
+ username,
281
+ key
282
+ ),
283
+ originExecutor,
284
+ nonce,
285
+ true
262
286
  )
263
287
  );
264
288
  }
265
289
 
266
290
  function buildMessageSignedForFlushCustomMetadata(
267
291
  uint256 evvmID,
268
- string memory _username,
269
- uint256 _nonce
270
- ) internal pure returns (bytes32 messageHash) {
292
+ address servicePointer,
293
+ string memory username,
294
+ address originExecutor,
295
+ uint256 nonce
296
+ ) internal pure returns (bytes32) {
271
297
  return
272
298
  buildHashForSign(
273
- string.concat(
274
- AdvancedStrings.uintToString(evvmID),
275
- ",",
276
- "flushCustomMetadata",
277
- ",",
278
- _username,
279
- ",",
280
- AdvancedStrings.uintToString(_nonce)
299
+ AdvancedStrings.buildSignaturePayload(
300
+ evvmID,
301
+ servicePointer,
302
+ NameServiceHashUtils.hashDataForFlushCustomMetadata(
303
+ username
304
+ ),
305
+ originExecutor,
306
+ nonce,
307
+ true
281
308
  )
282
309
  );
283
310
  }
284
311
 
285
312
  function buildMessageSignedForFlushUsername(
286
313
  uint256 evvmID,
287
- string memory _username,
288
- uint256 _nonce
289
- ) internal pure returns (bytes32 messageHash) {
314
+ address servicePointer,
315
+ string memory username,
316
+ address originExecutor,
317
+ uint256 nonce
318
+ ) internal pure returns (bytes32) {
290
319
  return
291
320
  buildHashForSign(
292
- string.concat(
293
- AdvancedStrings.uintToString(evvmID),
294
- ",",
295
- "flushUsername",
296
- ",",
297
- _username,
298
- ",",
299
- AdvancedStrings.uintToString(_nonce)
321
+ AdvancedStrings.buildSignaturePayload(
322
+ evvmID,
323
+ servicePointer,
324
+ NameServiceHashUtils.hashDataForFlushUsername(username),
325
+ originExecutor,
326
+ nonce,
327
+ true
300
328
  )
301
329
  );
302
330
  }
@@ -305,71 +333,50 @@ library Erc191TestBuilder {
305
333
  // staking functions
306
334
  //-----------------------------------------------------------------------------------
307
335
 
308
- function buildMessageSignedForPublicServiceStake(
336
+ function buildMessageSignedForPresaleStaking(
309
337
  uint256 evvmID,
310
- address _serviceAddress,
311
- bool _isStaking,
312
- uint256 _amountOfStaking,
313
- uint256 _nonce
314
- ) internal pure returns (bytes32 messageHash) {
338
+ address servicePointer,
339
+ bool isStaking,
340
+ uint256 amountOfStaking,
341
+ address originExecutor,
342
+ uint256 nonce
343
+ ) internal pure returns (bytes32) {
315
344
  return
316
345
  buildHashForSign(
317
- string.concat(
318
- AdvancedStrings.uintToString(evvmID),
319
- ",",
320
- "publicServiceStaking",
321
- ",",
322
- AdvancedStrings.addressToString(_serviceAddress),
323
- ",",
324
- _isStaking ? "true" : "false",
325
- ",",
326
- AdvancedStrings.uintToString(_amountOfStaking),
327
- ",",
328
- AdvancedStrings.uintToString(_nonce)
346
+ AdvancedStrings.buildSignaturePayload(
347
+ evvmID,
348
+ servicePointer,
349
+ StakingHashUtils.hashDataForPresaleStake(
350
+ isStaking,
351
+ amountOfStaking
352
+ ),
353
+ originExecutor,
354
+ nonce,
355
+ true
329
356
  )
330
357
  );
331
358
  }
332
359
 
333
360
  function buildMessageSignedForPublicStaking(
334
361
  uint256 evvmID,
335
- bool _isStaking,
336
- uint256 _amountOfStaking,
337
- uint256 _nonce
338
- ) internal pure returns (bytes32 messageHash) {
339
- return
340
- buildHashForSign(
341
- string.concat(
342
- AdvancedStrings.uintToString(evvmID),
343
- ",",
344
- "publicStaking",
345
- ",",
346
- _isStaking ? "true" : "false",
347
- ",",
348
- AdvancedStrings.uintToString(_amountOfStaking),
349
- ",",
350
- AdvancedStrings.uintToString(_nonce)
351
- )
352
- );
353
- }
354
-
355
- function buildMessageSignedForPresaleStaking(
356
- uint256 evvmID,
357
- bool _isStaking,
358
- uint256 _amountOfStaking,
359
- uint256 _nonce
360
- ) internal pure returns (bytes32 messageHash) {
362
+ address servicePointer,
363
+ bool isStaking,
364
+ uint256 amountOfStaking,
365
+ address originExecutor,
366
+ uint256 nonce
367
+ ) internal pure returns (bytes32) {
361
368
  return
362
369
  buildHashForSign(
363
- string.concat(
364
- AdvancedStrings.uintToString(evvmID),
365
- ",",
366
- "presaleStaking",
367
- ",",
368
- _isStaking ? "true" : "false",
369
- ",",
370
- AdvancedStrings.uintToString(_amountOfStaking),
371
- ",",
372
- AdvancedStrings.uintToString(_nonce)
370
+ AdvancedStrings.buildSignaturePayload(
371
+ evvmID,
372
+ servicePointer,
373
+ StakingHashUtils.hashDataForPublicStake(
374
+ isStaking,
375
+ amountOfStaking
376
+ ),
377
+ originExecutor,
378
+ nonce,
379
+ true
373
380
  )
374
381
  );
375
382
  }
@@ -380,78 +387,110 @@ library Erc191TestBuilder {
380
387
 
381
388
  function buildMessageSignedForMakeOrder(
382
389
  uint256 evvmID,
383
- uint256 _nonce,
384
- address _tokenA,
385
- address _tokenB,
386
- uint256 _amountA,
387
- uint256 _amountB
388
- ) internal pure returns (bytes32 messageHash) {
390
+ address servicePointer,
391
+ address originExecutor,
392
+ uint256 nonce,
393
+ address tokenA,
394
+ address tokenB,
395
+ uint256 amountA,
396
+ uint256 amountB
397
+ ) internal pure returns (bytes32) {
389
398
  return
390
399
  buildHashForSign(
391
- string.concat(
392
- AdvancedStrings.uintToString(evvmID),
393
- ",",
394
- "makeOrder",
395
- ",",
396
- AdvancedStrings.uintToString(_nonce),
397
- ",",
398
- AdvancedStrings.addressToString(_tokenA),
399
- ",",
400
- AdvancedStrings.addressToString(_tokenB),
401
- ",",
402
- AdvancedStrings.uintToString(_amountA),
403
- ",",
404
- AdvancedStrings.uintToString(_amountB)
400
+ AdvancedStrings.buildSignaturePayload(
401
+ evvmID,
402
+ servicePointer,
403
+ P2PSwapHashUtils.hashDataForMakeOrder(
404
+ tokenA,
405
+ tokenB,
406
+ amountA,
407
+ amountB
408
+ ),
409
+ originExecutor,
410
+ nonce,
411
+ true
405
412
  )
406
413
  );
407
414
  }
408
415
 
409
416
  function buildMessageSignedForCancelOrder(
410
417
  uint256 evvmID,
411
- uint256 _nonce,
412
- address _tokenA,
413
- address _tokenB,
414
- uint256 _orderId
415
- ) internal pure returns (bytes32 messageHash) {
418
+ address servicePointer,
419
+ address originExecutor,
420
+ uint256 nonce,
421
+ address tokenA,
422
+ address tokenB,
423
+ uint256 orderId
424
+ ) internal pure returns (bytes32) {
416
425
  return
417
426
  buildHashForSign(
418
- string.concat(
419
- AdvancedStrings.uintToString(evvmID),
420
- ",",
421
- "cancelOrder",
422
- ",",
423
- AdvancedStrings.uintToString(_nonce),
424
- ",",
425
- AdvancedStrings.addressToString(_tokenA),
426
- ",",
427
- AdvancedStrings.addressToString(_tokenB),
428
- ",",
429
- AdvancedStrings.uintToString(_orderId)
427
+ AdvancedStrings.buildSignaturePayload(
428
+ evvmID,
429
+ servicePointer,
430
+ P2PSwapHashUtils.hashDataForCancelOrder(
431
+ tokenA,
432
+ tokenB,
433
+ orderId
434
+ ),
435
+ originExecutor,
436
+ nonce,
437
+ true
430
438
  )
431
439
  );
432
440
  }
433
441
 
434
442
  function buildMessageSignedForDispatchOrder(
435
443
  uint256 evvmID,
436
- uint256 _nonce,
437
- address _tokenA,
438
- address _tokenB,
439
- uint256 _orderId
440
- ) internal pure returns (bytes32 messageHash) {
444
+ address servicePointer,
445
+ address originExecutor,
446
+ uint256 nonce,
447
+ address tokenA,
448
+ address tokenB,
449
+ uint256 orderId
450
+ ) internal pure returns (bytes32) {
451
+ return
452
+ buildHashForSign(
453
+ AdvancedStrings.buildSignaturePayload(
454
+ evvmID,
455
+ servicePointer,
456
+ P2PSwapHashUtils.hashDataForDispatchOrder(
457
+ tokenA,
458
+ tokenB,
459
+ orderId
460
+ ),
461
+ originExecutor,
462
+ nonce,
463
+ true
464
+ )
465
+ );
466
+ }
467
+
468
+ //-----------------------------------------------------------------------------------
469
+ // nonceConsumer functions
470
+ //-----------------------------------------------------------------------------------
471
+
472
+ function buildMessageSignedForStateTest(
473
+ uint256 evvmID,
474
+ address servicePointer,
475
+ string memory testA,
476
+ uint256 testB,
477
+ address testC,
478
+ bool testD,
479
+ address originExecutor,
480
+ uint256 nonce,
481
+ bool isAsyncExec
482
+ ) internal pure returns (bytes32) {
441
483
  return
442
484
  buildHashForSign(
443
- string.concat(
444
- AdvancedStrings.uintToString(evvmID),
445
- ",",
446
- "dispatchOrder",
447
- ",",
448
- AdvancedStrings.uintToString(_nonce),
449
- ",",
450
- AdvancedStrings.addressToString(_tokenA),
451
- ",",
452
- AdvancedStrings.addressToString(_tokenB),
453
- ",",
454
- AdvancedStrings.uintToString(_orderId)
485
+ AdvancedStrings.buildSignaturePayload(
486
+ evvmID,
487
+ servicePointer,
488
+ keccak256(
489
+ abi.encode("StateTest", testA, testB, testC, testD)
490
+ ),
491
+ originExecutor,
492
+ nonce,
493
+ isAsyncExec
455
494
  )
456
495
  );
457
496
  }
@@ -460,6 +499,12 @@ library Erc191TestBuilder {
460
499
  // General functions
461
500
  //-----------------------------------------------------------------------------------
462
501
 
502
+ /**
503
+ * @notice Creates an EIP-191 formatted hash from a message string
504
+ * @dev Prepends the Ethereum Signed Message prefix and message length
505
+ * @param messageToSign The message string to hash
506
+ * @return The EIP-191 formatted hash ready for signature verification
507
+ */
463
508
  function buildHashForSign(
464
509
  string memory messageToSign
465
510
  ) internal pure returns (bytes32) {
@@ -473,6 +518,14 @@ library Erc191TestBuilder {
473
518
  );
474
519
  }
475
520
 
521
+ /**
522
+ * @notice Combines signature components into a 65-byte signature
523
+ * @dev Packs r, s, and v into the standard EIP-191 signature format
524
+ * @param v Recovery identifier (27 or 28)
525
+ * @param r First 32 bytes of the signature
526
+ * @param s Second 32 bytes of the signature
527
+ * @return 65-byte encoded signature in (r, s, v) format
528
+ */
476
529
  function buildERC191Signature(
477
530
  uint8 v,
478
531
  bytes32 r,