@dynamic-labs/sui 4.9.7 → 4.9.8

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,11 @@
1
1
 
2
+ ### [4.9.8](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.7...v4.9.8) (2025-03-24)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * unlink wallets when using 7702 account ([#8367](https://github.com/dynamic-labs/dynamic-auth/issues/8367)) ([f5acf05](https://github.com/dynamic-labs/dynamic-auth/commit/f5acf05ef31b8f411f3b0cd0e90e919e71f4ad50))
8
+
2
9
  ### [4.9.7](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.6...v4.9.7) (2025-03-21)
3
10
 
4
11
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.9.7";
6
+ var version = "4.9.8";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.9.7";
2
+ var version = "4.9.8";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sui",
3
- "version": "4.9.7",
3
+ "version": "4.9.8",
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",
@@ -21,12 +21,12 @@
21
21
  "@dynamic-labs/sdk-api-core": "0.0.644",
22
22
  "@mysten/wallet-standard": "0.13.29",
23
23
  "text-encoding": "0.7.0",
24
- "@dynamic-labs/assert-package-version": "4.9.7",
25
- "@dynamic-labs/logger": "4.9.7",
26
- "@dynamic-labs/rpc-providers": "4.9.7",
27
- "@dynamic-labs/utils": "4.9.7",
28
- "@dynamic-labs/wallet-book": "4.9.7",
29
- "@dynamic-labs/wallet-connector-core": "4.9.7"
24
+ "@dynamic-labs/assert-package-version": "4.9.8",
25
+ "@dynamic-labs/logger": "4.9.8",
26
+ "@dynamic-labs/rpc-providers": "4.9.8",
27
+ "@dynamic-labs/utils": "4.9.8",
28
+ "@dynamic-labs/wallet-book": "4.9.8",
29
+ "@dynamic-labs/wallet-connector-core": "4.9.8"
30
30
  },
31
31
  "peerDependencies": {}
32
32
  }
@@ -16,6 +16,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
16
16
  this.ChainWallet = SuiWallet.SuiWallet;
17
17
  this.connectedChain = 'SUI';
18
18
  this.supportedChains = ['SUI'];
19
+ this.switchNetworkOnlyFromWallet = true;
19
20
  /** required for metamask snap integration as MM snaps don't have event listeners */
20
21
  this.canSetEventListeners = true;
21
22
  this.name = name;
@@ -73,6 +74,12 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
73
74
  return this.account.chains[0];
74
75
  });
75
76
  }
