dkg.js 6.5.3 → 6.5.4
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/constants.js +10 -0
- package/managers/assertion-operations-manager.js +1 -1
- package/managers/asset-operations-manager.js +6 -6
- package/managers/paranet-operations-manager.js +107 -92
- package/package.json +3 -3
- package/services/blockchain-service/blockchain-service-base.js +130 -48
- package/services/node-api-service/implementations/http-service.js +24 -8
package/constants.js
CHANGED
|
@@ -78,6 +78,12 @@ const BLOCKCHAINS = {
|
|
|
78
78
|
|
|
79
79
|
const INCENTIVE_TYPE = {
|
|
80
80
|
NEUROWEB: 'Neuroweb',
|
|
81
|
+
NEUROWEB_ERC20: 'NeurowebERC20',
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const INCENTIVE_MULTIPLIER = {
|
|
85
|
+
Neuroweb: 10n ** 12n,
|
|
86
|
+
NeurowebERC20: 10n ** 18n,
|
|
81
87
|
};
|
|
82
88
|
|
|
83
89
|
const BLOCKCHAINS_RENAME_PAIRS = {
|
|
@@ -240,6 +246,8 @@ const BID_SUGGESTION_RANGE_ENUM = [
|
|
|
240
246
|
ALL_BID_SUGGESTION,
|
|
241
247
|
];
|
|
242
248
|
|
|
249
|
+
const NEUROWEB_BLOCKCHAIN_PREFIX = 'otp';
|
|
250
|
+
|
|
243
251
|
module.exports = {
|
|
244
252
|
MAX_FILE_SIZE,
|
|
245
253
|
DID_PREFIX,
|
|
@@ -256,6 +264,7 @@ module.exports = {
|
|
|
256
264
|
CONTENT_TYPES,
|
|
257
265
|
GET_OUTPUT_FORMATS,
|
|
258
266
|
INCENTIVE_TYPE,
|
|
267
|
+
INCENTIVE_MULTIPLIER,
|
|
259
268
|
ASSET_STATES,
|
|
260
269
|
STORE_TYPES,
|
|
261
270
|
GRAPH_LOCATIONS,
|
|
@@ -273,4 +282,5 @@ module.exports = {
|
|
|
273
282
|
HIGH_BID_SUGGESTION,
|
|
274
283
|
ALL_BID_SUGGESTION,
|
|
275
284
|
BID_SUGGESTION_RANGE_ENUM,
|
|
285
|
+
NEUROWEB_BLOCKCHAIN_PREFIX,
|
|
276
286
|
};
|
|
@@ -319,7 +319,7 @@ class AssetOperationsManager {
|
|
|
319
319
|
? 0
|
|
320
320
|
: assertionMetadata.getAssertionSizeInBytes(privateAssertion)),
|
|
321
321
|
);
|
|
322
|
-
const publicAssertionId = calculateRoot(publicAssertion);
|
|
322
|
+
const publicAssertionId = await calculateRoot(publicAssertion);
|
|
323
323
|
|
|
324
324
|
const contentAssetStorageAddress = await this.blockchainService.getContractAddress(
|
|
325
325
|
'ContentAssetStorage',
|
|
@@ -395,7 +395,7 @@ class AssetOperationsManager {
|
|
|
395
395
|
if (privateAssertion?.length) {
|
|
396
396
|
assertions.push({
|
|
397
397
|
...resolvedUAL,
|
|
398
|
-
assertionId: calculateRoot(privateAssertion),
|
|
398
|
+
assertionId: await calculateRoot(privateAssertion),
|
|
399
399
|
assertion: privateAssertion,
|
|
400
400
|
storeType: STORE_TYPES.TRIPLE,
|
|
401
401
|
});
|
|
@@ -613,7 +613,7 @@ class AssetOperationsManager {
|
|
|
613
613
|
|
|
614
614
|
const publicAssertion = getPublicOperationResult.data.assertion;
|
|
615
615
|
|
|
616
|
-
if (validate === true && calculateRoot(publicAssertion) !== publicAssertionId) {
|
|
616
|
+
if (validate === true && (await calculateRoot(publicAssertion)) !== publicAssertionId) {
|
|
617
617
|
getPublicOperationResult.data = {
|
|
618
618
|
errorType: 'DKG_CLIENT_ERROR',
|
|
619
619
|
errorMessage: "Calculated root hashes don't match!",
|
|
@@ -713,7 +713,7 @@ class AssetOperationsManager {
|
|
|
713
713
|
if (
|
|
714
714
|
privateAssertion.length &&
|
|
715
715
|
validate === true &&
|
|
716
|
-
calculateRoot(privateAssertion) !== privateAssertionId
|
|
716
|
+
(await calculateRoot(privateAssertion)) !== privateAssertionId
|
|
717
717
|
) {
|
|
718
718
|
queryPrivateOperationResult.data = {
|
|
719
719
|
errorType: 'DKG_CLIENT_ERROR',
|
|
@@ -809,7 +809,7 @@ class AssetOperationsManager {
|
|
|
809
809
|
? 0
|
|
810
810
|
: assertionMetadata.getAssertionSizeInBytes(privateAssertion)),
|
|
811
811
|
);
|
|
812
|
-
const publicAssertionId = calculateRoot(publicAssertion);
|
|
812
|
+
const publicAssertionId = await calculateRoot(publicAssertion);
|
|
813
813
|
|
|
814
814
|
const contentAssetStorageAddress = await this.blockchainService.getContractAddress(
|
|
815
815
|
'ContentAssetStorage',
|
|
@@ -861,7 +861,7 @@ class AssetOperationsManager {
|
|
|
861
861
|
if (privateAssertion?.length) {
|
|
862
862
|
assertions.push({
|
|
863
863
|
...resolvedUAL,
|
|
864
|
-
assertionId: calculateRoot(privateAssertion),
|
|
864
|
+
assertionId: await calculateRoot(privateAssertion),
|
|
865
865
|
assertion: privateAssertion,
|
|
866
866
|
storeType: STORE_TYPES.PENDING,
|
|
867
867
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const { ethers } = require('ethers');
|
|
2
2
|
const { resolveUAL } = require('../services/utilities.js');
|
|
3
|
-
const {
|
|
4
|
-
INCENTIVE_TYPE,
|
|
5
|
-
} = require('../constants.js');
|
|
3
|
+
const { INCENTIVE_TYPE, INCENTIVE_MULTIPLIER } = require('../constants.js');
|
|
6
4
|
|
|
7
5
|
class ParanetOperationsManager {
|
|
8
6
|
constructor(services) {
|
|
@@ -27,11 +25,8 @@ class ParanetOperationsManager {
|
|
|
27
25
|
* });
|
|
28
26
|
*/
|
|
29
27
|
async create(UAL, options = {}) {
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
paranetName,
|
|
33
|
-
paranetDescription,
|
|
34
|
-
} = this.inputService.getParanetCreateArguments(options);
|
|
28
|
+
const { blockchain, paranetName, paranetDescription } =
|
|
29
|
+
this.inputService.getParanetCreateArguments(options);
|
|
35
30
|
|
|
36
31
|
this.validationService.validateParanetCreate(
|
|
37
32
|
UAL,
|
|
@@ -42,18 +37,19 @@ class ParanetOperationsManager {
|
|
|
42
37
|
|
|
43
38
|
const { contract, tokenId } = resolveUAL(UAL);
|
|
44
39
|
|
|
45
|
-
|
|
40
|
+
const receipt = await this.blockchainService.registerParanet(
|
|
41
|
+
{
|
|
46
42
|
contract,
|
|
47
43
|
tokenId,
|
|
48
44
|
paranetName,
|
|
49
45
|
paranetDescription,
|
|
50
46
|
},
|
|
51
|
-
blockchain
|
|
47
|
+
blockchain,
|
|
52
48
|
);
|
|
53
49
|
|
|
54
50
|
return {
|
|
55
51
|
paranetUAL: UAL,
|
|
56
|
-
operation: receipt
|
|
52
|
+
operation: receipt,
|
|
57
53
|
};
|
|
58
54
|
}
|
|
59
55
|
|
|
@@ -89,29 +85,37 @@ class ParanetOperationsManager {
|
|
|
89
85
|
operatorRewardPercentage,
|
|
90
86
|
incentivizationProposalVotersRewardPercentage,
|
|
91
87
|
);
|
|
92
|
-
if(
|
|
93
|
-
const {contract, tokenId} = resolveUAL(paranetUAL);
|
|
88
|
+
if ([INCENTIVE_TYPE.NEUROWEB, INCENTIVE_TYPE.NEUROWEB_ERC20].includes(incentiveType)) {
|
|
89
|
+
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
90
|
+
|
|
91
|
+
const isNativeReward = incentiveType === INCENTIVE_TYPE.NEUROWEB;
|
|
92
|
+
|
|
93
|
+
const emissionMultiplier =
|
|
94
|
+
BigInt(tracToNeuroEmissionMultiplier) * INCENTIVE_MULTIPLIER[incentiveType];
|
|
94
95
|
|
|
95
|
-
const receipt = await this.blockchainService.deployNeuroIncentivesPool(
|
|
96
|
+
const receipt = await this.blockchainService.deployNeuroIncentivesPool(
|
|
97
|
+
{
|
|
98
|
+
isNativeReward,
|
|
96
99
|
contract,
|
|
97
100
|
tokenId,
|
|
98
|
-
tracToNeuroEmissionMultiplier,
|
|
101
|
+
tracToNeuroEmissionMultiplier: emissionMultiplier,
|
|
99
102
|
operatorRewardPercentage,
|
|
100
103
|
incentivizationProposalVotersRewardPercentage,
|
|
101
104
|
},
|
|
102
|
-
blockchain
|
|
105
|
+
blockchain,
|
|
103
106
|
);
|
|
104
107
|
|
|
105
108
|
const paranetId = ethers.keccak256(
|
|
106
109
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
107
110
|
);
|
|
108
111
|
|
|
109
|
-
const neuroIncentivesPoolAddress =
|
|
112
|
+
const neuroIncentivesPoolAddress =
|
|
113
|
+
await this.blockchainService.getNeuroIncentivesPoolAddress(paranetId, blockchain);
|
|
110
114
|
|
|
111
115
|
return {
|
|
112
116
|
paranetUAL,
|
|
113
117
|
incentivesPoolContractAddress: neuroIncentivesPoolAddress,
|
|
114
|
-
operation: receipt
|
|
118
|
+
operation: receipt,
|
|
115
119
|
};
|
|
116
120
|
}
|
|
117
121
|
|
|
@@ -148,19 +152,20 @@ class ParanetOperationsManager {
|
|
|
148
152
|
|
|
149
153
|
const { contract, tokenId } = resolveUAL(UAL);
|
|
150
154
|
|
|
151
|
-
const receipt = await this.blockchainService.registerParanetService(
|
|
155
|
+
const receipt = await this.blockchainService.registerParanetService(
|
|
156
|
+
{
|
|
152
157
|
contract,
|
|
153
158
|
tokenId,
|
|
154
159
|
paranetServiceName,
|
|
155
160
|
paranetServiceDescription,
|
|
156
161
|
paranetServiceAddresses,
|
|
157
162
|
},
|
|
158
|
-
blockchain
|
|
163
|
+
blockchain,
|
|
159
164
|
);
|
|
160
165
|
|
|
161
166
|
return {
|
|
162
167
|
serviceUAL: UAL,
|
|
163
|
-
operation: receipt
|
|
168
|
+
operation: receipt,
|
|
164
169
|
};
|
|
165
170
|
}
|
|
166
171
|
|
|
@@ -184,23 +189,24 @@ class ParanetOperationsManager {
|
|
|
184
189
|
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
185
190
|
|
|
186
191
|
const processedServicesArray = [];
|
|
187
|
-
for(const serviceUAL of paranetServiceUALs) {
|
|
188
|
-
const { contract: serviceContract, tokenId: serviceTokenId } = resolveUAL(serviceUAL)
|
|
189
|
-
processedServicesArray.push([
|
|
192
|
+
for (const serviceUAL of paranetServiceUALs) {
|
|
193
|
+
const { contract: serviceContract, tokenId: serviceTokenId } = resolveUAL(serviceUAL);
|
|
194
|
+
processedServicesArray.push([serviceContract, serviceTokenId]);
|
|
190
195
|
}
|
|
191
196
|
|
|
192
|
-
const receipt = await this.blockchainService.addParanetServices(
|
|
197
|
+
const receipt = await this.blockchainService.addParanetServices(
|
|
198
|
+
{
|
|
193
199
|
contract,
|
|
194
200
|
tokenId,
|
|
195
|
-
processedServicesArray
|
|
201
|
+
processedServicesArray,
|
|
196
202
|
},
|
|
197
|
-
blockchain
|
|
203
|
+
blockchain,
|
|
198
204
|
);
|
|
199
205
|
|
|
200
206
|
return {
|
|
201
207
|
paranetUAL,
|
|
202
208
|
paranetServiceUALs,
|
|
203
|
-
operation: receipt
|
|
209
|
+
operation: receipt,
|
|
204
210
|
};
|
|
205
211
|
}
|
|
206
212
|
|
|
@@ -215,17 +221,17 @@ class ParanetOperationsManager {
|
|
|
215
221
|
*/
|
|
216
222
|
async claimMinerReward(paranetUAL, options = {}) {
|
|
217
223
|
const blockchain = this.inputService.getBlockchain(options);
|
|
218
|
-
this.validationService.validateParanetRewardArguments(
|
|
219
|
-
paranetUAL,
|
|
220
|
-
blockchain,
|
|
221
|
-
);
|
|
224
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
222
225
|
|
|
223
226
|
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
224
227
|
const paranetId = ethers.keccak256(
|
|
225
228
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
226
229
|
);
|
|
227
230
|
|
|
228
|
-
const receipt = await this.blockchainService.claimKnowledgeMinerReward(
|
|
231
|
+
const receipt = await this.blockchainService.claimKnowledgeMinerReward(
|
|
232
|
+
paranetId,
|
|
233
|
+
blockchain,
|
|
234
|
+
);
|
|
229
235
|
|
|
230
236
|
return {
|
|
231
237
|
operation: receipt,
|
|
@@ -245,10 +251,7 @@ class ParanetOperationsManager {
|
|
|
245
251
|
*/
|
|
246
252
|
async claimVoterReward(paranetUAL, options = {}) {
|
|
247
253
|
const blockchain = this.inputService.getBlockchain(options);
|
|
248
|
-
this.validationService.validateParanetRewardArguments(
|
|
249
|
-
paranetUAL,
|
|
250
|
-
blockchain,
|
|
251
|
-
);
|
|
254
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
252
255
|
|
|
253
256
|
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
254
257
|
const paranetId = ethers.keccak256(
|
|
@@ -275,10 +278,7 @@ class ParanetOperationsManager {
|
|
|
275
278
|
*/
|
|
276
279
|
async claimOperatorReward(paranetUAL, options = {}) {
|
|
277
280
|
const blockchain = this.inputService.getBlockchain(options);
|
|
278
|
-
this.validationService.validateParanetRewardArguments(
|
|
279
|
-
paranetUAL,
|
|
280
|
-
blockchain,
|
|
281
|
-
);
|
|
281
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
282
282
|
|
|
283
283
|
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
284
284
|
const paranetId = ethers.keccak256(
|
|
@@ -304,17 +304,17 @@ class ParanetOperationsManager {
|
|
|
304
304
|
*/
|
|
305
305
|
async getClaimableMinerReward(paranetUAL, options = {}) {
|
|
306
306
|
const blockchain = this.inputService.getBlockchain(options);
|
|
307
|
-
this.validationService.validateParanetRewardArguments(
|
|
308
|
-
paranetUAL,
|
|
309
|
-
blockchain,
|
|
310
|
-
);
|
|
307
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
311
308
|
|
|
312
309
|
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
313
310
|
const paranetId = ethers.keccak256(
|
|
314
311
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
315
312
|
);
|
|
316
313
|
|
|
317
|
-
const claimableValue = await this.blockchainService.getClaimableKnowledgeMinerReward(
|
|
314
|
+
const claimableValue = await this.blockchainService.getClaimableKnowledgeMinerReward(
|
|
315
|
+
paranetId,
|
|
316
|
+
blockchain,
|
|
317
|
+
);
|
|
318
318
|
|
|
319
319
|
return claimableValue;
|
|
320
320
|
}
|
|
@@ -330,17 +330,17 @@ class ParanetOperationsManager {
|
|
|
330
330
|
*/
|
|
331
331
|
async getClaimableAllMinersReward(paranetUAL, options = {}) {
|
|
332
332
|
const blockchain = this.inputService.getBlockchain(options);
|
|
333
|
-
this.validationService.validateParanetRewardArguments(
|
|
334
|
-
paranetUAL,
|
|
335
|
-
blockchain,
|
|
336
|
-
);
|
|
333
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
337
334
|
|
|
338
335
|
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
339
336
|
const paranetId = ethers.keccak256(
|
|
340
337
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
341
338
|
);
|
|
342
339
|
|
|
343
|
-
const claimableValue = await this.blockchainService.getClaimableAllKnowledgeMinersReward(
|
|
340
|
+
const claimableValue = await this.blockchainService.getClaimableAllKnowledgeMinersReward(
|
|
341
|
+
paranetId,
|
|
342
|
+
blockchain,
|
|
343
|
+
);
|
|
344
344
|
|
|
345
345
|
return claimableValue;
|
|
346
346
|
}
|
|
@@ -356,17 +356,17 @@ class ParanetOperationsManager {
|
|
|
356
356
|
*/
|
|
357
357
|
async getClaimableVoterReward(paranetUAL, options = {}) {
|
|
358
358
|
const blockchain = this.inputService.getBlockchain(options);
|
|
359
|
-
this.validationService.validateParanetRewardArguments(
|
|
360
|
-
paranetUAL,
|
|
361
|
-
blockchain,
|
|
362
|
-
);
|
|
359
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
363
360
|
|
|
364
|
-
const {contract, tokenId} = resolveUAL(paranetUAL);
|
|
361
|
+
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
365
362
|
const paranetId = ethers.keccak256(
|
|
366
363
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
367
364
|
);
|
|
368
365
|
|
|
369
|
-
const claimableValue = await this.blockchainService.getClaimableVoterReward(
|
|
366
|
+
const claimableValue = await this.blockchainService.getClaimableVoterReward(
|
|
367
|
+
paranetId,
|
|
368
|
+
blockchain,
|
|
369
|
+
);
|
|
370
370
|
|
|
371
371
|
return claimableValue;
|
|
372
372
|
}
|
|
@@ -382,17 +382,17 @@ class ParanetOperationsManager {
|
|
|
382
382
|
*/
|
|
383
383
|
async getClaimableAllVotersReward(paranetUAL, options = {}) {
|
|
384
384
|
const blockchain = this.inputService.getBlockchain(options);
|
|
385
|
-
this.validationService.validateParanetRewardArguments(
|
|
386
|
-
paranetUAL,
|
|
387
|
-
blockchain,
|
|
388
|
-
);
|
|
385
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
389
386
|
|
|
390
|
-
const {contract, tokenId} = resolveUAL(paranetUAL);
|
|
387
|
+
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
391
388
|
const paranetId = ethers.keccak256(
|
|
392
389
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
393
390
|
);
|
|
394
391
|
|
|
395
|
-
const claimableValue = await this.blockchainService.getClaimableAllVotersReward(
|
|
392
|
+
const claimableValue = await this.blockchainService.getClaimableAllVotersReward(
|
|
393
|
+
paranetId,
|
|
394
|
+
blockchain,
|
|
395
|
+
);
|
|
396
396
|
|
|
397
397
|
return claimableValue;
|
|
398
398
|
}
|
|
@@ -408,17 +408,17 @@ class ParanetOperationsManager {
|
|
|
408
408
|
*/
|
|
409
409
|
async getClaimableOperatorReward(paranetUAL, options = {}) {
|
|
410
410
|
const blockchain = this.inputService.getBlockchain(options);
|
|
411
|
-
this.validationService.validateParanetRewardArguments(
|
|
412
|
-
paranetUAL,
|
|
413
|
-
blockchain,
|
|
414
|
-
);
|
|
411
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
415
412
|
|
|
416
|
-
const {contract, tokenId} = resolveUAL(paranetUAL);
|
|
413
|
+
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
417
414
|
const paranetId = ethers.keccak256(
|
|
418
415
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
419
416
|
);
|
|
420
417
|
|
|
421
|
-
const claimableValue = await this.blockchainService.getClaimableOperatorReward(
|
|
418
|
+
const claimableValue = await this.blockchainService.getClaimableOperatorReward(
|
|
419
|
+
paranetId,
|
|
420
|
+
blockchain,
|
|
421
|
+
);
|
|
422
422
|
|
|
423
423
|
return claimableValue;
|
|
424
424
|
}
|
|
@@ -434,24 +434,28 @@ class ParanetOperationsManager {
|
|
|
434
434
|
*/
|
|
435
435
|
async updateClaimableRewards(paranetUAL, options = {}) {
|
|
436
436
|
const blockchain = this.inputService.getBlockchain(options);
|
|
437
|
-
this.validationService.validateParanetRewardArguments(
|
|
438
|
-
paranetUAL,
|
|
439
|
-
blockchain,
|
|
440
|
-
);
|
|
437
|
+
this.validationService.validateParanetRewardArguments(paranetUAL, blockchain);
|
|
441
438
|
|
|
442
439
|
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
443
440
|
const paranetId = ethers.keccak256(
|
|
444
441
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
445
442
|
);
|
|
446
443
|
|
|
447
|
-
const updatingKnowledgeAssetStates =
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
444
|
+
const updatingKnowledgeAssetStates =
|
|
445
|
+
await this.blockchainService.getUpdatingKnowledgeAssetStates(
|
|
446
|
+
{ miner: blockchain.publicKey, paranetId },
|
|
447
|
+
blockchain,
|
|
448
|
+
);
|
|
449
|
+
if (updatingKnowledgeAssetStates.length > 0) {
|
|
450
|
+
const receipt = await this.blockchainService.updateClaimableRewards(
|
|
451
|
+
{
|
|
452
|
+
contract,
|
|
453
|
+
tokenId,
|
|
454
|
+
start: 0,
|
|
455
|
+
end: updatingKnowledgeAssetStates.length,
|
|
456
|
+
},
|
|
457
|
+
blockchain,
|
|
458
|
+
);
|
|
455
459
|
|
|
456
460
|
return {
|
|
457
461
|
operation: receipt,
|
|
@@ -461,7 +465,7 @@ class ParanetOperationsManager {
|
|
|
461
465
|
}
|
|
462
466
|
|
|
463
467
|
return {
|
|
464
|
-
status: 'No updated knowledge assets.'
|
|
468
|
+
status: 'No updated knowledge assets.',
|
|
465
469
|
};
|
|
466
470
|
}
|
|
467
471
|
|
|
@@ -476,7 +480,7 @@ class ParanetOperationsManager {
|
|
|
476
480
|
*/
|
|
477
481
|
async isKnowledgeMiner(paranetUAL, options = {}) {
|
|
478
482
|
// eslint-disable-next-line prefer-const
|
|
479
|
-
let { blockchain, roleAddress }
|
|
483
|
+
let { blockchain, roleAddress } = this.inputService.getParanetRoleCheckArguments(options);
|
|
480
484
|
if (roleAddress == null) {
|
|
481
485
|
roleAddress = blockchain.publicKey;
|
|
482
486
|
}
|
|
@@ -486,12 +490,16 @@ class ParanetOperationsManager {
|
|
|
486
490
|
blockchain,
|
|
487
491
|
);
|
|
488
492
|
|
|
489
|
-
const {contract, tokenId} = resolveUAL(paranetUAL);
|
|
493
|
+
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
490
494
|
const paranetId = ethers.keccak256(
|
|
491
495
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
492
496
|
);
|
|
493
497
|
|
|
494
|
-
const isParanetKnowledgeMiner = await this.blockchainService.isParanetKnowledgeMiner(
|
|
498
|
+
const isParanetKnowledgeMiner = await this.blockchainService.isParanetKnowledgeMiner(
|
|
499
|
+
roleAddress,
|
|
500
|
+
paranetId,
|
|
501
|
+
blockchain,
|
|
502
|
+
);
|
|
495
503
|
|
|
496
504
|
return isParanetKnowledgeMiner;
|
|
497
505
|
}
|
|
@@ -507,7 +515,7 @@ class ParanetOperationsManager {
|
|
|
507
515
|
*/
|
|
508
516
|
async isParanetOperator(paranetUAL, options = {}) {
|
|
509
517
|
// eslint-disable-next-line prefer-const
|
|
510
|
-
let { blockchain, roleAddress }
|
|
518
|
+
let { blockchain, roleAddress } = this.inputService.getParanetRoleCheckArguments(options);
|
|
511
519
|
if (roleAddress == null) {
|
|
512
520
|
roleAddress = blockchain.publicKey;
|
|
513
521
|
}
|
|
@@ -517,12 +525,16 @@ class ParanetOperationsManager {
|
|
|
517
525
|
blockchain,
|
|
518
526
|
);
|
|
519
527
|
|
|
520
|
-
const {contract, tokenId} = resolveUAL(paranetUAL);
|
|
528
|
+
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
521
529
|
const paranetId = ethers.keccak256(
|
|
522
530
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
523
531
|
);
|
|
524
532
|
|
|
525
|
-
const isParanetOperator = await this.blockchainService.isParanetOperator(
|
|
533
|
+
const isParanetOperator = await this.blockchainService.isParanetOperator(
|
|
534
|
+
roleAddress,
|
|
535
|
+
paranetId,
|
|
536
|
+
blockchain,
|
|
537
|
+
);
|
|
526
538
|
|
|
527
539
|
return isParanetOperator;
|
|
528
540
|
}
|
|
@@ -538,7 +550,7 @@ class ParanetOperationsManager {
|
|
|
538
550
|
*/
|
|
539
551
|
async isProposalVoter(paranetUAL, options = {}) {
|
|
540
552
|
// eslint-disable-next-line prefer-const
|
|
541
|
-
let { blockchain, roleAddress }
|
|
553
|
+
let { blockchain, roleAddress } = this.inputService.getParanetRoleCheckArguments(options);
|
|
542
554
|
if (roleAddress == null) {
|
|
543
555
|
roleAddress = blockchain.publicKey;
|
|
544
556
|
}
|
|
@@ -548,15 +560,18 @@ class ParanetOperationsManager {
|
|
|
548
560
|
blockchain,
|
|
549
561
|
);
|
|
550
562
|
|
|
551
|
-
const {contract, tokenId} = resolveUAL(paranetUAL);
|
|
563
|
+
const { contract, tokenId } = resolveUAL(paranetUAL);
|
|
552
564
|
const paranetId = ethers.keccak256(
|
|
553
565
|
ethers.solidityPacked(['address', 'uint256'], [contract, tokenId]),
|
|
554
566
|
);
|
|
555
567
|
|
|
556
|
-
const isProposalVoter = await this.blockchainService.isParanetProposalVoter(
|
|
568
|
+
const isProposalVoter = await this.blockchainService.isParanetProposalVoter(
|
|
569
|
+
roleAddress,
|
|
570
|
+
paranetId,
|
|
571
|
+
blockchain,
|
|
572
|
+
);
|
|
557
573
|
|
|
558
574
|
return isProposalVoter;
|
|
559
575
|
}
|
|
560
|
-
|
|
561
576
|
}
|
|
562
577
|
module.exports = ParanetOperationsManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dkg.js",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.4",
|
|
4
4
|
"description": "Javascript library for interaction with the OriginTrail Decentralized Knowledge Graph",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/OriginTrail/dkg.js/tree/main#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"assertion-tools": "^2.1
|
|
32
|
+
"assertion-tools": "^2.2.1",
|
|
33
33
|
"axios": "^0.27.2",
|
|
34
|
-
"dkg-evm-module": "^4.
|
|
34
|
+
"dkg-evm-module": "^4.4.0",
|
|
35
35
|
"ethers": "^6.1.0",
|
|
36
36
|
"jsonld": "^8.1.0",
|
|
37
37
|
"web3": "^1.7.3"
|
|
@@ -15,7 +15,11 @@ const ParanetsRegistryAbi = require('dkg-evm-module/abi/ParanetsRegistry.json');
|
|
|
15
15
|
const ParanetIncentivesPoolFactoryAbi = require('dkg-evm-module/abi/ParanetIncentivesPoolFactory.json');
|
|
16
16
|
const ParanetNeuroIncentivesPoolAbi = require('dkg-evm-module/abi/ParanetNeuroIncentivesPool.json');
|
|
17
17
|
const ParanetKnowledgeMinersRegistryAbi = require('dkg-evm-module/abi/ParanetKnowledgeMinersRegistry.json');
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
OPERATIONS_STEP_STATUS,
|
|
20
|
+
DEFAULT_GAS_PRICE,
|
|
21
|
+
NEUROWEB_BLOCKCHAIN_PREFIX,
|
|
22
|
+
} = require('../../constants');
|
|
19
23
|
const emptyHooks = require('../../util/empty-hooks.js');
|
|
20
24
|
const { sleepForMilliseconds } = require('../utilities.js');
|
|
21
25
|
|
|
@@ -74,8 +78,9 @@ class BlockchainServiceBase {
|
|
|
74
78
|
|
|
75
79
|
const web3Instance = await this.getWeb3Instance(blockchain);
|
|
76
80
|
this[blockchain.name].contracts[blockchain.hubContract].Hub =
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
new web3Instance.eth.Contract(this.abis.Hub, blockchain.hubContract, {
|
|
82
|
+
from: blockchain.publicKey,
|
|
83
|
+
});
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
|
|
@@ -167,7 +172,7 @@ class BlockchainServiceBase {
|
|
|
167
172
|
let gasLimit = Number(
|
|
168
173
|
await contractInstance.methods[functionName](...args).estimateGas({
|
|
169
174
|
from: publicKey,
|
|
170
|
-
})
|
|
175
|
+
}),
|
|
171
176
|
);
|
|
172
177
|
gasLimit = Math.round(gasLimit * blockchain.gasLimitMultiplier);
|
|
173
178
|
|
|
@@ -188,7 +193,9 @@ class BlockchainServiceBase {
|
|
|
188
193
|
|
|
189
194
|
// Search for pending tx in the pending block
|
|
190
195
|
const pendingTx = Object.values(pendingBlock.transactions).find(
|
|
191
|
-
tx =>
|
|
196
|
+
(tx) =>
|
|
197
|
+
tx.from.toLowerCase() === publicKey.toLowerCase() &&
|
|
198
|
+
tx.nonce === confirmedNonce,
|
|
192
199
|
);
|
|
193
200
|
|
|
194
201
|
if (pendingTx) {
|
|
@@ -197,7 +204,9 @@ class BlockchainServiceBase {
|
|
|
197
204
|
} else {
|
|
198
205
|
// If not found, use default/network gas price increased by 20%
|
|
199
206
|
// Theoretically this should never happen
|
|
200
|
-
gasPrice = Math.round(
|
|
207
|
+
gasPrice = Math.round(
|
|
208
|
+
(blockchain.gasPrice || (await this.getNetworkGasPrice(blockchain))) * 1.2,
|
|
209
|
+
);
|
|
201
210
|
}
|
|
202
211
|
}
|
|
203
212
|
} else {
|
|
@@ -231,31 +240,50 @@ class BlockchainServiceBase {
|
|
|
231
240
|
let reminingTime = 0;
|
|
232
241
|
let receipt = initialReceipt;
|
|
233
242
|
let finalized = false;
|
|
234
|
-
|
|
243
|
+
|
|
235
244
|
try {
|
|
236
|
-
while (
|
|
245
|
+
while (
|
|
246
|
+
!finalized &&
|
|
247
|
+
Date.now() - startTime + reminingTime < blockchain.transactionFinalityMaxWaitTime
|
|
248
|
+
) {
|
|
237
249
|
try {
|
|
238
250
|
// Check if the block containing the transaction is finalized
|
|
239
|
-
const finalizedBlockNumber = (await web3Instance.eth.getBlock('finalized'))
|
|
251
|
+
const finalizedBlockNumber = (await web3Instance.eth.getBlock('finalized'))
|
|
252
|
+
.number;
|
|
240
253
|
if (finalizedBlockNumber >= receipt.blockNumber) {
|
|
241
254
|
finalized = true;
|
|
242
255
|
break;
|
|
243
256
|
} else {
|
|
244
|
-
let currentReceipt = await web3Instance.eth.getTransactionReceipt(
|
|
257
|
+
let currentReceipt = await web3Instance.eth.getTransactionReceipt(
|
|
258
|
+
receipt.transactionHash,
|
|
259
|
+
);
|
|
245
260
|
if (currentReceipt && currentReceipt.blockNumber === receipt.blockNumber) {
|
|
246
261
|
// Transaction is still in the same block, wait and check again
|
|
247
|
-
} else if (
|
|
262
|
+
} else if (
|
|
263
|
+
currentReceipt &&
|
|
264
|
+
currentReceipt.blockNumber !== receipt.blockNumber
|
|
265
|
+
) {
|
|
248
266
|
// Transaction has been re-included in a different block
|
|
249
267
|
receipt = currentReceipt; // Update the receipt with the new block information
|
|
250
268
|
} else {
|
|
251
269
|
// Transaction is no longer mined, wait for it to be mined again
|
|
252
270
|
const reminingStartTime = Date.now();
|
|
253
|
-
while (
|
|
254
|
-
|
|
255
|
-
|
|
271
|
+
while (
|
|
272
|
+
!currentReceipt &&
|
|
273
|
+
Date.now() - reminingStartTime <
|
|
274
|
+
blockchain.transactionReminingMaxWaitTime
|
|
275
|
+
) {
|
|
276
|
+
await sleepForMilliseconds(
|
|
277
|
+
blockchain.transactionReminingPollingInterval,
|
|
278
|
+
);
|
|
279
|
+
currentReceipt = await web3Instance.eth.getTransactionReceipt(
|
|
280
|
+
receipt.transactionHash,
|
|
281
|
+
);
|
|
256
282
|
}
|
|
257
283
|
if (!currentReceipt) {
|
|
258
|
-
throw new Error(
|
|
284
|
+
throw new Error(
|
|
285
|
+
'Transaction was not re-mined within the expected time frame.',
|
|
286
|
+
);
|
|
259
287
|
}
|
|
260
288
|
reminingTime = Date.now() - reminingStartTime;
|
|
261
289
|
receipt = currentReceipt; // Update the receipt
|
|
@@ -267,11 +295,11 @@ class BlockchainServiceBase {
|
|
|
267
295
|
throw new Error(`Error during finality polling: ${error.message}`);
|
|
268
296
|
}
|
|
269
297
|
}
|
|
270
|
-
|
|
298
|
+
|
|
271
299
|
if (!finalized) {
|
|
272
300
|
throw new Error('Transaction was not finalized within the expected time frame.');
|
|
273
301
|
}
|
|
274
|
-
|
|
302
|
+
|
|
275
303
|
return receipt;
|
|
276
304
|
} catch (error) {
|
|
277
305
|
throw new Error(`Failed to wait for transaction finalization: ${error.message}`);
|
|
@@ -318,7 +346,12 @@ class BlockchainServiceBase {
|
|
|
318
346
|
return this[blockchain.name].contracts[blockchain.hubContract][contractName];
|
|
319
347
|
}
|
|
320
348
|
|
|
321
|
-
async increaseServiceAgreementV1Allowance(
|
|
349
|
+
async increaseServiceAgreementV1Allowance(
|
|
350
|
+
sender,
|
|
351
|
+
serviceAgreementV1Address,
|
|
352
|
+
tokenAmount,
|
|
353
|
+
blockchain,
|
|
354
|
+
) {
|
|
322
355
|
const allowance = await this.callContractFunction(
|
|
323
356
|
'Token',
|
|
324
357
|
'allowance',
|
|
@@ -345,12 +378,18 @@ class BlockchainServiceBase {
|
|
|
345
378
|
return {
|
|
346
379
|
allowanceIncreased: false,
|
|
347
380
|
allowanceGap,
|
|
348
|
-
}
|
|
381
|
+
};
|
|
349
382
|
}
|
|
350
383
|
|
|
351
384
|
// Knowledge assets operations
|
|
352
385
|
|
|
353
|
-
async createAsset(
|
|
386
|
+
async createAsset(
|
|
387
|
+
requestData,
|
|
388
|
+
paranetKaContract,
|
|
389
|
+
paranetTokenId,
|
|
390
|
+
blockchain,
|
|
391
|
+
stepHooks = emptyHooks,
|
|
392
|
+
) {
|
|
354
393
|
const sender = await this.getPublicKey(blockchain);
|
|
355
394
|
let serviceAgreementV1Address;
|
|
356
395
|
let allowanceIncreased = false;
|
|
@@ -366,7 +405,7 @@ class BlockchainServiceBase {
|
|
|
366
405
|
sender,
|
|
367
406
|
serviceAgreementV1Address,
|
|
368
407
|
requestData.tokenAmount,
|
|
369
|
-
blockchain
|
|
408
|
+
blockchain,
|
|
370
409
|
));
|
|
371
410
|
|
|
372
411
|
stepHooks.afterHook({
|
|
@@ -374,7 +413,7 @@ class BlockchainServiceBase {
|
|
|
374
413
|
});
|
|
375
414
|
|
|
376
415
|
let receipt;
|
|
377
|
-
if(paranetKaContract == null && paranetTokenId == null) {
|
|
416
|
+
if (paranetKaContract == null && paranetTokenId == null) {
|
|
378
417
|
receipt = await this.executeContractFunction(
|
|
379
418
|
'ContentAsset',
|
|
380
419
|
'createAsset',
|
|
@@ -437,7 +476,7 @@ class BlockchainServiceBase {
|
|
|
437
476
|
sender,
|
|
438
477
|
serviceAgreementV1Address,
|
|
439
478
|
tokenAmount,
|
|
440
|
-
blockchain
|
|
479
|
+
blockchain,
|
|
441
480
|
));
|
|
442
481
|
|
|
443
482
|
return this.executeContractFunction(
|
|
@@ -526,7 +565,7 @@ class BlockchainServiceBase {
|
|
|
526
565
|
sender,
|
|
527
566
|
serviceAgreementV1Address,
|
|
528
567
|
tokenAmount,
|
|
529
|
-
blockchain
|
|
568
|
+
blockchain,
|
|
530
569
|
));
|
|
531
570
|
|
|
532
571
|
return this.executeContractFunction(
|
|
@@ -564,7 +603,7 @@ class BlockchainServiceBase {
|
|
|
564
603
|
sender,
|
|
565
604
|
serviceAgreementV1Address,
|
|
566
605
|
tokenAmount,
|
|
567
|
-
blockchain
|
|
606
|
+
blockchain,
|
|
568
607
|
));
|
|
569
608
|
|
|
570
609
|
return this.executeContractFunction(
|
|
@@ -602,7 +641,7 @@ class BlockchainServiceBase {
|
|
|
602
641
|
sender,
|
|
603
642
|
serviceAgreementV1Address,
|
|
604
643
|
tokenAmount,
|
|
605
|
-
blockchain
|
|
644
|
+
blockchain,
|
|
606
645
|
));
|
|
607
646
|
|
|
608
647
|
return this.executeContractFunction(
|
|
@@ -753,33 +792,46 @@ class BlockchainServiceBase {
|
|
|
753
792
|
);
|
|
754
793
|
}
|
|
755
794
|
|
|
756
|
-
async getNeuroIncentivesPoolAddress(paranetId,blockchain) {
|
|
795
|
+
async getNeuroIncentivesPoolAddress(paranetId, blockchain) {
|
|
757
796
|
return this.getIncentivesPoolAddress(
|
|
758
797
|
{
|
|
759
798
|
paranetId,
|
|
760
|
-
incentivesPoolType:
|
|
799
|
+
incentivesPoolType: blockchain.name.includes(NEUROWEB_BLOCKCHAIN_PREFIX)
|
|
800
|
+
? 'Neuroweb'
|
|
801
|
+
: 'NeurowebERC20',
|
|
761
802
|
},
|
|
762
|
-
blockchain
|
|
763
|
-
)
|
|
803
|
+
blockchain,
|
|
804
|
+
);
|
|
764
805
|
}
|
|
765
806
|
|
|
766
|
-
async setIncentivesPool(contractAddress, blockchain){
|
|
807
|
+
async setIncentivesPool(contractAddress, blockchain) {
|
|
767
808
|
await this.ensureBlockchainInfo(blockchain);
|
|
768
809
|
|
|
769
|
-
if (
|
|
770
|
-
this[blockchain.name].contractAddresses[blockchain.hubContract][
|
|
810
|
+
if (
|
|
811
|
+
this[blockchain.name].contractAddresses[blockchain.hubContract][
|
|
812
|
+
'ParanetNeuroIncentivesPool'
|
|
813
|
+
] !== contractAddress
|
|
814
|
+
) {
|
|
815
|
+
this[blockchain.name].contractAddresses[blockchain.hubContract][
|
|
816
|
+
'ParanetNeuroIncentivesPool'
|
|
817
|
+
] = contractAddress;
|
|
771
818
|
const web3Instance = await this.getWeb3Instance(blockchain);
|
|
772
819
|
this[blockchain.name].contracts[blockchain.hubContract]['ParanetNeuroIncentivesPool'] =
|
|
773
820
|
await new web3Instance.eth.Contract(
|
|
774
821
|
this.abis['ParanetNeuroIncentivesPool'],
|
|
775
|
-
this[blockchain.name].contractAddresses[blockchain.hubContract][
|
|
822
|
+
this[blockchain.name].contractAddresses[blockchain.hubContract][
|
|
823
|
+
'ParanetNeuroIncentivesPool'
|
|
824
|
+
],
|
|
776
825
|
{ from: blockchain.publicKey },
|
|
777
826
|
);
|
|
778
827
|
}
|
|
779
828
|
}
|
|
780
829
|
|
|
781
830
|
async claimKnowledgeMinerReward(paranetId, blockchain) {
|
|
782
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
831
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
832
|
+
paranetId,
|
|
833
|
+
blockchain,
|
|
834
|
+
);
|
|
783
835
|
|
|
784
836
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
785
837
|
|
|
@@ -792,7 +844,10 @@ class BlockchainServiceBase {
|
|
|
792
844
|
}
|
|
793
845
|
|
|
794
846
|
async claimVoterReward(paranetId, blockchain) {
|
|
795
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
847
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
848
|
+
paranetId,
|
|
849
|
+
blockchain,
|
|
850
|
+
);
|
|
796
851
|
|
|
797
852
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
798
853
|
|
|
@@ -805,7 +860,10 @@ class BlockchainServiceBase {
|
|
|
805
860
|
}
|
|
806
861
|
|
|
807
862
|
async claimOperatorReward(paranetId, blockchain) {
|
|
808
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
863
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
864
|
+
paranetId,
|
|
865
|
+
blockchain,
|
|
866
|
+
);
|
|
809
867
|
|
|
810
868
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
811
869
|
|
|
@@ -818,7 +876,10 @@ class BlockchainServiceBase {
|
|
|
818
876
|
}
|
|
819
877
|
|
|
820
878
|
async getClaimableKnowledgeMinerReward(paranetId, blockchain) {
|
|
821
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
879
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
880
|
+
paranetId,
|
|
881
|
+
blockchain,
|
|
882
|
+
);
|
|
822
883
|
|
|
823
884
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
824
885
|
|
|
@@ -831,7 +892,10 @@ class BlockchainServiceBase {
|
|
|
831
892
|
}
|
|
832
893
|
|
|
833
894
|
async getClaimableAllKnowledgeMinersReward(paranetId, blockchain) {
|
|
834
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
895
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
896
|
+
paranetId,
|
|
897
|
+
blockchain,
|
|
898
|
+
);
|
|
835
899
|
|
|
836
900
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
837
901
|
|
|
@@ -844,7 +908,10 @@ class BlockchainServiceBase {
|
|
|
844
908
|
}
|
|
845
909
|
|
|
846
910
|
async getClaimableVoterReward(paranetId, blockchain) {
|
|
847
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
911
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
912
|
+
paranetId,
|
|
913
|
+
blockchain,
|
|
914
|
+
);
|
|
848
915
|
|
|
849
916
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
850
917
|
|
|
@@ -857,7 +924,10 @@ class BlockchainServiceBase {
|
|
|
857
924
|
}
|
|
858
925
|
|
|
859
926
|
async getClaimableAllVotersReward(paranetId, blockchain) {
|
|
860
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
927
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
928
|
+
paranetId,
|
|
929
|
+
blockchain,
|
|
930
|
+
);
|
|
861
931
|
|
|
862
932
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
863
933
|
|
|
@@ -870,7 +940,10 @@ class BlockchainServiceBase {
|
|
|
870
940
|
}
|
|
871
941
|
|
|
872
942
|
async getClaimableOperatorReward(paranetId, blockchain) {
|
|
873
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
943
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
944
|
+
paranetId,
|
|
945
|
+
blockchain,
|
|
946
|
+
);
|
|
874
947
|
|
|
875
948
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
876
949
|
|
|
@@ -882,8 +955,11 @@ class BlockchainServiceBase {
|
|
|
882
955
|
);
|
|
883
956
|
}
|
|
884
957
|
|
|
885
|
-
async isParanetKnowledgeMiner(address
|
|
886
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
958
|
+
async isParanetKnowledgeMiner(address, paranetId, blockchain) {
|
|
959
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
960
|
+
paranetId,
|
|
961
|
+
blockchain,
|
|
962
|
+
);
|
|
887
963
|
|
|
888
964
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
889
965
|
|
|
@@ -895,8 +971,11 @@ class BlockchainServiceBase {
|
|
|
895
971
|
);
|
|
896
972
|
}
|
|
897
973
|
|
|
898
|
-
async isParanetOperator(address
|
|
899
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
974
|
+
async isParanetOperator(address, paranetId, blockchain) {
|
|
975
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
976
|
+
paranetId,
|
|
977
|
+
blockchain,
|
|
978
|
+
);
|
|
900
979
|
|
|
901
980
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
902
981
|
|
|
@@ -908,8 +987,11 @@ class BlockchainServiceBase {
|
|
|
908
987
|
);
|
|
909
988
|
}
|
|
910
989
|
|
|
911
|
-
async isParanetProposalVoter(address
|
|
912
|
-
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
990
|
+
async isParanetProposalVoter(address, paranetId, blockchain) {
|
|
991
|
+
const neuroIncentivesPoolAddress = await this.getNeuroIncentivesPoolAddress(
|
|
992
|
+
paranetId,
|
|
993
|
+
blockchain,
|
|
994
|
+
);
|
|
913
995
|
|
|
914
996
|
await this.setIncentivesPool(neuroIncentivesPoolAddress, blockchain);
|
|
915
997
|
|
|
@@ -5,13 +5,25 @@ const { sleepForMilliseconds } = require('../../utilities.js');
|
|
|
5
5
|
class HttpService {
|
|
6
6
|
constructor(config = {}) {
|
|
7
7
|
this.config = config;
|
|
8
|
+
|
|
9
|
+
if (
|
|
10
|
+
!(
|
|
11
|
+
config.nodeApiVersion === '/' ||
|
|
12
|
+
config.nodeApiVersion === '/latest' ||
|
|
13
|
+
/^\/v\d+$/.test(config.nodeApiVersion)
|
|
14
|
+
)
|
|
15
|
+
) {
|
|
16
|
+
throw Error(`Version must be '/latest', '/' or in '/v{digits}' format.`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.apiVersion = config.nodeApiVersion ?? '/v0';
|
|
8
20
|
}
|
|
9
21
|
|
|
10
22
|
async info(endpoint, port, authToken) {
|
|
11
23
|
try {
|
|
12
24
|
const response = await axios({
|
|
13
25
|
method: 'get',
|
|
14
|
-
url: `${endpoint
|
|
26
|
+
url: `${this.getBaseUrl(endpoint, port)}/info`,
|
|
15
27
|
headers: this.prepareRequestConfig(authToken),
|
|
16
28
|
});
|
|
17
29
|
|
|
@@ -47,7 +59,7 @@ class HttpService {
|
|
|
47
59
|
}
|
|
48
60
|
const response = await axios({
|
|
49
61
|
method: 'get',
|
|
50
|
-
url: `${endpoint
|
|
62
|
+
url: `${this.getBaseUrl(endpoint, port)}/bid-suggestion`,
|
|
51
63
|
params,
|
|
52
64
|
headers: this.prepareRequestConfig(authToken),
|
|
53
65
|
});
|
|
@@ -62,7 +74,7 @@ class HttpService {
|
|
|
62
74
|
try {
|
|
63
75
|
const response = await axios({
|
|
64
76
|
method: 'post',
|
|
65
|
-
url: `${endpoint
|
|
77
|
+
url: `${this.getBaseUrl(endpoint, port)}/local-store`,
|
|
66
78
|
data: assertions,
|
|
67
79
|
headers: this.prepareRequestConfig(authToken),
|
|
68
80
|
});
|
|
@@ -87,7 +99,7 @@ class HttpService {
|
|
|
87
99
|
try {
|
|
88
100
|
const response = await axios({
|
|
89
101
|
method: 'post',
|
|
90
|
-
url: `${endpoint
|
|
102
|
+
url: `${this.getBaseUrl(endpoint, port)}/publish`,
|
|
91
103
|
data: {
|
|
92
104
|
assertionId,
|
|
93
105
|
assertion,
|
|
@@ -109,7 +121,7 @@ class HttpService {
|
|
|
109
121
|
try {
|
|
110
122
|
const response = await axios({
|
|
111
123
|
method: 'post',
|
|
112
|
-
url: `${endpoint
|
|
124
|
+
url: `${this.getBaseUrl(endpoint, port)}/get`,
|
|
113
125
|
data: {
|
|
114
126
|
id: UAL,
|
|
115
127
|
state,
|
|
@@ -138,7 +150,7 @@ class HttpService {
|
|
|
138
150
|
try {
|
|
139
151
|
const response = await axios({
|
|
140
152
|
method: 'post',
|
|
141
|
-
url: `${endpoint
|
|
153
|
+
url: `${this.getBaseUrl(endpoint, port)}/update`,
|
|
142
154
|
data: {
|
|
143
155
|
assertionId,
|
|
144
156
|
assertion,
|
|
@@ -160,7 +172,7 @@ class HttpService {
|
|
|
160
172
|
try {
|
|
161
173
|
const response = await axios({
|
|
162
174
|
method: 'post',
|
|
163
|
-
url: `${endpoint
|
|
175
|
+
url: `${this.getBaseUrl(endpoint, port)}/query`,
|
|
164
176
|
data: { query, type, repository },
|
|
165
177
|
headers: this.prepareRequestConfig(authToken),
|
|
166
178
|
});
|
|
@@ -187,7 +199,7 @@ class HttpService {
|
|
|
187
199
|
|
|
188
200
|
const axios_config = {
|
|
189
201
|
method: 'get',
|
|
190
|
-
url: `${endpoint
|
|
202
|
+
url: `${this.getBaseUrl(endpoint, port)}/${operation}/${operationId}`,
|
|
191
203
|
headers: this.prepareRequestConfig(authToken),
|
|
192
204
|
};
|
|
193
205
|
do {
|
|
@@ -220,5 +232,9 @@ class HttpService {
|
|
|
220
232
|
|
|
221
233
|
return {};
|
|
222
234
|
}
|
|
235
|
+
|
|
236
|
+
getBaseUrl(endpoint, port) {
|
|
237
|
+
return `${endpoint}:${port}${this.apiVersion}`;
|
|
238
|
+
}
|
|
223
239
|
}
|
|
224
240
|
module.exports = HttpService;
|