@dynamic-labs/solana 4.0.0-alpha.33 → 4.0.0-alpha.35

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,29 @@
1
1
 
2
+ ## [4.0.0-alpha.35](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.34...v4.0.0-alpha.35) (2024-11-25)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * eclipse and solana wallets getting mixed up in connect only ([#7487](https://github.com/dynamic-labs/dynamic-auth/issues/7487)) ([6cabfb8](https://github.com/dynamic-labs/dynamic-auth/commit/6cabfb8da4d23a858652634844653aadc75be062))
8
+ * eclipse wallets never get detected ([#7479](https://github.com/dynamic-labs/dynamic-auth/issues/7479)) ([4a1a040](https://github.com/dynamic-labs/dynamic-auth/commit/4a1a04027e447a0c5c42b2dd3808b82c2ce7724c))
9
+ * **ui:** add missing rule for social login modals ([#7476](https://github.com/dynamic-labs/dynamic-auth/issues/7476)) ([59b5a2d](https://github.com/dynamic-labs/dynamic-auth/commit/59b5a2de10600decedbc167ee30e7900ec53618b))
10
+ * use correct fallback connector for each chain ([#7318](https://github.com/dynamic-labs/dynamic-auth/issues/7318)) ([91dcf8b](https://github.com/dynamic-labs/dynamic-auth/commit/91dcf8b6be4932c8e4122ce4dbceafee7ba1d194))
11
+
12
+ ## [4.0.0-alpha.34](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.33...v4.0.0-alpha.34) (2024-11-20)
13
+
14
+
15
+ ### ⚠ BREAKING CHANGES
16
+
17
+ * remove `supportsSatsConnect` helper ([#7453](https://github.com/dynamic-labs/dynamic-auth/issues/7453)) ([920c63b](https://github.com/dynamic-labs/dynamic-auth/commit/920c63bbb5a38dc3d676664db512a4da539c0909))
18
+ * moved `getWalletLinks` helper from `@dynamic-labs/wallet-book` to `@dynamic-labs/wallet-connector-core` ([#7416](https://github.com/dynamic-labs/dynamic-auth/issues/7416)) ([73fdfa8](https://github.com/dynamic-labs/dynamic-auth/commit/73fdfa8a19fe4c2cca55410d5ed3cb7b5bd8cdfd))
19
+
20
+ ### Features
21
+
22
+ * allow listening to dynamic events without using a hook ([#7466](https://github.com/dynamic-labs/dynamic-auth/issues/7466)) ([3b34e1b](https://github.com/dynamic-labs/dynamic-auth/commit/3b34e1bd2737003b987887a02d0e21436e9bf908))
23
+ * emit primaryWalletChanged event when primary wallets changes ([#7464](https://github.com/dynamic-labs/dynamic-auth/issues/7464)) ([3bc6ba0](https://github.com/dynamic-labs/dynamic-auth/commit/3bc6ba055e0232bff3c6c6bb93d3d57b1dd90bc6))
24
+ * emit primaryWalletNetworkChanged event when primary wallet network changes ([#7465](https://github.com/dynamic-labs/dynamic-auth/issues/7465)) ([33cc629](https://github.com/dynamic-labs/dynamic-auth/commit/33cc629d3c6a03c381b7e5591a8f4557987cc6fc))
25
+
26
+
2
27
  ## [4.0.0-alpha.33](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.32...v4.0.0-alpha.33) (2024-11-18)
3
28
 
4
29
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.0.0-alpha.33";
6
+ var version = "4.0.0-alpha.35";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.0.0-alpha.33";
2
+ var version = "4.0.0-alpha.35";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana",
3
- "version": "4.0.0-alpha.33",
3
+ "version": "4.0.0-alpha.35",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -25,16 +25,16 @@
25
25
  "@wallet-standard/experimental-features": "0.1.1",
26
26
  "bs58": "5.0.0",
27
27
  "tweetnacl": "1.0.3",
28
- "@dynamic-labs/assert-package-version": "4.0.0-alpha.33",
29
- "@dynamic-labs/embedded-wallet-solana": "4.0.0-alpha.33",
30
- "@dynamic-labs/logger": "4.0.0-alpha.33",
31
- "@dynamic-labs/rpc-providers": "4.0.0-alpha.33",
32
- "@dynamic-labs/sdk-api-core": "0.0.565",
33
- "@dynamic-labs/solana-core": "4.0.0-alpha.33",
34
- "@dynamic-labs/types": "4.0.0-alpha.33",
35
- "@dynamic-labs/utils": "4.0.0-alpha.33",
36
- "@dynamic-labs/wallet-book": "4.0.0-alpha.33",
37
- "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.33"
28
+ "@dynamic-labs/assert-package-version": "4.0.0-alpha.35",
29
+ "@dynamic-labs/embedded-wallet-solana": "4.0.0-alpha.35",
30
+ "@dynamic-labs/logger": "4.0.0-alpha.35",
31
+ "@dynamic-labs/rpc-providers": "4.0.0-alpha.35",
32
+ "@dynamic-labs/sdk-api-core": "0.0.570",
33
+ "@dynamic-labs/solana-core": "4.0.0-alpha.35",
34
+ "@dynamic-labs/types": "4.0.0-alpha.35",
35
+ "@dynamic-labs/utils": "4.0.0-alpha.35",
36
+ "@dynamic-labs/wallet-book": "4.0.0-alpha.35",
37
+ "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.35"
38
38
  },
39
39
  "peerDependencies": {}
40
40
  }
@@ -5,16 +5,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var utils = require('@dynamic-labs/utils');
8
- var walletBook = require('@dynamic-labs/wallet-book');
9
8
  var InjectedWalletBase = require('../injected/InjectedWalletBase.cjs');
10
9
  var isSignedMessage = require('../utils/isSignedMessage.cjs');
11
10
 
12
11
  class CoinbaseSolana extends InjectedWalletBase.InjectedWalletBase {
13
- constructor(opts) {
14
- super(opts);
12
+ constructor() {
13
+ super(...arguments);
15
14
  this.name = 'CoinbaseSolana';
16
15
  this.overrideKey = 'coinbasesolana';
17
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
18
16
  }
19
17
  getSigner() {
20
18
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -1,9 +1,7 @@
1
- import { SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
1
  import { InjectedWalletBase } from '../injected/InjectedWalletBase';
3
2
  export declare class CoinbaseSolana extends InjectedWalletBase {
4
3
  name: string;
5
4
  overrideKey: string;
6
- constructor(opts: SolanaWalletConnectorOpts);
7
5
  getSigner<ICoinbaseSolanaSigner>(): Promise<ICoinbaseSolanaSigner | undefined>;
8
6
  signMessage(messageToSign: string): Promise<string | undefined>;
9
7
  }
@@ -1,16 +1,14 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { bufferToBase64 } from '@dynamic-labs/utils';
4
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
5
4
  import { InjectedWalletBase } from '../injected/InjectedWalletBase.js';
6
5
  import { isSignedMessage } from '../utils/isSignedMessage.js';
7
6
 
8
7
  class CoinbaseSolana extends InjectedWalletBase {
9
- constructor(opts) {
10
- super(opts);
8
+ constructor() {
9
+ super(...arguments);
11
10
  this.name = 'CoinbaseSolana';
12
11
  this.overrideKey = 'coinbasesolana';
13
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
14
12
  }
15
13
  getSigner() {
16
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -6,18 +6,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var utils = require('@dynamic-labs/utils');
8
8
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
- var isSignedMessage = require('../utils/isSignedMessage.cjs');
10
9
  var findWalletProviderFromWalletStandard = require('../utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.cjs');
10
+ var isSignedMessage = require('../utils/isSignedMessage.cjs');
11
11
 
12
12
  class SolProviderHelper {
13
- constructor(wallet) {
13
+ constructor(wallet, chain) {
14
14
  this.wallet = wallet;
15
+ this.chain = chain;
15
16
  }
16
17
  getInjectedConfig() {
17
18
  if (!this.wallet || !this.wallet.injectedConfig)
18
19
  return;
19
20
  const { injectedConfig } = this.wallet;
20
- return injectedConfig.find((c) => c.chain === 'sol');
21
+ return injectedConfig.find((c) => c.chain === this.chain);
21
22
  }
22
23
  getInstalledProvider() {
23
24
  const config = this.getInjectedConfig();
@@ -1,9 +1,11 @@
1
+ import { ExtensionLocator, ISolana } from '@dynamic-labs/solana-core';
1
2
  import { WalletSchema } from '@dynamic-labs/wallet-book';
2
3
  import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
3
- import { ISolana, ExtensionLocator as ExtensionLocator } from '@dynamic-labs/solana-core';
4
+ import { AllowedSolanaChain } from '../types';
4
5
  export declare class SolProviderHelper {
5
6
  private wallet;
6
- constructor(wallet: WalletSchema);
7
+ private chain;
8
+ constructor(wallet: WalletSchema, chain: AllowedSolanaChain);
7
9
  getInjectedConfig(): {
8
10
  chain: string;
9
11
  extensionLocators: {
@@ -2,18 +2,19 @@
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { getProvidersFromWindow, bufferToBase64 } from '@dynamic-labs/utils';
4
4
  import { ProviderLookup, logger } from '@dynamic-labs/wallet-connector-core';
5
- import { isSignedMessage } from '../utils/isSignedMessage.js';
6
5
  import { findWalletProviderFromWalletStandard } from '../utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js';
6
+ import { isSignedMessage } from '../utils/isSignedMessage.js';
7
7
 
8
8
  class SolProviderHelper {
9
- constructor(wallet) {
9
+ constructor(wallet, chain) {
10
10
  this.wallet = wallet;
11
+ this.chain = chain;
11
12
  }
12
13
  getInjectedConfig() {
13
14
  if (!this.wallet || !this.wallet.injectedConfig)
14
15
  return;
15
16
  const { injectedConfig } = this.wallet;
16
- return injectedConfig.find((c) => c.chain === 'sol');
17
+ return injectedConfig.find((c) => c.chain === this.chain);
17
18
  }
18
19
  getInstalledProvider() {
19
20
  const config = this.getInjectedConfig();
@@ -5,31 +5,30 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var utils = require('@dynamic-labs/utils');
8
- var walletBook = require('@dynamic-labs/wallet-book');
9
8
  var InjectedWalletBase = require('../injected/InjectedWalletBase.cjs');
10
9
 
11
10
  class Solflare extends InjectedWalletBase.InjectedWalletBase {
12
- constructor(opts) {
13
- super(opts);
11
+ constructor() {
12
+ super(...arguments);
14
13
  this.name = 'Solflare';
15
14
  this.overrideKey = 'solflare';
16
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
17
15
  }
18
16
  getAddress() {
19
17
  return _tslib.__awaiter(this, void 0, void 0, function* () {
20
- var _a, _b, _c, _d, _e;
18
+ var _a, _b;
21
19
  /**
22
20
  * It should redirect to in-app browser if on mobile and if not in the in-app browser,
23
21
  * this checks if it is not in the in-app browser by checking if the provider is not available.
24
22
  */
25
23
  if (utils.isMobile() && !this.isInstalledOnBrowser()) {
24
+ const mobileDeepLinks = (_a = this.metadata.deepLinks) === null || _a === void 0 ? void 0 : _a.mobile;
26
25
  utils.handleMobileWalletRedirect({
27
- nativeLink: ((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.native) || 'solflare://ul/v1/browse',
28
- universalLink: ((_d = (_c = this.wallet) === null || _c === void 0 ? void 0 : _c.mobile) === null || _d === void 0 ? void 0 : _d.universal) || 'https://solflare.com/ul/v1/browse',
26
+ nativeLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.native) || 'solflare://ul/v1/browse',
27
+ universalLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.universal) || 'https://solflare.com/ul/v1/browse',
29
28
  });
30
29
  return;
31
30
  }
32
- return (_e = this.getSolProviderHelper()) === null || _e === void 0 ? void 0 : _e.getAddress();
31
+ return (_b = this.getSolProviderHelper()) === null || _b === void 0 ? void 0 : _b.getAddress();
33
32
  });
34
33
  }
35
34
  signMessage(messageToSign) {
@@ -1,9 +1,7 @@
1
- import { SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
1
  import { InjectedWalletBase } from '../injected/InjectedWalletBase';
3
2
  export declare class Solflare extends InjectedWalletBase {
4
3
  name: string;
5
4
  overrideKey: string;
6
- constructor(opts: SolanaWalletConnectorOpts);
7
5
  getAddress(): Promise<string | undefined>;
8
6
  signMessage(messageToSign: string): Promise<string | undefined>;
9
7
  }
@@ -1,31 +1,30 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { isMobile, handleMobileWalletRedirect, bufferToBase64 } from '@dynamic-labs/utils';
4
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
5
4
  import { InjectedWalletBase } from '../injected/InjectedWalletBase.js';
6
5
 
7
6
  class Solflare extends InjectedWalletBase {
8
- constructor(opts) {
9
- super(opts);
7
+ constructor() {
8
+ super(...arguments);
10
9
  this.name = 'Solflare';
11
10
  this.overrideKey = 'solflare';
12
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
13
11
  }
14
12
  getAddress() {
15
13
  return __awaiter(this, void 0, void 0, function* () {
16
- var _a, _b, _c, _d, _e;
14
+ var _a, _b;
17
15
  /**
18
16
  * It should redirect to in-app browser if on mobile and if not in the in-app browser,
19
17
  * this checks if it is not in the in-app browser by checking if the provider is not available.
20
18
  */
21
19
  if (isMobile() && !this.isInstalledOnBrowser()) {
20
+ const mobileDeepLinks = (_a = this.metadata.deepLinks) === null || _a === void 0 ? void 0 : _a.mobile;
22
21
  handleMobileWalletRedirect({
23
- nativeLink: ((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.native) || 'solflare://ul/v1/browse',
24
- universalLink: ((_d = (_c = this.wallet) === null || _c === void 0 ? void 0 : _c.mobile) === null || _d === void 0 ? void 0 : _d.universal) || 'https://solflare.com/ul/v1/browse',
22
+ nativeLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.native) || 'solflare://ul/v1/browse',
23
+ universalLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.universal) || 'https://solflare.com/ul/v1/browse',
25
24
  });
26
25
  return;
27
26
  }
28
- return (_e = this.getSolProviderHelper()) === null || _e === void 0 ? void 0 : _e.getAddress();
27
+ return (_b = this.getSolProviderHelper()) === null || _b === void 0 ? void 0 : _b.getAddress();
29
28
  });
30
29
  }
31
30
  signMessage(messageToSign) {
package/src/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export { BackpackSol as BackpackConnector } from './injected/BackpackSol';
4
4
  export { InjectedWalletBase as SolanaInjectedConnector } from './injected/InjectedWalletBase';
5
5
  export { SolanaWalletConnectors } from './SolanaWalletConnectors';
6
6
  export { SolanaWalletConnectorsWithConfig } from './SolanaWalletConnectorsWithConfig';
7
+ export type { AllowedSolanaChain } from './types';
7
8
  export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
8
9
  export { isSignedMessage } from './utils/isSignedMessage';
@@ -5,15 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var utils = require('@dynamic-labs/utils');
8
- var walletBook = require('@dynamic-labs/wallet-book');
9
8
  var InjectedWalletBase = require('./InjectedWalletBase.cjs');
10
9
 
11
10
  class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
12
- constructor(opts) {
13
- super(opts);
11
+ constructor() {
12
+ super(...arguments);
14
13
  this.name = 'Backpack';
15
14
  this.overrideKey = 'backpacksol';
16
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
17
15
  }
18
16
  getSigner() {
19
17
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -1,9 +1,7 @@
1
- import { SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
1
  import { InjectedWalletBase } from './InjectedWalletBase';
3
2
  export declare class BackpackSol extends InjectedWalletBase {
4
3
  name: string;
5
4
  overrideKey: string;
6
- constructor(opts: SolanaWalletConnectorOpts);
7
5
  getSigner<IBackpackSolanaSigner>(): Promise<IBackpackSolanaSigner | undefined>;
8
6
  signMessage(messageToSign: string): Promise<string | undefined>;
9
7
  }
@@ -1,15 +1,13 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { bufferToBase64 } from '@dynamic-labs/utils';
4
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
5
4
  import { InjectedWalletBase } from './InjectedWalletBase.js';
6
5
 
7
6
  class BackpackSol extends InjectedWalletBase {
8
- constructor(opts) {
9
- super(opts);
7
+ constructor() {
8
+ super(...arguments);
10
9
  this.name = 'Backpack';
11
10
  this.overrideKey = 'backpacksol';
12
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
13
11
  }
14
12
  getSigner() {
15
13
  return __awaiter(this, void 0, void 0, function* () {
@@ -3,16 +3,14 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var walletBook = require('@dynamic-labs/wallet-book');
7
6
  var InjectedWalletBase = require('./InjectedWalletBase.cjs');
8
7
 
9
8
  class FallbackSolanaConnector extends InjectedWalletBase.InjectedWalletBase {
10
- constructor(opts) {
11
- super(opts);
9
+ constructor() {
10
+ super(...arguments);
12
11
  this.name = 'Fallback Connector';
13
12
  this.overrideKey = 'fallbackconnector';
14
13
  this.isAvailable = false;
15
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
16
14
  }
17
15
  isInstalledOnBrowser() {
18
16
  return false;
@@ -1,9 +1,7 @@
1
- import { SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
1
  import { InjectedWalletBase } from './InjectedWalletBase';
3
2
  export declare class FallbackSolanaConnector extends InjectedWalletBase {
4
3
  name: string;
5
4
  overrideKey: string;
6
5
  isAvailable: boolean;
7
- constructor(opts: SolanaWalletConnectorOpts);
8
6
  isInstalledOnBrowser(): boolean;
9
7
  }
@@ -1,14 +1,12 @@
1
1
  'use client'
2
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
3
2
  import { InjectedWalletBase } from './InjectedWalletBase.js';
4
3
 
5
4
  class FallbackSolanaConnector extends InjectedWalletBase {
6
- constructor(opts) {
7
- super(opts);
5
+ constructor() {
6
+ super(...arguments);
8
7
  this.name = 'Fallback Connector';
9
8
  this.overrideKey = 'fallbackconnector';
10
9
  this.isAvailable = false;
11
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
12
10
  }
13
11
  isInstalledOnBrowser() {
14
12
  return false;
@@ -12,12 +12,24 @@ var SolProviderHelper = require('../SolProviderHelper/SolProviderHelper.cjs');
12
12
  var SignMessageNotSupportedError = require('../errors/SignMessageNotSupportedError.cjs');
13
13
 
14
14
  class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
15
- getSolProviderHelper() {
16
- if (!this.wallet) {
17
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
15
+ constructor() {
16
+ super(...arguments);
17
+ /**
18
+ * The chain being used.
19
+ * Defaults to 'sol', obviously, but since this connector is also used for other chains,
20
+ * such as eclipse, this can be overridden.
21
+ */
22
+ this.solanaChain = 'sol';
23
+ }
24
+ get wallet() {
25
+ if (!this._wallet) {
26
+ this._wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
18
27
  }
28
+ return this._wallet;
29
+ }
30
+ getSolProviderHelper() {
19
31
  if (this.wallet && !this.solProviderHelper) {
20
- this.solProviderHelper = new SolProviderHelper.SolProviderHelper(this.wallet);
32
+ this.solProviderHelper = new SolProviderHelper.SolProviderHelper(this.wallet, this.solanaChain);
21
33
  }
22
34
  return this.solProviderHelper;
23
35
  }
@@ -3,9 +3,86 @@ import { SolanaWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
3
3
  import { IUITransaction } from '@dynamic-labs/types';
4
4
  import { ISendBalanceWalletConnector } from '@dynamic-labs/wallet-connector-core';
5
5
  import { SolProviderHelper } from '../SolProviderHelper';
6
+ import { AllowedSolanaChain } from '../types';
6
7
  export declare abstract class InjectedWalletBase extends SolanaWalletConnector implements ISendBalanceWalletConnector {
7
8
  solProviderHelper: SolProviderHelper | undefined;
8
- wallet: WalletSchema | undefined;
9
+ _wallet: WalletSchema | undefined;
10
+ /**
11
+ * The chain being used.
12
+ * Defaults to 'sol', obviously, but since this connector is also used for other chains,
13
+ * such as eclipse, this can be overridden.
14
+ */
15
+ solanaChain: AllowedSolanaChain;
16
+ get wallet(): {
17
+ name: string;
18
+ brand?: {
19
+ alt?: string | undefined;
20
+ primaryColor?: string | undefined;
21
+ spriteId?: string | undefined;
22
+ } | undefined;
23
+ chainGroup?: string | undefined;
24
+ chains?: string[] | undefined;
25
+ desktop?: {
26
+ chromeId?: string | undefined;
27
+ edgeId?: string | undefined;
28
+ firefoxId?: string | undefined;
29
+ native?: string | undefined;
30
+ operaId?: string | undefined;
31
+ safariId?: string | undefined;
32
+ universal?: string | undefined;
33
+ } | undefined;
34
+ eip6963Config?: {
35
+ rdns: string;
36
+ } | undefined;
37
+ filterFromWalletConnect?: boolean | undefined;
38
+ group?: string | undefined;
39
+ hardwareWallets?: string[] | undefined;
40
+ injectedConfig?: {
41
+ chain: string;
42
+ extensionLocators: {
43
+ value: boolean;
44
+ flag: string;
45
+ }[];
46
+ providerInterface?: string | undefined;
47
+ walletStandard?: {
48
+ features: string[];
49
+ name: string;
50
+ providerId?: string | undefined;
51
+ } | undefined;
52
+ walletStandardLocators?: {
53
+ name: string;
54
+ locator: string;
55
+ }[] | undefined;
56
+ windowLocations?: string[] | undefined;
57
+ }[] | undefined;
58
+ mobile?: {
59
+ android?: string | null | undefined;
60
+ androidId?: string | undefined;
61
+ inAppBrowser?: string | null | undefined;
62
+ ios?: string | null | undefined;
63
+ iosId?: string | undefined;
64
+ native?: string | undefined;
65
+ universal?: string | undefined;
66
+ } | undefined;
67
+ mobileExperience?: "in-app-browser" | "redirect" | undefined;
68
+ shortName?: string | undefined;
69
+ showOnlyIfInstalled?: boolean | undefined;
70
+ switchNetworkOnlyFromWallet?: boolean | undefined;
71
+ walletConnect?: {
72
+ sdks?: string[] | undefined;
73
+ } | undefined;
74
+ walletGroup?: string | undefined;
75
+ walletLimitations?: {
76
+ browserExtension?: {
77
+ unsupportedEvents?: string[] | undefined;
78
+ unsupportedMethods?: string[] | undefined;
79
+ } | undefined;
80
+ mobile?: {
81
+ unsupportedEvents?: string[] | undefined;
82
+ unsupportedMethods?: string[] | undefined;
83
+ } | undefined;
84
+ } | undefined;
85
+ } | undefined;
9
86
  getSolProviderHelper(): SolProviderHelper | undefined;
10
87
  getProvider(): ISolana | undefined;
11
88
  setupEventListeners(): void;
@@ -8,12 +8,24 @@ import { SolProviderHelper } from '../SolProviderHelper/SolProviderHelper.js';
8
8
  import { SignMessageNotSupportedError } from '../errors/SignMessageNotSupportedError.js';
9
9
 
10
10
  class InjectedWalletBase extends SolanaWalletConnector {
11
- getSolProviderHelper() {
12
- if (!this.wallet) {
13
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
11
+ constructor() {
12
+ super(...arguments);
13
+ /**
14
+ * The chain being used.
15
+ * Defaults to 'sol', obviously, but since this connector is also used for other chains,
16
+ * such as eclipse, this can be overridden.
17
+ */
18
+ this.solanaChain = 'sol';
19
+ }
20
+ get wallet() {
21
+ if (!this._wallet) {
22
+ this._wallet = findWalletBookWallet(this.walletBook, this.key);
14
23
  }
24
+ return this._wallet;
25
+ }
26
+ getSolProviderHelper() {
15
27
  if (this.wallet && !this.solProviderHelper) {
16
- this.solProviderHelper = new SolProviderHelper(this.wallet);
28
+ this.solProviderHelper = new SolProviderHelper(this.wallet, this.solanaChain);
17
29
  }
18
30
  return this.solProviderHelper;
19
31
  }
@@ -5,15 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var utils = require('@dynamic-labs/utils');
8
- var walletBook = require('@dynamic-labs/wallet-book');
9
8
  var InjectedWalletBase = require('./InjectedWalletBase.cjs');
10
9
 
11
10
  class PhantomInjected extends InjectedWalletBase.InjectedWalletBase {
12
- constructor(opts) {
13
- super(opts);
11
+ constructor() {
12
+ super(...arguments);
14
13
  this.name = 'Phantom';
15
14
  this.overrideKey = 'phantom';
16
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
17
15
  }
18
16
  getAddress() {
19
17
  const _super = Object.create(null, {
@@ -1,9 +1,7 @@
1
- import { SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
1
  import { InjectedWalletBase } from './InjectedWalletBase';
3
2
  export declare class PhantomInjected extends InjectedWalletBase {
4
3
  name: string;
5
4
  overrideKey: string;
6
- constructor(opts: SolanaWalletConnectorOpts);
7
5
  getAddress(): Promise<string | undefined>;
8
6
  canGetChainAddress(): boolean;
9
7
  }
@@ -1,15 +1,13 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { isMobile, handleMobileWalletRedirect } from '@dynamic-labs/utils';
4
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
5
4
  import { InjectedWalletBase } from './InjectedWalletBase.js';
6
5
 
7
6
  class PhantomInjected extends InjectedWalletBase {
8
- constructor(opts) {
9
- super(opts);
7
+ constructor() {
8
+ super(...arguments);
10
9
  this.name = 'Phantom';
11
10
  this.overrideKey = 'phantom';
12
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
13
11
  }
14
12
  getAddress() {
15
13
  const _super = Object.create(null, {
@@ -3,15 +3,13 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var walletBook = require('@dynamic-labs/wallet-book');
7
6
  var InjectedWalletBase = require('./InjectedWalletBase.cjs');
8
7
 
9
8
  class UnknownInjected extends InjectedWalletBase.InjectedWalletBase {
10
- constructor(opts) {
11
- super(opts);
9
+ constructor() {
10
+ super(...arguments);
12
11
  this.name = 'Unknown';
13
12
  this.overrideKey = 'unknown';
14
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
15
13
  }
16
14
  isInstalledOnBrowser() {
17
15
  return false;
@@ -1,8 +1,6 @@
1
- import { SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
1
  import { InjectedWalletBase } from './InjectedWalletBase';
3
2
  export declare class UnknownInjected extends InjectedWalletBase {
4
3
  name: string;
5
4
  overrideKey: string;
6
- constructor(opts: SolanaWalletConnectorOpts);
7
5
  isInstalledOnBrowser(): boolean;
8
6
  }
@@ -1,13 +1,11 @@
1
1
  'use client'
2
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
3
2
  import { InjectedWalletBase } from './InjectedWalletBase.js';
4
3
 
5
4
  class UnknownInjected extends InjectedWalletBase {
6
- constructor(opts) {
7
- super(opts);
5
+ constructor() {
6
+ super(...arguments);
8
7
  this.name = 'Unknown';
9
8
  this.overrideKey = 'unknown';
10
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
11
9
  }
12
10
  isInstalledOnBrowser() {
13
11
  return false;
@@ -48,13 +48,15 @@ const fetchInjectedWalletConnectors = ({ walletBook, }) => {
48
48
  }
49
49
  }
50
50
  return class extends InjectedWalletBase.InjectedWalletBase {
51
- constructor(props) {
52
- super(Object.assign({}, props));
51
+ constructor() {
52
+ super(...arguments);
53
53
  this.name = name;
54
- this.wallet = wallet;
55
54
  // this is the key from the wallet book entry so that we don't purely rely on the normalized name
56
55
  this.overrideKey = key;
57
56
  }
57
+ get wallet() {
58
+ return wallet;
59
+ }
58
60
  };
59
61
  });
60
62
  };
@@ -44,13 +44,15 @@ const fetchInjectedWalletConnectors = ({ walletBook, }) => {
44
44
  }
45
45
  }
46
46
  return class extends InjectedWalletBase {
47
- constructor(props) {
48
- super(Object.assign({}, props));
47
+ constructor() {
48
+ super(...arguments);
49
49
  this.name = name;
50
- this.wallet = wallet;
51
50
  // this is the key from the wallet book entry so that we don't purely rely on the normalized name
52
51
  this.overrideKey = key;
53
52
  }
53
+ get wallet() {
54
+ return wallet;
55
+ }
54
56
  };
55
57
  });
56
58
  };
package/src/types.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Which Solana chains are available for use.
3
+ *
4
+ * Should follow the same names as those seen in the `injectedConfig[number].chain` property
5
+ * from the `getInjectedConfig` method under SolProviderHelper.
6
+ */
7
+ export type AllowedSolanaChain = 'sol' | 'eclipse';