@dynamic-labs/solana-core 4.4.0 → 4.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/CHANGELOG.md CHANGED
@@ -1,4 +1,16 @@
1
1
 
2
+ ### [4.4.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.4.0...v4.4.1) (2025-01-27)
3
+
4
+
5
+ ### Features
6
+
7
+ * allow override of rpc urls in connectionConfig for Solana and Eclipse ([#7884](https://github.com/dynamic-labs/dynamic-auth/issues/7884)) ([b65cea0](https://github.com/dynamic-labs/dynamic-auth/commit/b65cea0f7f5240c0e021843266c1437feffa51c5))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * close banxa modal when clicking outside of modal ([#7890](https://github.com/dynamic-labs/dynamic-auth/issues/7890)) ([cc5b5a5](https://github.com/dynamic-labs/dynamic-auth/commit/cc5b5a5911615925065411472f7874aeafff0a25))
13
+
2
14
  ## [4.4.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.3.2...v4.4.0) (2025-01-24)
3
15
 
4
16
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.4.0";
6
+ var version = "4.4.1";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.4.0";
2
+ var version = "4.4.1";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana-core",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "Core package for utilities and types for solana",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -23,12 +23,12 @@
23
23
  "@solana/spl-token": "0.4.6"
24
24
  },
25
25
  "peerDependencies": {
26
- "@dynamic-labs/assert-package-version": "4.4.0",
27
- "@dynamic-labs/rpc-providers": "4.4.0",
28
- "@dynamic-labs/types": "4.4.0",
29
- "@dynamic-labs/utils": "4.4.0",
30
- "@dynamic-labs/wallet-book": "4.4.0",
31
- "@dynamic-labs/wallet-connector-core": "4.4.0",
26
+ "@dynamic-labs/assert-package-version": "4.4.1",
27
+ "@dynamic-labs/rpc-providers": "4.4.1",
28
+ "@dynamic-labs/types": "4.4.1",
29
+ "@dynamic-labs/utils": "4.4.1",
30
+ "@dynamic-labs/wallet-book": "4.4.1",
31
+ "@dynamic-labs/wallet-connector-core": "4.4.1",
32
32
  "eventemitter3": "5.0.1"
33
33
  }
34
34
  }
@@ -10,6 +10,7 @@ var utils = require('@dynamic-labs/utils');
10
10
  var SolanaWallet = require('../wallet/SolanaWallet.cjs');
11
11
  var extractNonce = require('../utils/extractNonce/extractNonce.cjs');
12
12
  var getGenesisHashLSKey = require('../utils/getGenesisHashLSKey/getGenesisHashLSKey.cjs');
13
+ var getOverrideRpcUrlForNetwork = require('../utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.cjs');
13
14
 
14
15
  const MEMO_PROGRAM_ID = new web3_js.PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
15
16
  class SolanaWalletConnector extends walletConnectorCore.WalletConnectorBase {
@@ -55,13 +56,13 @@ class SolanaWalletConnector extends walletConnectorCore.WalletConnectorBase {
55
56
  });
56
57
  }
57
58
  getWalletClient() {
58
- var _a, _b;
59
+ var _a;
59
60
  const [network] = this.solNetworks;
60
61
  if (!network) {
61
62
  throw new utils.DynamicError('No enabled networks');
62
63
  }
63
- const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
64
- return new web3_js.Connection(rpcUrl, (_b = this.connectionConfig) !== null && _b !== void 0 ? _b : 'confirmed');
64
+ const rpcUrl = getOverrideRpcUrlForNetwork.getOverrideRpcUrlForNetwork(this.connectionConfig, network);
65
+ return new web3_js.Connection(rpcUrl, (_a = this.connectionConfig) !== null && _a !== void 0 ? _a : 'confirmed');
65
66
  }
