@evvm/testnet-contracts 2.3.0 → 3.0.1

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 (67) hide show
  1. package/README.md +44 -24
  2. package/contracts/core/Core.sol +1392 -0
  3. package/contracts/core/lib/CoreStorage.sol +171 -0
  4. package/contracts/nameService/NameService.sol +613 -543
  5. package/contracts/nameService/lib/IdentityValidation.sol +15 -21
  6. package/contracts/p2pSwap/P2PSwap.sol +258 -145
  7. package/contracts/staking/Estimator.sol +25 -44
  8. package/contracts/staking/Staking.sol +284 -262
  9. package/contracts/treasury/Treasury.sol +40 -47
  10. package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +585 -198
  11. package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +425 -174
  12. package/contracts/treasuryTwoChains/lib/PayloadUtils.sol +2 -4
  13. package/interfaces/{IEvvm.sol → ICore.sol} +58 -25
  14. package/interfaces/IEstimator.sol +1 -1
  15. package/interfaces/INameService.sol +46 -49
  16. package/interfaces/IP2PSwap.sol +16 -17
  17. package/interfaces/IStaking.sol +21 -17
  18. package/interfaces/ITreasury.sol +2 -1
  19. package/interfaces/ITreasuryExternalChainStation.sol +15 -9
  20. package/interfaces/ITreasuryHostChainStation.sol +14 -11
  21. package/interfaces/IUserValidator.sol +6 -0
  22. package/library/Erc191TestBuilder.sol +336 -471
  23. package/library/EvvmService.sol +27 -71
  24. package/library/errors/CoreError.sol +116 -0
  25. package/library/errors/CrossChainTreasuryError.sol +36 -0
  26. package/library/errors/NameServiceError.sol +79 -0
  27. package/library/errors/StakingError.sol +79 -0
  28. package/{contracts/treasury/lib/ErrorsLib.sol → library/errors/TreasuryError.sol} +9 -17
  29. package/library/structs/CoreStructs.sol +146 -0
  30. package/library/structs/ExternalChainStationStructs.sol +92 -0
  31. package/library/structs/HostChainStationStructs.sol +77 -0
  32. package/library/structs/NameServiceStructs.sol +47 -0
  33. package/library/structs/P2PSwapStructs.sol +127 -0
  34. package/library/structs/StakingStructs.sol +67 -0
  35. package/library/utils/AdvancedStrings.sol +62 -44
  36. package/library/utils/CAUtils.sol +29 -0
  37. package/library/utils/governance/Admin.sol +66 -0
  38. package/library/utils/governance/ProposalStructs.sol +49 -0
  39. package/library/utils/service/CoreExecution.sol +158 -0
  40. package/library/utils/service/StakingServiceUtils.sol +20 -37
  41. package/library/utils/signature/CoreHashUtils.sol +73 -0
  42. package/library/utils/signature/NameServiceHashUtils.sol +156 -0
  43. package/library/utils/signature/P2PSwapHashUtils.sol +65 -0
  44. package/library/utils/signature/StakingHashUtils.sol +41 -0
  45. package/library/utils/signature/TreasuryCrossChainHashUtils.sol +40 -0
  46. package/package.json +1 -1
  47. package/contracts/evvm/Evvm.sol +0 -1300
  48. package/contracts/evvm/lib/ErrorsLib.sol +0 -131
  49. package/contracts/evvm/lib/EvvmStorage.sol +0 -217
  50. package/contracts/evvm/lib/EvvmStructs.sol +0 -208
  51. package/contracts/evvm/lib/SignatureUtils.sol +0 -162
  52. package/contracts/nameService/lib/ErrorsLib.sol +0 -155
  53. package/contracts/nameService/lib/NameServiceStructs.sol +0 -125
  54. package/contracts/nameService/lib/SignatureUtils.sol +0 -420
  55. package/contracts/p2pSwap/lib/P2PSwapStructs.sol +0 -59
  56. package/contracts/p2pSwap/lib/SignatureUtils.sol +0 -98
  57. package/contracts/staking/lib/ErrorsLib.sol +0 -98
  58. package/contracts/staking/lib/SignatureUtils.sol +0 -105
  59. package/contracts/staking/lib/StakingStructs.sol +0 -106
  60. package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +0 -48
  61. package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +0 -80
  62. package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +0 -87
  63. package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +0 -79
  64. package/library/utils/GovernanceUtils.sol +0 -81
  65. package/library/utils/nonces/AsyncNonce.sol +0 -74
  66. package/library/utils/nonces/SyncNonce.sol +0 -71
  67. package/library/utils/service/EvvmPayments.sol +0 -144
