@quicknode/sdk 2.2.1 → 2.3.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/cjs/index.js CHANGED
@@ -275,25 +275,35 @@ const qnChainToViemChain = {
275
275
  'base-mainnet': chains.base,
276
276
  'base-goerli': chains.baseGoerli,
277
277
  'base-sepolia': chains.baseSepolia,
278
+ 'bera-artio': chains.berachainTestnet,
279
+ 'blast-mainnet': chains.blast,
280
+ 'blast-sepolia': chains.blastSepolia,
278
281
  ['bsc']: chains.bsc,
279
282
  'bsc-testnet': chains.bscTestnet,
280
283
  'celo-mainnet': chains.celo,
284
+ 'cyber-mainnet': chains.cyber,
285
+ 'cyber-sepolia': chains.cyberTestnet,
281
286
  ['fantom']: chains.fantom,
282
287
  ['xdai']: chains.gnosis,
283
288
  ['gnosis']: chains.gnosis,
284
289
  'ethereum-goerli': chains.goerli,
285
290
  'harmony-mainnet': chains.harmonyOne,
286
291
  [ETH_MAINNET_NETWORK]: chains.mainnet,
292
+ 'mantle-mainnet': chains.mantle,
293
+ 'mantle-sepolia': chains.mantleSepoliaTestnet,
287
294
  ['optimism']: chains.optimism,
288
295
  'optimism-goerli': chains.optimismGoerli,
289
296
  'optimism-sepolia': chains.optimismSepolia,
290
297
  ['matic']: chains.polygon,
291
298
  ['polygon']: chains.polygon,
292
299
  'scroll-mainnet': chains.scroll,
293
- 'scroll-testnet': chains.scrollTestnet,
300
+ 'scroll-testnet': chains.scrollSepolia,
294
301
  'matic-testnet': chains.polygonMumbai,
302
+ 'matic-amoy': chains.polygonAmoy,
295
303
  'zkevm-mainnet': chains.polygonZkEvm,
296
304
  'zkevm-testnet': chains.polygonZkEvmTestnet,
305
+ 'sei-pacific': chains.sei,
306
+ 'sei-arctic': chains.seiDevnet,
297
307
  'ethereum-sepolia': chains.sepolia,
298
308
  'ethereum-holesky': chains.holesky,
299
309
  };
