@evvm/testnet-contracts 1.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 (34) hide show
  1. package/LICENSE +166 -0
  2. package/README.md +216 -0
  3. package/package.json +51 -0
  4. package/src/contracts/evvm/Evvm.sol +1327 -0
  5. package/src/contracts/evvm/EvvmLegacy.sol +1553 -0
  6. package/src/contracts/evvm/lib/ErrorsLib.sol +17 -0
  7. package/src/contracts/evvm/lib/EvvmStorage.sol +60 -0
  8. package/src/contracts/evvm/lib/EvvmStructs.sol +64 -0
  9. package/src/contracts/evvm/lib/SignatureUtils.sol +124 -0
  10. package/src/contracts/nameService/NameService.sol +1751 -0
  11. package/src/contracts/nameService/lib/ErrorsLib.sol +27 -0
  12. package/src/contracts/nameService/lib/SignatureUtils.sol +239 -0
  13. package/src/contracts/staking/Estimator.sol +358 -0
  14. package/src/contracts/staking/Staking.sol +1148 -0
  15. package/src/contracts/staking/lib/ErrorsLib.sol +19 -0
  16. package/src/contracts/staking/lib/SignatureUtils.sol +68 -0
  17. package/src/contracts/treasury/Treasury.sol +104 -0
  18. package/src/contracts/treasury/lib/ErrorsLib.sol +11 -0
  19. package/src/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +551 -0
  20. package/src/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +512 -0
  21. package/src/contracts/treasuryTwoChains/lib/ErrorsLib.sol +15 -0
  22. package/src/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +41 -0
  23. package/src/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +52 -0
  24. package/src/contracts/treasuryTwoChains/lib/SignatureUtils.sol +47 -0
  25. package/src/interfaces/IEstimator.sol +102 -0
  26. package/src/interfaces/IEvvm.sol +195 -0
  27. package/src/interfaces/INameService.sol +283 -0
  28. package/src/interfaces/IStaking.sol +202 -0
  29. package/src/interfaces/ITreasury.sol +17 -0
  30. package/src/interfaces/ITreasuryExternalChainStation.sol +262 -0
  31. package/src/interfaces/ITreasuryHostChainStation.sol +251 -0
  32. package/src/lib/AdvancedStrings.sol +77 -0
  33. package/src/lib/Erc191TestBuilder.sol +402 -0
  34. package/src/lib/SignatureRecover.sol +56 -0
