@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.
- package/README.md +44 -24
- package/contracts/core/Core.sol +1392 -0
- package/contracts/core/lib/CoreStorage.sol +171 -0
- package/contracts/nameService/NameService.sol +613 -543
- package/contracts/nameService/lib/IdentityValidation.sol +15 -21
- package/contracts/p2pSwap/P2PSwap.sol +258 -145
- package/contracts/staking/Estimator.sol +25 -44
- package/contracts/staking/Staking.sol +284 -262
- package/contracts/treasury/Treasury.sol +40 -47
- package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +585 -198
- package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +425 -174
- package/contracts/treasuryTwoChains/lib/PayloadUtils.sol +2 -4
- package/interfaces/{IEvvm.sol → ICore.sol} +58 -25
- package/interfaces/IEstimator.sol +1 -1
- package/interfaces/INameService.sol +46 -49
- package/interfaces/IP2PSwap.sol +16 -17
- package/interfaces/IStaking.sol +21 -17
- package/interfaces/ITreasury.sol +2 -1
- package/interfaces/ITreasuryExternalChainStation.sol +15 -9
- package/interfaces/ITreasuryHostChainStation.sol +14 -11
- package/interfaces/IUserValidator.sol +6 -0
- package/library/Erc191TestBuilder.sol +336 -471
- package/library/EvvmService.sol +27 -71
- package/library/errors/CoreError.sol +116 -0
- package/library/errors/CrossChainTreasuryError.sol +36 -0
- package/library/errors/NameServiceError.sol +79 -0
- package/library/errors/StakingError.sol +79 -0
- package/{contracts/treasury/lib/ErrorsLib.sol → library/errors/TreasuryError.sol} +9 -17
- package/library/structs/CoreStructs.sol +146 -0
- package/library/structs/ExternalChainStationStructs.sol +92 -0
- package/library/structs/HostChainStationStructs.sol +77 -0
- package/library/structs/NameServiceStructs.sol +47 -0
- package/library/structs/P2PSwapStructs.sol +127 -0
- package/library/structs/StakingStructs.sol +67 -0
- package/library/utils/AdvancedStrings.sol +62 -44
- package/library/utils/CAUtils.sol +29 -0
- package/library/utils/governance/Admin.sol +66 -0
- package/library/utils/governance/ProposalStructs.sol +49 -0
- package/library/utils/service/CoreExecution.sol +158 -0
- package/library/utils/service/StakingServiceUtils.sol +20 -37
- package/library/utils/signature/CoreHashUtils.sol +73 -0
- package/library/utils/signature/NameServiceHashUtils.sol +156 -0
- package/library/utils/signature/P2PSwapHashUtils.sol +65 -0
- package/library/utils/signature/StakingHashUtils.sol +41 -0
- package/library/utils/signature/TreasuryCrossChainHashUtils.sol +40 -0
- package/package.json +1 -1
- package/contracts/evvm/Evvm.sol +0 -1300
- package/contracts/evvm/lib/ErrorsLib.sol +0 -131
- package/contracts/evvm/lib/EvvmStorage.sol +0 -217
- package/contracts/evvm/lib/EvvmStructs.sol +0 -208
- package/contracts/evvm/lib/SignatureUtils.sol +0 -162
- package/contracts/nameService/lib/ErrorsLib.sol +0 -155
- package/contracts/nameService/lib/NameServiceStructs.sol +0 -125
- package/contracts/nameService/lib/SignatureUtils.sol +0 -420
- package/contracts/p2pSwap/lib/P2PSwapStructs.sol +0 -59
- package/contracts/p2pSwap/lib/SignatureUtils.sol +0 -98
- package/contracts/staking/lib/ErrorsLib.sol +0 -98
- package/contracts/staking/lib/SignatureUtils.sol +0 -105
- package/contracts/staking/lib/StakingStructs.sol +0 -106
- package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +0 -48
- package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +0 -80
- package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +0 -87
- package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +0 -79
- package/library/utils/GovernanceUtils.sol +0 -81
- package/library/utils/nonces/AsyncNonce.sol +0 -74
- package/library/utils/nonces/SyncNonce.sol +0 -71
- package/library/utils/service/EvvmPayments.sol +0 -144
|
@@ -1,71 +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 SyncNonce
|
|
7
|
-
* @author Mate Labs
|
|
8
|
-
* @notice Abstract contract for synchronous (sequential) nonce management in EVVM services
|
|
9
|
-
* @dev Provides replay protection using a sequential nonce system where nonces must be
|
|
10
|
-
* used in strict ascending order starting from 0.
|
|
11
|
-
*
|
|
12
|
-
* Key Features:
|
|
13
|
-
* - Sequential nonce enforcement (must use nonce N before N+1)
|
|
14
|
-
* - Gas-efficient single uint256 counter per user
|
|
15
|
-
* - Guarantees transaction ordering
|
|
16
|
-
*
|
|
17
|
-
* Use Cases:
|
|
18
|
-
* - Operations requiring strict ordering guarantees
|
|
19
|
-
* - Financial transactions where sequence matters
|
|
20
|
-
* - State-dependent operations that must execute in order
|
|
21
|
-
*
|
|
22
|
-
* Trade-offs:
|
|
23
|
-
* - Cannot submit parallel transactions (must wait for confirmation)
|
|
24
|
-
* - Transaction N+1 cannot be mined before transaction N
|
|
25
|
-
*
|
|
26
|
-
* This contract is designed for use by community-developed services that need
|
|
27
|
-
* strict sequential ordering for their operations.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
abstract contract SyncNonce {
|
|
31
|
-
/// @dev Thrown when the provided nonce does not match the expected next nonce
|
|
32
|
-
error SyncNonceMismatch();
|
|
33
|
-
|
|
34
|
-
/// @dev Mapping to track the next expected nonce for each user
|
|
35
|
-
mapping(address user => uint256 nonce) private syncNonce;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @notice Increments the nonce counter for a user after successful operation
|
|
39
|
-
* @dev Should be called after operation validation to advance the nonce
|
|
40
|
-
* @param user Address of the user whose nonce counter should be incremented
|
|
41
|
-
*/
|
|
42
|
-
function incrementSyncNonce(address user) internal virtual {
|
|
43
|
-
syncNonce[user]++;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @notice Verifies that the provided nonce matches the expected next nonce
|
|
48
|
-
* @dev Reverts with SyncNonceMismatch if the nonce is not the expected value
|
|
49
|
-
* @param user Address of the user to verify the nonce for
|
|
50
|
-
* @param nonce The nonce value to verify
|
|
51
|
-
* @custom:throws SyncNonceMismatch If nonce does not match the expected value
|
|
52
|
-
*/
|
|
53
|
-
function verifySyncNonce(
|
|
54
|
-
address user,
|
|
55
|
-
uint256 nonce
|
|
56
|
-
) internal view virtual {
|
|
57
|
-
if (syncNonce[user] != nonce) revert SyncNonceMismatch();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @notice Gets the current (next expected) nonce for a user
|
|
62
|
-
* @dev Public view function for external queries and transaction preparation
|
|
63
|
-
* @param user Address of the user to query
|
|
64
|
-
* @return The next nonce value that must be used by the user
|
|
65
|
-
*/
|
|
66
|
-
function getNextCurrentSyncNonce(
|
|
67
|
-
address user
|
|
68
|
-
) public view virtual returns (uint256) {
|
|
69
|
-
return syncNonce[user];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,144 +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 EvvmPayments
|
|
7
|
-
* @author Mate Labs
|
|
8
|
-
* @notice Abstract contract providing EVVM payment integration for services
|
|
9
|
-
* @dev This contract provides a standardized interface for interacting with
|
|
10
|
-
* the EVVM core contract for payment operations. It supports:
|
|
11
|
-
*
|
|
12
|
-
* Payment Types:
|
|
13
|
-
* - Single payments (pay): Transfer tokens from a user to the service
|
|
14
|
-
* - Disperse payments (dispersePay): Batch payments from multiple sources
|
|
15
|
-
* - Contract-authorized payments (caPay): Service-initiated token distributions
|
|
16
|
-
* - Disperse CA payments: Batch service-initiated distributions
|
|
17
|
-
*
|
|
18
|
-
* This contract is designed for use by community-developed services that need
|
|
19
|
-
* to process payments through the EVVM ecosystem.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import {IEvvm, EvvmStructs} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
|
|
23
|
-
|
|
24
|
-
abstract contract EvvmPayments {
|
|
25
|
-
/// @dev Reference to the EVVM core contract for payment operations
|
|
26
|
-
IEvvm internal evvm;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @notice Initializes the EvvmPayments contract with the EVVM address
|
|
30
|
-
* @param evvmAddress Address of the EVVM core contract
|
|
31
|
-
*/
|
|
32
|
-
constructor(address evvmAddress) {
|
|
33
|
-
evvm = IEvvm(evvmAddress);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @notice Requests a payment from a user to this contract
|
|
38
|
-
* @dev Calls the EVVM pay function to transfer tokens with signature verification
|
|
39
|
-
* @param from Address of the user making the payment
|
|
40
|
-
* @param token Address of the token being transferred
|
|
41
|
-
* @param amount Amount of tokens to transfer
|
|
42
|
-
* @param priorityFee Additional fee for priority processing
|
|
43
|
-
* @param nonce Nonce for replay protection in EVVM
|
|
44
|
-
* @param priorityFlag True for async nonce, false for sync nonce in EVVM
|
|
45
|
-
* @param signature EIP-191 signature authorizing the payment
|
|
46
|
-
*/
|
|
47
|
-
function requestPay(
|
|
48
|
-
address from,
|
|
49
|
-
address token,
|
|
50
|
-
uint256 amount,
|
|
51
|
-
uint256 priorityFee,
|
|
52
|
-
uint256 nonce,
|
|
53
|
-
bool priorityFlag,
|
|
54
|
-
bytes memory signature
|
|
55
|
-
) internal virtual {
|
|
56
|
-
evvm.pay(
|
|
57
|
-
from,
|
|
58
|
-
address(this),
|
|
59
|
-
"",
|
|
60
|
-
token,
|
|
61
|
-
amount,
|
|
62
|
-
priorityFee,
|
|
63
|
-
nonce,
|
|
64
|
-
priorityFlag,
|
|
65
|
-
address(this),
|
|
66
|
-
signature
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @notice Requests a batch payment from the caller to multiple recipients
|
|
72
|
-
* @dev Calls the EVVM dispersePay function for efficient batch transfers
|
|
73
|
-
* @param toData Array of recipient addresses and amounts
|
|
74
|
-
* @param token Address of the token being transferred
|
|
75
|
-
* @param amount Total amount being transferred (for signature verification)
|
|
76
|
-
* @param priorityFee Additional fee for priority processing
|
|
77
|
-
* @param nonce Nonce for replay protection in EVVM
|
|
78
|
-
* @param priorityFlag True for async nonce, false for sync nonce in EVVM
|
|
79
|
-
* @param signature EIP-191 signature authorizing the batch payment
|
|
80
|
-
*/
|
|
81
|
-
function requestDispersePay(
|
|
82
|
-
EvvmStructs.DispersePayMetadata[] memory toData,
|
|
83
|
-
address token,
|
|
84
|
-
uint256 amount,
|
|
85
|
-
uint256 priorityFee,
|
|
86
|
-
uint256 nonce,
|
|
87
|
-
bool priorityFlag,
|
|
88
|
-
bytes memory signature
|
|
89
|
-
) internal virtual {
|
|
90
|
-
evvm.dispersePay(
|
|
91
|
-
address(this),
|
|
92
|
-
toData,
|
|
93
|
-
token,
|
|
94
|
-
amount,
|
|
95
|
-
priorityFee,
|
|
96
|
-
nonce,
|
|
97
|
-
priorityFlag,
|
|
98
|
-
address(this),
|
|
99
|
-
signature
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @notice Sends tokens from this contract to a recipient (contract-authorized)
|
|
105
|
-
* @dev Calls the EVVM caPay function for service-initiated token transfers.
|
|
106
|
-
* This function does not require user signature as it's authorized by the contract.
|
|
107
|
-
* @param to Address of the recipient
|
|
108
|
-
* @param token Address of the token to transfer
|
|
109
|
-
* @param amount Amount of tokens to transfer
|
|
110
|
-
*/
|
|
111
|
-
function makeCaPay(
|
|
112
|
-
address to,
|
|
113
|
-
address token,
|
|
114
|
-
uint256 amount
|
|
115
|
-
) internal virtual {
|
|
116
|
-
evvm.caPay(to, token, amount);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @notice Sends tokens from this contract to multiple recipients (batch CA pay)
|
|
121
|
-
* @dev Calls the EVVM disperseCaPay for efficient batch distributions.
|
|
122
|
-
* This function does not require user signatures.
|
|
123
|
-
* @param toData Array of recipient addresses and amounts
|
|
124
|
-
* @param token Address of the token to transfer
|
|
125
|
-
* @param amount Total amount being distributed
|
|
126
|
-
*/
|
|
127
|
-
function makeDisperseCaPay(
|
|
128
|
-
EvvmStructs.DisperseCaPayMetadata[] memory toData,
|
|
129
|
-
address token,
|
|
130
|
-
uint256 amount
|
|
131
|
-
) internal virtual {
|
|
132
|
-
evvm.disperseCaPay(toData, token, amount);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @notice Updates the EVVM contract address
|
|
137
|
-
* @dev Internal function for governance-controlled EVVM address changes.
|
|
138
|
-
* Should be protected by time-delayed governance in implementing contracts.
|
|
139
|
-
* @param newEvvmAddress Address of the new EVVM contract
|
|
140
|
-
*/
|
|
141
|
-
function _changeEvvmAddress(address newEvvmAddress) internal virtual {
|
|
142
|
-
evvm = IEvvm(newEvvmAddress);
|
|
143
|
-
}
|
|
144
|
-
}
|