@@ -383,16 +393,19 @@ class Solana {
383
393
  */
384
394
  async prepareSmartTransaction(args) {
385
395
  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 = [
396
+ // Send simulation with placeholders so the value calculated is accurate
397
+ // placeholders kept low to avoid InsufficientFundsForFee error with the high cu budget limit
398
+ const simulationInstructions = [
399
+ web3_js.ComputeBudgetProgram.setComputeUnitPrice({
400
+ microLamports: 1,
401
+ }),
402
+ web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1400000 }),
390
403
  ...transaction.instructions,
391
- computeUnitPriceInstruction,
392
404
  ];
393
405
  // eslint-disable-next-line prefer-const
394
- let [units, recentBlockhash] = await Promise.all([
395
- this.getSimulationUnits(this.connection, allInstructions, payerPublicKey),
406
+ let [units, computeUnitPriceInstruction, recentBlockhash] = await Promise.all([
407
+ this.getSimulationUnits(this.connection, simulationInstructions, payerPublicKey),
408
+ this.createDynamicPriorityFeeInstruction(feeLevel),
396
409
  this.connection.getLatestBlockhash(),
397
410
  ]);
398
411
  transaction.add(computeUnitPriceInstruction);
@@ -446,7 +459,8 @@ class Solana {
446
459
  sigVerify: false,
447
460
  });
448
461
  if (simulation.value.err) {
449
- return undefined;
462
+ console.error('Simulation error:', simulation.value.err);
463
+ throw new Error(`Failed to simulate transaction ${simulation.value.err}`);
450
464
  }
451
465
  return simulation.value.unitsConsumed;
452
466
  }
@@ -1,6 +1,6 @@
1
1
  import { QNInvalidEndpointUrl } from '../lib/errors/QNInvalidEnpointUrl.js';
2
2
  import { QNChainNotSupported } from '../lib/errors/QNChainNotSupported.js';
3
- import { arbitrum, arbitrumGoerli, arbitrumSepolia, arbitrumNova, avalanche, avalancheFuji, base, baseGoerli, baseSepolia, bsc, bscTestnet, celo, fantom, gnosis, goerli, harmonyOne, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, scroll, scrollTestnet, polygonMumbai, polygonZkEvm, polygonZkEvmTestnet, sepolia, holesky } from 'viem/chains';
3
+ import { arbitrum, arbitrumGoerli, arbitrumSepolia, arbitrumNova, avalanche, avalancheFuji, base, baseGoerli, baseSepolia, berachainTestnet, blast, blastSepolia, bsc, bscTestnet, celo, cyber, cyberTestnet, fantom, gnosis, goerli, harmonyOne, mainnet, mantle, mantleSepoliaTestnet, optimism, optimismGoerli, optimismSepolia, polygon, scroll, scrollSepolia, polygonMumbai, polygonAmoy, polygonZkEvm, polygonZkEvmTestnet, sei, seiDevnet, sepolia, holesky } from 'viem/chains';
4
4
 
5
5
  const ETH_MAINNET_NETWORK = 'ethereum-mainnet';
6
6
  const qnChainToViemChain = {
@@ -13,25 +13,35 @@ const qnChainToViemChain = {
13
13
  'base-mainnet': base,
14
14
  'base-goerli': baseGoerli,
15
15
  'base-sepolia': baseSepolia,
16
+ 'bera-artio': berachainTestnet,
17
+ 'blast-mainnet': blast,
18
+ 'blast-sepolia': blastSepolia,
16
19
  ['bsc']: bsc,
17
20
  'bsc-testnet': bscTestnet,
18
21
  'celo-mainnet': celo,
22
+ 'cyber-mainnet': cyber,
23
+ 'cyber-sepolia': cyberTestnet,
19
24
  ['fantom']: fantom,
20
25
  ['xdai']: gnosis,
21
26
  ['gnosis']: gnosis,
22
27
  'ethereum-goerli': goerli,
23
28
  'harmony-mainnet': harmonyOne,
24
29
  [ETH_MAINNET_NETWORK]: mainnet,
30
+ 'mantle-mainnet': mantle,
31
+ 'mantle-sepolia': mantleSepoliaTestnet,
25
32
  ['optimism']: optimism,
26
33
  'optimism-goerli': optimismGoerli,
27
34
  'optimism-sepolia': optimismSepolia,
28
35
  ['matic']: polygon,
29
36
  ['polygon']: polygon,
30
37
  'scroll-mainnet': scroll,
31
- 'scroll-testnet': scrollTestnet,
38
+ 'scroll-testnet': scrollSepolia,
32
39
  'matic-testnet': polygonMumbai,
40
+ 'matic-amoy': polygonAmoy,
33
41
  'zkevm-mainnet': polygonZkEvm,
34
42
  'zkevm-testnet': polygonZkEvmTestnet,
43
+ 'sei-pacific': sei,
44
+ 'sei-arctic': seiDevnet,
35
45
  'ethereum-sepolia': sepolia,
36
46
  'ethereum-holesky': holesky,
37
47
  };
@@ -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,7 +6,7 @@
6
6
  "directory": "packages/libs/sdk"
7
7
  },
8
8
  "license": "MIT",
9
- "version": "2.2.1",
9
+ "version": "2.3.0",
10
10
  "main": "./cjs/index.js",
11
11
  "module": "./esm/index.js",
12
12
  "types": "./index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "@solana/web3.js": "^1.91",
16
16
  "cross-fetch": "^3.1.6",
17
17
  "tslib": "^2.5.3",
18
- "viem": "^1.20.0",
18
+ "viem": "^2.13.7",
19
19
  "zod": "^3.21.4"
20
20
  },
21
21
  "devDependencies": {