77
+ getConnectedAccounts() {
78
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
79
+ var _a;
80
+ return ((_a = this.account) === null || _a === void 0 ? void 0 : _a.address) ? [this.account.address] : [];
81
+ });
82
+ }
76
83
  getBalance(address) {
77
84
  return _tslib.__awaiter(this, void 0, void 0, function* () {
78
85
  // Make RPC call to get balance
@@ -8,6 +8,7 @@ export declare abstract class SuiWalletConnector extends WalletConnectorBase<typ
8
8
  ChainWallet: typeof SuiWallet;
9
9
  connectedChain: Chain;
10
10
  supportedChains: Chain[];
11
+ switchNetworkOnlyFromWallet: boolean;
11
12
  /** required for metamask snap integration as MM snaps don't have event listeners */
12
13
  canSetEventListeners: boolean;
13
14
  /** Sui wallet instance */
@@ -18,12 +19,13 @@ export declare abstract class SuiWalletConnector extends WalletConnectorBase<typ
18
19
  logger: Logger;
19
20
  constructor(name: string, opts: SuiWalletConnectorProps);
20
21
  /** Helper to return the wallet features */
21
- protected getFeatures(): SuiWalletFeatures | undefined;
22
+ getFeatures(): SuiWalletFeatures | undefined;
22
23
  /** Connect to the wallet using the standard:connect feature */
23
24
  connect(): Promise<void>;
24
25
  /** Get the wallet address by connecting to the current account */
25
26
  getAddress(): Promise<string | undefined>;
26
27
  getNetwork(): Promise<`${string}:${string}` | undefined>;
28
+ getConnectedAccounts(): Promise<string[]>;
27
29
  getBalance(address: string): Promise<string | undefined>;
28
30
  signMessage(messageToSign: string): Promise<string | undefined>;
29
31
  getWalletAccount(): Promise<WalletAccount | undefined>;
@@ -12,6 +12,7 @@ class SuiWalletConnector extends WalletConnectorBase {
12
12
  this.ChainWallet = SuiWallet;
13
13
  this.connectedChain = 'SUI';
14
14
  this.supportedChains = ['SUI'];
15
+ this.switchNetworkOnlyFromWallet = true;
15
16
  /** required for metamask snap integration as MM snaps don't have event listeners */
16
17
  this.canSetEventListeners = true;
17
18
  this.name = name;
@@ -69,6 +70,12 @@ class SuiWalletConnector extends WalletConnectorBase {
69
70
  return this.account.chains[0];
70
71
  });
71
72
  }
73
+ getConnectedAccounts() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ var _a;
76
+ return ((_a = this.account) === null || _a === void 0 ? void 0 : _a.address) ? [this.account.address] : [];
77
+ });
78
+ }
72
79
  getBalance(address) {
73
80
  return __awaiter(this, void 0, void 0, function* () {
74
81
  // Make RPC call to get balance
package/src/index.cjs CHANGED
@@ -10,8 +10,9 @@ var SuiWalletConnector = require('./SuiWalletConnector.cjs');
10
10
 
11
11
  /* eslint-disable @typescript-eslint/no-unused-vars */
12
12
  assertPackageVersion.assertPackageVersion('@dynamic-labs/sui', _package.version);
13
- const SuiWalletConnectors = () => [
14
- ...fetchSuiInjectedWalletConnectors.fetchSuiInjectedWalletConnectors(),
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ const SuiWalletConnectors = (props) => [
15
+ ...fetchSuiInjectedWalletConnectors.fetchSuiInjectedWalletConnectors(props),
15
16
  ];
16
17
 
17
18
  exports.SuiWalletConnector = SuiWalletConnector.SuiWalletConnector;
package/src/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SuiWalletConnectors: () => import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor[];
1
+ export declare const SuiWalletConnectors: (props: any) => import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor[];
2
2
  export { SuiWalletConnector } from './SuiWalletConnector';
package/src/index.js CHANGED
@@ -6,8 +6,9 @@ export { SuiWalletConnector } from './SuiWalletConnector.js';
6
6
 
7
7
  /* eslint-disable @typescript-eslint/no-unused-vars */
8
8
  assertPackageVersion('@dynamic-labs/sui', version);
9
- const SuiWalletConnectors = () => [
10
- ...fetchSuiInjectedWalletConnectors(),
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ const SuiWalletConnectors = (props) => [
11
+ ...fetchSuiInjectedWalletConnectors(props),
11
12
  ];
12
13
 
13
14
  export { SuiWalletConnectors };
package/src/types.d.ts CHANGED
@@ -9,4 +9,5 @@ export type SuiWalletConnectorProps = {
9
9
  walletBook: WalletBookSchema;
10
10
  metadata?: WalletMetadata;
11
11
  wallet: WalletWithFeatures<SuiWalletFeatures>;
12
+ overrideKey?: string;
12
13
  };
@@ -4,25 +4,63 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var walletStandard = require('@mysten/wallet-standard');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
+ var utils = require('@dynamic-labs/utils');
7
9
  var injected = require('./injected.cjs');
8
10
 
9
- const fetchSuiInjectedWalletConnectors = () => {
11
+ const fetchSuiInjectedWalletConnectors = ({ walletBook, }) => {
12
+ var _a;
10
13
  const walletStandardWallets = walletStandard.getWallets().get();
11
14
  // Wallet standard wallets don't always have injectedConfig from wallet book,
12
15
  // so we filter them by checking if they support critical sui features.
16
+ const suiWalletStandardWallets = walletStandardWallets.filter((wallet) => { var _a; return (_a = wallet.features) === null || _a === void 0 ? void 0 : _a['sui:signPersonalMessage']; });
17
+ const suiWalletsByKey = Object.fromEntries(suiWalletStandardWallets.map((wallet) => [wallet.name, wallet]));
18
+ const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
19
+ .filter(([, wallet]) => {
20
+ var _a, _b;
21
+ const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sui');
22
+ const isSuiWallet = Boolean(injectedConfig);
23
+ const walletStandardName = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.name;
24
+ // If the wallet is injected via wallet standard, use that over the wallet book entry
25
+ const shouldBeFiltered = walletStandardName && suiWalletsByKey[walletStandardName];
26
+ return isSuiWallet && !shouldBeFiltered;
27
+ })
28
+ .map(([key, wallet]) => {
29
+ // Wallet book wallets are not currently installed on the browser
30
+ const isInstalled = false;
31
+ const metadata = walletConnectorCore.getWalletMetadataFromWalletBook({
32
+ walletBook,
33
+ walletBookWallet: wallet,
34
+ walletKey: key,
35
+ });
36
+ return class extends injected.Injected {
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ constructor(props) {
39
+ super(wallet.name, isInstalled, Object.assign({ metadata, overrideKey: key, wallet: wallet, walletBookEntry: wallet }, props));
40
+ }
41
+ };
42
+ });
43
+ // The remaining wallets are wallet standard wallets injected from the browser
44
+ const isInstalled = true;
45
+ // Wallet standard wallets don't always have injectedConfig from wallet book,
46
+ // so we filter them by checking if they support critical sui features.
13
47
  const walletStandardConnectors = walletStandardWallets
14
48
  .filter((wallet) => { var _a; return (_a = wallet.features) === null || _a === void 0 ? void 0 : _a['sui:signPersonalMessage']; })
15
- .map((wallet) => class extends injected.Injected {
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- constructor(props) {
18
- super(wallet.name, Object.assign({ metadata: {
19
- icon: wallet.icon,
20
- id: wallet.name,
21
- name: wallet.name,
22
- }, name: wallet.name, wallet: wallet }, props));
23
- }
49
+ .map((wallet) => {
50
+ const sanitizedName = utils.sanitizeName(wallet.name);
51
+ return class extends injected.Injected {
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ constructor(props) {
54
+ super(wallet.name, isInstalled, Object.assign({ metadata: {
55
+ groupKey: sanitizedName,
56
+ icon: wallet.icon,
57
+ id: wallet.name,
58
+ name: wallet.name,
59
+ }, name: wallet.name, overrideKey: `${sanitizedName}sui`, wallet: wallet }, props));
60
+ }
61
+ };
24
62
  });
25
- return [...walletStandardConnectors];
63
+ return [...walletBookConnectors, ...walletStandardConnectors];
26
64
  };
27
65
 
28
66
  exports.fetchSuiInjectedWalletConnectors = fetchSuiInjectedWalletConnectors;
@@ -1,2 +1,5 @@
1
1
  import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
2
- export declare const fetchSuiInjectedWalletConnectors: () => WalletConnectorConstructor[];
2
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
3
+ export declare const fetchSuiInjectedWalletConnectors: ({ walletBook, }: {
4
+ walletBook?: WalletBookSchema;
5
+ }) => WalletConnectorConstructor[];
@@ -1,24 +1,62 @@
1
1
  'use client'
2
2
  import { getWallets } from '@mysten/wallet-standard';
3
+ import { getWalletMetadataFromWalletBook } from '@dynamic-labs/wallet-connector-core';
4
+ import { sanitizeName } from '@dynamic-labs/utils';
3
5
  import { Injected } from './injected.js';
4
6
 
5
- const fetchSuiInjectedWalletConnectors = () => {
7
+ const fetchSuiInjectedWalletConnectors = ({ walletBook, }) => {
8
+ var _a;
6
9
  const walletStandardWallets = getWallets().get();
7
10
  // Wallet standard wallets don't always have injectedConfig from wallet book,
8
11
  // so we filter them by checking if they support critical sui features.
12
+ const suiWalletStandardWallets = walletStandardWallets.filter((wallet) => { var _a; return (_a = wallet.features) === null || _a === void 0 ? void 0 : _a['sui:signPersonalMessage']; });
13
+ const suiWalletsByKey = Object.fromEntries(suiWalletStandardWallets.map((wallet) => [wallet.name, wallet]));
14
+ const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
15
+ .filter(([, wallet]) => {
16
+ var _a, _b;
17
+ const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sui');
18
+ const isSuiWallet = Boolean(injectedConfig);
19
+ const walletStandardName = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.name;
20
+ // If the wallet is injected via wallet standard, use that over the wallet book entry
21
+ const shouldBeFiltered = walletStandardName && suiWalletsByKey[walletStandardName];
22
+ return isSuiWallet && !shouldBeFiltered;
23
+ })
24
+ .map(([key, wallet]) => {
25
+ // Wallet book wallets are not currently installed on the browser
26
+ const isInstalled = false;
27
+ const metadata = getWalletMetadataFromWalletBook({
28
+ walletBook,
29
+ walletBookWallet: wallet,
30
+ walletKey: key,
31
+ });
32
+ return class extends Injected {
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ constructor(props) {
35
+ super(wallet.name, isInstalled, Object.assign({ metadata, overrideKey: key, wallet: wallet, walletBookEntry: wallet }, props));
36
+ }
37
+ };
38
+ });
39
+ // The remaining wallets are wallet standard wallets injected from the browser
40
+ const isInstalled = true;
41
+ // Wallet standard wallets don't always have injectedConfig from wallet book,
42
+ // so we filter them by checking if they support critical sui features.
9
43
  const walletStandardConnectors = walletStandardWallets
10
44
  .filter((wallet) => { var _a; return (_a = wallet.features) === null || _a === void 0 ? void 0 : _a['sui:signPersonalMessage']; })
11
- .map((wallet) => class extends Injected {
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- constructor(props) {
14
- super(wallet.name, Object.assign({ metadata: {
15
- icon: wallet.icon,
16
- id: wallet.name,
17
- name: wallet.name,
18
- }, name: wallet.name, wallet: wallet }, props));
19
- }
45
+ .map((wallet) => {
46
+ const sanitizedName = sanitizeName(wallet.name);
47
+ return class extends Injected {
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ constructor(props) {
50
+ super(wallet.name, isInstalled, Object.assign({ metadata: {
51
+ groupKey: sanitizedName,
52
+ icon: wallet.icon,
53
+ id: wallet.name,
54
+ name: wallet.name,
55
+ }, name: wallet.name, overrideKey: `${sanitizedName}sui`, wallet: wallet }, props));
56
+ }
57
+ };
20
58
  });
21
- return [...walletStandardConnectors];
59
+ return [...walletBookConnectors, ...walletStandardConnectors];
22
60
  };
23
61
 
24
62
  export { fetchSuiInjectedWalletConnectors };
@@ -6,12 +6,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var SuiWalletConnector = require('../../SuiWalletConnector.cjs');
7
7
 
8
8
  class Injected extends SuiWalletConnector.SuiWalletConnector {
9
- constructor(name, props) {
9
+ constructor(name, isInstalledOnBrowser, props) {
10
10
  super(name, props);
11
+ this._isInstalledOnBrowser = isInstalledOnBrowser;
12
+ this.overrideKey = props.overrideKey;
11
13
  }
12
- // Injected wallets are always already installed on browser
13
14
  isInstalledOnBrowser() {
14
- return true;
15
+ return this._isInstalledOnBrowser;
15
16
  }
16
17
  }
17
18
 
@@ -1,6 +1,13 @@
1
1
  import { SuiWalletConnector } from '../../SuiWalletConnector';
2
2
  import { SuiWalletConnectorProps } from '../../types';
3
3
  export declare class Injected extends SuiWalletConnector {
4
- constructor(name: string, props: SuiWalletConnectorProps);
4
+ /**
5
+ * Tracks whether the injected wallet is installed on the browser
6
+ *
7
+ * If the wallet is in wallet book but not found with getWallets().get(),
8
+ * it's not installed on the browser.
9
+ */
10
+ private _isInstalledOnBrowser;
11
+ constructor(name: string, isInstalledOnBrowser: boolean, props: SuiWalletConnectorProps);
5
12
  isInstalledOnBrowser(): boolean;
6
13
  }
@@ -2,12 +2,13 @@
2
2
  import { SuiWalletConnector } from '../../SuiWalletConnector.js';
3
3
 
4
4
  class Injected extends SuiWalletConnector {
5
- constructor(name, props) {
5
+ constructor(name, isInstalledOnBrowser, props) {
6
6
  super(name, props);
7
+ this._isInstalledOnBrowser = isInstalledOnBrowser;
8
+ this.overrideKey = props.overrideKey;
7
9
  }
8
- // Injected wallets are always already installed on browser
9
10
  isInstalledOnBrowser() {
10
- return true;
11
+ return this._isInstalledOnBrowser;
11
12
  }
12
13
  }
13
14