@dynamic-labs/solana 4.40.0 → 4.40.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +12 -12
  5. package/src/CoinbaseSolana/CoinbaseSolana.cjs +4 -0
  6. package/src/CoinbaseSolana/CoinbaseSolana.js +4 -0
  7. package/src/Phantom/Phantom.cjs +4 -0
  8. package/src/Phantom/Phantom.js +4 -0
  9. package/src/SolanaWalletConnectors.cjs +16 -9
  10. package/src/SolanaWalletConnectors.js +16 -9
  11. package/src/Solflare/Solflare.cjs +4 -0
  12. package/src/Solflare/Solflare.js +4 -0
  13. package/src/index.cjs +3 -1
  14. package/src/index.js +3 -1
  15. package/src/injected/BackpackSol/BackpackSol.cjs +4 -0
  16. package/src/injected/BackpackSol/BackpackSol.js +4 -0
  17. package/src/injected/FallbackSolanaConnector/FallbackSolanaConnector.cjs +4 -0
  18. package/src/injected/FallbackSolanaConnector/FallbackSolanaConnector.js +4 -0
  19. package/src/injected/InjectedWalletBase/InjectedWalletBase.cjs +37 -14
  20. package/src/injected/InjectedWalletBase/InjectedWalletBase.d.ts +8 -0
  21. package/src/injected/InjectedWalletBase/InjectedWalletBase.js +37 -14
  22. package/src/injected/fetchInjectedWalletConnectors.cjs +2 -13
  23. package/src/injected/fetchInjectedWalletConnectors.js +2 -13
  24. package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs +46 -0
  25. package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.d.ts +9 -0
  26. package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js +42 -0
  27. package/src/utils/getConnectorConstructorInjectedWallet/index.d.ts +1 -0
  28. package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs +43 -28
  29. package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.d.ts +4 -3
  30. package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.js +44 -29
  31. package/src/walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.cjs +64 -0
  32. package/src/walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.d.ts +12 -0
  33. package/src/walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.js +60 -0
  34. package/src/walletConnect/utils/addSolanaWalletConnectConnectors/index.d.ts +1 -0
  35. package/src/walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.cjs +11 -4
  36. package/src/walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.js +11 -4
package/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ ### [4.40.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.40.0...v4.40.1) (2025-10-24)
3
+
4
+ ### Bug Fixes
5
+
6
+ * add support for Keplr in-app browser redirect for cosmos chain ([#9770](https://github.com/dynamic-labs/dynamic-auth/issues/9770)) ([35652f3](https://github.com/dynamic-labs/dynamic-auth/commit/35652f3167a4e768f5d4c634ab1b4f127fd5076a))
7
+
2
8
  ## [4.40.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.39.0...v4.40.0) (2025-10-22)
3
9
 
4
10
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.40.0";
6
+ var version = "4.40.1";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.40.0";
2
+ var version = "4.40.1";
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.40.0",
3
+ "version": "4.40.1",
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",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/wallet-connect": "4.40.0",
21
+ "@dynamic-labs/wallet-connect": "4.40.1",
22
22
  "@solana/web3.js": "1.98.1",
23
23
  "@wallet-standard/app": "1.0.1",
24
24
  "@wallet-standard/base": "1.0.1",
@@ -29,17 +29,17 @@
29
29
  "@walletconnect/sign-client": "2.21.5",
30
30
  "@walletconnect/utils": "2.21.5",
31
31
  "@walletconnect/types": "2.21.5",
32
- "@dynamic-labs/assert-package-version": "4.40.0",
33
- "@dynamic-labs/embedded-wallet-solana": "4.40.0",
34
- "@dynamic-labs/logger": "4.40.0",
35
- "@dynamic-labs/rpc-providers": "4.40.0",
32
+ "@dynamic-labs/assert-package-version": "4.40.1",
33
+ "@dynamic-labs/embedded-wallet-solana": "4.40.1",
34
+ "@dynamic-labs/logger": "4.40.1",
35
+ "@dynamic-labs/rpc-providers": "4.40.1",
36
36
  "@dynamic-labs/sdk-api-core": "0.0.813",
37
- "@dynamic-labs/solana-core": "4.40.0",
38
- "@dynamic-labs/types": "4.40.0",
39
- "@dynamic-labs/utils": "4.40.0",
40
- "@dynamic-labs/waas-svm": "4.40.0",
41
- "@dynamic-labs/wallet-book": "4.40.0",
42
- "@dynamic-labs/wallet-connector-core": "4.40.0",
37
+ "@dynamic-labs/solana-core": "4.40.1",
38
+ "@dynamic-labs/types": "4.40.1",
39
+ "@dynamic-labs/utils": "4.40.1",
40
+ "@dynamic-labs/waas-svm": "4.40.1",
41
+ "@dynamic-labs/wallet-book": "4.40.1",
42
+ "@dynamic-labs/wallet-connector-core": "4.40.1",
43
43
  "eventemitter3": "5.0.1"
44
44
  },
45
45
  "peerDependencies": {}
@@ -39,5 +39,9 @@ class CoinbaseSolana extends InjectedWalletBase.InjectedWalletBase {
39
39
  });
40
40
  }
41
41
  }
42
+ Object.defineProperty(CoinbaseSolana, 'key', {
43
+ value: 'coinbasesolana',
44
+ writable: false,
45
+ });
42
46
 
43
47
  exports.CoinbaseSolana = CoinbaseSolana;
@@ -35,5 +35,9 @@ class CoinbaseSolana extends InjectedWalletBase {
35
35
  });
36
36
  }
37
37
  }
38
+ Object.defineProperty(CoinbaseSolana, 'key', {
39
+ value: 'coinbasesolana',
40
+ writable: false,
41
+ });
38
42
 
39
43
  export { CoinbaseSolana };
@@ -38,5 +38,9 @@ class Phantom extends solanaCore.SolanaWalletConnector {
38
38
  }
39
39
  }
40
40
  }
41
+ Object.defineProperty(Phantom, 'key', {
42
+ value: 'phantom',
43
+ writable: false,
44
+ });
41
45
 
42
46
  exports.Phantom = Phantom;
@@ -34,5 +34,9 @@ class Phantom extends SolanaWalletConnector {
34
34
  }
35
35
  }
36
36
  }
37
+ Object.defineProperty(Phantom, 'key', {
38
+ value: 'phantom',
39
+ writable: false,
40
+ });
37
41
 
38
42
  export { Phantom };
@@ -14,17 +14,24 @@ require('@solana/web3.js');
14
14
  require('bs58');
15
15
  require('./utils/logger.cjs');
16
16
  var getSolanaWalletConnectConnector = require('./walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.cjs');