66
67
  getPublicClient() {
67
68
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -1,17 +1,17 @@
1
- import { Connection, ConnectionConfig } from '@solana/web3.js';
1
+ import { Connection } from '@solana/web3.js';
2
2
  import { Chain, IHardwareWalletConnector, WalletConnectorBase, WalletMetadata } from '@dynamic-labs/wallet-connector-core';
3
3
  import { GenericNetwork } from '@dynamic-labs/types';
4
4
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
5
5
  import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
6
6
  import { IChainRpcProviders } from '../rpc';
7
7
  import { SolanaWallet } from '../wallet';
8
- import { ISolana } from '../types';
8
+ import { ISolana, SolanaConnectionConfig } from '../types';
9
9
  export type SolanaWalletConnectorOpts = {
10
10
  chainRpcProviders: IChainRpcProviders;
11
11
  solNetworks: GenericNetwork[];
12
12
  walletBook: WalletBookSchema;
13
13
  metadata?: WalletMetadata;
14
- connectionConfig?: ConnectionConfig;
14
+ connectionConfig?: SolanaConnectionConfig;
15
15
  };
16
16
  export declare abstract class SolanaWalletConnector extends WalletConnectorBase<typeof SolanaWallet> implements IHardwareWalletConnector {
17
17
  isHardwareWalletEnabled: boolean;
@@ -20,7 +20,7 @@ export declare abstract class SolanaWalletConnector extends WalletConnectorBase<
20
20
  ChainWallet: typeof SolanaWallet;
21
21
  supportedChains: Chain[];
22
22
  connectedChain: Chain;
23
- protected connectionConfig: ConnectionConfig | undefined;
23
+ protected connectionConfig: SolanaConnectionConfig | undefined;
24
24
  constructor(opts: SolanaWalletConnectorOpts);
25
25
  getNetwork(): Promise<string>;
26
26
  endSession(): Promise<void>;
@@ -6,6 +6,7 @@ import { DynamicError, isLedgerAddressViaVerifiedCredentials, NotSupportedError
6
6
  import { SolanaWallet } from '../wallet/SolanaWallet.js';
7
7
  import { extractNonce } from '../utils/extractNonce/extractNonce.js';
8
8
  import { getGenesisHashLSKey } from '../utils/getGenesisHashLSKey/getGenesisHashLSKey.js';
9
+ import { getOverrideRpcUrlForNetwork } from '../utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.js';
9
10
 
10
11
  const MEMO_PROGRAM_ID = new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
11
12
  class SolanaWalletConnector extends WalletConnectorBase {
@@ -51,13 +52,13 @@ class SolanaWalletConnector extends WalletConnectorBase {
51
52
  });
52
53
  }
53
54
  getWalletClient() {
54
- var _a, _b;
55
+ var _a;
55
56
  const [network] = this.solNetworks;
56
57
  if (!network) {
57
58
  throw new DynamicError('No enabled networks');
58
59
  }
59
- const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
60
- return new Connection(rpcUrl, (_b = this.connectionConfig) !== null && _b !== void 0 ? _b : 'confirmed');
60
+ const rpcUrl = getOverrideRpcUrlForNetwork(this.connectionConfig, network);
61
+ return new Connection(rpcUrl, (_a = this.connectionConfig) !== null && _a !== void 0 ? _a : 'confirmed');
61
62
  }
62
63
  getPublicClient() {
63
64
  return __awaiter(this, void 0, void 0, function* () {
package/src/index.cjs CHANGED
@@ -15,6 +15,7 @@ var isVersionedTransaction = require('./utils/isVersionedTransaction/isVersioned
15
15
  var encodeTransactionToBase64 = require('./utils/encodeTransactionToBase64/encodeTransactionToBase64.cjs');
16
16
  var getGenesisHashLSKey = require('./utils/getGenesisHashLSKey/getGenesisHashLSKey.cjs');
17
17
  var isTransactionSigned = require('./utils/isTransactionSigned/isTransactionSigned.cjs');
18
+ var getOverrideRpcUrlForNetwork = require('./utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.cjs');
18
19
  var SolanaWallet = require('./wallet/SolanaWallet.cjs');
19
20
  var isSolanaWallet = require('./wallet/isSolanaWallet/isSolanaWallet.cjs');
20
21
  var isLedgerSolanaWallet = require('./wallet/isLedgerSolanaWallet/isLedgerSolanaWallet.cjs');
@@ -30,6 +31,7 @@ exports.isVersionedTransaction = isVersionedTransaction.isVersionedTransaction;
30
31
  exports.encodeTransactionToBase64 = encodeTransactionToBase64.encodeTransactionToBase64;
31
32
  exports.getGenesisHashLSKey = getGenesisHashLSKey.getGenesisHashLSKey;
32
33
  exports.isTxAlreadySigned = isTransactionSigned.isTxAlreadySigned;
34
+ exports.getOverrideRpcUrlForNetwork = getOverrideRpcUrlForNetwork.getOverrideRpcUrlForNetwork;
33
35
  exports.SolanaWallet = SolanaWallet.SolanaWallet;
34
36
  exports.isSolanaWallet = isSolanaWallet.isSolanaWallet;
35
37
  exports.isLedgerSolanaWallet = isLedgerSolanaWallet.isLedgerSolanaWallet;
package/src/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export * from './rpc';
3
3
  export * from './utils';
4
4
  export * from './wallet';
5
5
  export { SOLANA_GENESIS_HASH } from './constants';
6
- export type { ConnectionResult, ExtensionLocator, ISolana, IBackpackSolanaSigner, SignedMessage, ISolanaSigner, } from './types';
6
+ export type { ConnectionResult, ExtensionLocator, ISolana, IBackpackSolanaSigner, SignedMessage, ISolanaSigner, SolanaConnectionConfig, } from './types';
package/src/index.js CHANGED
@@ -11,6 +11,7 @@ export { isVersionedTransaction } from './utils/isVersionedTransaction/isVersion
11
11
  export { encodeTransactionToBase64 } from './utils/encodeTransactionToBase64/encodeTransactionToBase64.js';
12
12
  export { getGenesisHashLSKey } from './utils/getGenesisHashLSKey/getGenesisHashLSKey.js';
13
13
  export { isTxAlreadySigned } from './utils/isTransactionSigned/isTransactionSigned.js';
14
+ export { getOverrideRpcUrlForNetwork } from './utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.js';
14
15
  export { SolanaWallet } from './wallet/SolanaWallet.js';
15
16
  export { isSolanaWallet } from './wallet/isSolanaWallet/isSolanaWallet.js';
16
17
  export { isLedgerSolanaWallet } from './wallet/isLedgerSolanaWallet/isLedgerSolanaWallet.js';
@@ -3,6 +3,10 @@
3
3
 
4
4
  var web3_js = require('@solana/web3.js');
5
5
  var rpcProviders = require('@dynamic-labs/rpc-providers');
6
+ require('../../../_virtual/_tslib.cjs');
7
+ require('@solana/spl-token');
8
+ require('@dynamic-labs/utils');
9
+ var getOverrideRpcUrlForNetwork = require('../../utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.cjs');
6
10
 
7
11
  rpcProviders.ChainRpcProviders.getSolanaProviderByChainId = (rpcProviders, chainId) => {
8
12
  var _a;
@@ -14,8 +18,7 @@ rpcProviders.ChainRpcProviders.registerSolanaProviders = (connectionConfig) => {
14
18
  const rpcProviders = {};
15
19
  if (config === null || config === void 0 ? void 0 : config.solana) {
16
20
  rpcProviders.solana = config.solana.map((network) => {
17
- var _a;
18
- const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
21
+ const rpcUrl = getOverrideRpcUrlForNetwork.getOverrideRpcUrlForNetwork(connectionConfig, network);
19
22
  const provider = new web3_js.Connection(rpcUrl, connectionConfig);
20
23
  return {
21
24
  chainId: network.chainId.toString(),
@@ -1,5 +1,6 @@
1
- import { Connection, ConnectionConfig } from '@solana/web3.js';
1
+ import { Connection } from '@solana/web3.js';
2
2
  import { RpcProviders } from '@dynamic-labs/rpc-providers';
3
+ import { SolanaConnectionConfig } from '../../types';
3
4
  type ISolanaRpcProvider = {
4
5
  chainId: string;
5
6
  chainName: string;
@@ -12,7 +13,7 @@ declare module '@dynamic-labs/rpc-providers' {
12
13
  }
13
14
  interface IChainRpcProviders {
14
15
  getSolanaProviderByChainId(rpcProviders: RpcProviders, chainId: string): SolanaRpcProvider | undefined;
15
- registerSolanaProviders(connectionConfig?: ConnectionConfig): void;
16
+ registerSolanaProviders(connectionConfig?: SolanaConnectionConfig): void;
16
17
  }
17
18
  }
18
19
  export {};
@@ -1,6 +1,10 @@
1
1
  'use client'
2
2
  import { Connection } from '@solana/web3.js';
3
3
  import { ChainRpcProviders, ProviderChain } from '@dynamic-labs/rpc-providers';
4
+ import '../../../_virtual/_tslib.js';
5
+ import '@solana/spl-token';
6
+ import '@dynamic-labs/utils';
7
+ import { getOverrideRpcUrlForNetwork } from '../../utils/getOverrideRpcUrlForNetwork/getOverrideRpcUrlForNetwork.js';
4
8
 
5
9
  ChainRpcProviders.getSolanaProviderByChainId = (rpcProviders, chainId) => {
6
10
  var _a;
@@ -12,8 +16,7 @@ ChainRpcProviders.registerSolanaProviders = (connectionConfig) => {
12
16
  const rpcProviders = {};
13
17
  if (config === null || config === void 0 ? void 0 : config.solana) {
14
18
  rpcProviders.solana = config.solana.map((network) => {
15
- var _a;
16
- const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
19
+ const rpcUrl = getOverrideRpcUrlForNetwork(connectionConfig, network);
17
20
  const provider = new Connection(rpcUrl, connectionConfig);
18
21
  return {
19
22
  chainId: network.chainId.toString(),
package/src/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Connection, SendOptions, Signer, Transaction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
1
+ import { Connection, ConnectionConfig, SendOptions, Signer, Transaction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
2
2
  import EventEmitter from 'eventemitter3';
3
3
  declare global {
4
4
  interface IWindowPhantom {
@@ -57,4 +57,10 @@ export type IBackpackSolanaSigner = ISolanaSigner & {
57
57
  };
58
58
  export type ISolana = ISolanaSigner | IBackpackSolanaSigner;
59
59
  export type ExtensionLocator = 'isBraveWallet' | 'isGlow' | 'isPhantom' | 'isSolflare' | 'isExodus' | 'isBackpack' | 'isMagicEden';
60
+ export type SolanaConnectionConfig = ConnectionConfig & {
61
+ customRpcUrls?: {
62
+ solana?: string[];
63
+ eclipse?: string[];
64
+ };
65
+ };
60
66
  export {};
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const getOverrideRpcUrlForNetwork = (connectionConfig, network) => {
7
+ var _a, _b, _c, _d, _e;
8
+ const isSolanaNetwork = network.name.toLowerCase().includes('solana');
9
+ const isEclipseNetwork = network.name.toLowerCase().includes('eclipse');
10
+ let overrideRpcUrl;
11
+ if (isSolanaNetwork) {
12
+ overrideRpcUrl = (_b = (_a = connectionConfig === null || connectionConfig === void 0 ? void 0 : connectionConfig.customRpcUrls) === null || _a === void 0 ? void 0 : _a.solana) === null || _b === void 0 ? void 0 : _b[0];
13
+ }
14
+ if (isEclipseNetwork) {
15
+ overrideRpcUrl = (_d = (_c = connectionConfig === null || connectionConfig === void 0 ? void 0 : connectionConfig.customRpcUrls) === null || _c === void 0 ? void 0 : _c.eclipse) === null || _d === void 0 ? void 0 : _d[0];
16
+ }
17
+ return (overrideRpcUrl || ((_e = network.privateCustomerRpcUrls) === null || _e === void 0 ? void 0 : _e[0]) || network.rpcUrls[0]);
18
+ };
19
+
20
+ exports.getOverrideRpcUrlForNetwork = getOverrideRpcUrlForNetwork;
@@ -0,0 +1,3 @@
1
+ import { GenericNetwork } from '@dynamic-labs/types';
2
+ import { SolanaConnectionConfig } from '../../types';
3
+ export declare const getOverrideRpcUrlForNetwork: (connectionConfig: SolanaConnectionConfig | undefined, network: GenericNetwork) => string;
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+ const getOverrideRpcUrlForNetwork = (connectionConfig, network) => {
3
+ var _a, _b, _c, _d, _e;
4
+ const isSolanaNetwork = network.name.toLowerCase().includes('solana');
5
+ const isEclipseNetwork = network.name.toLowerCase().includes('eclipse');
6
+ let overrideRpcUrl;
7
+ if (isSolanaNetwork) {
8
+ overrideRpcUrl = (_b = (_a = connectionConfig === null || connectionConfig === void 0 ? void 0 : connectionConfig.customRpcUrls) === null || _a === void 0 ? void 0 : _a.solana) === null || _b === void 0 ? void 0 : _b[0];
9
+ }
10
+ if (isEclipseNetwork) {
11
+ overrideRpcUrl = (_d = (_c = connectionConfig === null || connectionConfig === void 0 ? void 0 : connectionConfig.customRpcUrls) === null || _c === void 0 ? void 0 : _c.eclipse) === null || _d === void 0 ? void 0 : _d[0];
12
+ }
13
+ return (overrideRpcUrl || ((_e = network.privateCustomerRpcUrls) === null || _e === void 0 ? void 0 : _e[0]) || network.rpcUrls[0]);
14
+ };
15
+
16
+ export { getOverrideRpcUrlForNetwork };
@@ -0,0 +1 @@
1
+ export { getOverrideRpcUrlForNetwork } from './getOverrideRpcUrlForNetwork';
@@ -4,3 +4,4 @@ export { isVersionedTransaction } from './isVersionedTransaction';
4
4
  export { encodeTransactionToBase64, type EncodedTransaction, } from './encodeTransactionToBase64';
5
5
  export { getGenesisHashLSKey } from './getGenesisHashLSKey';
6
6
  export { isTxAlreadySigned } from './isTransactionSigned';
7
+ export { getOverrideRpcUrlForNetwork } from './getOverrideRpcUrlForNetwork';
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- const isSolanaWallet = (wallet) => wallet.chain === 'SOL';
6
+ const isSolanaWallet = (wallet) => ['SOL'].includes(wallet.chain);
7
7
 
8
8
  exports.isSolanaWallet = isSolanaWallet;
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- const isSolanaWallet = (wallet) => wallet.chain === 'SOL';
2
+ const isSolanaWallet = (wallet) => ['SOL'].includes(wallet.chain);
3
3
 
4
4
  export { isSolanaWallet };