@@ -0,0 +1,102 @@
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
+ interface IEstimator {
7
+ struct AddressTypeProposal {
8
+ address actual;
9
+ address proposal;
10
+ uint256 timeToAccept;
11
+ }
12
+
13
+ struct EpochMetadata {
14
+ address tokenPool;
15
+ uint256 totalPool;
16
+ uint256 totalStaked;
17
+ uint256 tFinal;
18
+ uint256 tStart;
19
+ }
20
+
21
+ function acceptActivatorProposal() external;
22
+
23
+ function acceptAddressStakingProposal() external;
24
+
25
+ function acceptAdminProposal() external;
26
+
27
+ function acceptEvvmAddressProposal() external;
28
+
29
+ function cancelActivatorProposal() external;
30
+
31
+ function cancelAddressStakingProposal() external;
32
+
33
+ function cancelAdminProposal() external;
34
+
35
+ function cancelEvvmAddressProposal() external;
36
+
37
+ function getActivatorMetadata()
38
+ external
39
+ view
40
+ returns (AddressTypeProposal memory);
41
+
42
+ function getActualEpochInFormat() external view returns (bytes32);
43
+
44
+ function getActualEpochInUint() external view returns (uint256);
45
+
46
+ function getAddressStakingMetadata()
47
+ external
48
+ view
49
+ returns (AddressTypeProposal memory);
50
+
51
+ function getAdminMetadata()
52
+ external
53
+ view
54
+ returns (AddressTypeProposal memory);
55
+
56
+ function getEpochMetadata() external view returns (EpochMetadata memory);
57
+
58
+ function getEvvmAddressMetadata()
59
+ external
60
+ view
61
+ returns (AddressTypeProposal memory);
62
+
63
+ function makeEstimation(
64
+ address _user
65
+ )
66
+ external
67
+ returns (
68
+ bytes32 epochAnswer,
69
+ address tokenAddress,
70
+ uint256 amountTotalToBeRewarded,
71
+ uint256 idToOverwrite,
72
+ uint256 timestampToOverwrite
73
+ );
74
+
75
+ function notifyNewEpoch(
76
+ address tokenPool,
77
+ uint256 totalPool,
78
+ uint256 totalStaked,
79
+ uint256 tStart
80
+ ) external;
81
+
82
+ function setActivatorProposal(address _proposal) external;
83
+
84
+ function setAddressStakingProposal(address _proposal) external;
85
+
86
+ function setAdminProposal(address _proposal) external;
87
+
88
+ function setEvvmAddressProposal(address _proposal) external;
89
+
90
+ function simulteEstimation(
91
+ address _user
92
+ )
93
+ external
94
+ view
95
+ returns (
96
+ bytes32 epochAnswer,
97
+ address tokenAddress,
98
+ uint256 amountTotalToBeRewarded,
99
+ uint256 idToOverwrite,
100
+ uint256 timestampToOverwrite
101
+ );
102
+ }
@@ -0,0 +1,195 @@
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
+ library EvvmStructs {
7
+ struct DisperseCaPayMetadata {
8
+ uint256 amount;
9
+ address toAddress;
10
+ }
11
+
12
+ struct DispersePayMetadata {
13
+ uint256 amount;
14
+ address to_address;
15
+ string to_identity;
16
+ }
17
+
18
+ struct EvvmMetadata {
19
+ string EvvmName;
20
+ uint256 EvvmID;
21
+ string principalTokenName;
22
+ string principalTokenSymbol;
23
+ address principalTokenAddress;
24
+ uint256 totalSupply;
25
+ uint256 eraTokens;
26
+ uint256 reward;
27
+ }
28
+
29
+ struct PayData {
30
+ address from;
31
+ address to_address;
32
+ string to_identity;
33
+ address token;
34
+ uint256 amount;
35
+ uint256 priorityFee;
36
+ uint256 nonce;
37
+ bool priorityFlag;
38
+ address executor;
39
+ bytes signature;
40
+ }
41
+ }
42
+
43
+ interface IEvvm {
44
+ error InsufficientBalance();
45
+ error InvalidAmount(uint256, uint256);
46
+ error InvalidAsyncNonce();
47
+ error InvalidSignature();
48
+ error NotAnCA();
49
+ error SenderIsNotTheExecutor();
50
+ error SenderIsNotTreasury();
51
+ error UpdateBalanceFailed();
52
+ error WindowToChangeEvvmIDExpired();
53
+
54
+ fallback() external;
55
+
56
+ function _setupNameServiceAndTreasuryAddress(
57
+ address _nameServiceAddress,
58
+ address _treasuryAddress
59
+ ) external;
60
+
61
+ function acceptAdmin() external;
62
+
63
+ function acceptImplementation() external;
64
+
65
+ function addAmountToUser(
66
+ address user,
67
+ address token,
68
+ uint256 amount
69
+ ) external;
70
+
71
+ function addBalance(address user, address token, uint256 quantity) external;
72
+
73
+ function caPay(address to, address token, uint256 amount) external;
74
+
75
+ function disperseCaPay(
76
+ EvvmStructs.DisperseCaPayMetadata[] memory toData,
77
+ address token,
78
+ uint256 amount
79
+ ) external;
80
+
81
+ function dispersePay(
82
+ address from,
83
+ EvvmStructs.DispersePayMetadata[] memory toData,
84
+ address token,
85
+ uint256 amount,
86
+ uint256 priorityFee,
87
+ uint256 nonce,
88
+ bool priorityFlag,
89
+ address executor,
90
+ bytes memory signature
91
+ ) external;
92
+
93
+ function getBalance(
94
+ address user,
95
+ address token
96
+ ) external view returns (uint256);
97
+
98
+ function getCurrentAdmin() external view returns (address);
99
+
100
+ function getCurrentImplementation() external view returns (address);
101
+
102
+ function getEraPrincipalToken() external view returns (uint256);
103
+
104
+ function getEvvmID() external view returns (uint256);
105
+
106
+ function getEvvmMetadata()
107
+ external
108
+ view
109
+ returns (EvvmStructs.EvvmMetadata memory);
110
+
111
+ function getIfUsedAsyncNonce(
112
+ address user,
113
+ uint256 nonce
114
+ ) external view returns (bool);
115
+
116
+ function getNameServiceAddress() external view returns (address);
117
+
118
+ function getNextCurrentSyncNonce(
119
+ address user
120
+ ) external view returns (uint256);
121
+
122
+ function getNextFisherDepositNonce(
123
+ address user
124
+ ) external view returns (uint256);
125
+
126
+ function getPrincipalTokenTotalSupply() external view returns (uint256);
127
+
128
+ function getProposalAdmin() external view returns (address);
129
+
130
+ function getProposalImplementation() external view returns (address);
131
+
132
+ function getRewardAmount() external view returns (uint256);
133
+
134
+ function getStakingContractAddress() external view returns (address);
135
+
136
+ function getTimeToAcceptAdmin() external view returns (uint256);
137
+
138
+ function getTimeToAcceptImplementation() external view returns (uint256);
139
+
140
+ function getWhitelistTokenToBeAdded() external view returns (address);
141
+
142
+ function getWhitelistTokenToBeAddedDateToSet()
143
+ external
144
+ view
145
+ returns (uint256);
146
+
147
+ function isAddressStaker(address user) external view returns (bool);
148
+
149
+ function pay(
150
+ address from,
151
+ address to_address,
152
+ string memory to_identity,
153
+ address token,
154
+ uint256 amount,
155
+ uint256 priorityFee,
156
+ uint256 nonce,
157
+ bool priorityFlag,
158
+ address executor,
159
+ bytes memory signature
160
+ ) external;
161
+
162
+ function payMultiple(
163
+ EvvmStructs.PayData[] memory payData
164
+ )
165
+ external
166
+ returns (
167
+ uint256 successfulTransactions,
168
+ uint256 failedTransactions,
169
+ bool[] memory results
170
+ );
171
+
172
+ function pointStaker(address user, bytes1 answer) external;
173
+
174
+ function proposeAdmin(address _newOwner) external;
175
+
176
+ function proposeImplementation(address _newImpl) external;
177
+
178
+ function recalculateReward() external;
179
+
180
+ function rejectProposalAdmin() external;
181
+
182
+ function rejectUpgrade() external;
183
+
184
+ function removeAmountFromUser(
185
+ address user,
186
+ address token,
187
+ uint256 amount
188
+ ) external;
189
+
190
+ function setEvvmID(uint256 newEvvmID) external;
191
+
192
+ function setNameServiceAddress(address _nameServiceAddress) external;
193
+
194
+ function setPointStaker(address user, bytes1 answer) external;
195
+ }
@@ -0,0 +1,283 @@
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
+ interface INameService {
7
+ struct OfferMetadata {
8
+ address offerer;
9
+ uint256 expireDate;
10
+ uint256 amount;
11
+ }
12
+
13
+ error AcceptOfferVerificationFailed();
14
+ error EmptyCustomMetadata();
15
+ error FlushUsernameVerificationFailed();
16
+ error InvalidKey();
17
+ error InvalidSignatureOnNameService();
18
+ error InvalidUsername(bytes1);
19
+ error NonceAlreadyUsed();
20
+ error PreRegistrationNotValid();
21
+ error RenewUsernameVerificationFailed();
22
+ error SenderIsNotAdmin();
23
+ error UserIsNotOwnerOfIdentity();
24
+ error UserIsNotOwnerOfOffer();
25
+ error UsernameAlreadyRegistered();
26
+
27
+ function acceptChangeEvvmAddress() external;
28
+
29
+ function acceptOffer(
30
+ address user,
31
+ string memory username,
32
+ uint256 offerID,
33
+ uint256 nonce,
34
+ bytes memory signature,
35
+ uint256 priorityFee_EVVM,
36
+ uint256 nonce_EVVM,
37
+ bool priorityFlag_EVVM,
38
+ bytes memory signature_EVVM
39
+ ) external;
40
+
41
+ function acceptProposeAdmin() external;
42
+
43
+ function addCustomMetadata(
44
+ address user,
45
+ string memory identity,
46
+ string memory value,
47
+ uint256 nonce,
48
+ bytes memory signature,
49
+ uint256 priorityFee_EVVM,
50
+ uint256 nonce_EVVM,
51
+ bool priorityFlag_EVVM,
52
+ bytes memory signature_EVVM
53
+ ) external;
54
+
55
+ function cancelChangeEvvmAddress() external;
56
+
57
+ function cancelProposeAdmin() external;
58
+
59
+ function cancelWithdrawPrincipalTokens() external;
60
+
61
+ function checkIfNameServiceNonceIsAvailable(
62
+ address _user,
63
+ uint256 _nonce
64
+ ) external view returns (bool);
65
+
66
+ function claimWithdrawPrincipalTokens() external;
67
+
68
+ function flushCustomMetadata(
69
+ address user,
70
+ string memory identity,
71
+ uint256 nonce,
72
+ bytes memory signature,
73
+ uint256 priorityFee_EVVM,
74
+ uint256 nonce_EVVM,
75
+ bool priorityFlag_EVVM,
76
+ bytes memory signature_EVVM
77
+ ) external;
78
+
79
+ function flushUsername(
80
+ address user,
81
+ string memory username,
82
+ uint256 nonce,
83
+ bytes memory signature,
84
+ uint256 priorityFee_EVVM,
85
+ uint256 nonce_EVVM,
86
+ bool priorityFlag_EVVM,
87
+ bytes memory signature_EVVM
88
+ ) external;
89
+
90
+ function getAdmin() external view returns (address);
91
+
92
+ function getAdminFullDetails()
93
+ external
94
+ view
95
+ returns (
96
+ address currentAdmin,
97
+ address proposalAdmin,
98
+ uint256 timeToAcceptAdmin
99
+ );
100
+
101
+ function getAmountOfCustomMetadata(
102
+ string memory _username
103
+ ) external view returns (uint256);
104
+
105
+ function getCustomMetadataMaxSlotsOfIdentity(
106
+ string memory _username
107
+ ) external view returns (uint256);
108
+
109
+ function getEvvmAddress() external view returns (address);
110
+
111
+ function getEvvmAddressFullDetails()
112
+ external
113
+ view
114
+ returns (
115
+ address currentEvvmAddress,
116
+ address proposalEvvmAddress,
117
+ uint256 timeToAcceptEvvmAddress
118
+ );
119
+
120
+ function getExpireDateOfIdentity(
121
+ string memory _identity
122
+ ) external view returns (uint256);
123
+
124
+ function getFullCustomMetadataOfIdentity(
125
+ string memory _username
126
+ ) external view returns (string[] memory);
127
+
128
+ function getIdentityBasicMetadata(
129
+ string memory _username
130
+ ) external view returns (address, uint256);
131
+
132
+ function getLengthOfOffersUsername(
133
+ string memory _username
134
+ ) external view returns (uint256 length);
135
+
136
+ function getOffersOfUsername(
137
+ string memory _username
138
+ ) external view returns (OfferMetadata[] memory offers);
139
+
140
+ function getOwnerOfIdentity(
141
+ string memory _username
142
+ ) external view returns (address);
143
+
144
+ function getPricePerRegistration() external view returns (uint256);
145
+
146
+ function getPriceToAddCustomMetadata()
147
+ external
148
+ view
149
+ returns (uint256 price);
150
+
151
+ function getPriceToFlushCustomMetadata(
152
+ string memory _identity
153
+ ) external view returns (uint256 price);
154
+
155
+ function getPriceToFlushUsername(
156
+ string memory _identity
157
+ ) external view returns (uint256 price);
158
+
159
+ function getPriceToRemoveCustomMetadata()
160
+ external
161
+ view
162
+ returns (uint256 price);
163
+
164
+ function getProposedWithdrawAmountFullDetails()
165
+ external
166
+ view
167
+ returns (
168
+ uint256 proposalAmountToWithdrawTokens,
169
+ uint256 timeToAcceptAmountToWithdrawTokens
170
+ );
171
+
172
+ function getSingleCustomMetadataOfIdentity(
173
+ string memory _username,
174
+ uint256 _key
175
+ ) external view returns (string memory);
176
+
177
+ function getSingleOfferOfUsername(
178
+ string memory _username,
179
+ uint256 _offerID
180
+ ) external view returns (OfferMetadata memory offer);
181
+
182
+ function hashUsername(
183
+ string memory _username,
184
+ uint256 _randomNumber
185
+ ) external pure returns (bytes32);
186
+
187
+ function isUsernameAvailable(
188
+ string memory _username
189
+ ) external view returns (bool);
190
+
191
+ function makeOffer(
192
+ address user,
193
+ string memory username,
194
+ uint256 expireDate,
195
+ uint256 amount,
196
+ uint256 nonce,
197
+ bytes memory signature,
198
+ uint256 priorityFee_EVVM,
199
+ uint256 nonce_EVVM,
200
+ bool priorityFlag_EVVM,
201
+ bytes memory signature_EVVM
202
+ ) external returns (uint256 offerID);
203
+
204
+ function preRegistrationUsername(
205
+ address user,
206
+ bytes32 hashPreRegisteredUsername,
207
+ uint256 nonce,
208
+ bytes memory signature,
209
+ uint256 priorityFee_EVVM,
210
+ uint256 nonce_EVVM,
211
+ bool priorityFlag_EVVM,
212
+ bytes memory signature_EVVM
213
+ ) external;
214
+
215
+ function proposeAdmin(address _adminToPropose) external;
216
+
217
+ function proposeChangeEvvmAddress(address _newEvvmAddress) external;
218
+
219
+ function proposeWithdrawPrincipalTokens(uint256 _amount) external;
220
+
221
+ function registrationUsername(
222
+ address user,
223
+ string memory username,
224
+ uint256 clowNumber,
225
+ uint256 nonce,
226
+ bytes memory signature,
227
+ uint256 priorityFee_EVVM,
228
+ uint256 nonce_EVVM,
229
+ bool priorityFlag_EVVM,
230
+ bytes memory signature_EVVM
231
+ ) external;
232
+
233
+ function removeCustomMetadata(
234
+ address user,
235
+ string memory identity,
236
+ uint256 key,
237
+ uint256 nonce,
238
+ bytes memory signature,
239
+ uint256 priorityFee_EVVM,
240
+ uint256 nonce_EVVM,
241
+ bool priorityFlag_EVVM,
242
+ bytes memory signature_EVVM
243
+ ) external;
244
+
245
+ function renewUsername(
246
+ address user,
247
+ string memory username,
248
+ uint256 nonce,
249
+ bytes memory signature,
250
+ uint256 priorityFee_EVVM,
251
+ uint256 nonce_EVVM,
252
+ bool priorityFlag_EVVM,
253
+ bytes memory signature_EVVM
254
+ ) external;
255
+
256
+ function seePriceToRenew(
257
+ string memory _identity
258
+ ) external view returns (uint256 price);
259
+
260
+ function strictVerifyIfIdentityExist(
261
+ string memory _username
262
+ ) external view returns (bool);
263
+
264
+ function verifyIfIdentityExists(
265
+ string memory _identity
266
+ ) external view returns (bool);
267
+
268
+ function verifyStrictAndGetOwnerOfIdentity(
269
+ string memory _username
270
+ ) external view returns (address answer);
271
+
272
+ function withdrawOffer(
273
+ address user,
274
+ string memory username,
275
+ uint256 offerID,
276
+ uint256 nonce,
277
+ bytes memory signature,
278
+ uint256 priorityFee_EVVM,
279
+ uint256 nonce_EVVM,
280
+ bool priorityFlag_EVVM,
281
+ bytes memory signature_EVVM
282
+ ) external;
283
+ }