@quicknode/sdk 2.2.0 → 2.2.2

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/cjs/index.js CHANGED
@@ -383,16 +383,19 @@ class Solana {
383
383
  */
384
384
  async prepareSmartTransaction(args) {
385
385
  const { transaction, payerPublicKey, feeLevel = 'medium' } = args;
386
- // Need to fetch this ahead of time and add to transaction so it's in the transaction instructions
387
- // for the simulation
388
- const computeUnitPriceInstruction = await this.createDynamicPriorityFeeInstruction(feeLevel);
389
- const allInstructions = [
386
+ // Send simulation with placeholders so the value calculated is accurate
387
+ // placeholders kept low to avoid InsufficientFundsForFee error with the high cu budget limit
388
+ const simulationInstructions = [
389
+ web3_js.ComputeBudgetProgram.setComputeUnitPrice({
390
+ microLamports: 1,
391
+ }),
392
+ web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1400000 }),
390
393
  ...transaction.instructions,
391
- computeUnitPriceInstruction,
392
394
  ];
393
395
  // eslint-disable-next-line prefer-const
394
- let [units, recentBlockhash] = await Promise.all([
395
- this.getSimulationUnits(this.connection, allInstructions, payerPublicKey),
396
+ let [units, computeUnitPriceInstruction, recentBlockhash] = await Promise.all([
397
+ this.getSimulationUnits(this.connection, simulationInstructions, payerPublicKey),
398
+ this.createDynamicPriorityFeeInstruction(feeLevel),
396
399
  this.connection.getLatestBlockhash(),
397
400
  ]);
398
401
  transaction.add(computeUnitPriceInstruction);
@@ -446,7 +449,8 @@ class Solana {
446
449
  sigVerify: false,
447
450
  });
448
451
  if (simulation.value.err) {
449
- return undefined;
452
+ console.error('Simulation error:', simulation.value.err);
453
+ throw new Error(`Failed to simulate transaction ${simulation.value.err}`);
450
454
  }
451
455
  return simulation.value.unitsConsumed;
452
456
  }
@@ -28,16 +28,19 @@ class Solana {
28
28
  */
29
29
  async prepareSmartTransaction(args) {
30
30
  const { transaction, payerPublicKey, feeLevel = 'medium' } = args;
31
- // Need to fetch this ahead of time and add to transaction so it's in the transaction instructions
32
- // for the simulation
33
- const computeUnitPriceInstruction = await this.createDynamicPriorityFeeInstruction(feeLevel);
34
- const allInstructions = [
31
+ // Send simulation with placeholders so the value calculated is accurate
32
+ // placeholders kept low to avoid InsufficientFundsForFee error with the high cu budget limit
33
+ const simulationInstructions = [
34
+ ComputeBudgetProgram.setComputeUnitPrice({
35
+ microLamports: 1,
36
+ }),
37
+ ComputeBudgetProgram.setComputeUnitLimit({ units: 1400000 }),
35
38
  ...transaction.instructions,
36
- computeUnitPriceInstruction,
37
39
  ];
38
40
  // eslint-disable-next-line prefer-const
39
- let [units, recentBlockhash] = await Promise.all([
40
- this.getSimulationUnits(this.connection, allInstructions, payerPublicKey),
41
+ let [units, computeUnitPriceInstruction, recentBlockhash] = await Promise.all([
42
+ this.getSimulationUnits(this.connection, simulationInstructions, payerPublicKey),
43
+ this.createDynamicPriorityFeeInstruction(feeLevel),
41
44
  this.connection.getLatestBlockhash(),
42
45
  ]);
43
46
  transaction.add(computeUnitPriceInstruction);
@@ -91,7 +94,8 @@ class Solana {
91
94
  sigVerify: false,
92
95
  });
93
96
  if (simulation.value.err) {
94
- return undefined;
97
+ console.error('Simulation error:', simulation.value.err);
98
+ throw new Error(`Failed to simulate transaction ${simulation.value.err}`);
95
99
  }
96
100
  return simulation.value.unitsConsumed;
97
101
  }
package/package.json CHANGED
@@ -6,12 +6,13 @@
6
6
  "directory": "packages/libs/sdk"
7
7
  },
8
8
  "license": "MIT",
9
- "version": "2.2.0",
9
+ "version": "2.2.2",
10
10
  "main": "./cjs/index.js",
11
11
  "module": "./esm/index.js",
12
12
  "types": "./index.d.ts",
13
13
  "sideEffects": false,
14
14
  "dependencies": {
15
+ "@solana/web3.js": "^1.91",
15
16
  "cross-fetch": "^3.1.6",
16
17
  "tslib": "^2.5.3",
17
18
  "viem": "^1.20.0",
@@ -21,7 +22,6 @@
21
22
  "@pollyjs/adapter-node-http": "^6.0.5",
22
23
  "@pollyjs/core": "^6.0.5",
23
24
  "@pollyjs/persister-fs": "^6.0.5",
24
- "@solana/web3.js": "^1.91",
25
25
  "@types/jest": "^29.5.1",
26
26
  "@types/mocha": "^10.0.1",
27
27
  "@types/node": "^18.13.0",