@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "0.8.17-alpha.solana.12",
3
+ "version": "0.8.17-alpha.solana.14",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -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('Solana_simulateTransaction_Error ==> ', err);
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 cuPrice = await Promise.any([this.calculateCUPriceHelius(txData), this.calculateCUPriceSolWeb3()]);
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
- const tx = (0, utility_funcs_1.convertB64DataToTx)(txData);
47
- const resp = await this.httpClient.post(`${this.HELIUS_API_URL}/?api-key=${this.HELIUS_API_KEY}`, {
48
- jsonrpc: '2.0',
49
- id: '1',
50
- method: 'getPriorityFeeEstimate',
51
- params: [
52
- {
53
- transaction: utils_1.base58.encode(tx.serialize()), // Pass the serialized transaction in Base58
54
- options: { priorityLevel: 'Medium' }
55
- }
56
- ]
57
- });
58
- return new bignumber_js_1.default(resp.result.priorityFeeEstimate);
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;