17
+ var addSolanaWalletConnectConnectors = require('./walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.cjs');
17
18
 
18
19
  const SolanaWalletConnectors = (
19
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- props) => [
21
- ...fetchInjectedWalletConnectors.injectedWalletOverrides,
22
- ...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(props),
23
- ...embeddedWalletSolana.TurnkeySolanaWalletConnectors(props),
24
- ...waasSvm.DynamicWaasSVMConnectors(),
25
- Phantom.Phantom,
26
- FallbackSolanaConnector.FallbackSolanaConnector,
27
- getSolanaWalletConnectConnector.getSolanaWalletConnectConnector(),
28
- ];
21
+ props) => {
22
+ const initialConnectors = [
23
+ ...fetchInjectedWalletConnectors.injectedWalletOverrides,
24
+ ...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(props),
25
+ ...embeddedWalletSolana.TurnkeySolanaWalletConnectors(props),
26
+ ...waasSvm.DynamicWaasSVMConnectors(),
27
+ Phantom.Phantom,
28
+ FallbackSolanaConnector.FallbackSolanaConnector,
29
+ getSolanaWalletConnectConnector.getSolanaWalletConnectConnector(),
30
+ ];
31
+ return addSolanaWalletConnectConnectors.addSolanaWalletConnectConnectors({
32
+ connectors: initialConnectors,
33
+ walletBook: props.walletBook,
34
+ });
35
+ };
29
36
 
30
37
  exports.SolanaWalletConnectors = SolanaWalletConnectors;
@@ -10,17 +10,24 @@ import '@solana/web3.js';
10
10
  import 'bs58';
11
11
  import './utils/logger.js';
12
12
  import { getSolanaWalletConnectConnector } from './walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.js';
13
+ import { addSolanaWalletConnectConnectors } from './walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.js';
13
14
 
14
15
  const SolanaWalletConnectors = (
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- props) => [
17
- ...injectedWalletOverrides,
18
- ...fetchInjectedWalletConnectors(props),
19
- ...TurnkeySolanaWalletConnectors(props),
20
- ...DynamicWaasSVMConnectors(),
21
- Phantom,
22
- FallbackSolanaConnector,
23
- getSolanaWalletConnectConnector(),
24
- ];
17
+ props) => {
18
+ const initialConnectors = [
19
+ ...injectedWalletOverrides,
20
+ ...fetchInjectedWalletConnectors(props),
21
+ ...TurnkeySolanaWalletConnectors(props),
22
+ ...DynamicWaasSVMConnectors(),
23
+ Phantom,
24
+ FallbackSolanaConnector,
25
+ getSolanaWalletConnectConnector(),
26
+ ];
27
+ return addSolanaWalletConnectConnectors({
28
+ connectors: initialConnectors,
29
+ walletBook: props.walletBook,
30
+ });
31
+ };
25
32
 
26
33
  export { SolanaWalletConnectors };
@@ -58,5 +58,9 @@ class Solflare extends InjectedWalletBase.InjectedWalletBase {
58
58
  });
59
59
  }
60
60
  }
61
+ Object.defineProperty(Solflare, 'key', {
62
+ value: 'solflare',
63
+ writable: false,
64
+ });
61
65
 
62
66
  exports.Solflare = Solflare;
@@ -54,5 +54,9 @@ class Solflare extends InjectedWalletBase {
54
54
  });
55
55
  }
56
56
  }
57
+ Object.defineProperty(Solflare, 'key', {
58
+ value: 'solflare',
59
+ writable: false,
60
+ });
57
61
 
58
62
  export { Solflare };
package/src/index.cjs CHANGED
@@ -15,11 +15,13 @@ var isSignedMessage = require('./utils/isSignedMessage.cjs');
15
15
  require('@dynamic-labs/wallet-book');
16
16
  require('@dynamic-labs/wallet-connector-core');
17
17
  require('@dynamic-labs/utils');
18
- require('../_virtual/_tslib.cjs');
18
+ require('./CoinbaseSolana/CoinbaseSolana.cjs');
19
+ require('./Solflare/Solflare.cjs');
19
20
  require('./utils/logger.cjs');
20
21
  var createSolanaSignerFromWalletStandard = require('./injected/walletStandard/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs');
21
22
  var getWalletStandardWallets = require('./injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.cjs');
22
23
  var hasAllWalletStandardRequiredFeatures = require('./injected/walletStandard/hasAllWalletStandardRequiredFeatures/hasAllWalletStandardRequiredFeatures.cjs');
24
+ require('./injected/FallbackSolanaConnector/FallbackSolanaConnector.cjs');
23
25
 
24
26
  /* eslint-disable @typescript-eslint/no-unused-vars */
25
27
  assertPackageVersion.assertPackageVersion('@dynamic-labs/solana', _package.version);
package/src/index.js CHANGED
@@ -11,11 +11,13 @@ export { isSignedMessage } from './utils/isSignedMessage.js';
11
11
  import '@dynamic-labs/wallet-book';
12
12
  import '@dynamic-labs/wallet-connector-core';
13
13
  import '@dynamic-labs/utils';
14
- import '../_virtual/_tslib.js';
14
+ import './CoinbaseSolana/CoinbaseSolana.js';
15
+ import './Solflare/Solflare.js';
15
16
  import './utils/logger.js';
16
17
  export { createSolanaSignerFromWalletStandard } from './injected/walletStandard/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js';
17
18
  export { getWalletStandardWallets } from './injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.js';
18
19
  export { hasAllWalletStandardRequiredFeatures } from './injected/walletStandard/hasAllWalletStandardRequiredFeatures/hasAllWalletStandardRequiredFeatures.js';
20
+ import './injected/FallbackSolanaConnector/FallbackSolanaConnector.js';
19
21
 
20
22
  /* eslint-disable @typescript-eslint/no-unused-vars */
21
23
  assertPackageVersion('@dynamic-labs/solana', version);
@@ -40,5 +40,9 @@ class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
40
40
  });
41
41
  }
42
42
  }
43
+ Object.defineProperty(BackpackSol, 'key', {
44
+ value: 'backpacksol',
45
+ writable: false,
46
+ });
43
47
 
44
48
  exports.BackpackSol = BackpackSol;
@@ -36,5 +36,9 @@ class BackpackSol extends InjectedWalletBase {
36
36
  });
37
37
  }
38
38
  }
39
+ Object.defineProperty(BackpackSol, 'key', {
40
+ value: 'backpacksol',
41
+ writable: false,
42
+ });
39
43
 
40
44
  export { BackpackSol };
@@ -16,5 +16,9 @@ class FallbackSolanaConnector extends InjectedWalletBase.InjectedWalletBase {
16
16
  return false;
17
17
  }
