@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
|
@@ -11,105 +11,86 @@ pragma solidity ^0.8.0;
|
|
|
11
11
|
* https://book.getfoundry.sh/cheatcodes/sign
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
CoreStructs
|
|
16
|
+
} from "@evvm/testnet-contracts/library/structs/CoreStructs.sol";
|
|
17
|
+
import {
|
|
18
|
+
AdvancedStrings
|
|
19
|
+
} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
20
|
+
import {
|
|
21
|
+
CoreHashUtils
|
|
22
|
+
} from "@evvm/testnet-contracts/library/utils/signature/CoreHashUtils.sol";
|
|
23
|
+
import {
|
|
24
|
+
NameServiceHashUtils
|
|
25
|
+
} from "@evvm/testnet-contracts/library/utils/signature/NameServiceHashUtils.sol";
|
|
26
|
+
import {
|
|
27
|
+
P2PSwapHashUtils
|
|
28
|
+
} from "@evvm/testnet-contracts/library/utils/signature/P2PSwapHashUtils.sol";
|
|
29
|
+
import {
|
|
30
|
+
StakingHashUtils
|
|
31
|
+
} from "@evvm/testnet-contracts/library/utils/signature/StakingHashUtils.sol";
|
|
15
32
|
|
|
16
33
|
library Erc191TestBuilder {
|
|
17
34
|
//-----------------------------------------------------------------------------------
|
|
18
35
|
// EVVM
|
|
19
36
|
//-----------------------------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @notice Builds the message hash for a pay operation signature
|
|
23
|
-
* @dev Creates an EIP-191 compatible hash for EVVM pay function
|
|
24
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
25
|
-
* @param _receiverAddress Address of the payment receiver (use address(0) if using identity)
|
|
26
|
-
* @param _receiverIdentity String identity of receiver (used if address is zero)
|
|
27
|
-
* @param _token Token address being transferred
|
|
28
|
-
* @param _amount Amount of tokens to transfer
|
|
29
|
-
* @param _priorityFee Priority fee for transaction processing
|
|
30
|
-
* @param _nonce Nonce for replay protection
|
|
31
|
-
* @param _priority_boolean True for async nonce, false for sync nonce
|
|
32
|
-
* @param _executor Address authorized to execute the transaction
|
|
33
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
34
|
-
*/
|
|
37
|
+
|
|
35
38
|
function buildMessageSignedForPay(
|
|
36
39
|
uint256 evvmID,
|
|
37
|
-
address
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
uint256
|
|
42
|
-
uint256
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
",",
|
|
65
|
-
AdvancedStrings.addressToString(_executor)
|
|
66
|
-
);
|
|
67
|
-
messageHash = buildHashForSign(messageToSign);
|
|
40
|
+
address servicePointer,
|
|
41
|
+
address to_address,
|
|
42
|
+
string memory to_identity,
|
|
43
|
+
address token,
|
|
44
|
+
uint256 amount,
|
|
45
|
+
uint256 priorityFee,
|
|
46
|
+
address senderExecutor,
|
|
47
|
+
uint256 nonce,
|
|
48
|
+
bool isAsyncExec
|
|
49
|
+
) internal pure returns (bytes32) {
|
|
50
|
+
return
|
|
51
|
+
buildHashForSign(
|
|
52
|
+
AdvancedStrings.buildSignaturePayload(
|
|
53
|
+
evvmID,
|
|
54
|
+
servicePointer,
|
|
55
|
+
CoreHashUtils.hashDataForPay(
|
|
56
|
+
to_address,
|
|
57
|
+
to_identity,
|
|
58
|
+
token,
|
|
59
|
+
amount,
|
|
60
|
+
priorityFee
|
|
61
|
+
),
|
|
62
|
+
senderExecutor,
|
|
63
|
+
nonce,
|
|
64
|
+
isAsyncExec
|
|
65
|
+
)
|
|
66
|
+
);
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
/**
|
|
71
|
-
* @notice Builds the message hash for a disperse pay operation signature
|
|
72
|
-
* @dev Creates an EIP-191 compatible hash for EVVM dispersePay function
|
|
73
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
74
|
-
* @param hashList Hash of the recipient list for batch payment
|
|
75
|
-
* @param _token Token address being transferred
|
|
76
|
-
* @param _amount Total amount of tokens to transfer
|
|
77
|
-
* @param _priorityFee Priority fee for transaction processing
|
|
78
|
-
* @param _nonce Nonce for replay protection
|
|
79
|
-
* @param _priority_boolean True for async nonce, false for sync nonce
|
|
80
|
-
* @param _executor Address authorized to execute the transaction
|
|
81
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
82
|
-
*/
|
|
83
69
|
function buildMessageSignedForDispersePay(
|
|
84
70
|
uint256 evvmID,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
uint256
|
|
89
|
-
uint256
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
71
|
+
address servicePointer,
|
|
72
|
+
CoreStructs.DispersePayMetadata[] memory toData,
|
|
73
|
+
address token,
|
|
74
|
+
uint256 amount,
|
|
75
|
+
uint256 priorityFee,
|
|
76
|
+
address senderExecutor,
|
|
77
|
+
uint256 nonce,
|
|
78
|
+
bool isAsyncExec
|
|
79
|
+
) public pure returns (bytes32) {
|
|
93
80
|
return
|
|
94
81
|
buildHashForSign(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
",",
|
|
108
|
-
AdvancedStrings.uintToString(_nonce),
|
|
109
|
-
",",
|
|
110
|
-
_priority_boolean ? "true" : "false",
|
|
111
|
-
",",
|
|
112
|
-
AdvancedStrings.addressToString(_executor)
|
|
82
|
+
AdvancedStrings.buildSignaturePayload(
|
|
83
|
+
evvmID,
|
|
84
|
+
servicePointer,
|
|
85
|
+
CoreHashUtils.hashDataForDispersePay(
|
|
86
|
+
toData,
|
|
87
|
+
token,
|
|
88
|
+
amount,
|
|
89
|
+
priorityFee
|
|
90
|
+
),
|
|
91
|
+
senderExecutor,
|
|
92
|
+
nonce,
|
|
93
|
+
isAsyncExec
|
|
113
94
|
)
|
|
114
95
|
);
|
|
115
96
|
}
|
|
@@ -118,300 +99,232 @@ library Erc191TestBuilder {
|
|
|
118
99
|
// MATE NAME SERVICE
|
|
119
100
|
//-----------------------------------------------------------------------------------
|
|
120
101
|
|
|
121
|
-
/**
|
|
122
|
-
* @notice Builds the message hash for username pre-registration
|
|
123
|
-
* @dev Creates an EIP-191 compatible hash for NameService preRegistrationUsername
|
|
124
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
125
|
-
* @param _hashUsername Hash of username + random number for commit-reveal
|
|
126
|
-
* @param _nameServiceNonce Nonce for NameService replay protection
|
|
127
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
128
|
-
*/
|
|
129
102
|
function buildMessageSignedForPreRegistrationUsername(
|
|
130
103
|
uint256 evvmID,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
104
|
+
address servicePointer,
|
|
105
|
+
bytes32 hashPreRegisteredUsername,
|
|
106
|
+
address originExecutor,
|
|
107
|
+
uint256 nonce
|
|
108
|
+
) internal pure returns (bytes32) {
|
|
134
109
|
return
|
|
135
110
|
buildHashForSign(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
111
|
+
AdvancedStrings.buildSignaturePayload(
|
|
112
|
+
evvmID,
|
|
113
|
+
servicePointer,
|
|
114
|
+
NameServiceHashUtils.hashDataForPreRegistrationUsername(
|
|
115
|
+
hashPreRegisteredUsername
|
|
116
|
+
),
|
|
117
|
+
originExecutor,
|
|
118
|
+
nonce,
|
|
119
|
+
true
|
|
144
120
|
)
|
|
145
121
|
);
|
|
146
122
|
}
|
|
147
123
|
|
|
148
|
-
/**
|
|
149
|
-
* @notice Builds the message hash for username registration
|
|
150
|
-
* @dev Creates an EIP-191 compatible hash for NameService registrationUsername
|
|
151
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
152
|
-
* @param _username The username being registered
|
|
153
|
-
* @param _clowNumber Random number from pre-registration
|
|
154
|
-
* @param _nameServiceNonce Nonce for NameService replay protection
|
|
155
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
156
|
-
*/
|
|
157
124
|
function buildMessageSignedForRegistrationUsername(
|
|
158
125
|
uint256 evvmID,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
uint256
|
|
162
|
-
|
|
126
|
+
address servicePointer,
|
|
127
|
+
string memory username,
|
|
128
|
+
uint256 lockNumber,
|
|
129
|
+
address originExecutor,
|
|
130
|
+
uint256 nonce
|
|
131
|
+
) internal pure returns (bytes32) {
|
|
163
132
|
return
|
|
164
133
|
buildHashForSign(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
134
|
+
AdvancedStrings.buildSignaturePayload(
|
|
135
|
+
evvmID,
|
|
136
|
+
servicePointer,
|
|
137
|
+
NameServiceHashUtils.hashDataForRegistrationUsername(
|
|
138
|
+
username,
|
|
139
|
+
lockNumber
|
|
140
|
+
),
|
|
141
|
+
originExecutor,
|
|
142
|
+
nonce,
|
|
143
|
+
true
|
|
175
144
|
)
|
|
176
145
|
);
|
|
177
146
|
}
|
|
178
147
|
|
|
179
|
-
/**
|
|
180
|
-
* @notice Builds the message hash for making a username offer
|
|
181
|
-
* @dev Creates an EIP-191 compatible hash for NameService makeOffer
|
|
182
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
183
|
-
* @param _username Target username for the offer
|
|
184
|
-
* @param _dateExpire Timestamp when the offer expires
|
|
185
|
-
* @param _amount Amount being offered in Principal Tokens
|
|
186
|
-
* @param _nameServiceNonce Nonce for NameService replay protection
|
|
187
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
188
|
-
*/
|
|
189
148
|
function buildMessageSignedForMakeOffer(
|
|
190
149
|
uint256 evvmID,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
uint256
|
|
194
|
-
uint256
|
|
195
|
-
|
|
150
|
+
address servicePointer,
|
|
151
|
+
string memory username,
|
|
152
|
+
uint256 amount,
|
|
153
|
+
uint256 expirationDate,
|
|
154
|
+
address originExecutor,
|
|
155
|
+
uint256 nonce
|
|
156
|
+
) internal pure returns (bytes32) {
|
|
196
157
|
return
|
|
197
158
|
buildHashForSign(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
159
|
+
AdvancedStrings.buildSignaturePayload(
|
|
160
|
+
evvmID,
|
|
161
|
+
servicePointer,
|
|
162
|
+
NameServiceHashUtils.hashDataForMakeOffer(
|
|
163
|
+
username,
|
|
164
|
+
amount,
|
|
165
|
+
expirationDate
|
|
166
|
+
),
|
|
167
|
+
originExecutor,
|
|
168
|
+
nonce,
|
|
169
|
+
true
|
|
210
170
|
)
|
|
211
171
|
);
|
|
212
172
|
}
|
|
213
173
|
|
|
214
|
-
/**
|
|
215
|
-
* @notice Builds the message hash for withdrawing a username offer
|
|
216
|
-
* @dev Creates an EIP-191 compatible hash for NameService withdrawOffer
|
|
217
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
218
|
-
* @param _username Username the offer was made for
|
|
219
|
-
* @param _offerId ID of the offer to withdraw
|
|
220
|
-
* @param _nameServiceNonce Nonce for NameService replay protection
|
|
221
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
222
|
-
*/
|
|
223
174
|
function buildMessageSignedForWithdrawOffer(
|
|
224
175
|
uint256 evvmID,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
uint256
|
|
228
|
-
|
|
176
|
+
address servicePointer,
|
|
177
|
+
string memory username,
|
|
178
|
+
uint256 offerId,
|
|
179
|
+
address originExecutor,
|
|
180
|
+
uint256 nonce
|
|
181
|
+
) internal pure returns (bytes32) {
|
|
229
182
|
return
|
|
230
183
|
buildHashForSign(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
184
|
+
AdvancedStrings.buildSignaturePayload(
|
|
185
|
+
evvmID,
|
|
186
|
+
servicePointer,
|
|
187
|
+
NameServiceHashUtils.hashDataForWithdrawOffer(
|
|
188
|
+
username,
|
|
189
|
+
offerId
|
|
190
|
+
),
|
|
191
|
+
originExecutor,
|
|
192
|
+
nonce,
|
|
193
|
+
true
|
|
241
194
|
)
|
|
242
195
|
);
|
|
243
196
|
}
|
|
244
197
|
|
|
245
|
-
/**
|
|
246
|
-
* @notice Builds the message hash for accepting a username offer
|
|
247
|
-
* @dev Creates an EIP-191 compatible hash for NameService acceptOffer
|
|
248
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
249
|
-
* @param _username Username being sold
|
|
250
|
-
* @param _offerId ID of the offer to accept
|
|
251
|
-
* @param _nameServiceNonce Nonce for NameService replay protection
|
|
252
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
253
|
-
*/
|
|
254
198
|
function buildMessageSignedForAcceptOffer(
|
|
255
199
|
uint256 evvmID,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
uint256
|
|
259
|
-
|
|
200
|
+
address servicePointer,
|
|
201
|
+
string memory username,
|
|
202
|
+
uint256 offerId,
|
|
203
|
+
address originExecutor,
|
|
204
|
+
uint256 nonce
|
|
205
|
+
) internal pure returns (bytes32) {
|
|
260
206
|
return
|
|
261
207
|
buildHashForSign(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
208
|
+
AdvancedStrings.buildSignaturePayload(
|
|
209
|
+
evvmID,
|
|
210
|
+
servicePointer,
|
|
211
|
+
NameServiceHashUtils.hashDataForAcceptOffer(
|
|
212
|
+
username,
|
|
213
|
+
offerId
|
|
214
|
+
),
|
|
215
|
+
originExecutor,
|
|
216
|
+
nonce,
|
|
217
|
+
true
|
|
272
218
|
)
|
|
273
219
|
);
|
|
274
220
|
}
|
|
275
221
|
|
|
276
|
-
/**
|
|
277
|
-
* @notice Builds the message hash for renewing a username
|
|
278
|
-
* @dev Creates an EIP-191 compatible hash for NameService renewUsername
|
|
279
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
280
|
-
* @param _username Username to renew
|
|
281
|
-
* @param _nameServiceNonce Nonce for NameService replay protection
|
|
282
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
283
|
-
*/
|
|
284
222
|
function buildMessageSignedForRenewUsername(
|
|
285
223
|
uint256 evvmID,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
224
|
+
address servicePointer,
|
|
225
|
+
string memory username,
|
|
226
|
+
address originExecutor,
|
|
227
|
+
uint256 nonce
|
|
228
|
+
) internal pure returns (bytes32) {
|
|
289
229
|
return
|
|
290
230
|
buildHashForSign(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
231
|
+
AdvancedStrings.buildSignaturePayload(
|
|
232
|
+
evvmID,
|
|
233
|
+
servicePointer,
|
|
234
|
+
NameServiceHashUtils.hashDataForRenewUsername(username),
|
|
235
|
+
originExecutor,
|
|
236
|
+
nonce,
|
|
237
|
+
true
|
|
299
238
|
)
|
|
300
239
|
);
|
|
301
240
|
}
|
|
302
241
|
|
|
303
|
-
/**
|
|
304
|
-
* @notice Builds the message hash for adding custom metadata
|
|
305
|
-
* @dev Creates an EIP-191 compatible hash for NameService addCustomMetadata
|
|
306
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
307
|
-
* @param _username Username to add metadata to
|
|
308
|
-
* @param _value Metadata value following schema format
|
|
309
|
-
* @param _nameServiceNonce Nonce for NameService replay protection
|
|
310
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
311
|
-
*/
|
|
312
242
|
function buildMessageSignedForAddCustomMetadata(
|
|
313
243
|
uint256 evvmID,
|
|
314
|
-
|
|
315
|
-
string memory
|
|
316
|
-
|
|
317
|
-
|
|
244
|
+
address servicePointer,
|
|
245
|
+
string memory username,
|
|
246
|
+
string memory value,
|
|
247
|
+
address originExecutor,
|
|
248
|
+
uint256 nonce
|
|
249
|
+
) internal pure returns (bytes32) {
|
|
318
250
|
return
|
|
319
251
|
buildHashForSign(
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
252
|
+
AdvancedStrings.buildSignaturePayload(
|
|
253
|
+
evvmID,
|
|
254
|
+
servicePointer,
|
|
255
|
+
NameServiceHashUtils.hashDataForAddCustomMetadata(
|
|
256
|
+
username,
|
|
257
|
+
value
|
|
258
|
+
),
|
|
259
|
+
originExecutor,
|
|
260
|
+
nonce,
|
|
261
|
+
true
|
|
330
262
|
)
|
|
331
263
|
);
|
|
332
264
|
}
|
|
333
265
|
|
|
334
|
-
/**
|
|
335
|
-
* @notice Builds the message hash for removing custom metadata
|
|
336
|
-
* @dev Creates an EIP-191 compatible hash for NameService removeCustomMetadata
|
|
337
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
338
|
-
* @param _username Username to remove metadata from
|
|
339
|
-
* @param _key Index of the metadata entry to remove
|
|
340
|
-
* @param _nonce Nonce for NameService replay protection
|
|
341
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
342
|
-
*/
|
|
343
266
|
function buildMessageSignedForRemoveCustomMetadata(
|
|
344
267
|
uint256 evvmID,
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
uint256
|
|
348
|
-
|
|
268
|
+
address servicePointer,
|
|
269
|
+
string memory username,
|
|
270
|
+
uint256 key,
|
|
271
|
+
address originExecutor,
|
|
272
|
+
uint256 nonce
|
|
273
|
+
) internal pure returns (bytes32) {
|
|
349
274
|
return
|
|
350
275
|
buildHashForSign(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
276
|
+
AdvancedStrings.buildSignaturePayload(
|
|
277
|
+
evvmID,
|
|
278
|
+
servicePointer,
|
|
279
|
+
NameServiceHashUtils.hashDataForRemoveCustomMetadata(
|
|
280
|
+
username,
|
|
281
|
+
key
|
|
282
|
+
),
|
|
283
|
+
originExecutor,
|
|
284
|
+
nonce,
|
|
285
|
+
true
|
|
361
286
|
)
|
|
362
287
|
);
|
|
363
288
|
}
|
|
364
289
|
|
|
365
|
-
/**
|
|
366
|
-
* @notice Builds the message hash for flushing all custom metadata
|
|
367
|
-
* @dev Creates an EIP-191 compatible hash for NameService flushCustomMetadata
|
|
368
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
369
|
-
* @param _username Username to flush metadata from
|
|
370
|
-
* @param _nonce Nonce for NameService replay protection
|
|
371
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
372
|
-
*/
|
|
373
290
|
function buildMessageSignedForFlushCustomMetadata(
|
|
374
291
|
uint256 evvmID,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
292
|
+
address servicePointer,
|
|
293
|
+
string memory username,
|
|
294
|
+
address originExecutor,
|
|
295
|
+
uint256 nonce
|
|
296
|
+
) internal pure returns (bytes32) {
|
|
378
297
|
return
|
|
379
298
|
buildHashForSign(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
299
|
+
AdvancedStrings.buildSignaturePayload(
|
|
300
|
+
evvmID,
|
|
301
|
+
servicePointer,
|
|
302
|
+
NameServiceHashUtils.hashDataForFlushCustomMetadata(
|
|
303
|
+
username
|
|
304
|
+
),
|
|
305
|
+
originExecutor,
|
|
306
|
+
nonce,
|
|
307
|
+
true
|
|
388
308
|
)
|
|
389
309
|
);
|
|
390
310
|
}
|
|
391
311
|
|
|
392
|
-
/**
|
|
393
|
-
* @notice Builds the message hash for flushing a username
|
|
394
|
-
* @dev Creates an EIP-191 compatible hash for NameService flushUsername
|
|
395
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
396
|
-
* @param _username Username to completely remove
|
|
397
|
-
* @param _nonce Nonce for NameService replay protection
|
|
398
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
399
|
-
*/
|
|
400
312
|
function buildMessageSignedForFlushUsername(
|
|
401
313
|
uint256 evvmID,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
314
|
+
address servicePointer,
|
|
315
|
+
string memory username,
|
|
316
|
+
address originExecutor,
|
|
317
|
+
uint256 nonce
|
|
318
|
+
) internal pure returns (bytes32) {
|
|
405
319
|
return
|
|
406
320
|
buildHashForSign(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
AdvancedStrings.uintToString(_nonce)
|
|
321
|
+
AdvancedStrings.buildSignaturePayload(
|
|
322
|
+
evvmID,
|
|
323
|
+
servicePointer,
|
|
324
|
+
NameServiceHashUtils.hashDataForFlushUsername(username),
|
|
325
|
+
originExecutor,
|
|
326
|
+
nonce,
|
|
327
|
+
true
|
|
415
328
|
)
|
|
416
329
|
);
|
|
417
330
|
}
|
|
@@ -420,99 +333,50 @@ library Erc191TestBuilder {
|
|
|
420
333
|
// staking functions
|
|
421
334
|
//-----------------------------------------------------------------------------------
|
|
422
335
|
|
|
423
|
-
|
|
424
|
-
* @notice Builds the message hash for public service staking
|
|
425
|
-
* @dev Creates an EIP-191 compatible hash for Staking publicServiceStaking
|
|
426
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
427
|
-
* @param _serviceAddress Address of the service to stake for
|
|
428
|
-
* @param _isStaking True for staking, false for unstaking
|
|
429
|
-
* @param _amountOfStaking Amount of staking units
|
|
430
|
-
* @param _nonce Nonce for replay protection
|
|
431
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
432
|
-
*/
|
|
433
|
-
function buildMessageSignedForPublicServiceStake(
|
|
336
|
+
function buildMessageSignedForPresaleStaking(
|
|
434
337
|
uint256 evvmID,
|
|
435
|
-
address
|
|
436
|
-
bool
|
|
437
|
-
uint256
|
|
438
|
-
|
|
439
|
-
|
|
338
|
+
address servicePointer,
|
|
339
|
+
bool isStaking,
|
|
340
|
+
uint256 amountOfStaking,
|
|
341
|
+
address originExecutor,
|
|
342
|
+
uint256 nonce
|
|
343
|
+
) internal pure returns (bytes32) {
|
|
440
344
|
return
|
|
441
345
|
buildHashForSign(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
",",
|
|
453
|
-
AdvancedStrings.uintToString(_nonce)
|
|
346
|
+
AdvancedStrings.buildSignaturePayload(
|
|
347
|
+
evvmID,
|
|
348
|
+
servicePointer,
|
|
349
|
+
StakingHashUtils.hashDataForPresaleStake(
|
|
350
|
+
isStaking,
|
|
351
|
+
amountOfStaking
|
|
352
|
+
),
|
|
353
|
+
originExecutor,
|
|
354
|
+
nonce,
|
|
355
|
+
true
|
|
454
356
|
)
|
|
455
357
|
);
|
|
456
358
|
}
|
|
457
359
|
|
|
458
|
-
/**
|
|
459
|
-
* @notice Builds the message hash for public staking
|
|
460
|
-
* @dev Creates an EIP-191 compatible hash for Staking publicStaking
|
|
461
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
462
|
-
* @param _isStaking True for staking, false for unstaking
|
|
463
|
-
* @param _amountOfStaking Amount of staking units
|
|
464
|
-
* @param _nonce Nonce for replay protection
|
|
465
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
466
|
-
*/
|
|
467
360
|
function buildMessageSignedForPublicStaking(
|
|
468
361
|
uint256 evvmID,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
uint256
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
string.concat(
|
|
476
|
-
AdvancedStrings.uintToString(evvmID),
|
|
477
|
-
",",
|
|
478
|
-
"publicStaking",
|
|
479
|
-
",",
|
|
480
|
-
_isStaking ? "true" : "false",
|
|
481
|
-
",",
|
|
482
|
-
AdvancedStrings.uintToString(_amountOfStaking),
|
|
483
|
-
",",
|
|
484
|
-
AdvancedStrings.uintToString(_nonce)
|
|
485
|
-
)
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* @notice Builds the message hash for presale staking
|
|
491
|
-
* @dev Creates an EIP-191 compatible hash for Staking presaleStaking
|
|
492
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
493
|
-
* @param _isStaking True for staking, false for unstaking
|
|
494
|
-
* @param _amountOfStaking Amount of staking units
|
|
495
|
-
* @param _nonce Nonce for replay protection
|
|
496
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
497
|
-
*/
|
|
498
|
-
function buildMessageSignedForPresaleStaking(
|
|
499
|
-
uint256 evvmID,
|
|
500
|
-
bool _isStaking,
|
|
501
|
-
uint256 _amountOfStaking,
|
|
502
|
-
uint256 _nonce
|
|
503
|
-
) internal pure returns (bytes32 messageHash) {
|
|
362
|
+
address servicePointer,
|
|
363
|
+
bool isStaking,
|
|
364
|
+
uint256 amountOfStaking,
|
|
365
|
+
address originExecutor,
|
|
366
|
+
uint256 nonce
|
|
367
|
+
) internal pure returns (bytes32) {
|
|
504
368
|
return
|
|
505
369
|
buildHashForSign(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
370
|
+
AdvancedStrings.buildSignaturePayload(
|
|
371
|
+
evvmID,
|
|
372
|
+
servicePointer,
|
|
373
|
+
StakingHashUtils.hashDataForPublicStake(
|
|
374
|
+
isStaking,
|
|
375
|
+
amountOfStaking
|
|
376
|
+
),
|
|
377
|
+
originExecutor,
|
|
378
|
+
nonce,
|
|
379
|
+
true
|
|
516
380
|
)
|
|
517
381
|
);
|
|
518
382
|
}
|
|
@@ -521,111 +385,112 @@ library Erc191TestBuilder {
|
|
|
521
385
|
// P2PSwap functions
|
|
522
386
|
//-----------------------------------------------------------------------------------
|
|
523
387
|
|
|
524
|
-
/**
|
|
525
|
-
* @notice Builds the message hash for making a P2P swap order
|
|
526
|
-
* @dev Creates an EIP-191 compatible hash for P2PSwap makeOrder
|
|
527
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
528
|
-
* @param _nonce Nonce for replay protection
|
|
529
|
-
* @param _tokenA Token address being offered
|
|
530
|
-
* @param _tokenB Token address being requested
|
|
531
|
-
* @param _amountA Amount of tokenA being offered
|
|
532
|
-
* @param _amountB Amount of tokenB being requested
|
|
533
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
534
|
-
*/
|
|
535
388
|
function buildMessageSignedForMakeOrder(
|
|
536
389
|
uint256 evvmID,
|
|
537
|
-
|
|
538
|
-
address
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
390
|
+
address servicePointer,
|
|
391
|
+
address originExecutor,
|
|
392
|
+
uint256 nonce,
|
|
393
|
+
address tokenA,
|
|
394
|
+
address tokenB,
|
|
395
|
+
uint256 amountA,
|
|
396
|
+
uint256 amountB
|
|
397
|
+
) internal pure returns (bytes32) {
|
|
543
398
|
return
|
|
544
399
|
buildHashForSign(
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
",",
|
|
558
|
-
AdvancedStrings.uintToString(_amountB)
|
|
400
|
+
AdvancedStrings.buildSignaturePayload(
|
|
401
|
+
evvmID,
|
|
402
|
+
servicePointer,
|
|
403
|
+
P2PSwapHashUtils.hashDataForMakeOrder(
|
|
404
|
+
tokenA,
|
|
405
|
+
tokenB,
|
|
406
|
+
amountA,
|
|
407
|
+
amountB
|
|
408
|
+
),
|
|
409
|
+
originExecutor,
|
|
410
|
+
nonce,
|
|
411
|
+
true
|
|
559
412
|
)
|
|
560
413
|
);
|
|
561
414
|
}
|
|
562
415
|
|
|
563
|
-
/**
|
|
564
|
-
* @notice Builds the message hash for canceling a P2P swap order
|
|
565
|
-
* @dev Creates an EIP-191 compatible hash for P2PSwap cancelOrder
|
|
566
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
567
|
-
* @param _nonce Nonce for replay protection
|
|
568
|
-
* @param _tokenA Token address that was offered
|
|
569
|
-
* @param _tokenB Token address that was requested
|
|
570
|
-
* @param _orderId ID of the order to cancel
|
|
571
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
572
|
-
*/
|
|
573
416
|
function buildMessageSignedForCancelOrder(
|
|
574
417
|
uint256 evvmID,
|
|
575
|
-
|
|
576
|
-
address
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
418
|
+
address servicePointer,
|
|
419
|
+
address originExecutor,
|
|
420
|
+
uint256 nonce,
|
|
421
|
+
address tokenA,
|
|
422
|
+
address tokenB,
|
|
423
|
+
uint256 orderId
|
|
424
|
+
) internal pure returns (bytes32) {
|
|
580
425
|
return
|
|
581
426
|
buildHashForSign(
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
AdvancedStrings.uintToString(_orderId)
|
|
427
|
+
AdvancedStrings.buildSignaturePayload(
|
|
428
|
+
evvmID,
|
|
429
|
+
servicePointer,
|
|
430
|
+
P2PSwapHashUtils.hashDataForCancelOrder(
|
|
431
|
+
tokenA,
|
|
432
|
+
tokenB,
|
|
433
|
+
orderId
|
|
434
|
+
),
|
|
435
|
+
originExecutor,
|
|
436
|
+
nonce,
|
|
437
|
+
true
|
|
594
438
|
)
|
|
595
439
|
);
|
|
596
440
|
}
|
|
597
441
|
|
|
598
|
-
/**
|
|
599
|
-
* @notice Builds the message hash for dispatching (accepting) a P2P swap order
|
|
600
|
-
* @dev Creates an EIP-191 compatible hash for P2PSwap dispatchOrder
|
|
601
|
-
* @param evvmID Unique identifier of the EVVM instance
|
|
602
|
-
* @param _nonce Nonce for replay protection
|
|
603
|
-
* @param _tokenA Token address that was offered
|
|
604
|
-
* @param _tokenB Token address that was requested
|
|
605
|
-
* @param _orderId ID of the order to dispatch
|
|
606
|
-
* @return messageHash The EIP-191 formatted hash ready for signing
|
|
607
|
-
*/
|
|
608
442
|
function buildMessageSignedForDispatchOrder(
|
|
609
443
|
uint256 evvmID,
|
|
610
|
-
|
|
611
|
-
address
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
444
|
+
address servicePointer,
|
|
445
|
+
address originExecutor,
|
|
446
|
+
uint256 nonce,
|
|
447
|
+
address tokenA,
|
|
448
|
+
address tokenB,
|
|
449
|
+
uint256 orderId
|
|
450
|
+
) internal pure returns (bytes32) {
|
|
451
|
+
return
|
|
452
|
+
buildHashForSign(
|
|
453
|
+
AdvancedStrings.buildSignaturePayload(
|
|
454
|
+
evvmID,
|
|
455
|
+
servicePointer,
|
|
456
|
+
P2PSwapHashUtils.hashDataForDispatchOrder(
|
|
457
|
+
tokenA,
|
|
458
|
+
tokenB,
|
|
459
|
+
orderId
|
|
460
|
+
),
|
|
461
|
+
originExecutor,
|
|
462
|
+
nonce,
|
|
463
|
+
true
|
|
464
|
+
)
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
//-----------------------------------------------------------------------------------
|
|
469
|
+
// nonceConsumer functions
|
|
470
|
+
//-----------------------------------------------------------------------------------
|
|
471
|
+
|
|
472
|
+
function buildMessageSignedForStateTest(
|
|
473
|
+
uint256 evvmID,
|
|
474
|
+
address servicePointer,
|
|
475
|
+
string memory testA,
|
|
476
|
+
uint256 testB,
|
|
477
|
+
address testC,
|
|
478
|
+
bool testD,
|
|
479
|
+
address originExecutor,
|
|
480
|
+
uint256 nonce,
|
|
481
|
+
bool isAsyncExec
|
|
482
|
+
) internal pure returns (bytes32) {
|
|
615
483
|
return
|
|
616
484
|
buildHashForSign(
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
AdvancedStrings.addressToString(_tokenB),
|
|
627
|
-
",",
|
|
628
|
-
AdvancedStrings.uintToString(_orderId)
|
|
485
|
+
AdvancedStrings.buildSignaturePayload(
|
|
486
|
+
evvmID,
|
|
487
|
+
servicePointer,
|
|
488
|
+
keccak256(
|
|
489
|
+
abi.encode("StateTest", testA, testB, testC, testD)
|
|
490
|
+
),
|
|
491
|
+
originExecutor,
|
|
492
|
+
nonce,
|
|
493
|
+
isAsyncExec
|
|
629
494
|
)
|
|
630
495
|
);
|
|
631
496
|
}
|