@evvm/testnet-contracts 2.1.3 → 2.2.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.
@@ -77,7 +77,7 @@ import {NameService} from "@evvm/testnet-contracts/contracts/nameService/NameSer
77
77
  import {EvvmStorage} from "@evvm/testnet-contracts/contracts/evvm/lib/EvvmStorage.sol";
78
78
  import {ErrorsLib} from "@evvm/testnet-contracts/contracts/evvm/lib/ErrorsLib.sol";
79
79
  import {SignatureUtils} from "@evvm/testnet-contracts/contracts/evvm/lib/SignatureUtils.sol";
80
- import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
80
+ import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
81
81
 
82
82
  contract Evvm is EvvmStorage {
83
83
  /**
@@ -145,6 +145,8 @@ contract Evvm is EvvmStorage {
145
145
  address _stakingContractAddress,
146
146
  EvvmMetadata memory _evvmMetadata
147
147
  ) {
148
+ evvmMetadata = _evvmMetadata;
149
+
148
150
  stakingContractAddress = _stakingContractAddress;
149
151
 
150
152
  admin.current = _initialOwner;
@@ -157,7 +159,7 @@ contract Evvm is EvvmStorage {
157
159
 
158
160
  breakerSetupNameServiceAddress = FLAG_IS_STAKER;
159
161
 
160
- evvmMetadata = _evvmMetadata;
162
+
161
163
  }
162
164
 
163
165
  /**
@@ -209,14 +211,14 @@ contract Evvm is EvvmStorage {
209
211
  * @dev Allows the admin to change the EVVM ID within a 1-day window after deployment
210
212
  */
211
213
  function setEvvmID(uint256 newEvvmID) external onlyAdmin {
212
- if (newEvvmID == 0) {
214
+ if (evvmMetadata.EvvmID != 0) {
213
215
  if (block.timestamp > windowTimeToChangeEvvmID)
214
216
  revert ErrorsLib.WindowToChangeEvvmIDExpired();
215
217
  }
216
218
 
217
219
  evvmMetadata.EvvmID = newEvvmID;
218
220
 
219
- windowTimeToChangeEvvmID = block.timestamp + 1 minutes;
221
+ windowTimeToChangeEvvmID = block.timestamp + 24 hours;
220
222
  }
221
223
 
222
224
  /**
@@ -380,7 +382,7 @@ contract Evvm is EvvmStorage {
380
382
  if (priorityFlag && asyncUsedNonce[from][nonce])
381
383
  revert ErrorsLib.InvalidAsyncNonce();
382
384
 
383
- address to = !Strings.equal(to_identity, "")
385
+ address to = !AdvancedStrings.equal(to_identity, "")
384
386
  ? NameService(nameServiceAddress).verifyStrictAndGetOwnerOfIdentity(
385
387
  to_identity
386
388
  )
@@ -501,7 +503,7 @@ contract Evvm is EvvmStorage {
501
503
  }
502
504
  }
503
505
 
504
- to_aux = !Strings.equal(payData[iteration].to_identity, "")
506
+ to_aux = !AdvancedStrings.equal(payData[iteration].to_identity, "")
505
507
  ? NameService(nameServiceAddress)
506
508
  .verifyStrictAndGetOwnerOfIdentity(
507
509
  payData[iteration].to_identity
@@ -633,7 +635,7 @@ contract Evvm is EvvmStorage {
633
635
  for (uint256 i = 0; i < toData.length; i++) {
634
636
  acomulatedAmount += toData[i].amount;
635
637
 
636
- if (!Strings.equal(toData[i].to_identity, "")) {
638
+ if (!AdvancedStrings.equal(toData[i].to_identity, "")) {
637
639
  if (
638
640
  NameService(nameServiceAddress).strictVerifyIfIdentityExist(
639
641
  toData[i].to_identity
@@ -950,7 +952,9 @@ contract Evvm is EvvmStorage {
950
952
  */
951
953
  function proposeImplementation(address _newImpl) external onlyAdmin {
952
954
  proposalImplementation = _newImpl;
953
- timeToAcceptImplementation = block.timestamp + 30 days;
955
+ timeToAcceptImplementation =
956
+ block.timestamp +
957
+ TIME_TO_ACCEPT_IMPLEMENTATION;
954
958
  }
955
959
 
956
960
  /**
@@ -999,7 +1003,7 @@ contract Evvm is EvvmStorage {
999
1003
  }
1000
1004
 
1001
1005
  admin.proposal = _newOwner;
1002
- admin.timeToAccept = block.timestamp + 1 minutes;
1006
+ admin.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
1003
1007
  }
1004
1008
 
1005
1009
  /**
@@ -20,6 +20,8 @@ import {EvvmStructs} from "./EvvmStructs.sol";
20
20
  abstract contract EvvmStorage is EvvmStructs {
21
21
  address constant ETH_ADDRESS = address(0);
22
22
  bytes1 constant FLAG_IS_STAKER = 0x01;
23
+ uint256 constant TIME_TO_ACCEPT_PROPOSAL = 1 days;
24
+ uint256 constant TIME_TO_ACCEPT_IMPLEMENTATION = 30 days;
23
25
 
24
26
  address nameServiceAddress;
25
27
 
@@ -1,9 +1,8 @@
1
1
  // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
2
  // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
3
 
4
- import {SignatureRecover} from "@evvm/testnet-contracts/library/SignatureRecover.sol";
5
- import {AdvancedStrings} from "@evvm/testnet-contracts/library/AdvancedStrings.sol";
6
- import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
4
+ import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
5
+ import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
7
6
 
8
7
  pragma solidity ^0.8.0;
9
8
 
@@ -14,6 +13,7 @@ library SignatureUtils {
14
13
  * by the users
15
14
  */
16
15
 
16
+
17
17
  /**
18
18
  * @notice This function is used to verify the message signed for the payment
19
19
  * @param signer user who signed the message
@@ -45,8 +45,8 @@ library SignatureUtils {
45
45
  bytes memory signature
46
46
  ) internal pure returns (bool) {
47
47
  return
48
- SignatureRecover.signatureVerification(
49
- Strings.toString(evvmID),
48
+ SignatureUtil.verifySignature(
49
+ evvmID,
50
50
  "pay",
51
51
  string.concat(
52
52
  _receiverAddress == address(0)
@@ -55,11 +55,11 @@ library SignatureUtils {
55
55
  ",",
56
56
  AdvancedStrings.addressToString(_token),
57
57
  ",",
58
- Strings.toString(_amount),
58
+ AdvancedStrings.uintToString(_amount),
59
59
  ",",
60
- Strings.toString(_priorityFee),
60
+ AdvancedStrings.uintToString(_priorityFee),
61
61
  ",",
62
- Strings.toString(_nonce),
62
+ AdvancedStrings.uintToString(_nonce),
63
63
  ",",
64
64
  _priorityFlag ? "true" : "false",
65
65
  ",",
@@ -97,19 +97,19 @@ library SignatureUtils {
97
97
  bytes memory signature
98
98
  ) internal pure returns (bool) {
99
99
  return
100
- SignatureRecover.signatureVerification(
101
- Strings.toString(evvmID),
100
+ SignatureUtil.verifySignature(
101
+ evvmID,
102
102
  "dispersePay",
103
103
  string.concat(
104
104
  AdvancedStrings.bytes32ToString(hashList),
105
105
  ",",
106
106
  AdvancedStrings.addressToString(_token),
107
107
  ",",
108
- Strings.toString(_amount),
108
+ AdvancedStrings.uintToString(_amount),
109
109
  ",",
110
- Strings.toString(_priorityFee),
110
+ AdvancedStrings.uintToString(_priorityFee),
111
111
  ",",
112
- Strings.toString(_nonce),
112
+ AdvancedStrings.uintToString(_nonce),
113
113
  ",",
114
114
  _priorityFlag ? "true" : "false",
115
115
  ",",
@@ -57,8 +57,7 @@ pragma solidity ^0.8.0;
57
57
  */
58
58
 
59
59
  import {Evvm} from "@evvm/testnet-contracts/contracts/evvm/Evvm.sol";
60
- import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
61
- import {AdvancedStrings} from "@evvm/testnet-contracts/library/AdvancedStrings.sol";
60
+ import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
62
61
  import {ErrorsLib} from "@evvm/testnet-contracts/contracts/nameService/lib/ErrorsLib.sol";
63
62
  import {SignatureUtils} from "@evvm/testnet-contracts/contracts/nameService/lib/SignatureUtils.sol";
64
63
 
@@ -129,6 +128,11 @@ contract NameService {
129
128
  uint256 amount;
130
129
  }
131
130
 
131
+ uint256 constant TIME_TO_ACCEPT_PROPOSAL = 1 days;
132
+
133
+ /// @dev Amount of Principal Tokens locked in pending marketplace offers
134
+ uint256 private principalTokenTokenLockedForWithdrawOffers;
135
+
132
136
  /// @dev Nested mapping: username => offer ID => offer details
133
137
  mapping(string username => mapping(uint256 id => OfferMetadata))
134
138
  private usernameOffers;
@@ -153,9 +157,6 @@ contract NameService {
153
157
  address private constant PRINCIPAL_TOKEN_ADDRESS =
154
158
  0x0000000000000000000000000000000000000001;
155
159
 
156
- /// @dev Amount of Principal Tokens locked in pending marketplace offers
157
- uint256 private principalTokenTokenLockedForWithdrawOffers;
158
-
159
160
  /// @dev Restricts function access to the current admin address only
160
161
  modifier onlyAdmin() {
161
162
  if (msg.sender != admin.current) revert ErrorsLib.SenderIsNotAdmin();
@@ -955,7 +956,7 @@ contract NameService {
955
956
  }
956
957
 
957
958
  admin.proposal = _adminToPropose;
958
- admin.timeToAccept = block.timestamp + 1 minutes;
959
+ admin.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
959
960
  }
960
961
 
961
962
  /**
@@ -1007,7 +1008,9 @@ contract NameService {
1007
1008
  }
1008
1009
 
1009
1010
  amountToWithdrawTokens.proposal = _amount;
1010
- amountToWithdrawTokens.timeToAccept = block.timestamp + 1 minutes;
1011
+ amountToWithdrawTokens.timeToAccept =
1012
+ block.timestamp +
1013
+ TIME_TO_ACCEPT_PROPOSAL;
1011
1014
  }
1012
1015
 
1013
1016
  /**
@@ -1046,7 +1049,7 @@ contract NameService {
1046
1049
  revert();
1047
1050
  }
1048
1051
  evvmAddress.proposal = _newEvvmAddress;
1049
- evvmAddress.timeToAccept = block.timestamp + 1 minutes;
1052
+ evvmAddress.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
1050
1053
  }
1051
1054
 
1052
1055
  /**
@@ -24,4 +24,4 @@ library ErrorsLib {
24
24
  error EmptyCustomMetadata();
25
25
  error InvalidKey();
26
26
  error FlushUsernameVerificationFailed();
27
- }
27
+ }
@@ -1,9 +1,8 @@
1
1
  // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
2
  // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
3
 
4
- import {SignatureRecover} from "@evvm/testnet-contracts/library/SignatureRecover.sol";
5
- import {AdvancedStrings} from "@evvm/testnet-contracts/library/AdvancedStrings.sol";
6
- import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
4
+ import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
5
+ import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
7
6
 
8
7
  pragma solidity ^0.8.0;
9
8
 
@@ -22,13 +21,13 @@ library SignatureUtils {
22
21
  bytes memory signature
23
22
  ) internal pure returns (bool) {
24
23
  return
25
- SignatureRecover.signatureVerification(
26
- Strings.toString(evvmID),
24
+ SignatureUtil.verifySignature(
25
+ evvmID,
27
26
  "preRegistrationUsername",
28
27
  string.concat(
29
28
  AdvancedStrings.bytes32ToString(_hashUsername),
30
29
  ",",
31
- Strings.toString(_nameServiceNonce)
30
+ AdvancedStrings.uintToString(_nameServiceNonce)
32
31
  ),
33
32
  signature,
34
33
  signer
@@ -44,15 +43,15 @@ library SignatureUtils {
44
43
  bytes memory signature
45
44
  ) internal pure returns (bool) {
46
45
  return
47
- SignatureRecover.signatureVerification(
48
- Strings.toString(evvmID),
46
+ SignatureUtil.verifySignature(
47
+ evvmID,
49
48
  "registrationUsername",
50
49
  string.concat(
51
50
  _username,
52
51
  ",",
53
- Strings.toString(_clowNumber),
52
+ AdvancedStrings.uintToString(_clowNumber),
54
53
  ",",
55
- Strings.toString(_nameServiceNonce)
54
+ AdvancedStrings.uintToString(_nameServiceNonce)
56
55
  ),
57
56
  signature,
58
57
  signer
@@ -69,17 +68,17 @@ library SignatureUtils {
69
68
  bytes memory signature
70
69
  ) internal pure returns (bool) {
71
70
  return
72
- SignatureRecover.signatureVerification(
73
- Strings.toString(evvmID),
71
+ SignatureUtil.verifySignature(
72
+ evvmID,
74
73
  "makeOffer",
75
74
  string.concat(
76
75
  _username,
77
76
  ",",
78
- Strings.toString(_dateExpire),
77
+ AdvancedStrings.uintToString(_dateExpire),
79
78
  ",",
80
- Strings.toString(_amount),
79
+ AdvancedStrings.uintToString(_amount),
81
80
  ",",
82
- Strings.toString(_nameServiceNonce)
81
+ AdvancedStrings.uintToString(_nameServiceNonce)
83
82
  ),
84
83
  signature,
85
84
  signer
@@ -95,15 +94,15 @@ library SignatureUtils {
95
94
  bytes memory signature
96
95
  ) internal pure returns (bool) {
97
96
  return
98
- SignatureRecover.signatureVerification(
99
- Strings.toString(evvmID),
97
+ SignatureUtil.verifySignature(
98
+ evvmID,
100
99
  "withdrawOffer",
101
100
  string.concat(
102
101
  _username,
103
102
  ",",
104
- Strings.toString(_offerId),
103
+ AdvancedStrings.uintToString(_offerId),
105
104
  ",",
106
- Strings.toString(_nameServiceNonce)
105
+ AdvancedStrings.uintToString(_nameServiceNonce)
107
106
  ),
108
107
  signature,
109
108
  signer
@@ -119,15 +118,15 @@ library SignatureUtils {
119
118
  bytes memory signature
120
119
  ) internal pure returns (bool) {
121
120
  return
122
- SignatureRecover.signatureVerification(
123
- Strings.toString(evvmID),
121
+ SignatureUtil.verifySignature(
122
+ evvmID,
124
123
  "acceptOffer",
125
124
  string.concat(
126
125
  _username,
127
126
  ",",
128
- Strings.toString(_offerId),
127
+ AdvancedStrings.uintToString(_offerId),
129
128
  ",",
130
- Strings.toString(_nameServiceNonce)
129
+ AdvancedStrings.uintToString(_nameServiceNonce)
131
130
  ),
132
131
  signature,
133
132
  signer
@@ -142,13 +141,13 @@ library SignatureUtils {
142
141
  bytes memory signature
143
142
  ) internal pure returns (bool) {
144
143
  return
145
- SignatureRecover.signatureVerification(
146
- Strings.toString(evvmID),
144
+ SignatureUtil.verifySignature(
145
+ evvmID,
147
146
  "renewUsername",
148
147
  string.concat(
149
148
  _username,
150
149
  ",",
151
- Strings.toString(_nameServiceNonce)
150
+ AdvancedStrings.uintToString(_nameServiceNonce)
152
151
  ),
153
152
  signature,
154
153
  signer
@@ -164,15 +163,15 @@ library SignatureUtils {
164
163
  bytes memory signature
165
164
  ) internal pure returns (bool) {
166
165
  return
167
- SignatureRecover.signatureVerification(
168
- Strings.toString(evvmID),
166
+ SignatureUtil.verifySignature(
167
+ evvmID,
169
168
  "addCustomMetadata",
170
169
  string.concat(
171
170
  _identity,
172
171
  ",",
173
172
  _value,
174
173
  ",",
175
- Strings.toString(_nameServiceNonce)
174
+ AdvancedStrings.uintToString(_nameServiceNonce)
176
175
  ),
177
176
  signature,
178
177
  signer
@@ -188,15 +187,15 @@ library SignatureUtils {
188
187
  bytes memory signature
189
188
  ) internal pure returns (bool) {
190
189
  return
191
- SignatureRecover.signatureVerification(
192
- Strings.toString(evvmID),
190
+ SignatureUtil.verifySignature(
191
+ evvmID,
193
192
  "removeCustomMetadata",
194
193
  string.concat(
195
194
  _username,
196
195
  ",",
197
- Strings.toString(_key),
196
+ AdvancedStrings.uintToString(_key),
198
197
  ",",
199
- Strings.toString(_nonce)
198
+ AdvancedStrings.uintToString(_nonce)
200
199
  ),
201
200
  signature,
202
201
  signer
@@ -211,10 +210,10 @@ library SignatureUtils {
211
210
  bytes memory signature
212
211
  ) internal pure returns (bool) {
213
212
  return
214
- SignatureRecover.signatureVerification(
215
- Strings.toString(evvmID),
213
+ SignatureUtil.verifySignature(
214
+ evvmID,
216
215
  "flushCustomMetadata",
217
- string.concat(_identity, ",", Strings.toString(_nonce)),
216
+ string.concat(_identity, ",", AdvancedStrings.uintToString(_nonce)),
218
217
  signature,
219
218
  signer
220
219
  );
@@ -228,10 +227,10 @@ library SignatureUtils {
228
227
  bytes memory signature
229
228
  ) internal pure returns (bool) {
230
229
  return
231
- SignatureRecover.signatureVerification(
232
- Strings.toString(evvmID),
230
+ SignatureUtil.verifySignature(
231
+ evvmID,
233
232
  "flushUsername",
234
- string.concat(_username, ",", Strings.toString(_nonce)),
233
+ string.concat(_username, ",", AdvancedStrings.uintToString(_nonce)),
235
234
  signature,
236
235
  signer
237
236
  );