18
18
  }
19
+ Object.defineProperty(FallbackSolanaConnector, 'key', {
20
+ value: 'fallbackconnector',
21
+ writable: false,
22
+ });
19
23
 
20
24
  exports.FallbackSolanaConnector = FallbackSolanaConnector;
@@ -12,5 +12,9 @@ class FallbackSolanaConnector extends InjectedWalletBase {
12
12
  return false;
13
13
  }
14
14
  }
15
+ Object.defineProperty(FallbackSolanaConnector, 'key', {
16
+ value: 'fallbackconnector',
17
+ writable: false,
18
+ });
15
19
 
16
20
  export { FallbackSolanaConnector };
@@ -6,11 +6,43 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../../_virtual/_tslib.cjs');
7
7
  var web3_js = require('@solana/web3.js');
8
8
  var solanaCore = require('@dynamic-labs/solana-core');
9
- var utils = require('@dynamic-labs/utils');
9
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
10
10
  var SolProviderHelper = require('../../SolProviderHelper/SolProviderHelper.cjs');
11
11
  var SignMessageNotSupportedError = require('../../errors/SignMessageNotSupportedError.cjs');
12
+ var logger = require('../../utils/logger.cjs');
13
+ var SolanaWalletConnectConnector = require('../../walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs');
12
14
 
13
15
  class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
