@evvm/testnet-contracts 2.2.0 → 2.2.2
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.
- package/LICENSE +2 -2
- package/README.md +46 -521
- package/contracts/evvm/Evvm.sol +28 -31
- package/contracts/evvm/lib/ErrorsLib.sol +2 -1
- package/contracts/evvm/lib/EvvmStructs.sol +27 -1
- package/contracts/evvm/lib/SignatureUtils.sol +2 -5
- package/contracts/nameService/NameService.sol +118 -363
- package/contracts/nameService/lib/ErrorsLib.sol +1 -7
- package/contracts/nameService/lib/IdentityValidation.sol +182 -0
- package/contracts/nameService/lib/NameServiceStructs.sol +69 -0
- package/contracts/nameService/lib/SignatureUtils.sol +11 -4
- package/contracts/p2pSwap/P2PSwap.sol +41 -154
- package/contracts/p2pSwap/lib/P2PSwapStructs.sol +59 -0
- package/contracts/p2pSwap/lib/SignatureUtils.sol +1 -2
- package/contracts/staking/Estimator.sol +7 -6
- package/contracts/staking/Staking.sol +46 -146
- package/contracts/staking/lib/SignatureUtils.sol +1 -2
- package/contracts/staking/lib/StakingStructs.sol +94 -0
- package/contracts/treasury/Treasury.sol +18 -20
- package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +88 -35
- package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +81 -47
- package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +2 -0
- package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +3 -14
- package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +3 -7
- package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +5 -7
- package/interfaces/IEstimator.sol +7 -50
- package/interfaces/IEvvm.sol +16 -90
- package/interfaces/INameService.sol +37 -88
- package/interfaces/IP2PSwap.sol +19 -15
- package/interfaces/IStaking.sol +20 -50
- package/interfaces/ITreasury.sol +1 -4
- package/interfaces/ITreasuryExternalChainStation.sol +11 -15
- package/interfaces/ITreasuryHostChainStation.sol +7 -10
- package/library/Erc191TestBuilder.sol +0 -1
- package/library/EvvmService.sol +14 -78
- package/library/primitives/IERC20.sol +79 -0
- package/library/utils/GovernanceUtils.sol +81 -0
- package/library/utils/{service/AsyncNonceService.sol → nonces/AsyncNonce.sol} +9 -11
- package/library/utils/nonces/SyncNonce.sol +27 -0
- package/library/utils/service/EvvmPayments.sol +77 -0
- package/library/utils/service/StakingServiceUtils.sol +15 -20
- package/package.json +11 -13
- package/library/utils/service/MakeServicePaymentOnEvvm.sol +0 -49
- package/library/utils/service/SyncNonceService.sol +0 -18
package/contracts/evvm/Evvm.sol
CHANGED
|
@@ -146,7 +146,7 @@ contract Evvm is EvvmStorage {
|
|
|
146
146
|
EvvmMetadata memory _evvmMetadata
|
|
147
147
|
) {
|
|
148
148
|
evvmMetadata = _evvmMetadata;
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
stakingContractAddress = _stakingContractAddress;
|
|
151
151
|
|
|
152
152
|
admin.current = _initialOwner;
|
|
@@ -158,8 +158,6 @@ contract Evvm is EvvmStorage {
|
|
|
158
158
|
stakerList[_stakingContractAddress] = FLAG_IS_STAKER;
|
|
159
159
|
|
|
160
160
|
breakerSetupNameServiceAddress = FLAG_IS_STAKER;
|
|
161
|
-
|
|
162
|
-
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
/**
|
|
@@ -367,20 +365,23 @@ contract Evvm is EvvmStorage {
|
|
|
367
365
|
token,
|
|
368
366
|
amount,
|
|
369
367
|
priorityFee,
|
|
370
|
-
|
|
368
|
+
nonce,
|
|
371
369
|
priorityFlag,
|
|
372
370
|
executor,
|
|
373
371
|
signature
|
|
374
372
|
)
|
|
375
373
|
) revert ErrorsLib.InvalidSignature();
|
|
376
374
|
|
|
377
|
-
if (executor != address(0))
|
|
378
|
-
|
|
379
|
-
revert ErrorsLib.SenderIsNotTheExecutor();
|
|
380
|
-
}
|
|
375
|
+
if ((executor != address(0)) && (msg.sender != executor))
|
|
376
|
+
revert ErrorsLib.SenderIsNotTheExecutor();
|
|
381
377
|
|
|
382
|
-
if (priorityFlag
|
|
383
|
-
|
|
378
|
+
if (priorityFlag) {
|
|
379
|
+
if (asyncUsedNonce[from][nonce])
|
|
380
|
+
revert ErrorsLib.AsyncNonceAlreadyUsed();
|
|
381
|
+
} else {
|
|
382
|
+
if (nextSyncUsedNonce[from] != nonce)
|
|
383
|
+
revert ErrorsLib.SyncNonceMismatch();
|
|
384
|
+
}
|
|
384
385
|
|
|
385
386
|
address to = !AdvancedStrings.equal(to_identity, "")
|
|
386
387
|
? NameService(nameServiceAddress).verifyStrictAndGetOwnerOfIdentity(
|
|
@@ -425,24 +426,15 @@ contract Evvm is EvvmStorage {
|
|
|
425
426
|
*
|
|
426
427
|
* Return Values:
|
|
427
428
|
* - successfulTransactions: Count of completed payments
|
|
428
|
-
* - failedTransactions: Count of failed payments
|
|
429
429
|
* - results: Boolean array indicating success/failure for each payment
|
|
430
430
|
*
|
|
431
431
|
* @param payData Array of PayData structures containing payment details
|
|
432
432
|
* @return successfulTransactions Number of payments that completed successfully
|
|
433
|
-
* @return failedTransactions Number of payments that failed
|
|
434
433
|
* @return results Boolean array with success status for each payment
|
|
435
434
|
*/
|
|
436
435
|
function payMultiple(
|
|
437
436
|
PayData[] memory payData
|
|
438
|
-
)
|
|
439
|
-
external
|
|
440
|
-
returns (
|
|
441
|
-
uint256 successfulTransactions,
|
|
442
|
-
uint256 failedTransactions,
|
|
443
|
-
bool[] memory results
|
|
444
|
-
)
|
|
445
|
-
{
|
|
437
|
+
) external returns (uint256 successfulTransactions, bool[] memory results) {
|
|
446
438
|
address to_aux;
|
|
447
439
|
results = new bool[](payData.length);
|
|
448
440
|
for (uint256 iteration = 0; iteration < payData.length; iteration++) {
|
|
@@ -455,9 +447,7 @@ contract Evvm is EvvmStorage {
|
|
|
455
447
|
payData[iteration].token,
|
|
456
448
|
payData[iteration].amount,
|
|
457
449
|
payData[iteration].priorityFee,
|
|
458
|
-
payData[iteration].
|
|
459
|
-
? payData[iteration].nonce
|
|
460
|
-
: nextSyncUsedNonce[payData[iteration].from],
|
|
450
|
+
payData[iteration].nonce,
|
|
461
451
|
payData[iteration].priorityFlag,
|
|
462
452
|
payData[iteration].executor,
|
|
463
453
|
payData[iteration].signature
|
|
@@ -466,7 +456,6 @@ contract Evvm is EvvmStorage {
|
|
|
466
456
|
|
|
467
457
|
if (payData[iteration].executor != address(0)) {
|
|
468
458
|
if (msg.sender != payData[iteration].executor) {
|
|
469
|
-
failedTransactions++;
|
|
470
459
|
results[iteration] = false;
|
|
471
460
|
continue;
|
|
472
461
|
}
|
|
@@ -484,7 +473,6 @@ contract Evvm is EvvmStorage {
|
|
|
484
473
|
payData[iteration].nonce
|
|
485
474
|
] = true;
|
|
486
475
|
} else {
|
|
487
|
-
failedTransactions++;
|
|
488
476
|
results[iteration] = false;
|
|
489
477
|
continue;
|
|
490
478
|
}
|
|
@@ -497,7 +485,6 @@ contract Evvm is EvvmStorage {
|
|
|
497
485
|
) {
|
|
498
486
|
nextSyncUsedNonce[payData[iteration].from]++;
|
|
499
487
|
} else {
|
|
500
|
-
failedTransactions++;
|
|
501
488
|
results[iteration] = false;
|
|
502
489
|
continue;
|
|
503
490
|
}
|
|
@@ -514,7 +501,6 @@ contract Evvm is EvvmStorage {
|
|
|
514
501
|
payData[iteration].priorityFee + payData[iteration].amount >
|
|
515
502
|
balances[payData[iteration].from][payData[iteration].token]
|
|
516
503
|
) {
|
|
517
|
-
failedTransactions++;
|
|
518
504
|
results[iteration] = false;
|
|
519
505
|
continue;
|
|
520
506
|
}
|
|
@@ -527,7 +513,6 @@ contract Evvm is EvvmStorage {
|
|
|
527
513
|
payData[iteration].amount
|
|
528
514
|
)
|
|
529
515
|
) {
|
|
530
|
-
failedTransactions++;
|
|
531
516
|
results[iteration] = false;
|
|
532
517
|
continue;
|
|
533
518
|
} else {
|
|
@@ -543,7 +528,6 @@ contract Evvm is EvvmStorage {
|
|
|
543
528
|
payData[iteration].priorityFee
|
|
544
529
|
)
|
|
545
530
|
) {
|
|
546
|
-
failedTransactions++;
|
|
547
531
|
results[iteration] = false;
|
|
548
532
|
continue;
|
|
549
533
|
}
|
|
@@ -609,7 +593,7 @@ contract Evvm is EvvmStorage {
|
|
|
609
593
|
token,
|
|
610
594
|
amount,
|
|
611
595
|
priorityFee,
|
|
612
|
-
|
|
596
|
+
nonce,
|
|
613
597
|
priorityFlag,
|
|
614
598
|
executor,
|
|
615
599
|
signature
|
|
@@ -623,7 +607,10 @@ contract Evvm is EvvmStorage {
|
|
|
623
607
|
|
|
624
608
|
if (priorityFlag) {
|
|
625
609
|
if (asyncUsedNonce[from][nonce])
|
|
626
|
-
revert ErrorsLib.
|
|
610
|
+
revert ErrorsLib.AsyncNonceAlreadyUsed();
|
|
611
|
+
} else {
|
|
612
|
+
if (nextSyncUsedNonce[from] != nonce)
|
|
613
|
+
revert ErrorsLib.SyncNonceMismatch();
|
|
627
614
|
}
|
|
628
615
|
|
|
629
616
|
if (balances[from][token] < amount + priorityFee)
|
|
@@ -667,6 +654,7 @@ contract Evvm is EvvmStorage {
|
|
|
667
654
|
} else {
|
|
668
655
|
nextSyncUsedNonce[from]++;
|
|
669
656
|
}
|
|
657
|
+
|
|
670
658
|
}
|
|
671
659
|
|
|
672
660
|
/**
|
|
@@ -773,6 +761,7 @@ contract Evvm is EvvmStorage {
|
|
|
773
761
|
if (isAddressStaker(msg.sender)) {
|
|
774
762
|
_giveReward(msg.sender, 1);
|
|
775
763
|
}
|
|
764
|
+
|
|
776
765
|
}
|
|
777
766
|
|
|
778
767
|
//░▒▓█Treasury exclusive functions██████████████████████████████████████████▓▒░
|
|
@@ -1136,6 +1125,14 @@ contract Evvm is EvvmStorage {
|
|
|
1136
1125
|
return evvmMetadata;
|
|
1137
1126
|
}
|
|
1138
1127
|
|
|
1128
|
+
function getPrincipalTokenAddress() external view returns (address) {
|
|
1129
|
+
return evvmMetadata.principalTokenAddress;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
function getChainHostCoinAddress() external pure returns (address) {
|
|
1133
|
+
return address(0);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1139
1136
|
/**
|
|
1140
1137
|
* @notice Gets the unique identifier string for this EVVM instance
|
|
1141
1138
|
* @dev Returns the EvvmID used for distinguishing different EVVM deployments
|
|
@@ -7,7 +7,8 @@ library ErrorsLib {
|
|
|
7
7
|
error InvalidSignature();
|
|
8
8
|
error SenderIsNotTheExecutor();
|
|
9
9
|
error UpdateBalanceFailed();
|
|
10
|
-
error
|
|
10
|
+
error SyncNonceMismatch();
|
|
11
|
+
error AsyncNonceAlreadyUsed();
|
|
11
12
|
error NotAnStaker();
|
|
12
13
|
error InsufficientBalance();
|
|
13
14
|
error InvalidAmount(uint256, uint256);
|
|
@@ -28,6 +28,32 @@ abstract contract EvvmStructs {
|
|
|
28
28
|
bytes signature;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
struct DispersePayData {
|
|
32
|
+
address from;
|
|
33
|
+
DispersePayMetadata[] toData;
|
|
34
|
+
address token;
|
|
35
|
+
uint256 totalAmount;
|
|
36
|
+
uint256 priorityFee;
|
|
37
|
+
uint256 nonce;
|
|
38
|
+
bool priorityFlag;
|
|
39
|
+
address executor;
|
|
40
|
+
bytes signature;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
struct CaPayData {
|
|
44
|
+
address from;
|
|
45
|
+
address to;
|
|
46
|
+
address token;
|
|
47
|
+
uint256 amount;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
struct DisperseCaPayData{
|
|
51
|
+
address from;
|
|
52
|
+
DisperseCaPayMetadata[] toData;
|
|
53
|
+
address token;
|
|
54
|
+
uint256 amount;
|
|
55
|
+
}
|
|
56
|
+
|
|
31
57
|
struct DispersePayMetadata {
|
|
32
58
|
uint256 amount;
|
|
33
59
|
address to_address;
|
|
@@ -38,7 +64,7 @@ abstract contract EvvmStructs {
|
|
|
38
64
|
uint256 amount;
|
|
39
65
|
address toAddress;
|
|
40
66
|
}
|
|
41
|
-
|
|
67
|
+
|
|
42
68
|
struct EvvmMetadata {
|
|
43
69
|
string EvvmName;
|
|
44
70
|
uint256 EvvmID;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
2
|
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
3
4
|
|
|
4
5
|
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
5
6
|
import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
6
7
|
|
|
7
|
-
pragma solidity ^0.8.0;
|
|
8
|
-
|
|
9
8
|
library SignatureUtils {
|
|
10
9
|
/**
|
|
11
10
|
* @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
|
|
@@ -13,7 +12,6 @@ library SignatureUtils {
|
|
|
13
12
|
* by the users
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* @notice This function is used to verify the message signed for the payment
|
|
19
17
|
* @param signer user who signed the message
|
|
@@ -119,5 +117,4 @@ library SignatureUtils {
|
|
|
119
117
|
signer
|
|
120
118
|
);
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
}
|
|
120
|
+
}
|