@cryptorubic/web3 0.8.17-alpha.solana.12 → 0.8.17-alpha.solana.14
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
|
@@ -27,7 +27,7 @@ class SolanaGasService {
|
|
|
27
27
|
return resp.value.unitsConsumed ? new bignumber_js_1.default(resp.value.unitsConsumed * 1.2) : new bignumber_js_1.default(DEFAULT_CU_LIMIT);
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
30
|
-
console.error('
|
|
30
|
+
console.error('[SolanaApiService_getConsumedUnitsLimit] err ==> ', err);
|
|
31
31
|
return new bignumber_js_1.default(DEFAULT_CU_LIMIT);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -39,23 +39,33 @@ class SolanaGasService {
|
|
|
39
39
|
if (!this.HELIUS_API_KEY) {
|
|
40
40
|
console.warn('[SolanaApiService_getConsumedUnitsPrice] heliusApiKey is not provided in "createFactory"');
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const resp = await Promise.allSettled([this.calculateCUPriceHelius(txData), this.calculateCUPriceSolWeb3()]);
|
|
43
|
+
const cuPrice = resp
|
|
44
|
+
.filter((r) => r.status === 'fulfilled')
|
|
45
|
+
.map((r) => r.value)
|
|
46
|
+
.reduce((acc, price) => (acc.gt(price) ? acc : price), new bignumber_js_1.default(0));
|
|
43
47
|
return cuPrice;
|
|
44
48
|
}
|
|
45
49
|
async calculateCUPriceHelius(txData) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
try {
|
|
51
|
+
const tx = (0, utility_funcs_1.convertB64DataToTx)(txData);
|
|
52
|
+
const resp = await this.httpClient.post(`${this.HELIUS_API_URL}/?api-key=${this.HELIUS_API_KEY}`, {
|
|
53
|
+
jsonrpc: '2.0',
|
|
54
|
+
id: '1',
|
|
55
|
+
method: 'getPriorityFeeEstimate',
|
|
56
|
+
params: [
|
|
57
|
+
{
|
|
58
|
+
transaction: utils_1.base58.encode(tx.serialize()), // Pass the serialized transaction in Base58
|
|
59
|
+
options: { priorityLevel: 'Medium' }
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
return new bignumber_js_1.default(resp.result.priorityFeeEstimate);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
console.error('[SolanaGasService_getConsumedUnitsPrice] err ==> ', err);
|
|
67
|
+
return new bignumber_js_1.default(0);
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
async calculateCUPriceSolWeb3() {
|
|
61
71
|
const BASE_FEE = 5_000;
|