@@ -1,420 +0,0 @@
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
- import {
6
- SignatureUtil
7
- } from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
8
- import {
9
- AdvancedStrings
10
- } from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
11
-
12
- /**
13
- * @title SignatureUtils
14
- * @author Mate labs
15
- * @notice Library for EIP-191 signature verification exclusively for NameService.sol operations
16
- * @dev This library provides signature verification utilities for all NameService.sol operations,
17
- * including username registration, marketplace offers, custom metadata management, and
18
- * administrative functions. It constructs deterministic message formats and validates signatures.
19
- *
20
- * Signature Verification:
21
- * - Uses EIP-191 standard for message signing and verification
22
- * - Constructs deterministic message strings from operation parameters
23
- * - Integrates with SignatureUtil for cryptographic verification
24
- * - Prevents replay attacks through nonce inclusion
25
- * - Supports cross-chain safety through EvvmID inclusion
26
- *
27
- * Operation Types:
28
- * - Registration: preRegistrationUsername, registrationUsername
29
- * - Marketplace: makeOffer, withdrawOffer, acceptOffer
30
- * - Renewal: renewUsername
31
- * - Metadata: addCustomMetadata, removeCustomMetadata, flushCustomMetadata
32
- * - Management: flushUsername
33
- *
34
- * @custom:scope Exclusive to NameService.sol operations
35
- * @custom:standard EIP-191 (https://eips.ethereum.org/EIPS/eip-191)
36
- * @custom:security All signatures include EvvmID to prevent cross-chain replay attacks
37
- */
38
- library SignatureUtils {
39
-
40
- /**
41
- * @notice Verifies EIP-191 signature for username pre-registration operations
42
- * @dev Constructs message from hash and nonce, verifies against signer
43
- *
44
- * Message Format: "[hashUsername],[nameServiceNonce]"
45
- * Used in: preRegistrationUsername function
46
- *
47
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
48
- * @param signer Address that signed the message (user pre-registering)
49
- * @param hashUsername Keccak256 hash of username + random number for commitment
50
- * @param nameServiceNonce Transaction nonce for replay protection
51
- * @param signature EIP-191 signature from the signer
52
- * @return bool True if the signature is valid and matches the signer
53
- */
54
- function verifyMessageSignedForPreRegistrationUsername(
55
- uint256 evvmID,
56
- address signer,
57
- bytes32 hashUsername,
58
- uint256 nameServiceNonce,
59
- bytes memory signature
60
- ) internal pure returns (bool) {
61
- return
62
- SignatureUtil.verifySignature(
63
- evvmID,
64
- "preRegistrationUsername",
65
- string.concat(
66
- AdvancedStrings.bytes32ToString(hashUsername),
67
- ",",
68
- AdvancedStrings.uintToString(nameServiceNonce)
69
- ),
70
- signature,
71
- signer
72
- );
73
- }
74
-
75
- /**
76
- * @notice Verifies EIP-191 signature for username registration operations
77
- * @dev Constructs message from username, random number, and nonce
78
- *
79
- * Message Format: "[username],[clowNumber],[nameServiceNonce]"
80
- * Used in: registrationUsername function
81
- * Reveals the username from pre-registration commitment
82
- *
83
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
84
- * @param signer Address that signed the message (user registering)
85
- * @param username The actual username being registered
86
- * @param clowNumber Random number used in pre-registration hash
87
- * @param nameServiceNonce Transaction nonce for replay protection
88
- * @param signature EIP-191 signature from the signer
89
- * @return bool True if the signature is valid and matches the signer
90
- */
91
- function verifyMessageSignedForRegistrationUsername(
92
- uint256 evvmID,
93
- address signer,
94
- string memory username,
95
- uint256 clowNumber,
96
- uint256 nameServiceNonce,
97
- bytes memory signature
98
- ) internal pure returns (bool) {
99
- return
100
- SignatureUtil.verifySignature(
101
- evvmID,
102
- "registrationUsername",
103
- string.concat(
104
- username,
105
- ",",
106
- AdvancedStrings.uintToString(clowNumber),
107
- ",",
108
- AdvancedStrings.uintToString(nameServiceNonce)
109
- ),
110
- signature,
111
- signer
112
- );
113
- }
114
-
115
- /**
116
- * @notice Verifies EIP-191 signature for creating marketplace offers
117
- * @dev Constructs message from username, expiration, amount, and nonce
118
- *
119
- * Message Format: "[username],[dateExpire],[amount],[nameServiceNonce]"
120
- * Used in: makeOffer function
121
- *
122
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
123
- * @param signer Address that signed the message (offerer)
124
- * @param username Target username for the offer
125
- * @param dateExpire Timestamp when the offer expires
126
- * @param amount Amount being offered in Principal Tokens
127
- * @param nameServiceNonce Transaction nonce for replay protection
128
- * @param signature EIP-191 signature from the signer
129
- * @return bool True if the signature is valid and matches the signer
130
- */
131
- function verifyMessageSignedForMakeOffer(
132
- uint256 evvmID,
133
- address signer,
134
- string memory username,
135
- uint256 dateExpire,
136
- uint256 amount,
137
- uint256 nameServiceNonce,
138
- bytes memory signature
139
- ) internal pure returns (bool) {
140
- return
141
- SignatureUtil.verifySignature(
142
- evvmID,
143
- "makeOffer",
144
- string.concat(
145
- username,
146
- ",",
147
- AdvancedStrings.uintToString(dateExpire),
148
- ",",
149
- AdvancedStrings.uintToString(amount),
150
- ",",
151
- AdvancedStrings.uintToString(nameServiceNonce)
152
- ),
153
- signature,
154
- signer
155
- );
156
- }
157
-
158
- /**
159
- * @notice Verifies EIP-191 signature for withdrawing marketplace offers
160
- * @dev Constructs message from username, offer ID, and nonce
161
- *
162
- * Message Format: "[username],[offerId],[nameServiceNonce]"
163
- * Used in: withdrawOffer function
164
- *
165
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
166
- * @param signer Address that signed the message (offerer withdrawing)
167
- * @param username Username the offer was made for
168
- * @param offerId Unique identifier of the offer to withdraw
169
- * @param nameServiceNonce Transaction nonce for replay protection
170
- * @param signature EIP-191 signature from the signer
171
- * @return bool True if the signature is valid and matches the signer
172
- */
173
- function verifyMessageSignedForWithdrawOffer(
174
- uint256 evvmID,
175
- address signer,
176
- string memory username,
177
- uint256 offerId,
178
- uint256 nameServiceNonce,
179
- bytes memory signature
180
- ) internal pure returns (bool) {
181
- return
182
- SignatureUtil.verifySignature(
183
- evvmID,
184
- "withdrawOffer",
185
- string.concat(
186
- username,
187
- ",",
188
- AdvancedStrings.uintToString(offerId),
189
- ",",
190
- AdvancedStrings.uintToString(nameServiceNonce)
191
- ),
192
- signature,
193
- signer
194
- );
195
- }
196
-
197
- /**
198
- * @notice Verifies EIP-191 signature for accepting marketplace offers
199
- * @dev Constructs message from username, offer ID, and nonce
200
- *
201
- * Message Format: "[username],[offerId],[nameServiceNonce]"
202
- * Used in: acceptOffer function
203
- *
204
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
205
- * @param signer Address that signed the message (username owner accepting)
206
- * @param username Username being sold
207
- * @param offerId Unique identifier of the offer to accept
208
- * @param nameServiceNonce Transaction nonce for replay protection
209
- * @param signature EIP-191 signature from the signer
210
- * @return bool True if the signature is valid and matches the signer
211
- */
212
- function verifyMessageSignedForAcceptOffer(
213
- uint256 evvmID,
214
- address signer,
215
- string memory username,
216
- uint256 offerId,
217
- uint256 nameServiceNonce,
218
- bytes memory signature
219
- ) internal pure returns (bool) {
220
- return
221
- SignatureUtil.verifySignature(
222
- evvmID,
223
- "acceptOffer",
224
- string.concat(
225
- username,
226
- ",",
227
- AdvancedStrings.uintToString(offerId),
228
- ",",
229
- AdvancedStrings.uintToString(nameServiceNonce)
230
- ),
231
- signature,
232
- signer
233
- );
234
- }
235
-
236
- /**
237
- * @notice Verifies EIP-191 signature for username renewal operations
238
- * @dev Constructs message from username and nonce
239
- *
240
- * Message Format: "[username],[nameServiceNonce]"
241
- * Used in: renewUsername function
242
- *
243
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
244
- * @param signer Address that signed the message (username owner)
245
- * @param username Username to renew
246
- * @param nameServiceNonce Transaction nonce for replay protection
247
- * @param signature EIP-191 signature from the signer
248
- * @return bool True if the signature is valid and matches the signer
249
- */
250
- function verifyMessageSignedForRenewUsername(
251
- uint256 evvmID,
252
- address signer,
253
- string memory username,
254
- uint256 nameServiceNonce,
255
- bytes memory signature
256
- ) internal pure returns (bool) {
257
- return
258
- SignatureUtil.verifySignature(
259
- evvmID,
260
- "renewUsername",
261
- string.concat(
262
- username,
263
- ",",
264
- AdvancedStrings.uintToString(nameServiceNonce)
265
- ),
266
- signature,
267
- signer
268
- );
269
- }
270
-
271
- /**
272
- * @notice Verifies EIP-191 signature for adding custom metadata to identity
273
- * @dev Constructs message from identity, metadata value, and nonce
274
- *
275
- * Message Format: "[identity],[value],[nameServiceNonce]"
276
- * Used in: addCustomMetadata function
277
- *
278
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
279
- * @param signer Address that signed the message (identity owner)
280
- * @param identity Username/identity to add metadata to
281
- * @param value Metadata value in format: [schema]:[subschema]>[value]
282
- * @param nameServiceNonce Transaction nonce for replay protection
283
- * @param signature EIP-191 signature from the signer
284
- * @return bool True if the signature is valid and matches the signer
285
- */
286
- function verifyMessageSignedForAddCustomMetadata(
287
- uint256 evvmID,
288
- address signer,
289
- string memory identity,
290
- string memory value,
291
- uint256 nameServiceNonce,
292
- bytes memory signature
293
- ) internal pure returns (bool) {
294
- return
295
- SignatureUtil.verifySignature(
296
- evvmID,
297
- "addCustomMetadata",
298
- string.concat(
299
- identity,
300
- ",",
301
- value,
302
- ",",
303
- AdvancedStrings.uintToString(nameServiceNonce)
304
- ),
305
- signature,
306
- signer
307
- );
308
- }
309
-
310
- /**
311
- * @notice Verifies EIP-191 signature for removing custom metadata from username
312
- * @dev Constructs message from username, metadata key, and nonce
313
- *
314
- * Message Format: "[username],[key],[nonce]"
315
- * Used in: removeCustomMetadata function
316
- *
317
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
318
- * @param signer Address that signed the message (username owner)
319
- * @param username Username to remove metadata from
320
- * @param key Index of the metadata entry to remove
321
- * @param nonce Transaction nonce for replay protection
322
- * @param signature EIP-191 signature from the signer
323
- * @return bool True if the signature is valid and matches the signer
324
- */
325
- function verifyMessageSignedForRemoveCustomMetadata(
326
- uint256 evvmID,
327
- address signer,
328
- string memory username,
329
- uint256 key,
330
- uint256 nonce,
331
- bytes memory signature
332
- ) internal pure returns (bool) {
333
- return
334
- SignatureUtil.verifySignature(
335
- evvmID,
336
- "removeCustomMetadata",
337
- string.concat(
338
- username,
339
- ",",
340
- AdvancedStrings.uintToString(key),
341
- ",",
342
- AdvancedStrings.uintToString(nonce)
343
- ),
344
- signature,
345
- signer
346
- );
347
- }
348
-
349
- /**
350
- * @notice Verifies EIP-191 signature for flushing all custom metadata from identity
351
- * @dev Constructs message from identity and nonce
352
- *
353
- * Message Format: "[identity],[nonce]"
354
- * Used in: flushCustomMetadata function
355
- * Removes all custom metadata entries at once
356
- *
357
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
358
- * @param signer Address that signed the message (identity owner)
359
- * @param identity Username/identity to flush metadata from
360
- * @param nonce Transaction nonce for replay protection
361
- * @param signature EIP-191 signature from the signer
362
- * @return bool True if the signature is valid and matches the signer
363
- */
364
- function verifyMessageSignedForFlushCustomMetadata(
365
- uint256 evvmID,
366
- address signer,
367
- string memory identity,
368
- uint256 nonce,
369
- bytes memory signature
370
- ) internal pure returns (bool) {
371
- return
372
- SignatureUtil.verifySignature(
373
- evvmID,
374
- "flushCustomMetadata",
375
- string.concat(
376
- identity,
377
- ",",
378
- AdvancedStrings.uintToString(nonce)
379
- ),
380
- signature,
381
- signer
382
- );
383
- }
384
-
385
- /**
386
- * @notice Verifies EIP-191 signature for flushing/deleting a username entirely
387
- * @dev Constructs message from username and nonce
388
- *
389
- * Message Format: "[username],[nonce]"
390
- * Used in: flushUsername function
391
- * Permanently removes username and all associated data
392
- *
393
- * @param evvmID Unique identifier of the EVVM instance for cross-chain safety
394
- * @param signer Address that signed the message (username owner)
395
- * @param username Username to flush/delete
396
- * @param nonce Transaction nonce for replay protection
397
- * @param signature EIP-191 signature from the signer
398
- * @return bool True if the signature is valid and matches the signer
399
- */
400
- function verifyMessageSignedForFlushUsername(
401
- uint256 evvmID,
402
- address signer,
403
- string memory username,
404
- uint256 nonce,
405
- bytes memory signature
406
- ) internal pure returns (bool) {
407
- return
408
- SignatureUtil.verifySignature(
409
- evvmID,
410
- "flushUsername",
411
- string.concat(
412
- username,
413
- ",",
414
- AdvancedStrings.uintToString(nonce)
415
- ),
416
- signature,
417
- signer
418
- );
419
- }
420
- }
@@ -1,59 +0,0 @@
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;
5
-
6
-
7
- abstract contract P2PSwapStructs {
8
- struct MarketInformation {
9
- address tokenA;
10
- address tokenB;
11
- uint256 maxSlot;
12
- uint256 ordersAvailable;
13
- }
14
-
15
- struct Order {
16
- address seller;
17
- uint256 amountA;
18
- uint256 amountB;
19
- }
20
-
21
- struct OrderForGetter {
22
- uint256 marketId;
23
- uint256 orderId;
24
- address seller;
25
- uint256 amountA;
26
- uint256 amountB;
27
- }
28
-
29
- struct Percentage {
30
- uint256 seller;
31
- uint256 service;
32
- uint256 mateStaker;
33
- }
34
-
35
- struct MetadataMakeOrder {
36
- uint256 nonce;
37
- address tokenA;
38
- address tokenB;
39
- uint256 amountA;
40
- uint256 amountB;
41
- }
42
-
43
- struct MetadataCancelOrder {
44
- uint256 nonce;
45
- address tokenA;
46
- address tokenB;
47
- uint256 orderId;
48
- bytes signature;
49
- }
50
-
51
- struct MetadataDispatchOrder {
52
- uint256 nonce;
53
- address tokenA;
54
- address tokenB;
55
- uint256 orderId;
56
- uint256 amountOfTokenBToFill;
57
- bytes signature;
58
- }
59
- }
@@ -1,98 +0,0 @@
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
- import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
6
- import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
7
-
8
- library SignatureUtils {
9
- /**
10
- * @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
11
- * verify messages, the next functions are used to verify the messages signed
12
- * by the users
13
- */
14
-
15
- function verifyMessageSignedForMakeOrder(
16
- uint256 evvmID,
17
- address signer,
18
- uint256 _nonce,
19
- address _tokenA,
20
- address _tokenB,
21
- uint256 _amountA,
22
- uint256 _amountB,
23
- bytes memory signature
24
- ) internal pure returns (bool) {
25
- return
26
- SignatureUtil.verifySignature(
27
- evvmID,
28
- "makeOrder",
29
- string.concat(
30
- AdvancedStrings.uintToString(_nonce),
31
- ",",
32
- AdvancedStrings.addressToString(_tokenA),
33
- ",",
34
- AdvancedStrings.addressToString(_tokenB),
35
- ",",
36
- AdvancedStrings.uintToString(_amountA),
37
- ",",
38
- AdvancedStrings.uintToString(_amountB)
39
- ),
40
- signature,
41
- signer
42
- );
43
- }
44
-
45
- function verifyMessageSignedForCancelOrder(
46
- uint256 evvmID,
47
- address signer,
48
- uint256 _nonce,
49
- address _tokenA,
50
- address _tokenB,
51
- uint256 _orderId,
52
- bytes memory signature
53
- ) internal pure returns (bool) {
54
- return
55
- SignatureUtil.verifySignature(
56
- evvmID,
57
- "cancelOrder",
58
- string.concat(
59
- AdvancedStrings.uintToString(_nonce),
60
- ",",
61
- AdvancedStrings.addressToString(_tokenA),
62
- ",",
63
- AdvancedStrings.addressToString(_tokenB),
64
- ",",
65
- AdvancedStrings.uintToString(_orderId)
66
- ),
67
- signature,
68
- signer
69
- );
70
- }
71
-
72
- function verifyMessageSignedForDispatchOrder(
73
- uint256 evvmID,
74
- address signer,
75
- uint256 _nonce,
76
- address _tokenA,
77
- address _tokenB,
78
- uint256 _orderId,
79
- bytes memory signature
80
- ) internal pure returns (bool) {
81
- return
82
- SignatureUtil.verifySignature(
83
- evvmID,
84
- "dispatchOrder",
85
- string.concat(
86
- AdvancedStrings.uintToString(_nonce),
87
- ",",
88
- AdvancedStrings.addressToString(_tokenA),
89
- ",",
90
- AdvancedStrings.addressToString(_tokenB),
91
- ",",
92
- AdvancedStrings.uintToString(_orderId)
93
- ),
94
- signature,
95
- signer
96
- );
97
- }
98
- }
@@ -1,98 +0,0 @@
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;
5
- /**
6
- * @title ErrorsLib
7
- * @author Mate Labs
8
- * @notice Library containing all custom error definitions for the Staking contract
9
- * @dev This library is exclusive to the Staking.sol contract and provides descriptive
10
- * error types for better gas efficiency and debugging compared to revert strings.
11
- *
12
- * Error Categories:
13
- * - Access Control: Permission and authorization errors
14
- * - Signature Verification: EIP-191 signature validation errors
15
- * - Presale Staking: Presale-specific staking limitations
16
- * - Public Staking: General staking state errors
17
- * - Service Staking: Smart contract (service) staking errors
18
- * - Time Lock: Time-delayed governance and cooldown errors
19
- */
20
-
21
- library ErrorsLib {
22
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
23
- /// Access Control Errors
24
- /// ▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
25
-
26
- /// @dev Thrown when a non-admin address attempts to call an admin-only function
27
- error SenderIsNotAdmin();
28
-
29
- /// @dev Thrown when a non-golden-fisher address attempts to call a golden fisher function
30
- error SenderIsNotGoldenFisher();
31
-
32
- /// @dev Thrown when a non-proposed-admin address attempts to accept an admin proposal
33
- error SenderIsNotProposedAdmin();
34
-
35
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
36
- /// Signature Verification Errors
37
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
38
-
39
- /// @dev Thrown when EIP-191 signature verification fails for a staking operation
40
- error InvalidSignatureOnStaking();
41
-
42
- /// @dev Thrown when attempting to use a nonce that has already been consumed
43
- error StakingNonceAlreadyUsed();
44
-
45
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
46
- /// Presale Staking Errors
47
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
48
-
49
- /// @dev Thrown when presale staking is attempted while disabled or when public staking is active
50
- error PresaleStakingDisabled();
51
-
52
- /// @dev Thrown when a presale user tries to stake more than the 2-staking limit
53
- error UserPresaleStakerLimitExceeded();
54
-
55
- /// @dev Thrown when a non-presale-registered address attempts presale staking
56
- error UserIsNotPresaleStaker();
57
-
58
- /// @dev Thrown when attempting to add more presale stakers beyond the 800 limit
59
- error LimitPresaleStakersExceeded();
60
-
61
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
62
- /// Public Staking Errors
63
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
64
-
65
- /// @dev Thrown when public staking is attempted while the feature is disabled
66
- error PublicStakingDisabled();
67
-
68
- ///Service Staking Errors
69
-
70
- /// @dev Thrown when a non-contract address attempts to call a service-only function
71
- error AddressIsNotAService();
72
-
73
- /// @dev Thrown when the user address doesn't match the service address in staking metadata
74
- error UserAndServiceMismatch();
75
-
76
- /// @dev Thrown when confirmServiceStaking is called by a different address than prepareServiceStaking
77
- error AddressMismatch();
78
-
79
- /// @dev Thrown when the payment amount doesn't match the required staking cost
80
- /// @param requiredAmount The exact amount of Principal Tokens that should have been transferred
81
- error ServiceDoesNotFulfillCorrectStakingAmount(uint256 requiredAmount);
82
-
83
- /// @dev Thrown when confirmServiceStaking is not called in the same transaction as prepareServiceStaking
84
- error ServiceDoesNotStakeInSameTx();
85
-
86
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
87
- /// Time Lock Errors
88
- ///▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
89
-
90
- /// @dev Thrown when a user attempts to stake before their cooldown period expires
91
- error AddressMustWaitToStakeAgain();
92
-
93
- /// @dev Thrown when a user attempts full unstaking before the 21-day lock period expires
94
- error AddressMustWaitToFullUnstake();
95
-
96
- /// @dev Thrown when attempting to accept a proposal before the time delay has passed
97
- error TimeToAcceptProposalNotReached();
98
- }