@dynamic-labs/solana 2.1.1 → 2.1.2-alpha.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,24 @@
1
1
 
2
+ ### [2.1.2-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2-alpha.0...v2.1.2-alpha.1) (2024-06-07)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * find phantom solana provider when opening dapp on new tab ([#5902](https://github.com/dynamic-labs/DynamicAuth/issues/5902)) ([99daf87](https://github.com/dynamic-labs/DynamicAuth/commit/99daf87f17caed870a76e4f89a257a14da37c7ab)), closes [#5895](https://github.com/dynamic-labs/DynamicAuth/issues/5895) [#5896](https://github.com/dynamic-labs/DynamicAuth/issues/5896) [#5897](https://github.com/dynamic-labs/DynamicAuth/issues/5897)
8
+
9
+ ### [2.1.2-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.1...v2.1.2-alpha.0) (2024-06-07)
10
+
11
+
12
+ ### Features
13
+
14
+ * display enabled countries in phone number field ([#5825](https://github.com/dynamic-labs/DynamicAuth/issues/5825)) ([#5868](https://github.com/dynamic-labs/DynamicAuth/issues/5868)) ([640a4a7](https://github.com/dynamic-labs/DynamicAuth/commit/640a4a77c994390ceed759faf186717b38f393a4))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * btc getBalance should use ordinal address if payment not available ([#5883](https://github.com/dynamic-labs/DynamicAuth/issues/5883)) ([bc5ac55](https://github.com/dynamic-labs/DynamicAuth/commit/bc5ac5589e90193d41282d23ce037db360dd23e6))
20
+ * phone number in kyc step ([#5875](https://github.com/dynamic-labs/DynamicAuth/issues/5875)) ([#5879](https://github.com/dynamic-labs/DynamicAuth/issues/5879)) ([3d8a5be](https://github.com/dynamic-labs/DynamicAuth/commit/3d8a5bef35d4a13a1068aaf80d2c39e795b097cd))
21
+
2
22
  ### [2.1.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0...v2.1.1) (2024-06-04)
3
23
 
4
24
  ## [2.1.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.32...v2.1.0) (2024-06-04)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana",
3
- "version": "2.1.1",
3
+ "version": "2.1.2-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -27,20 +27,20 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@solana/web3.js": "1.92.1",
30
- "@dynamic-labs/sdk-api-core": "0.0.453",
30
+ "@dynamic-labs/sdk-api-core": "0.0.460",
31
31
  "@wallet-standard/app": "1.0.1",
32
32
  "@wallet-standard/base": "1.0.1",
33
33
  "@wallet-standard/features": "1.0.3",
34
34
  "@wallet-standard/experimental-features": "0.1.1",
35
35
  "bs58": "5.0.0",
36
36
  "tweetnacl": "1.0.3",
37
- "@dynamic-labs/rpc-provider-solana": "2.1.1",
38
- "@dynamic-labs/rpc-providers": "2.1.1",
39
- "@dynamic-labs/turnkey": "2.1.1",
40
- "@dynamic-labs/types": "2.1.1",
41
- "@dynamic-labs/utils": "2.1.1",
42
- "@dynamic-labs/wallet-book": "2.1.1",
43
- "@dynamic-labs/wallet-connector-core": "2.1.1",
37
+ "@dynamic-labs/rpc-provider-solana": "2.1.2-alpha.1",
38
+ "@dynamic-labs/rpc-providers": "2.1.2-alpha.1",
39
+ "@dynamic-labs/turnkey": "2.1.2-alpha.1",
40
+ "@dynamic-labs/types": "2.1.2-alpha.1",
41
+ "@dynamic-labs/utils": "2.1.2-alpha.1",
42
+ "@dynamic-labs/wallet-book": "2.1.2-alpha.1",
43
+ "@dynamic-labs/wallet-connector-core": "2.1.2-alpha.1",
44
44
  "eventemitter3": "5.0.1"
45
45
  },
46
46
  "peerDependencies": {}
@@ -7,6 +7,7 @@ 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
9
  var isSignedMessage = require('./utils/isSignedMessage.cjs');
10
+ var findWalletProviderFromWalletStandard = require('./utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.cjs');
10
11
 
11
12
  class SolProviderHelper {
12
13
  constructor(wallet) {
@@ -26,6 +27,7 @@ class SolProviderHelper {
26
27
  return this.installedProviderLookup(config.extensionLocators);
27
28
  }
28
29
  installedProviders() {
30
+ var _a, _b;
29
31
  const config = this.getInjectedConfig();
30
32
  if (!config)
31
33
  return [];
@@ -48,6 +50,12 @@ class SolProviderHelper {
48
50
  window.solana.providers.forEach((provider) => providers.push(provider));
49
51
  }
50
52
  }
53
+ if (((_b = (_a = config.walletStandardLocators) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) {
54
+ const walletStandardProvider = findWalletProviderFromWalletStandard.findWalletProviderFromWalletStandard(config);
55
+ if (walletStandardProvider) {
56
+ providers.push(walletStandardProvider);
57
+ }
58
+ }
51
59
  return providers;
52
60
  }
53
61
  installedProviderLookup(extensionLocators) {
@@ -15,6 +15,10 @@ export declare class SolProviderHelper {
15
15
  features: string[];
16
16
  name: string;
17
17
  } | undefined;
18
+ walletStandardLocators?: {
19
+ name: string;
20
+ locator: string;
21
+ }[] | undefined;
18
22
  windowLocations?: string[] | undefined;
19
23
  } | undefined;
20
24
  getInstalledProvider(): ISolana | undefined;
@@ -3,6 +3,7 @@ import { __awaiter } from '../_virtual/_tslib.js';
3
3
  import { getProvidersFromWindow, bufferToBase64 } from '@dynamic-labs/utils';
4
4
  import { ProviderLookup } from '@dynamic-labs/wallet-connector-core';
5
5
  import { isSignedMessage } from './utils/isSignedMessage.js';
6
+ import { findWalletProviderFromWalletStandard } from './utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js';
6
7
 
7
8
  class SolProviderHelper {
8
9
  constructor(wallet) {
@@ -22,6 +23,7 @@ class SolProviderHelper {
22
23
  return this.installedProviderLookup(config.extensionLocators);
23
24
  }
24
25
  installedProviders() {
26
+ var _a, _b;
25
27
  const config = this.getInjectedConfig();
26
28
  if (!config)
27
29
  return [];
@@ -44,6 +46,12 @@ class SolProviderHelper {
44
46
  window.solana.providers.forEach((provider) => providers.push(provider));
45
47
  }
46
48
  }
49
+ if (((_b = (_a = config.walletStandardLocators) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) {
50
+ const walletStandardProvider = findWalletProviderFromWalletStandard(config);
51
+ if (walletStandardProvider) {
52
+ providers.push(walletStandardProvider);
53
+ }
54
+ }
47
55
  return providers;
48
56
  }
49
57
  installedProviderLookup(extensionLocators) {
@@ -16,6 +16,7 @@ class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
16
16
  var _a;
17
17
  super(opts);
18
18
  this.isHardwareWalletEnabled = false;
19
+ this._network = undefined;
19
20
  this.verifiedCredentials = [];
20
21
  this.supportedChains = ['SOL'];
21
22
  this.connectedChain = 'SOL';
@@ -25,19 +26,25 @@ class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
25
26
  }
26
27
  getNetwork() {
27
28
  return _tslib.__awaiter(this, void 0, void 0, function* () {
29
+ if (this._network) {
30
+ return this._network;
31
+ }
28
32
  const provider = this.getWalletClient();
29
33
  let genesisHash = yield provider.getGenesisHash();
30
34
  genesisHash = genesisHash.substring(0, 32);
31
35
  // see: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
36
+ let network;
32
37
  if (genesisHash === '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp') {
33
- return 'mainnet';
38
+ network = 'mainnet';
34
39
  }
35
40
  else if (genesisHash === 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1') {
36
- return 'devnet';
41
+ network = 'devnet';
37
42
  }
38
43
  else {
39
- return 'testnet';
44
+ network = 'testnet';
40
45
  }
46
+ this._network = network;
47
+ return network;
41
48
  });
42
49
  }
43
50
  getWalletClient() {
@@ -10,8 +10,10 @@ export type SolWalletConnectorOpts = {
10
10
  solNetworks: GenericNetwork[];
11
11
  walletBook: WalletBookSchema;
12
12
  };
13
+ type SolanaNetwork = 'mainnet' | 'devnet' | 'testnet';
13
14
  export declare abstract class SolWalletConnector extends WalletConnectorBase implements IHardwareWalletConnector {
14
15
  isHardwareWalletEnabled: boolean;
16
+ _network: SolanaNetwork | undefined;
15
17
  verifiedCredentials: JwtVerifiedCredential[];
16
18
  solNetworks: GenericNetwork[];
17
19
  supportedChains: Chain[];
@@ -32,3 +34,4 @@ export declare abstract class SolWalletConnector extends WalletConnectorBase imp
32
34
  setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
33
35
  isLedgerAddress(address: string): boolean;
34
36
  }
37
+ export {};
@@ -12,6 +12,7 @@ class SolWalletConnector extends WalletConnectorBase {
12
12
  var _a;
13
13
  super(opts);
14
14
  this.isHardwareWalletEnabled = false;
15
+ this._network = undefined;
15
16
  this.verifiedCredentials = [];
16
17
  this.supportedChains = ['SOL'];
17
18
  this.connectedChain = 'SOL';
@@ -21,19 +22,25 @@ class SolWalletConnector extends WalletConnectorBase {
21
22
  }
22
23
  getNetwork() {
23
24
  return __awaiter(this, void 0, void 0, function* () {
25
+ if (this._network) {
26
+ return this._network;
27
+ }
24
28
  const provider = this.getWalletClient();
25
29
  let genesisHash = yield provider.getGenesisHash();
26
30
  genesisHash = genesisHash.substring(0, 32);
27
31
  // see: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
32
+ let network;
28
33
  if (genesisHash === '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp') {
29
- return 'mainnet';
34
+ network = 'mainnet';
30
35
  }
31
36
  else if (genesisHash === 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1') {
32
- return 'devnet';
37
+ network = 'devnet';
33
38
  }
34
39
  else {
35
- return 'testnet';
40
+ network = 'testnet';
36
41
  }
42
+ this._network = network;
43
+ return network;
37
44
  });
38
45
  }
39
46
  getWalletClient() {
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var app = require('@wallet-standard/app');
7
+ var utils = require('@dynamic-labs/utils');
8
+
9
+ const findWalletProviderFromWalletStandard = (injectConfig) => {
10
+ const { walletStandardLocators } = injectConfig;
11
+ if (!walletStandardLocators || walletStandardLocators.length === 0) {
12
+ return undefined;
13
+ }
14
+ const wallets = app.getWallets().get();
15
+ return walletStandardLocators.reduce((provider, walletStandardLocator) => {
16
+ /**
17
+ * Return early if the provider is already found
18
+ */
19
+ if (provider) {
20
+ return provider;
21
+ }
22
+ const wallet = wallets.find((w) => w.name === walletStandardLocator.name);
23
+ if (!wallet)
24
+ return undefined;
25
+ return utils.get(wallet, walletStandardLocator.locator);
26
+ }, undefined);
27
+ };
28
+
29
+ exports.findWalletProviderFromWalletStandard = findWalletProviderFromWalletStandard;
@@ -0,0 +1,3 @@
1
+ import { WalletSchema } from '@dynamic-labs/wallet-book';
2
+ import { ISolana } from '../../types';
3
+ export declare const findWalletProviderFromWalletStandard: (injectConfig: NonNullable<WalletSchema['injectedConfig']>[number]) => ISolana | undefined;
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+ import { getWallets } from '@wallet-standard/app';
3
+ import { get } from '@dynamic-labs/utils';
4
+
5
+ const findWalletProviderFromWalletStandard = (injectConfig) => {
6
+ const { walletStandardLocators } = injectConfig;
7
+ if (!walletStandardLocators || walletStandardLocators.length === 0) {
8
+ return undefined;
9
+ }
10
+ const wallets = getWallets().get();
11
+ return walletStandardLocators.reduce((provider, walletStandardLocator) => {
12
+ /**
13
+ * Return early if the provider is already found
14
+ */
15
+ if (provider) {
16
+ return provider;
17
+ }
18
+ const wallet = wallets.find((w) => w.name === walletStandardLocator.name);
19
+ if (!wallet)
20
+ return undefined;
21
+ return get(wallet, walletStandardLocator.locator);
22
+ }, undefined);
23
+ };
24
+
25
+ export { findWalletProviderFromWalletStandard };
@@ -0,0 +1 @@
1
+ export { findWalletProviderFromWalletStandard } from './findWalletProviderFromWalletStandard';