dkg.js 6.1.2 → 6.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dkg.js",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Javascript library for interaction with the OriginTrail Decentralized Knowledge Graph",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"assertion-tools": "^2.1.0",
|
|
33
33
|
"axios": "^0.27.2",
|
|
34
|
-
"dkg-evm-module": "^4.
|
|
34
|
+
"dkg-evm-module": "^4.2.4",
|
|
35
35
|
"ethers": "^6.1.0",
|
|
36
36
|
"jsonld": "^8.1.0",
|
|
37
37
|
"web3": "^1.7.3"
|
|
@@ -8,7 +8,7 @@ const ContentAssetStorageAbi = require('dkg-evm-module/abi/ContentAssetStorage.j
|
|
|
8
8
|
const UnfinalizedStateStorageAbi = require('dkg-evm-module/abi/UnfinalizedStateStorage.json');
|
|
9
9
|
const ContentAssetAbi = require('dkg-evm-module/abi/ContentAsset.json');
|
|
10
10
|
const TokenAbi = require('dkg-evm-module/abi/Token.json');
|
|
11
|
-
const { OPERATIONS_STEP_STATUS } = require('../../constants');
|
|
11
|
+
const { OPERATIONS_STEP_STATUS, DEFAULT_GAS_PRICE } = require('../../constants');
|
|
12
12
|
const emptyHooks = require('../../util/empty-hooks.js');
|
|
13
13
|
|
|
14
14
|
class BlockchainServiceBase {
|
|
@@ -64,15 +64,25 @@ class BlockchainServiceBase {
|
|
|
64
64
|
gasPrice = Math.round(response.data.average * 1e9);
|
|
65
65
|
}
|
|
66
66
|
} else {
|
|
67
|
-
gasPrice = Web3.utils.toWei(
|
|
67
|
+
gasPrice = Web3.utils.toWei(
|
|
68
|
+
blockchain.name.startsWith('otp')
|
|
69
|
+
? DEFAULT_GAS_PRICE.OTP
|
|
70
|
+
: DEFAULT_GAS_PRICE.GNOSIS,
|
|
71
|
+
'Gwei',
|
|
72
|
+
);
|
|
68
73
|
}
|
|
69
74
|
return gasPrice;
|
|
70
75
|
} catch (error) {
|
|
71
76
|
// eslint-disable-next-line no-console
|
|
72
77
|
console.warn(
|
|
73
|
-
`Failed to fetch the gas price from the network: ${error}. Using default value:
|
|
78
|
+
`Failed to fetch the gas price from the network: ${error}. Using default value: 2 Gwei.`,
|
|
79
|
+
);
|
|
80
|
+
return Web3.utils.toWei(
|
|
81
|
+
blockchain.name.startsWith('otp')
|
|
82
|
+
? DEFAULT_GAS_PRICE.OTP
|
|
83
|
+
: DEFAULT_GAS_PRICE.GNOSIS,
|
|
84
|
+
'Gwei',
|
|
74
85
|
);
|
|
75
|
-
return Web3.utils.toWei('100', 'Gwei');
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
88
|
|
|
@@ -531,22 +541,38 @@ class BlockchainServiceBase {
|
|
|
531
541
|
|
|
532
542
|
async getGasPrice(blockchain) {
|
|
533
543
|
const web3Instance = await this.getWeb3Instance(blockchain);
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
+
try {
|
|
545
|
+
let gasPrice;
|
|
546
|
+
if (blockchain.name.startsWith('otp')) {
|
|
547
|
+
gasPrice = await web3Instance.eth.getGasPrice();
|
|
548
|
+
} else if (blockchain.name.startsWith('gnosis')) {
|
|
549
|
+
const response = await axios.get(blockchain.gasPriceOracleLink);
|
|
550
|
+
if (blockchain.name.split(':')[1] === '100') {
|
|
551
|
+
gasPrice = Number(response.result, 10);
|
|
552
|
+
} else if (blockchain.name.split(':')[1] === '10200') {
|
|
553
|
+
gasPrice = Math.round(response.data.average * 1e9);
|
|
554
|
+
}
|
|
555
|
+
} else {
|
|
556
|
+
gasPrice = Web3.utils.toWei(
|
|
557
|
+
blockchain.name.startsWith('otp')
|
|
558
|
+
? DEFAULT_GAS_PRICE.OTP
|
|
559
|
+
: DEFAULT_GAS_PRICE.GNOSIS,
|
|
560
|
+
'Gwei',
|
|
561
|
+
);
|
|
544
562
|
}
|
|
545
|
-
|
|
546
|
-
|
|
563
|
+
return gasPrice;
|
|
564
|
+
} catch (error) {
|
|
565
|
+
// eslint-disable-next-line no-console
|
|
566
|
+
console.warn(
|
|
567
|
+
`Failed to fetch the gas price from the network: ${error}. Using default value: 2 Gwei.`,
|
|
568
|
+
);
|
|
569
|
+
return Web3.utils.toWei(
|
|
570
|
+
blockchain.name.startsWith('otp')
|
|
571
|
+
? DEFAULT_GAS_PRICE.OTP
|
|
572
|
+
: DEFAULT_GAS_PRICE.GNOSIS,
|
|
573
|
+
'Gwei',
|
|
574
|
+
);
|
|
547
575
|
}
|
|
548
|
-
|
|
549
|
-
return gasPrice;
|
|
550
576
|
}
|
|
551
577
|
|
|
552
578
|
async getWalletBalances(blockchain) {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {
|
|
2
|
+
DEFAULT_PARAMETERS,
|
|
3
|
+
DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS,
|
|
4
|
+
BLOCKCHAINS,
|
|
5
|
+
} = require('../constants');
|
|
2
6
|
|
|
3
7
|
class InputService {
|
|
4
8
|
constructor(config = {}) {
|
|
@@ -150,11 +154,11 @@ class InputService {
|
|
|
150
154
|
}
|
|
151
155
|
|
|
152
156
|
getScoreFunctionId(options) {
|
|
153
|
-
|
|
154
|
-
options.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
const environment =
|
|
158
|
+
options.environment ?? this.config.environment ?? DEFAULT_PARAMETERS.ENVIRONMENT;
|
|
159
|
+
const blockchainName = this.getBlockchain(options).name;
|
|
160
|
+
|
|
161
|
+
return DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS[environment][blockchainName];
|
|
158
162
|
}
|
|
159
163
|
|
|
160
164
|
getEpochsNum(options) {
|