@cryptorubic/web3 0.8.17-alpha.solana.21 → 0.8.17-alpha.solana.23

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.21",
3
+ "version": "0.8.17-alpha.solana.23",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -44,17 +44,28 @@ class SolanaAdapter extends abstract_adapter_1.AbstractAdapter {
44
44
  async multicallByAddress(_address, _abi, _method, _methodArgs = [], _allowErrors = true) {
45
45
  throw new Error('Method multicall is not supported');
46
46
  }
47
+ // 6024 - Insufficient balance
47
48
  async simulateTransaction(config, timeout = 15_000) {
48
49
  try {
49
50
  const bufferData = config.data.startsWith('0x') ? Buffer.from(config.data.slice(2), 'hex') : Buffer.from(config.data, 'base64');
50
51
  const { blockhash } = await this.public.getLatestBlockhash();
51
52
  const tx = web3_js_1.VersionedTransaction.deserialize(bufferData);
52
53
  tx.message.recentBlockhash = blockhash;
53
- const simulation = this.public.simulateTransaction(tx, { replaceRecentBlockhash: true });
54
+ const simulation = this.public.simulateTransaction(tx, {
55
+ replaceRecentBlockhash: true,
56
+ accounts: {
57
+ encoding: 'base64',
58
+ addresses: [config.walletAddress]
59
+ }
60
+ });
54
61
  const resp = await (0, timeout_1.withTimeout)(simulation, timeout, 'Solana Simulation Timeout!');
62
+ if (resp.value.err) {
63
+ throw new Error('Transaction simulation failed.');
64
+ }
55
65
  return new bignumber_js_1.default(resp.value.unitsConsumed || exports.DEFAULT_CU_LIMIT).toFixed(0);
56
66
  }
57
67
  catch (err) {
68
+ this.logger?.customError('Error while simulating transaction', err);
58
69
  throw err;
59
70
  }
60
71
  }
@@ -20,7 +20,7 @@ export declare class SolanaGasService {
20
20
  */
21
21
  getPriorityFee(txData: string): Promise<BigNumber>;
22
22
  /**
23
- * @returns consumedUnitsPrice in micro-lamports(lamport * 10^-6)
23
+ * @returns prioritizationFee in micro-lamports(lamport * 10^-6)
24
24
  */
25
25
  private calculatePriorityFeeHelius;
26
26
  private getRecentPriorityFeeSolWeb3;
@@ -40,7 +40,7 @@ class SolanaGasService {
40
40
  */
41
41
  async getPriorityFee(txData) {
42
42
  if (!this.HELIUS_API_KEY) {
43
- console.warn('[SolanaApiService_getConsumedUnitsPrice] heliusApiKey is not provided in "createFactory"');
43
+ console.warn('[SolanaApiService_getPriorityFee] heliusApiKey is not provided in "createFactory"');
44
44
  }
45
45
  const resp = await Promise.allSettled([this.calculatePriorityFeeHelius(txData), this.getRecentPriorityFeeSolWeb3()]);
46
46
  const cuPrice = resp
@@ -50,7 +50,7 @@ class SolanaGasService {
50
50
  return cuPrice;
51
51
  }
52
52
  /**
53
- * @returns consumedUnitsPrice in micro-lamports(lamport * 10^-6)
53
+ * @returns prioritizationFee in micro-lamports(lamport * 10^-6)
54
54
  */
55
55
  async calculatePriorityFeeHelius(txData) {
56
56
  try {
@@ -90,7 +90,7 @@ class SolanaGasService {
90
90
  .reduce((acc, fee) => acc.plus(fee), new bignumber_js_1.default(0))
91
91
  .div(filteredPriorityFees.length)
92
92
  .dp(0, bignumber_js_1.default.ROUND_CEIL);
93
- this.logger?.customLog('SOLANA_WEB3 PRIORITY_FEE SUCCESS', { priorityFeeEstimate: avgProrityFee.toNumber(), filteredPriorityFees });
93
+ this.logger?.customLog('SOLANA_WEB3 PRIORITY_FEE SUCCESS', { priorityFeeEstimate: avgProrityFee.toNumber() });
94
94
  return avgProrityFee;
95
95
  }
96
96
  }
@@ -1,5 +1,6 @@
1
1
  type Base64String = `AQA${string}`;
2
2
  export interface SolanaTxConfig {
3
3
  data: Base64String;
4
+ walletAddress: string;
4
5
  }
5
6
  export {};