@quicknode/sdk 2.1.2 → 2.2.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/README.md CHANGED
@@ -4,8 +4,6 @@ A SDK from [QuickNode](https://www.quicknode.com/) making it easy for developers
4
4
 
5
5
  QuickNode's SDK is a JavaScript and TypeScript framework-agnostic library that supports both CommonJS and ES module systems.
6
6
 
7
- Currently the SDK makes it even easier to use the [QuickNode Graph API](https://www.quicknode.com/graph-api) to query market insights, trading data, transactions by wallets and contracts, cached NFT images, and more!
8
-
9
7
  > :grey_question: We want to hear from you! Please take a few minutes to fill out our [QuickNode SDK feedback form](https://forms.gle/vWFXDDjEUySjWUof6) and let us know what you currently think about the SDK. This helps us further improve the SDK.
10
8
 
11
9
  [![Coverage Status](https://coveralls.io/repos/github/quiknode-labs/qn-oss/badge.svg?branch=main)](https://coveralls.io/github/quiknode-labs/qn-oss?branch=main)
@@ -80,11 +78,3 @@ API responses are recorded using [polly.js](https://github.com/Netflix/pollyjs).
80
78
  Run `nx lint libs-sdk` to execute the lint via [ESLint](https://eslint.org/).
81
79
 
82
80
  <br>
83
-
84
- ### Generate graphql codegen typings
85
-
86
- Generate graphql typings via [Codegen](https://www.the-guild.dev/graphql/codegen).
87
-
88
- 1. navigate to `packages/libs/sdk` from `qn-oss` monorepo root
89
- 1. `cp .env.example .env` and add api key
90
- 1. run `yarn run codegen`
package/cjs/index.js CHANGED
@@ -5,7 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var viem = require('viem');
6
6
  var zod = require('zod');
7
7
  var chains = require('viem/chains');
8
- var fetch = require('cross-fetch');
8
+ var fetch$1 = require('cross-fetch');
9
+ var web3_js = require('@solana/web3.js');
9
10
 
10
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
12
 
@@ -28,7 +29,8 @@ function _interopNamespace(e) {
28
29
  }
29
30
 
30
31
  var viem__namespace = /*#__PURE__*/_interopNamespace(viem);
31
- var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
32
+ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch$1);
33
+ var web3_js__namespace = /*#__PURE__*/_interopNamespace(web3_js);
32
34
 
33
35
  class QNInputValidationError extends Error {
34
36
  constructor({ messages, zodError, }) {
@@ -266,8 +268,11 @@ const ETH_MAINNET_NETWORK = 'ethereum-mainnet';
266
268
  const qnChainToViemChain = {
267
269
  'arbitrum-mainnet': chains.arbitrum,
268
270
  'arbitrum-goerli': chains.arbitrumGoerli,
271
+ 'arbitrum-sepolia': chains.arbitrumSepolia,
272
+ 'arbitrum-nova': chains.arbitrumNova,
269
273
  'avalanche-mainnet': chains.avalanche,
270
274
  'avalanche-testnet': chains.avalancheFuji,
275
+ 'base-mainnet': chains.base,
271
276
  'base-goerli': chains.baseGoerli,
272
277
  'base-sepolia': chains.baseSepolia,
273
278
  ['bsc']: chains.bsc,
@@ -281,8 +286,11 @@ const qnChainToViemChain = {
281
286
  [ETH_MAINNET_NETWORK]: chains.mainnet,
282
287
  ['optimism']: chains.optimism,
283
288
  'optimism-goerli': chains.optimismGoerli,
289
+ 'optimism-sepolia': chains.optimismSepolia,
284
290
  ['matic']: chains.polygon,
285
291
  ['polygon']: chains.polygon,
292
+ 'scroll-mainnet': chains.scroll,
293
+ 'scroll-testnet': chains.scrollTestnet,
286
294
  'matic-testnet': chains.polygonMumbai,
287
295
  'zkevm-mainnet': chains.polygonZkEvm,
288
296
  'zkevm-testnet': chains.polygonZkEvmTestnet,
@@ -323,9 +331,9 @@ function setupGlobalFetch() {
323
331
  // Required for viem to work in node
324
332
  if (!globalThis.fetch) {
325
333
  globalThis.fetch = fetch__default["default"];
326
- globalThis.Headers = fetch.Headers;
327
- globalThis.Request = fetch.Request;
328
- globalThis.Response = fetch.Response;
334
+ globalThis.Headers = fetch$1.Headers;
335
+ globalThis.Request = fetch$1.Request;
336
+ globalThis.Response = fetch$1.Response;
329
337
  }
330
338
  }
331
339
 
@@ -347,13 +355,113 @@ class Core {
347
355
  }
348
356
  }
349
357
 
358
+ // eslint-disable-next-line @nx/enforce-module-boundaries
359
+ class Solana {
360
+ constructor({ endpointUrl }) {
361
+ this.endpointUrl = endpointUrl;
362
+ this.connection = new web3_js.Connection(endpointUrl);
363
+ }
364
+ /**
365
+ * Sends a transaction with a dynamically generated priority fee based on the current network conditions and compute units needed by the transaction.
366
+ */
367
+ async sendSmartTransaction(args) {
368
+ const { transaction, keyPair, feeLevel = 'medium', sendTransactionOptions = {}, } = args;
369
+ const smartTransaction = await this.prepareSmartTransaction({
370
+ transaction,
371
+ payerPublicKey: keyPair.publicKey,
372
+ feeLevel,
373
+ });
374
+ smartTransaction.sign(keyPair);
375
+ const hash = await this.connection.sendRawTransaction(transaction.serialize(), { skipPreflight: true, ...sendTransactionOptions });
376
+ return hash;
377
+ }
378
+ /**
379
+ * Prepares a transaction to be sent with a dynamically generated priority fee based
380
+ * on the current network conditions. It adds a `setComputeUnitPrice` instruction to the transaction
381
+ * and simulates the transaction to estimate the number of compute units it will consume.
382
+ * The returned transaction still needs to be signed and sent to the network.
383
+ */
384
+ async prepareSmartTransaction(args) {
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 = [
390
+ ...transaction.instructions,
391
+ computeUnitPriceInstruction,
392
+ ];
393
+ // eslint-disable-next-line prefer-const
394
+ let [units, recentBlockhash] = await Promise.all([
395
+ this.getSimulationUnits(this.connection, allInstructions, payerPublicKey),
396
+ this.connection.getLatestBlockhash(),
397
+ ]);
398
+ transaction.add(computeUnitPriceInstruction);
399
+ if (units) {
400
+ units = Math.ceil(units * 1.05); // margin of error
401
+ transaction.add(web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units }));
402
+ }
403
+ transaction.recentBlockhash = recentBlockhash.blockhash;
404
+ return transaction;
405
+ }
406
+ // Get the priority fee averages based on fee data from the latest blocks
407
+ async fetchEstimatePriorityFees(args = {}) {
408
+ const payload = {
409
+ method: 'qn_estimatePriorityFees',
410
+ params: args,
411
+ id: 1,
412
+ jsonrpc: '2.0',
413
+ };
414
+ const response = await fetch(this.endpointUrl, {
415
+ method: 'POST',
416
+ headers: {
417
+ 'Content-Type': 'application/json',
418
+ },
419
+ body: JSON.stringify(payload),
420
+ });
421
+ if (!response.ok) {
422
+ if (response.status === 404) {
423
+ throw new Error(`The RPC method qn_estimatePriorityFees was not found on your endpoint! Your endpoint likely does not have the Priority Fee API add-on installed. Please visit https://marketplace.quicknode.com/add-on/solana-priority-fee to install the Priority Fee API and use this method to send your transactions with priority fees calculated with real-time data.`);
424
+ }
425
+ throw new Error('Failed to fetch priority fee estimates');
426
+ }
427
+ const data = await response.json();
428
+ return data;
429
+ }
430
+ async createDynamicPriorityFeeInstruction(feeType = 'medium') {
431
+ const { result } = await this.fetchEstimatePriorityFees({});
432
+ const priorityFee = result.per_compute_unit[feeType];
433
+ const priorityFeeInstruction = web3_js.ComputeBudgetProgram.setComputeUnitPrice({
434
+ microLamports: priorityFee,
435
+ });
436
+ return priorityFeeInstruction;
437
+ }
438
+ async getSimulationUnits(connection, instructions, publicKey) {
439
+ const testVersionedTxn = new web3_js.VersionedTransaction(new web3_js.TransactionMessage({
440
+ instructions: instructions,
441
+ payerKey: publicKey,
442
+ recentBlockhash: web3_js.PublicKey.default.toString(), // just a placeholder
443
+ }).compileToV0Message());
444
+ const simulation = await connection.simulateTransaction(testVersionedTxn, {
445
+ replaceRecentBlockhash: true,
446
+ sigVerify: false,
447
+ });
448
+ if (simulation.value.err) {
449
+ return undefined;
450
+ }
451
+ return simulation.value.unitsConsumed;
452
+ }
453
+ }
454
+
350
455
  const QuickNode = {
351
456
  Core: Core,
457
+ Solana: Solana,
352
458
  };
353
459
 
354
460
  exports.viem = viem__namespace;
461
+ exports.solanaWeb3 = web3_js__namespace;
355
462
  exports.Core = Core;
356
463
  exports.QNChainNotSupported = QNChainNotSupported;
357
464
  exports.QNInputValidationError = QNInputValidationError;
358
465
  exports.QNInvalidEndpointUrl = QNInvalidEndpointUrl;
466
+ exports.Solana = Solana;
359
467
  exports["default"] = QuickNode;
@@ -1,7 +1,9 @@
1
1
  import { Core } from '../core/core.js';
2
+ import { Solana } from '../solana/solana.js';
2
3
 
3
4
  const QuickNode = {
4
5
  Core: Core,
6
+ Solana: Solana,
5
7
  };
6
8
 
7
9
  export { QuickNode as default };
@@ -1,13 +1,16 @@
1
1
  import { QNInvalidEndpointUrl } from '../lib/errors/QNInvalidEnpointUrl.js';
2
2
  import { QNChainNotSupported } from '../lib/errors/QNChainNotSupported.js';
3
- import { arbitrum, arbitrumGoerli, avalanche, avalancheFuji, baseGoerli, baseSepolia, bsc, bscTestnet, celo, fantom, gnosis, goerli, harmonyOne, mainnet, optimism, optimismGoerli, polygon, polygonMumbai, polygonZkEvm, polygonZkEvmTestnet, sepolia, holesky } from 'viem/chains';
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';
4
4
 
5
5
  const ETH_MAINNET_NETWORK = 'ethereum-mainnet';
6
6
  const qnChainToViemChain = {
7
7
  'arbitrum-mainnet': arbitrum,
8
8
  'arbitrum-goerli': arbitrumGoerli,
9
+ 'arbitrum-sepolia': arbitrumSepolia,
10
+ 'arbitrum-nova': arbitrumNova,
9
11
  'avalanche-mainnet': avalanche,
10
12
  'avalanche-testnet': avalancheFuji,
13
+ 'base-mainnet': base,
11
14
  'base-goerli': baseGoerli,
12
15
  'base-sepolia': baseSepolia,
13
16
  ['bsc']: bsc,
@@ -21,8 +24,11 @@ const qnChainToViemChain = {
21
24
  [ETH_MAINNET_NETWORK]: mainnet,
22
25
  ['optimism']: optimism,
23
26
  'optimism-goerli': optimismGoerli,
27
+ 'optimism-sepolia': optimismSepolia,
24
28
  ['matic']: polygon,
25
29
  ['polygon']: polygon,
30
+ 'scroll-mainnet': scroll,
31
+ 'scroll-testnet': scrollTestnet,
26
32
  'matic-testnet': polygonMumbai,
27
33
  'zkevm-mainnet': polygonZkEvm,
28
34
  'zkevm-testnet': polygonZkEvmTestnet,
package/esm/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import QuickNode from './client/client.js';
2
2
  export { default } from './client/client.js';
3
3
  export { Core } from './core/core.js';
4
+ export { Solana } from './solana/solana.js';
4
5
  import * as viem from 'viem';
5
6
  export { viem };
7
+ import * as web3_js from '@solana/web3.js';
8
+ export { web3_js as solanaWeb3 };
6
9
  export { QNInputValidationError } from './lib/errors/QNInputValidationError.js';
7
10
  export { QNInvalidEndpointUrl } from './lib/errors/QNInvalidEnpointUrl.js';
8
11
  export { QNChainNotSupported } from './lib/errors/QNChainNotSupported.js';
@@ -0,0 +1,74 @@
1
+ import * as _solana_web3_js from '@solana/web3.js';
2
+ import { Transaction, PublicKey, Keypair, SendOptions, Connection } from '@solana/web3.js';
3
+
4
+ type PercentileRangeUnion = '0' | '5' | '10' | '15' | '20' | '25' | '30' | '35' | '40' | '45' | '50' | '55' | '60' | '65' | '70' | '75' | '80' | '85' | '90' | '95' | '100';
5
+ type PriorityFeeLevels = 'low' | 'medium' | 'high' | 'extreme';
6
+ interface PriorityFeeRequestPayload {
7
+ method: string;
8
+ params: {
9
+ last_n_blocks?: number;
10
+ account?: string;
11
+ };
12
+ id: number;
13
+ jsonrpc: string;
14
+ }
15
+ interface PriorityFeeEstimates {
16
+ extreme: number;
17
+ high: number;
18
+ low: number;
19
+ medium: number;
20
+ percentiles: {
21
+ [key in PercentileRangeUnion]: number;
22
+ };
23
+ }
24
+ interface PriorityFeeResponseData {
25
+ jsonrpc: string;
26
+ result: {
27
+ context: {
28
+ slot: number;
29
+ };
30
+ per_compute_unit: PriorityFeeEstimates;
31
+ per_transaction: PriorityFeeEstimates;
32
+ };
33
+ id: number;
34
+ }
35
+ interface EstimatePriorityFeesParams {
36
+ last_n_blocks?: number;
37
+ account?: string;
38
+ }
39
+ interface SolanaClientArgs {
40
+ endpointUrl: string;
41
+ }
42
+ interface SmartTransactionBaseArgs {
43
+ transaction: Transaction;
44
+ feeLevel?: PriorityFeeLevels;
45
+ }
46
+ interface PrepareSmartTransactionArgs extends SmartTransactionBaseArgs {
47
+ payerPublicKey: PublicKey;
48
+ }
49
+ interface SendSmartTransactionArgs extends SmartTransactionBaseArgs {
50
+ keyPair: Keypair;
51
+ sendTransactionOptions?: SendOptions;
52
+ }
53
+
54
+ declare class Solana {
55
+ readonly endpointUrl: string;
56
+ readonly connection: Connection;
57
+ constructor({ endpointUrl }: SolanaClientArgs);
58
+ /**
59
+ * Sends a transaction with a dynamically generated priority fee based on the current network conditions and compute units needed by the transaction.
60
+ */
61
+ sendSmartTransaction(args: SendSmartTransactionArgs): Promise<string>;
62
+ /**
63
+ * Prepares a transaction to be sent with a dynamically generated priority fee based
64
+ * on the current network conditions. It adds a `setComputeUnitPrice` instruction to the transaction
65
+ * and simulates the transaction to estimate the number of compute units it will consume.
66
+ * The returned transaction still needs to be signed and sent to the network.
67
+ */
68
+ prepareSmartTransaction(args: PrepareSmartTransactionArgs): Promise<_solana_web3_js.Transaction>;
69
+ fetchEstimatePriorityFees(args?: EstimatePriorityFeesParams): Promise<PriorityFeeResponseData>;
70
+ private createDynamicPriorityFeeInstruction;
71
+ private getSimulationUnits;
72
+ }
73
+
74
+ export { EstimatePriorityFeesParams, PrepareSmartTransactionArgs, PriorityFeeEstimates, PriorityFeeLevels, PriorityFeeRequestPayload, PriorityFeeResponseData, SendSmartTransactionArgs, SmartTransactionBaseArgs, SolanaClientArgs, Solana as default };
@@ -0,0 +1,2 @@
1
+ import { Solana } from './solana.js';
2
+ export { Solana as default } from './solana.js';
@@ -0,0 +1,100 @@
1
+ import { Connection, ComputeBudgetProgram, VersionedTransaction, TransactionMessage, PublicKey } from '@solana/web3.js';
2
+
3
+ // eslint-disable-next-line @nx/enforce-module-boundaries
4
+ class Solana {
5
+ constructor({ endpointUrl }) {
6
+ this.endpointUrl = endpointUrl;
7
+ this.connection = new Connection(endpointUrl);
8
+ }
9
+ /**
10
+ * Sends a transaction with a dynamically generated priority fee based on the current network conditions and compute units needed by the transaction.
11
+ */
12
+ async sendSmartTransaction(args) {
13
+ const { transaction, keyPair, feeLevel = 'medium', sendTransactionOptions = {}, } = args;
14
+ const smartTransaction = await this.prepareSmartTransaction({
15
+ transaction,
16
+ payerPublicKey: keyPair.publicKey,
17
+ feeLevel,
18
+ });
19
+ smartTransaction.sign(keyPair);
20
+ const hash = await this.connection.sendRawTransaction(transaction.serialize(), { skipPreflight: true, ...sendTransactionOptions });
21
+ return hash;
22
+ }
23
+ /**
24
+ * Prepares a transaction to be sent with a dynamically generated priority fee based
25
+ * on the current network conditions. It adds a `setComputeUnitPrice` instruction to the transaction
26
+ * and simulates the transaction to estimate the number of compute units it will consume.
27
+ * The returned transaction still needs to be signed and sent to the network.
28
+ */
29
+ async prepareSmartTransaction(args) {
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 = [
35
+ ...transaction.instructions,
36
+ computeUnitPriceInstruction,
37
+ ];
38
+ // eslint-disable-next-line prefer-const
39
+ let [units, recentBlockhash] = await Promise.all([
40
+ this.getSimulationUnits(this.connection, allInstructions, payerPublicKey),
41
+ this.connection.getLatestBlockhash(),
42
+ ]);
43
+ transaction.add(computeUnitPriceInstruction);
44
+ if (units) {
45
+ units = Math.ceil(units * 1.05); // margin of error
46
+ transaction.add(ComputeBudgetProgram.setComputeUnitLimit({ units }));
47
+ }
48
+ transaction.recentBlockhash = recentBlockhash.blockhash;
49
+ return transaction;
50
+ }
51
+ // Get the priority fee averages based on fee data from the latest blocks
52
+ async fetchEstimatePriorityFees(args = {}) {
53
+ const payload = {
54
+ method: 'qn_estimatePriorityFees',
55
+ params: args,
56
+ id: 1,
57
+ jsonrpc: '2.0',
58
+ };
59
+ const response = await fetch(this.endpointUrl, {
60
+ method: 'POST',
61
+ headers: {
62
+ 'Content-Type': 'application/json',
63
+ },
64
+ body: JSON.stringify(payload),
65
+ });
66
+ if (!response.ok) {
67
+ if (response.status === 404) {
68
+ throw new Error(`The RPC method qn_estimatePriorityFees was not found on your endpoint! Your endpoint likely does not have the Priority Fee API add-on installed. Please visit https://marketplace.quicknode.com/add-on/solana-priority-fee to install the Priority Fee API and use this method to send your transactions with priority fees calculated with real-time data.`);
69
+ }
70
+ throw new Error('Failed to fetch priority fee estimates');
71
+ }
72
+ const data = await response.json();
73
+ return data;
74
+ }
75
+ async createDynamicPriorityFeeInstruction(feeType = 'medium') {
76
+ const { result } = await this.fetchEstimatePriorityFees({});
77
+ const priorityFee = result.per_compute_unit[feeType];
78
+ const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
79
+ microLamports: priorityFee,
80
+ });
81
+ return priorityFeeInstruction;
82
+ }
83
+ async getSimulationUnits(connection, instructions, publicKey) {
84
+ const testVersionedTxn = new VersionedTransaction(new TransactionMessage({
85
+ instructions: instructions,
86
+ payerKey: publicKey,
87
+ recentBlockhash: PublicKey.default.toString(), // just a placeholder
88
+ }).compileToV0Message());
89
+ const simulation = await connection.simulateTransaction(testVersionedTxn, {
90
+ replaceRecentBlockhash: true,
91
+ sigVerify: false,
92
+ });
93
+ if (simulation.value.err) {
94
+ return undefined;
95
+ }
96
+ return simulation.value.unitsConsumed;
97
+ }
98
+ }
99
+
100
+ export { Solana };
package/index.d.ts CHANGED
@@ -2,6 +2,9 @@ import { Chain, PublicClient } from 'viem';
2
2
  import * as viem from 'viem';
3
3
  export { viem };
4
4
  import { z, ZodError } from 'zod';
5
+ import * as _solana_web3_js from '@solana/web3.js';
6
+ import { Transaction, PublicKey, Keypair, SendOptions, Connection } from '@solana/web3.js';
7
+ export { _solana_web3_js as solanaWeb3 };
5
8
 
6
9
  type SimplifyType<T> = T extends object ? {
7
10
  [K in keyof T]: SimplifyType<T[K]>;
@@ -557,8 +560,79 @@ declare class Core {
557
560
  constructor({ endpointUrl, chain, config }: CoreArguments);
558
561
  }
559
562
 
563
+ type PercentileRangeUnion = '0' | '5' | '10' | '15' | '20' | '25' | '30' | '35' | '40' | '45' | '50' | '55' | '60' | '65' | '70' | '75' | '80' | '85' | '90' | '95' | '100';
564
+ type PriorityFeeLevels = 'low' | 'medium' | 'high' | 'extreme';
565
+ interface PriorityFeeRequestPayload {
566
+ method: string;
567
+ params: {
568
+ last_n_blocks?: number;
569
+ account?: string;
570
+ };
571
+ id: number;
572
+ jsonrpc: string;
573
+ }
574
+ interface PriorityFeeEstimates {
575
+ extreme: number;
576
+ high: number;
577
+ low: number;
578
+ medium: number;
579
+ percentiles: {
580
+ [key in PercentileRangeUnion]: number;
581
+ };
582
+ }
583
+ interface PriorityFeeResponseData {
584
+ jsonrpc: string;
585
+ result: {
586
+ context: {
587
+ slot: number;
588
+ };
589
+ per_compute_unit: PriorityFeeEstimates;
590
+ per_transaction: PriorityFeeEstimates;
591
+ };
592
+ id: number;
593
+ }
594
+ interface EstimatePriorityFeesParams {
595
+ last_n_blocks?: number;
596
+ account?: string;
597
+ }
598
+ interface SolanaClientArgs {
599
+ endpointUrl: string;
600
+ }
601
+ interface SmartTransactionBaseArgs {
602
+ transaction: Transaction;
603
+ feeLevel?: PriorityFeeLevels;
604
+ }
605
+ interface PrepareSmartTransactionArgs extends SmartTransactionBaseArgs {
606
+ payerPublicKey: PublicKey;
607
+ }
608
+ interface SendSmartTransactionArgs extends SmartTransactionBaseArgs {
609
+ keyPair: Keypair;
610
+ sendTransactionOptions?: SendOptions;
611
+ }
612
+
613
+ declare class Solana {
614
+ readonly endpointUrl: string;
615
+ readonly connection: Connection;
616
+ constructor({ endpointUrl }: SolanaClientArgs);
617
+ /**
618
+ * Sends a transaction with a dynamically generated priority fee based on the current network conditions and compute units needed by the transaction.
619
+ */
620
+ sendSmartTransaction(args: SendSmartTransactionArgs): Promise<string>;
621
+ /**
622
+ * Prepares a transaction to be sent with a dynamically generated priority fee based
623
+ * on the current network conditions. It adds a `setComputeUnitPrice` instruction to the transaction
624
+ * and simulates the transaction to estimate the number of compute units it will consume.
625
+ * The returned transaction still needs to be signed and sent to the network.
626
+ */
627
+ prepareSmartTransaction(args: PrepareSmartTransactionArgs): Promise<_solana_web3_js.Transaction>;
628
+ fetchEstimatePriorityFees(args?: EstimatePriorityFeesParams): Promise<PriorityFeeResponseData>;
629
+ private createDynamicPriorityFeeInstruction;
630
+ private getSimulationUnits;
631
+ }
632
+
560
633
  declare const QuickNode: {
561
634
  Core: typeof Core;
635
+ Solana: typeof Solana;
562
636
  };
563
637
 
564
638
  declare class QNInputValidationError extends Error {
@@ -579,4 +653,4 @@ declare class QNChainNotSupported extends Error {
579
653
  constructor(endpointUrl: string);
580
654
  }
581
655
 
582
- export { Core, CoreArguments, QNChainNotSupported, QNCoreClient, QNCoreClientConfig, QNFetchNFTCollectionDetailsInput, QNFetchNFTCollectionDetailsResult, QNFetchNFTInput, QNFetchNFTResult, QNFetchNFTsByCollectionInput, QNFetchNFTsByCollectionResult, QNGetTokenMetadataByCAInput, QNGetTokenMetadataByCAResult, QNGetTokenMetadataBySymbolInput, QNGetTokenMetadataBySymbolResult, QNGetTransactionsByAddressInput, QNGetTransactionsByAddressResult, QNGetTransfersByNFTInput, QNGetTransfersByNFTResult, QNGetWalletTokenBalanceInput, QNGetWalletTokenBalanceResult, QNGetWalletTokenTransactionsInput, QNGetWalletTokenTransactionsResult, QNInputValidationError, QNInvalidEndpointUrl, QNVerifyNFTsOwnerInput, QNVerifyNFTsOwnerResult, QuickNode as default };
656
+ export { Core, CoreArguments, EstimatePriorityFeesParams, PrepareSmartTransactionArgs, PriorityFeeEstimates, PriorityFeeLevels, PriorityFeeRequestPayload, PriorityFeeResponseData, QNChainNotSupported, QNCoreClient, QNCoreClientConfig, QNFetchNFTCollectionDetailsInput, QNFetchNFTCollectionDetailsResult, QNFetchNFTInput, QNFetchNFTResult, QNFetchNFTsByCollectionInput, QNFetchNFTsByCollectionResult, QNGetTokenMetadataByCAInput, QNGetTokenMetadataByCAResult, QNGetTokenMetadataBySymbolInput, QNGetTokenMetadataBySymbolResult, QNGetTransactionsByAddressInput, QNGetTransactionsByAddressResult, QNGetTransfersByNFTInput, QNGetTransfersByNFTResult, QNGetWalletTokenBalanceInput, QNGetWalletTokenBalanceResult, QNGetWalletTokenTransactionsInput, QNGetWalletTokenTransactionsResult, QNInputValidationError, QNInvalidEndpointUrl, QNVerifyNFTsOwnerInput, QNVerifyNFTsOwnerResult, SendSmartTransactionArgs, SmartTransactionBaseArgs, Solana, SolanaClientArgs, QuickNode as default };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "directory": "packages/libs/sdk"
7
7
  },
8
8
  "license": "MIT",
9
- "version": "2.1.2",
9
+ "version": "2.2.0",
10
10
  "main": "./cjs/index.js",
11
11
  "module": "./esm/index.js",
12
12
  "types": "./index.d.ts",
@@ -21,6 +21,7 @@
21
21
  "@pollyjs/adapter-node-http": "^6.0.5",
22
22
  "@pollyjs/core": "^6.0.5",
23
23
  "@pollyjs/persister-fs": "^6.0.5",
24
+ "@solana/web3.js": "^1.91",
24
25
  "@types/jest": "^29.5.1",
25
26
  "@types/mocha": "^10.0.1",
26
27
  "@types/node": "^18.13.0",
@@ -40,12 +41,20 @@
40
41
  "import": "./esm/core/index.js",
41
42
  "default": "./cjs/core/index.js",
42
43
  "types": "./esm/core/index.d.ts"
44
+ },
45
+ "./solana": {
46
+ "import": "./esm/solana/index.js",
47
+ "default": "./cjs/solana/index.js",
48
+ "types": "./esm/solana/index.d.ts"
43
49
  }
44
50
  },
45
51
  "typesVersions": {
46
52
  "*": {
47
53
  "core": [
48
54
  "./esm/core/index.d.ts"
55
+ ],
56
+ "solana": [
57
+ "./esm/solana/index.d.ts"
49
58
  ]
50
59
  }
51
60
  }