16
+ constructor() {
17
+ super(...arguments);
18
+ /**
19
+ * For historical reasons, all wallet connect data for wallets reside in the EVM entry for the wallet in wallet book.
20
+ * Therefore, for Solana wallets that support wallet connect, we must also hold the reference to the wallet book
21
+ * entry that has the wallet connect data for it.
22
+ */
23
+ this.walletConnectWalletBookEntry = undefined;
24
+ }
25
+ getMobileOrInstalledWallet() {
26
+ // can use WC if the wallet has WC setting in wallet book and projectId is set
27
+ const canUseWalletConnect = this.walletConnectWalletBookEntry && this.constructorProps.projectId;
28
+ logger.logger.logVerboseTroubleshootingMessage('[SOL InjectedWalletBase] getMobileOrInstalledWallet', {
29
+ canUseWalletConnect,
30
+ isInstalledOnBrowser: this.isInstalledOnBrowser(),
31
+ projectId: this.constructorProps.projectId,
32
+ walletConnectWalletBookEntry: this.walletConnectWalletBookEntry,
33
+ });
34
+ // if the wallet is installed on the browser or WC is not available, return the injected connector
35
+ if (this.isInstalledOnBrowser() || !canUseWalletConnect) {
36
+ return this;
37
+ }
38
+ // if the wallet is not installed on the browser and WC is available, return the WC connector
39
+ const wcConnector = new SolanaWalletConnectConnector.SolanaWalletConnectConnector(Object.assign(Object.assign({}, this.constructorProps), { metadata: walletConnectorCore.getWalletMetadataFromWalletBook({
40
+ walletBookWallet: this.walletConnectWalletBookEntry,
41
+ walletKey: this.key,
42
+ }), overrideKey: this.key, walletName: this.name }));
43
+ wcConnector.init();
44
+ return wcConnector;
45
+ }
14
46
  get solProviderHelper() {
15
47
  if (!this._solProviderHelper) {
16
48
  this._solProviderHelper = new SolProviderHelper.SolProviderHelper(this);
@@ -79,21 +111,12 @@ class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
79
111
  }
80
112
  getAddress() {
81
113
  return _tslib.__awaiter(this, void 0, void 0, function* () {
82
- var _a, _b;
83
- if (!this.isInstalledOnBrowser()) {
84
- if (utils.isMobile() &&
85
- ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
86
- this.mobileExperience === 'in-app-browser') {
87
- const inAppBrowserCompiledTemplate = utils.template(this.metadata.inAppBrowserUrl);
88
- const { href } = utils.PlatformService.getUrl();
89
- const deepLink = inAppBrowserCompiledTemplate({
90
- encodedDappURI: encodeURIComponent(href),
91
- });
92
- utils.PlatformService.openURL(deepLink);
93
- }
114
+ var _a;
115
+ const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
116
+ if (didOpenInAppBrowser) {
94
117
  return;
95
118
  }
96
- return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
119
+ return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
97
120
  });
98
121
  }
99
122
  signMessage(messageToSign) {
@@ -1,9 +1,17 @@
1
1
  import { SolanaWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
2
2
  import { IUITransaction } from '@dynamic-labs/types';
3
3
  import { ISendBalanceWalletConnector } from '@dynamic-labs/wallet-connector-core';
4
+ import { WalletSchema } from '@dynamic-labs/wallet-book';
4
5
  import { SolProviderHelper } from '../../SolProviderHelper';
5
6
  export declare abstract class InjectedWalletBase extends SolanaWalletConnector implements ISendBalanceWalletConnector {
6
7
  _solProviderHelper: SolProviderHelper | undefined;
8
+ /**
9
+ * For historical reasons, all wallet connect data for wallets reside in the EVM entry for the wallet in wallet book.
10
+ * Therefore, for Solana wallets that support wallet connect, we must also hold the reference to the wallet book
11
+ * entry that has the wallet connect data for it.
12
+ */
13
+ walletConnectWalletBookEntry: WalletSchema | undefined;
14
+ getMobileOrInstalledWallet(): InjectedWalletBase;
7
15
  get solProviderHelper(): SolProviderHelper | undefined;
8
16
  findProvider(): ISolana | undefined;
9
17
  setupEventListeners(): void;
@@ -2,11 +2,43 @@
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
3
  import { PublicKey } from '@solana/web3.js';
4
4
  import { SolanaWalletConnector, SolanaUiTransaction } from '@dynamic-labs/solana-core';
5
- import { isMobile, template, PlatformService } from '@dynamic-labs/utils';
5
+ import { getWalletMetadataFromWalletBook } from '@dynamic-labs/wallet-connector-core';
6
6
  import { SolProviderHelper } from '../../SolProviderHelper/SolProviderHelper.js';
7
7
  import { SignMessageNotSupportedError } from '../../errors/SignMessageNotSupportedError.js';
8
+ import { logger } from '../../utils/logger.js';
9
+ import { SolanaWalletConnectConnector } from '../../walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.js';
8
10
 
9
11
  class InjectedWalletBase extends SolanaWalletConnector {
12
+ constructor() {
13
+ super(...arguments);
14
+ /**
15
+ * For historical reasons, all wallet connect data for wallets reside in the EVM entry for the wallet in wallet book.
16
+ * Therefore, for Solana wallets that support wallet connect, we must also hold the reference to the wallet book
17
+ * entry that has the wallet connect data for it.
18
+ */
19
+ this.walletConnectWalletBookEntry = undefined;
20
+ }
21
+ getMobileOrInstalledWallet() {
22
+ // can use WC if the wallet has WC setting in wallet book and projectId is set
23
+ const canUseWalletConnect = this.walletConnectWalletBookEntry && this.constructorProps.projectId;
24
+ logger.logVerboseTroubleshootingMessage('[SOL InjectedWalletBase] getMobileOrInstalledWallet', {
25
+ canUseWalletConnect,
26
+ isInstalledOnBrowser: this.isInstalledOnBrowser(),
27
+ projectId: this.constructorProps.projectId,
28
+ walletConnectWalletBookEntry: this.walletConnectWalletBookEntry,
29
+ });
30
+ // if the wallet is installed on the browser or WC is not available, return the injected connector
31
+ if (this.isInstalledOnBrowser() || !canUseWalletConnect) {
32
+ return this;
33
+ }
34
+ // if the wallet is not installed on the browser and WC is available, return the WC connector
35
+ const wcConnector = new SolanaWalletConnectConnector(Object.assign(Object.assign({}, this.constructorProps), { metadata: getWalletMetadataFromWalletBook({
36
+ walletBookWallet: this.walletConnectWalletBookEntry,
37
+ walletKey: this.key,
38
+ }), overrideKey: this.key, walletName: this.name }));
39
+ wcConnector.init();
40
+ return wcConnector;
41
+ }
10
42
  get solProviderHelper() {
11
43
  if (!this._solProviderHelper) {
12
44
  this._solProviderHelper = new SolProviderHelper(this);
@@ -75,21 +107,12 @@ class InjectedWalletBase extends SolanaWalletConnector {
75
107
  }
76
108
  getAddress() {
77
109
  return __awaiter(this, void 0, void 0, function* () {
78
- var _a, _b;
79
- if (!this.isInstalledOnBrowser()) {
80
- if (isMobile() &&
81
- ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
82
- this.mobileExperience === 'in-app-browser') {
83
- const inAppBrowserCompiledTemplate = template(this.metadata.inAppBrowserUrl);
84
- const { href } = PlatformService.getUrl();
85
- const deepLink = inAppBrowserCompiledTemplate({
86
- encodedDappURI: encodeURIComponent(href),
87
- });
88
- PlatformService.openURL(deepLink);
89
- }
110
+ var _a;
111
+ const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
112
+ if (didOpenInAppBrowser) {
90
113
  return;
91
114
  }
92
- return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
115
+ return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
93
116
  });
94
117
  }
95
118
  signMessage(messageToSign) {
@@ -9,7 +9,7 @@ var utils = require('@dynamic-labs/utils');
9
9
  var CoinbaseSolana = require('../CoinbaseSolana/CoinbaseSolana.cjs');
10
10
  var Solflare = require('../Solflare/Solflare.cjs');
11
11
  var logger = require('../utils/logger.cjs');
12
- var InjectedWalletBase = require('./InjectedWalletBase/InjectedWalletBase.cjs');
12
+ var getConnectorConstructorInjectedWallet = require('../utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs');
13
13
  var BackpackSol = require('./BackpackSol/BackpackSol.cjs');
14
14
  var getConnectorConstructorForWalletStandardWallet = require('./walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.cjs');
15
15
  var getWalletStandardWallets = require('./walletStandard/getWalletStandardWallets/getWalletStandardWallets.cjs');
@@ -66,18 +66,7 @@ const fetchInjectedWalletConnectors = ({ walletBook: walletBook$1, authMode, })
66
66
  ((_c = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.features) === null || _c === void 0 ? void 0 : _c.length);
67
67
  return isSolanaWallet && !shouldBeFiltered;
68
68
  })
69
- .map(([key, wallet]) => {
70
- const { shortName } = wallet;
71
- const name = shortName || wallet.name;
72
- return class extends InjectedWalletBase.InjectedWalletBase {
73
- constructor() {
74
- super(...arguments);
75
- this.name = name;
76
- // this is the key from the wallet book entry so that we don't purely rely on the normalized name
77
- this.overrideKey = key;
78
- }
79
- };
80
- });
69
+ .map(([key, wallet]) => getConnectorConstructorInjectedWallet.getConnectorConstructorInjectedWallet({ key, wallet, walletBook: walletBook$1 }));
81
70
  const walletStandardWallets = getWalletStandardWallets.getWalletStandardWallets();
82
71
  const walletStandardConnectors = walletStandardWallets
83
72
  .filter((wallet) => shouldAddWalletStandardConnector(wallet, walletBook$1, authMode))
@@ -5,7 +5,7 @@ import { sanitizeName } from '@dynamic-labs/utils';
5
5
  import { CoinbaseSolana } from '../CoinbaseSolana/CoinbaseSolana.js';
6
6
  import { Solflare } from '../Solflare/Solflare.js';
7
7
  import { logger } from '../utils/logger.js';
8
- import { InjectedWalletBase } from './InjectedWalletBase/InjectedWalletBase.js';
8
+ import { getConnectorConstructorInjectedWallet } from '../utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js';
9
9
  import { BackpackSol } from './BackpackSol/BackpackSol.js';
10
10
  import { getConnectorConstructorForWalletStandardWallet } from './walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.js';
11
11
  import { getWalletStandardWallets } from './walletStandard/getWalletStandardWallets/getWalletStandardWallets.js';
@@ -62,18 +62,7 @@ const fetchInjectedWalletConnectors = ({ walletBook, authMode, }) => {
62
62
  ((_c = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.features) === null || _c === void 0 ? void 0 : _c.length);
63
63
  return isSolanaWallet && !shouldBeFiltered;
64
64
  })
65
- .map(([key, wallet]) => {
66
- const { shortName } = wallet;
67
- const name = shortName || wallet.name;
68
- return class extends InjectedWalletBase {
69
- constructor() {
70
- super(...arguments);
71
- this.name = name;
72
- // this is the key from the wallet book entry so that we don't purely rely on the normalized name
73
- this.overrideKey = key;
74
- }
75
- };
76
- });
65
+ .map(([key, wallet]) => getConnectorConstructorInjectedWallet({ key, wallet, walletBook }));
77
66
  const walletStandardWallets = getWalletStandardWallets();
78
67
  const walletStandardConnectors = walletStandardWallets
79
68
  .filter((wallet) => shouldAddWalletStandardConnector(wallet, walletBook, authMode))
@@ -0,0 +1,46 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var InjectedWalletBase = require('../../injected/InjectedWalletBase/InjectedWalletBase.cjs');
7
+
8
+ const getConnectorConstructorInjectedWallet = ({ key, wallet, walletBook, }) => {
9
+ const { shortName } = wallet;
10
+ const name = shortName || wallet.name;
11
+ /**
12
+ * For historical reasons, all wallet connect data for wallets reside in the EVM entry for the wallet in wallet book.
13
+ * Therefore, in order to tell whether this Sol wallet supports wallet connect, we will have to find the wallet book
14
+ * entry that has the wallet connect data for it.
15
+ */
16
+ let walletConnectWalletBookEntry = undefined;
17
+ if (wallet.group) {
18
+ walletConnectWalletBookEntry = Object.values(walletBook.wallets).find((entry) => {
19
+ var _a;
20
+ return entry.walletConnect &&
21
+ entry.group === wallet.group &&
22
+ (
23
+ // Disregard if the wallet connect data does not support Solana. WC chains are prefixed with 'solana:'
24
+ // as they follow CAIP-2 format
25
+ (_a = entry.chains) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.includes('solana:')));
26
+ });
27
+ }
28
+ const InjectedWalletConstructor = class extends InjectedWalletBase.InjectedWalletBase {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.walletName = name;
32
+ this.name = name;
33
+ this.walletConnectWalletBookEntry = walletConnectWalletBookEntry;
34
+ // this is the key from the wallet book entry so that we don't purely rely on the normalized name
35
+ this.overrideKey = key;
36
+ }
37
+ };
38
+ // Add this key so we can later tell which wallet each constructor is for
39
+ Object.defineProperty(InjectedWalletConstructor, 'key', {
40
+ value: key,
41
+ writable: false,
42
+ });
43
+ return InjectedWalletConstructor;
44
+ };
45
+
46
+ exports.getConnectorConstructorInjectedWallet = getConnectorConstructorInjectedWallet;
@@ -0,0 +1,9 @@
1
+ import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
2
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
3
+ type GetConnectorConstructorInjectedWalletProps = {
4
+ key: string;
5
+ wallet: WalletSchema;
6
+ walletBook: WalletBookSchema;
7
+ };
8
+ export declare const getConnectorConstructorInjectedWallet: ({ key, wallet, walletBook, }: GetConnectorConstructorInjectedWalletProps) => WalletConnectorConstructor;
9
+ export {};
@@ -0,0 +1,42 @@
1
+ 'use client'
2
+ import { InjectedWalletBase } from '../../injected/InjectedWalletBase/InjectedWalletBase.js';
3
+
4
+ const getConnectorConstructorInjectedWallet = ({ key, wallet, walletBook, }) => {
5
+ const { shortName } = wallet;
6
+ const name = shortName || wallet.name;
7
+ /**
8
+ * For historical reasons, all wallet connect data for wallets reside in the EVM entry for the wallet in wallet book.
9
+ * Therefore, in order to tell whether this Sol wallet supports wallet connect, we will have to find the wallet book
10
+ * entry that has the wallet connect data for it.
11
+ */
12
+ let walletConnectWalletBookEntry = undefined;
13
+ if (wallet.group) {
14
+ walletConnectWalletBookEntry = Object.values(walletBook.wallets).find((entry) => {
15
+ var _a;
16
+ return entry.walletConnect &&
17
+ entry.group === wallet.group &&
18
+ (
19
+ // Disregard if the wallet connect data does not support Solana. WC chains are prefixed with 'solana:'
20
+ // as they follow CAIP-2 format
21
+ (_a = entry.chains) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.includes('solana:')));
22
+ });
23
+ }
24
+ const InjectedWalletConstructor = class extends InjectedWalletBase {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.walletName = name;
28
+ this.name = name;
29
+ this.walletConnectWalletBookEntry = walletConnectWalletBookEntry;
30
+ // this is the key from the wallet book entry so that we don't purely rely on the normalized name
31
+ this.overrideKey = key;
32
+ }
33
+ };
34
+ // Add this key so we can later tell which wallet each constructor is for
35
+ Object.defineProperty(InjectedWalletConstructor, 'key', {
36
+ value: key,
37
+ writable: false,
38
+ });
39
+ return InjectedWalletConstructor;
40
+ };
41
+
42
+ export { getConnectorConstructorInjectedWallet };
@@ -0,0 +1 @@
1
+ export { getConnectorConstructorInjectedWallet } from './getConnectorConstructorInjectedWallet';
@@ -4,14 +4,14 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../_virtual/_tslib.cjs');
7
- var bs58 = require('bs58');
8
- var utils$1 = require('@walletconnect/utils');
9
7
  var web3_js = require('@solana/web3.js');
8
+ var utils$1 = require('@walletconnect/utils');
9
+ var bs58 = require('bs58');
10
10
  var EventEmitter = require('eventemitter3');
11
11
  var solanaCore = require('@dynamic-labs/solana-core');
12
12
  var utils = require('@dynamic-labs/utils');
13
- var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
14
13
  var walletConnect = require('@dynamic-labs/wallet-connect');
14
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
15
15
  var logger = require('../../utils/logger.cjs');
16
16
  var createSolanaSignerForWalletConnect = require('./createSolanaSignerForWalletConnect/createSolanaSignerForWalletConnect.cjs');
17
17
 
@@ -34,6 +34,9 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
34
34
  if (storedChainId) {
35
35
  this.setNetworkId(storedChainId);
36
36
  }
37
+ if (opts.overrideKey) {
38
+ this.overrideKey = opts.overrideKey;
39
+ }
37
40
  if (!opts.projectId) {
38
41
  throw new utils.DynamicError('WalletConnect project ID is required');
39
42
  }
@@ -47,10 +50,10 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
47
50
  * immediately available.
48
51
  */
49
52
  get signClient() {
50
- if (!this.signClientReference) {
53
+ if (!SolanaWalletConnectConnector.signClientReference) {
51
54
  throw new utils.DynamicError('Failed to access sign client for Wallet Connect Solana: Sign client not initialized');
52
55
  }
53
- return this.signClientReference;
56
+ return SolanaWalletConnectConnector.signClientReference;
54
57
  }
55
58
  getSupportedNetworks() {
56
59
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -92,15 +95,21 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
92
95
  if (this.isInitialized) {
93
96
  return;
94
97
  }
98
+ logger.logger.logVerboseTroubleshootingMessage('[SolanaWalletConnect] init called');
95
99
  this.isInitialized = true;
100
+ if (SolanaWalletConnectConnector.signClientPromise) {
101
+ yield SolanaWalletConnectConnector.signClientPromise;
102
+ this.setupWCEventListeners();
103
+ return;
104
+ }
96
105
  const { appLogoUrl, appName, projectId } = this.constructorProps;
97
- logger.logger.logVerboseTroubleshootingMessage('[SolanaWalletConnect] init called');
98
- this.signClientPromise = walletConnect.getSignClientSingleton({
106
+ SolanaWalletConnectConnector.signClientPromise = walletConnect.getSignClientSingleton({
99
107
  appIcon: appLogoUrl !== null && appLogoUrl !== void 0 ? appLogoUrl : '',
100
108
  appName: appName !== null && appName !== void 0 ? appName : '',
101
109
  projectId,
102
110
  });
103
- this.signClientReference = yield this.signClientPromise;
111
+ SolanaWalletConnectConnector.signClientReference =
112
+ yield SolanaWalletConnectConnector.signClientPromise;
104
113
  this.setupWCEventListeners();
105
114
  });
106
115
  }
@@ -178,7 +187,7 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
178
187
  }
179
188
  getAddress(opts) {
180
189
  return _tslib.__awaiter(this, void 0, void 0, function* () {
181
- var _a, _b;
190
+ var _a;
182
191
  logger.logger.debug('[SolanaWalletConnect] getAddress', opts);
183
192
  /**
184
193
  * In mobile/Safari, if the user just navigates back after the deeplink prompt the connection
@@ -198,15 +207,8 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
198
207
  isMobile: utils.isMobile(),
199
208
  mobileExperience: this.mobileExperience,
200
209
  });
201
- if (utils.isMobile() &&
202
- ((_b = this.metadata) === null || _b === void 0 ? void 0 : _b.inAppBrowserUrl) &&
203
- this.mobileExperience === 'in-app-browser') {
204
- const inAppBrowserCompiledTemplate = utils.template(this.metadata.inAppBrowserUrl);
205
- const { href } = utils.PlatformService.getUrl();
206
- const deepLink = inAppBrowserCompiledTemplate({
207
- encodedDappURI: encodeURIComponent(href),
208
- });
209
- utils.PlatformService.openURL(deepLink);
210
+ const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
211
+ if (didOpenInAppBrowser) {
210
212
  return;
211
213
  }
212
214
  logger.logger.debug('[SolanaWalletConnect] getAddress - connecting to WalletConnect');
@@ -249,16 +251,29 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
249
251
  }
250
252
  const chainHash = (_c = (_b = this.getSelectedNetwork()) === null || _b === void 0 ? void 0 : _b.genesisHash) !== null && _c !== void 0 ? _c : this.solNetworks[0].genesisHash;
251
253
  const chainId = `solana:${chainHash}`;
252
- const requestPromise = this.signClient.request({
253
- chainId,
254
- request: {
255
- method,
256
- params,
257
- },
258
- topic: this.session.topic,
259
- });
260
- this.deepLinkIfApplicable({ method });
261
- return requestPromise;
254
+ try {
255
+ const requestPromise = this.signClient.request({
256
+ chainId,
257
+ request: {
258
+ method,
259
+ params,
260
+ },
261
+ topic: this.session.topic,
262
+ });
263
+ this.deepLinkIfApplicable({ method });
264
+ return yield requestPromise;
265
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
266
+ }
267
+ catch (error) {
268
+ // If they are throwing a generic error, lets end session to ensure the user will be prompted to reconnect
269
+ // on the next attempt. This should fix the issue.
270
+ // Yes their error message has a typo on "occured"
271
+ if (error.message === 'An error has occured. Please, try again.') {
272
+ yield this.endSession();
273
+ throw new utils.DynamicError('Wallet connection lost. Please, try again.');
274
+ }
275
+ throw error;
276
+ }
262
277
  });
263
278
  }
264
279
  deepLinkIfApplicable(params) {
@@ -1,6 +1,6 @@
1
+ import { SendOptions, Transaction, VersionedTransaction } from '@solana/web3.js';
1
2
  import SignClient from '@walletconnect/sign-client';
2
3
  import type { SessionTypes } from '@walletconnect/types';
3
- import { SendOptions, Transaction, VersionedTransaction } from '@solana/web3.js';
4
4
  import { ISolanaSigner, SolanaWalletConnector, SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
5
5
  import { DeepLinkVariant, GetAddressOpts, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
6
6
  export type SolanaWalletConnectConnectorOpts = SolanaWalletConnectorOpts & {
@@ -9,11 +9,12 @@ export type SolanaWalletConnectConnectorOpts = SolanaWalletConnectorOpts & {
9
9
  deepLinkPreference?: DeepLinkVariant;
10
10
  appLogoUrl?: string;
11
11
  appName?: string;
12
+ overrideKey?: string;
12
13
  };
13
14
  export declare class SolanaWalletConnectConnector extends SolanaWalletConnector implements IWalletConnectConnector {
14
15
  name: string;
15
- private signClientReference;
16
- private signClientPromise;
16
+ static signClientReference: SignClient | undefined;
17
+ static signClientPromise: Promise<SignClient> | undefined;
17
18
  /**
18
19
  * When a WalletConnect connection is initiated, we store the connection URI
19
20
  * so we can use it to handle the URI for wallet app connection and still have
@@ -1,13 +1,13 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
- import bs58 from 'bs58';
4
- import { SDK_ERRORS } from '@walletconnect/utils';
5
3
  import { PublicKey, VersionedTransaction, Transaction } from '@solana/web3.js';
4
+ import { SDK_ERRORS } from '@walletconnect/utils';
5
+ import bs58 from 'bs58';
6
6
  import EventEmitter from 'eventemitter3';
7
7
  import { SolanaWalletConnector, isVersionedTransaction } from '@dynamic-labs/solana-core';
8
- import { StorageService, DynamicError, filterDuplicates, isMobile, template, PlatformService, bufferToBase64 } from '@dynamic-labs/utils';
9
- import { performPlatformSpecificConnectionMethod, getDeepLink, isSameAddress } from '@dynamic-labs/wallet-connector-core';
8
+ import { StorageService, DynamicError, filterDuplicates, isMobile, PlatformService, bufferToBase64 } from '@dynamic-labs/utils';
10
9
  import { getSignClientSingleton } from '@dynamic-labs/wallet-connect';
10
+ import { performPlatformSpecificConnectionMethod, getDeepLink, isSameAddress } from '@dynamic-labs/wallet-connector-core';
11
11
  import { logger } from '../../utils/logger.js';
12
12
  import { createSolanaSignerForWalletConnect } from './createSolanaSignerForWalletConnect/createSolanaSignerForWalletConnect.js';
13
13
 
@@ -25,6 +25,9 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
25
25
  if (storedChainId) {
26
26
  this.setNetworkId(storedChainId);
27
27
  }
28
+ if (opts.overrideKey) {
29
+ this.overrideKey = opts.overrideKey;
30
+ }
28
31
  if (!opts.projectId) {
29
32
  throw new DynamicError('WalletConnect project ID is required');
30
33
  }
@@ -38,10 +41,10 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
38
41
  * immediately available.
39
42
  */
40
43
  get signClient() {
41
- if (!this.signClientReference) {
44
+ if (!SolanaWalletConnectConnector.signClientReference) {
42
45
  throw new DynamicError('Failed to access sign client for Wallet Connect Solana: Sign client not initialized');
43
46
  }
44
- return this.signClientReference;
47
+ return SolanaWalletConnectConnector.signClientReference;
45
48
  }
46
49
  getSupportedNetworks() {
47
50
  return __awaiter(this, void 0, void 0, function* () {
@@ -83,15 +86,21 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
83
86
  if (this.isInitialized) {
84
87
  return;
85
88
  }
89
+ logger.logVerboseTroubleshootingMessage('[SolanaWalletConnect] init called');
86
90
  this.isInitialized = true;
91
+ if (SolanaWalletConnectConnector.signClientPromise) {
92
+ yield SolanaWalletConnectConnector.signClientPromise;
93
+ this.setupWCEventListeners();
94
+ return;
95
+ }
87
96
  const { appLogoUrl, appName, projectId } = this.constructorProps;
88
- logger.logVerboseTroubleshootingMessage('[SolanaWalletConnect] init called');
89
- this.signClientPromise = getSignClientSingleton({
97
+ SolanaWalletConnectConnector.signClientPromise = getSignClientSingleton({
90
98
  appIcon: appLogoUrl !== null && appLogoUrl !== void 0 ? appLogoUrl : '',
91
99
  appName: appName !== null && appName !== void 0 ? appName : '',
92
100
  projectId,
93
101
  });
94
- this.signClientReference = yield this.signClientPromise;
102
+ SolanaWalletConnectConnector.signClientReference =
103
+ yield SolanaWalletConnectConnector.signClientPromise;
95
104
  this.setupWCEventListeners();
96
105
  });
97
106
  }
@@ -169,7 +178,7 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
169
178
  }
170
179
  getAddress(opts) {
171
180
  return __awaiter(this, void 0, void 0, function* () {
172
- var _a, _b;
181
+ var _a;
173
182
  logger.debug('[SolanaWalletConnect] getAddress', opts);
174
183
  /**
175
184
  * In mobile/Safari, if the user just navigates back after the deeplink prompt the connection
@@ -189,15 +198,8 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
189
198
  isMobile: isMobile(),
190
199
  mobileExperience: this.mobileExperience,
191
200
  });
192
- if (isMobile() &&
193
- ((_b = this.metadata) === null || _b === void 0 ? void 0 : _b.inAppBrowserUrl) &&
194
- this.mobileExperience === 'in-app-browser') {
195
- const inAppBrowserCompiledTemplate = template(this.metadata.inAppBrowserUrl);
196
- const { href } = PlatformService.getUrl();
197
- const deepLink = inAppBrowserCompiledTemplate({
198
- encodedDappURI: encodeURIComponent(href),
199
- });
200
- PlatformService.openURL(deepLink);
201
+ const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
202
+ if (didOpenInAppBrowser) {
201
203
  return;
202
204
  }
203
205
  logger.debug('[SolanaWalletConnect] getAddress - connecting to WalletConnect');
@@ -240,16 +242,29 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
240
242
  }
241
243
  const chainHash = (_c = (_b = this.getSelectedNetwork()) === null || _b === void 0 ? void 0 : _b.genesisHash) !== null && _c !== void 0 ? _c : this.solNetworks[0].genesisHash;
242
244
  const chainId = `solana:${chainHash}`;
243
- const requestPromise = this.signClient.request({
244
- chainId,
245
- request: {
246
- method,
247
- params,
248
- },
249
- topic: this.session.topic,
250
- });
251
- this.deepLinkIfApplicable({ method });
252
- return requestPromise;
245
+ try {
246
+ const requestPromise = this.signClient.request({
247
+ chainId,
248
+ request: {
249
+ method,
250
+ params,
251
+ },
252
+ topic: this.session.topic,
253
+ });
254
+ this.deepLinkIfApplicable({ method });
255
+ return yield requestPromise;
256
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
257
+ }
258
+ catch (error) {
259
+ // If they are throwing a generic error, lets end session to ensure the user will be prompted to reconnect
260
+ // on the next attempt. This should fix the issue.
261
+ // Yes their error message has a typo on "occured"
262
+ if (error.message === 'An error has occured. Please, try again.') {
263
+ yield this.endSession();
264
+ throw new DynamicError('Wallet connection lost. Please, try again.');
265
+ }
266
+ throw error;
267
+ }
253
268
  });
254
269
  }
255
270
  deepLinkIfApplicable(params) {
@@ -0,0 +1,64 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
+ var SolanaWalletConnectConnector = require('../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs');
8
+
9
+ /**
10
+ * Adds Solana WalletConnect connectors to the list of connectors, avoiding duplicates
11
+ * by checking what connectors are already present
12
+ */
13
+ const addSolanaWalletConnectConnectors = ({ walletBook, connectors: currentConnectors, }) => {
14
+ var _a;
15
+ const walletEntries = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {});
16
+ const allWcConstructors = walletEntries
17
+ .filter(([, wallet]) => {
18
+ var _a;
19
+ return wallet.walletConnect &&
20
+ (
21
+ // Exclude wallets that don't support Solana
22
+ (_a = wallet.chains) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.includes('solana:')));
23
+ })
24
+ .map(([key, wallet]) => {
25
+ const { shortName } = wallet;
26
+ const name = shortName || wallet.name;
27
+ const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector.SolanaWalletConnectConnector {
28
+ constructor(props) {
29
+ super(Object.assign(Object.assign({}, props), { metadata: walletConnectorCore.getWalletMetadataFromWalletBook({
30
+ walletBookWallet: wallet,
31
+ walletKey: key,
32
+ }), overrideKey: key, walletName: name }));
33
+ this.overrideKey = key;
34
+ }
35
+ };
36
+ const entryKeysWithSameGroup = walletEntries
37
+ .filter(([, { group }]) => group && group === wallet.group)
38
+ .map(([key]) => key);
39
+ // We store the key and the keys of all other entries in the same group
40
+ // so that we can filter out from the WC connectors we just built both the ones
41
+ // whose key is already present in the current connectors and the ones whose key is in the same group
42
+ // as one of the current connectors.
43
+ // We need to check the groups as well because the wallet book entry that we use to create the Sol WC
44
+ // connector might be coming from the EVM wallet book entry (due to historical reasons, that's the entry
45
+ // that has the WC data)
46
+ Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
47
+ value: key,
48
+ writable: false,
49
+ });
50
+ Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'groupedKeys', {
51
+ value: entryKeysWithSameGroup,
52
+ writable: false,
53
+ });
54
+ return SolanaWalletConnectConnectorConstructor;
55
+ });
56
+ const filteredWcConstructors = allWcConstructors.filter((constructor) => currentConnectors.every((existingConnector) =>
57
+ // @ts-expect-error - the key type is not defined for the constructor
58
+ existingConnector['key'] !== constructor['key'] &&
59
+ // @ts-expect-error - the key type is not defined for the constructor
60
+ !constructor['groupedKeys'].includes(existingConnector['key'])));
61
+ return [...currentConnectors, ...filteredWcConstructors];
62
+ };
63
+
64
+ exports.addSolanaWalletConnectConnectors = addSolanaWalletConnectConnectors;
@@ -0,0 +1,12 @@
1
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
2
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
3
+ type FetchSolanaWalletConnectWalletsProps = {
4
+ walletBook: WalletBookSchema;
5
+ connectors: WalletConnectorConstructor[];
6
+ };
7
+ /**
8
+ * Adds Solana WalletConnect connectors to the list of connectors, avoiding duplicates
9
+ * by checking what connectors are already present
10
+ */
11
+ export declare const addSolanaWalletConnectConnectors: ({ walletBook, connectors: currentConnectors, }: FetchSolanaWalletConnectWalletsProps) => Array<WalletConnectorConstructor>;
12
+ export {};
@@ -0,0 +1,60 @@
1
+ 'use client'
2
+ import { getWalletMetadataFromWalletBook } from '@dynamic-labs/wallet-connector-core';
3
+ import { SolanaWalletConnectConnector } from '../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.js';
4
+
5
+ /**
6
+ * Adds Solana WalletConnect connectors to the list of connectors, avoiding duplicates
7
+ * by checking what connectors are already present
8
+ */
9
+ const addSolanaWalletConnectConnectors = ({ walletBook, connectors: currentConnectors, }) => {
10
+ var _a;
11
+ const walletEntries = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {});
12
+ const allWcConstructors = walletEntries
13
+ .filter(([, wallet]) => {
14
+ var _a;
15
+ return wallet.walletConnect &&
16
+ (
17
+ // Exclude wallets that don't support Solana
18
+ (_a = wallet.chains) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.includes('solana:')));
19
+ })
20
+ .map(([key, wallet]) => {
21
+ const { shortName } = wallet;
22
+ const name = shortName || wallet.name;
23
+ const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector {
24
+ constructor(props) {
25
+ super(Object.assign(Object.assign({}, props), { metadata: getWalletMetadataFromWalletBook({
26
+ walletBookWallet: wallet,
27
+ walletKey: key,
28
+ }), overrideKey: key, walletName: name }));
29
+ this.overrideKey = key;
30
+ }
31
+ };
32
+ const entryKeysWithSameGroup = walletEntries
33
+ .filter(([, { group }]) => group && group === wallet.group)
34
+ .map(([key]) => key);
35
+ // We store the key and the keys of all other entries in the same group
36
+ // so that we can filter out from the WC connectors we just built both the ones
37
+ // whose key is already present in the current connectors and the ones whose key is in the same group
38
+ // as one of the current connectors.
39
+ // We need to check the groups as well because the wallet book entry that we use to create the Sol WC
40
+ // connector might be coming from the EVM wallet book entry (due to historical reasons, that's the entry
41
+ // that has the WC data)
42
+ Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
43
+ value: key,
44
+ writable: false,
45
+ });
46
+ Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'groupedKeys', {
47
+ value: entryKeysWithSameGroup,
48
+ writable: false,
49
+ });
50
+ return SolanaWalletConnectConnectorConstructor;
51
+ });
52
+ const filteredWcConstructors = allWcConstructors.filter((constructor) => currentConnectors.every((existingConnector) =>
53
+ // @ts-expect-error - the key type is not defined for the constructor
54
+ existingConnector['key'] !== constructor['key'] &&
55
+ // @ts-expect-error - the key type is not defined for the constructor
56
+ !constructor['groupedKeys'].includes(existingConnector['key'])));
57
+ return [...currentConnectors, ...filteredWcConstructors];
58
+ };
59
+
60
+ export { addSolanaWalletConnectConnectors };
@@ -0,0 +1 @@
1
+ export * from './addSolanaWalletConnectConnectors';
@@ -5,10 +5,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var SolanaWalletConnectConnector = require('../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs');
7
7
 
8
- const getSolanaWalletConnectConnector = () => class extends SolanaWalletConnectConnector.SolanaWalletConnectConnector {
9
- constructor(props) {
10
- super(Object.assign(Object.assign({}, props), { metadata: { groupKey: 'walletconnect', name: 'WalletConnect' }, walletName: 'WalletConnect Sol' }));
11
- }
8
+ const getSolanaWalletConnectConnector = () => {
9
+ const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector.SolanaWalletConnectConnector {
10
+ constructor(props) {
11
+ super(Object.assign(Object.assign({}, props), { metadata: { groupKey: 'walletconnect', name: 'WalletConnect' }, walletName: 'WalletConnect Sol' }));
12
+ }
13
+ };
14
+ Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
15
+ value: 'walletconnectsol',
16
+ writable: false,
17
+ });
18
+ return SolanaWalletConnectConnectorConstructor;
12
19
  };
13
20
 
14
21
  exports.getSolanaWalletConnectConnector = getSolanaWalletConnectConnector;
@@ -1,10 +1,17 @@
1
1
  'use client'
2
2
  import { SolanaWalletConnectConnector } from '../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.js';
3
3
 
4
- const getSolanaWalletConnectConnector = () => class extends SolanaWalletConnectConnector {
5
- constructor(props) {
6
- super(Object.assign(Object.assign({}, props), { metadata: { groupKey: 'walletconnect', name: 'WalletConnect' }, walletName: 'WalletConnect Sol' }));
7
- }
4
+ const getSolanaWalletConnectConnector = () => {
5
+ const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector {
6
+ constructor(props) {
7
+ super(Object.assign(Object.assign({}, props), { metadata: { groupKey: 'walletconnect', name: 'WalletConnect' }, walletName: 'WalletConnect Sol' }));
8
+ }
9
+ };
10
+ Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
11
+ value: 'walletconnectsol',
12
+ writable: false,
13
+ });
14
+ return SolanaWalletConnectConnectorConstructor;
8
15
  };
9
16
 
10
17
  export { getSolanaWalletConnectConnector };