dkg.js 6.2.0 → 6.2.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.
|
@@ -14,27 +14,35 @@ class NetworkOperationsManager {
|
|
|
14
14
|
* @returns {BigInt} Suggested bid for publishing Knowledge Asset with given parameters.
|
|
15
15
|
*/
|
|
16
16
|
async getBidSuggestion(publicAssertionId, sizeInBytes, options = {}) {
|
|
17
|
-
const {
|
|
18
|
-
|
|
17
|
+
const {
|
|
18
|
+
blockchain,
|
|
19
|
+
endpoint,
|
|
20
|
+
port,
|
|
21
|
+
epochsNum,
|
|
22
|
+
hashFunctionId,
|
|
23
|
+
authToken,
|
|
24
|
+
bidSuggestionRange,
|
|
25
|
+
} = this.inputService.getBidSuggestionArguments(options);
|
|
19
26
|
|
|
20
27
|
const contentAssetStorageAddress = await this.blockchainService.getContractAddress(
|
|
21
28
|
'ContentAssetStorage',
|
|
22
29
|
blockchain,
|
|
23
30
|
);
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
),
|
|
32
|
+
const response = await this.nodeApiService.getBidSuggestion(
|
|
33
|
+
endpoint,
|
|
34
|
+
port,
|
|
35
|
+
authToken,
|
|
36
|
+
blockchain.name,
|
|
37
|
+
epochsNum,
|
|
38
|
+
sizeInBytes,
|
|
39
|
+
contentAssetStorageAddress,
|
|
40
|
+
publicAssertionId,
|
|
41
|
+
hashFunctionId,
|
|
42
|
+
bidSuggestionRange,
|
|
37
43
|
);
|
|
44
|
+
|
|
45
|
+
return typeof response === 'string' ? BigInt(response) : response;
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
module.exports = NetworkOperationsManager;
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ const {
|
|
|
2
2
|
DEFAULT_PARAMETERS,
|
|
3
3
|
DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS,
|
|
4
4
|
BLOCKCHAINS,
|
|
5
|
+
LOW_BID_SUGGESTION,
|
|
5
6
|
} = require('../constants');
|
|
6
7
|
|
|
7
8
|
class InputService {
|
|
@@ -17,6 +18,7 @@ class InputService {
|
|
|
17
18
|
epochsNum: this.getEpochsNum(options),
|
|
18
19
|
hashFunctionId: this.getHashFunctionId(options),
|
|
19
20
|
authToken: this.getAuthToken(options),
|
|
21
|
+
bidSuggestionRange: this.getBidSuggestionRange(options),
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -200,6 +202,10 @@ class InputService {
|
|
|
200
202
|
getAuthToken(options) {
|
|
201
203
|
return options.auth?.token ?? this.config?.auth?.token ?? null;
|
|
202
204
|
}
|
|
205
|
+
|
|
206
|
+
getBidSuggestionRange(options) {
|
|
207
|
+
return options.bidSuggestionRange ?? LOW_BID_SUGGESTION;
|
|
208
|
+
}
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
module.exports = InputService;
|
|
@@ -31,19 +31,24 @@ class HttpService {
|
|
|
31
31
|
contentAssetStorageAddress,
|
|
32
32
|
firstAssertionId,
|
|
33
33
|
hashFunctionId,
|
|
34
|
+
bidSuggestionRange,
|
|
34
35
|
) {
|
|
35
36
|
try {
|
|
37
|
+
const params = {
|
|
38
|
+
blockchain,
|
|
39
|
+
epochsNumber,
|
|
40
|
+
assertionSize,
|
|
41
|
+
contentAssetStorageAddress,
|
|
42
|
+
firstAssertionId,
|
|
43
|
+
hashFunctionId,
|
|
44
|
+
};
|
|
45
|
+
if (bidSuggestionRange != null) {
|
|
46
|
+
params.bidSuggestionRange = bidSuggestionRange;
|
|
47
|
+
}
|
|
36
48
|
const response = await axios({
|
|
37
49
|
method: 'get',
|
|
38
50
|
url: `${endpoint}:${port}/bid-suggestion`,
|
|
39
|
-
params
|
|
40
|
-
blockchain,
|
|
41
|
-
epochsNumber,
|
|
42
|
-
assertionSize,
|
|
43
|
-
contentAssetStorageAddress,
|
|
44
|
-
firstAssertionId,
|
|
45
|
-
hashFunctionId,
|
|
46
|
-
},
|
|
51
|
+
params,
|
|
47
52
|
headers: this.prepareRequestConfig(authToken),
|
|
48
53
|
});
|
|
49
54
|
|
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
OPERATIONS,
|
|
8
8
|
GET_OUTPUT_FORMATS,
|
|
9
9
|
QUERY_TYPES,
|
|
10
|
+
BID_SUGGESTION_RANGE_ENUM,
|
|
10
11
|
} = require('../constants.js');
|
|
11
12
|
const { nodeSupported } = require('./utilities.js');
|
|
12
13
|
|
|
@@ -402,5 +403,17 @@ class ValidationService {
|
|
|
402
403
|
this.validateRequiredParam('newOwner', newOwner);
|
|
403
404
|
this.validateParamType('newOwner', newOwner, 'string');
|
|
404
405
|
}
|
|
406
|
+
|
|
407
|
+
validateGetBidSuggestion(bidSuggestionRange) {
|
|
408
|
+
this.validateBidSuggestionRange(bidSuggestionRange);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
validateBidSuggestionRange(bidSuggestionRange) {
|
|
412
|
+
if (!BID_SUGGESTION_RANGE_ENUM.includes(bidSuggestionRange)) {
|
|
413
|
+
throw Error(
|
|
414
|
+
`Invalid bidSuggestionRange parametar: supported parametars ${BID_SUGGESTION_RANGE_ENUM}`,
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
405
418
|
}
|
|
406
419
|
module.exports = ValidationService;
|