@quicknode/sdk 2.4.0 → 2.4.1

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
@@ -347,6 +347,17 @@ function setupGlobalFetch() {
347
347
  }
348
348
  }
349
349
 
350
+ // Ideally we read directly from package.json, but ran into some packaging issues with that
351
+ const PACKAGE_VERSION = '2.4.1';
352
+
353
+ // Headers to use in RPC clients
354
+ function getClientHeaders() {
355
+ const packageVersion = PACKAGE_VERSION ;
356
+ return {
357
+ 'x-qn-sdk-version': packageVersion,
358
+ };
359
+ }
360
+
350
361
  const buildQNActions = (config) => {
351
362
  return (client) => ({
352
363
  ...nftAndTokenActions(client, config),
@@ -355,10 +366,15 @@ const buildQNActions = (config) => {
355
366
  class Core {
356
367
  constructor({ endpointUrl, chain, config = {} }) {
357
368
  setupGlobalFetch();
369
+ const clientHeaders = getClientHeaders();
358
370
  this.endpointUrl = endpointUrl;
359
371
  const baseClient = viem.createClient({
360
372
  chain: chain || deriveChainFromUrl(endpointUrl),
361
- transport: viem.http(this.endpointUrl),
373
+ transport: viem.http(this.endpointUrl, {
374
+ fetchOptions: {
375
+ headers: clientHeaders,
376
+ },
377
+ }),
362
378
  }).extend(viem.publicActions);
363
379
  const qnClient = baseClient.extend(buildQNActions(config));
364
380
  this.client = qnClient;
@@ -368,8 +384,11 @@ class Core {
368
384
  // eslint-disable-next-line @nx/enforce-module-boundaries
369
385
  class Solana {
370
386
  constructor({ endpointUrl }) {
387
+ const clientHeaders = getClientHeaders();
371
388
  this.endpointUrl = endpointUrl;
372
- this.connection = new web3_js.Connection(endpointUrl);
389
+ this.connection = new web3_js.Connection(endpointUrl, {
390
+ httpHeaders: clientHeaders,
391
+ });
373
392
  }
374
393
  /**
375
394
  * Sends a transaction with a dynamically generated priority fee based on the current network conditions and compute units needed by the transaction.
package/esm/core/core.js CHANGED
@@ -2,6 +2,7 @@ import { createClient, http, publicActions } from 'viem';
2
2
  import { nftAndTokenActions } from './addOns/nftTokenV2/actions.js';
3
3
  import { deriveChainFromUrl } from './chains.js';
4
4
  import { setupGlobalFetch } from '../lib/helpers/globalFetch.js';
5
+ import { getClientHeaders } from '../lib/helpers/getClientHeaders.js';
5
6
 
6
7
  const buildQNActions = (config) => {
7
8
  return (client) => ({
@@ -11,10 +12,15 @@ const buildQNActions = (config) => {
11
12
  class Core {
12
13
  constructor({ endpointUrl, chain, config = {} }) {
13
14
  setupGlobalFetch();
15
+ const clientHeaders = getClientHeaders();
14
16
  this.endpointUrl = endpointUrl;
15
17
  const baseClient = createClient({
16
18
  chain: chain || deriveChainFromUrl(endpointUrl),
17
- transport: http(this.endpointUrl),
19
+ transport: http(this.endpointUrl, {
20
+ fetchOptions: {
21
+ headers: clientHeaders,
22
+ },
23
+ }),
18
24
  }).extend(publicActions);
19
25
  const qnClient = baseClient.extend(buildQNActions(config));
20
26
  this.client = qnClient;
@@ -0,0 +1,4 @@
1
+ // Ideally we read directly from package.json, but ran into some packaging issues with that
2
+ const PACKAGE_VERSION = '2.4.1';
3
+
4
+ export { PACKAGE_VERSION };
@@ -0,0 +1,11 @@
1
+ import { PACKAGE_VERSION } from '../constants.js';
2
+
3
+ // Headers to use in RPC clients
4
+ function getClientHeaders() {
5
+ const packageVersion = PACKAGE_VERSION ;
6
+ return {
7
+ 'x-qn-sdk-version': packageVersion,
8
+ };
9
+ }
10
+
11
+ export { getClientHeaders };
@@ -1,10 +1,15 @@
1
1
  import { Connection, ComputeBudgetProgram, VersionedTransaction, TransactionMessage, PublicKey } from '@solana/web3.js';
2
+ import 'cross-fetch';
3
+ import { getClientHeaders } from '../lib/helpers/getClientHeaders.js';
2
4
 
3
5
  // eslint-disable-next-line @nx/enforce-module-boundaries
4
6
  class Solana {
5
7
  constructor({ endpointUrl }) {
8
+ const clientHeaders = getClientHeaders();
6
9
  this.endpointUrl = endpointUrl;
7
- this.connection = new Connection(endpointUrl);
10
+ this.connection = new Connection(endpointUrl, {
11
+ httpHeaders: clientHeaders,
12
+ });
8
13
  }
9
14
  /**
10
15
  * Sends a transaction with a dynamically generated priority fee based on the current network conditions and compute units needed by the transaction.
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "directory": "packages/libs/sdk"
7
7
  },
8
8
  "license": "MIT",
9
- "version": "2.4.0",
9
+ "version": "2.4.1",
10
10
  "main": "./cjs/index.js",
11
11
  "module": "./esm/index.js",
12
12
  "types": "./index.d.ts",