@dynamic-labs/sui-core 4.47.3 → 4.48.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,26 @@
1
1
 
2
+ ### [4.48.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.48.0...v4.48.1) (2025-12-02)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * support for linking multiple slush wallets ([#9957](https://github.com/dynamic-labs/dynamic-auth/issues/9957)) ([b1433a4](https://github.com/dynamic-labs/dynamic-auth/commit/b1433a49d1b31abe4806bcc66fc5b03750c953d4))
8
+
9
+ ## [4.48.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.47.3...v4.48.0) (2025-12-01)
10
+
11
+
12
+ ### Features
13
+
14
+ * export share view ([#9973](https://github.com/dynamic-labs/dynamic-auth/issues/9973)) ([41831bf](https://github.com/dynamic-labs/dynamic-auth/commit/41831bf31f5661fae3a6664643f7b2e7875df137))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * add logout button to MFA verification view ([#9972](https://github.com/dynamic-labs/dynamic-auth/issues/9972)) ([240a286](https://github.com/dynamic-labs/dynamic-auth/commit/240a2864ca92ff2262720797001327b5721bd894))
20
+ * allow user to login with MFA after logout ([#9975](https://github.com/dynamic-labs/dynamic-auth/issues/9975)) ([b404874](https://github.com/dynamic-labs/dynamic-auth/commit/b404874d65ffca166f8f2e8289a6624c685fa257))
21
+ * issue connecting with custom cosmos chain using Keplr wallet ([#9995](https://github.com/dynamic-labs/dynamic-auth/issues/9995)) ([8e045ea](https://github.com/dynamic-labs/dynamic-auth/commit/8e045ea084299f5264ae7a7515fd8d68d4f9caf2))
22
+ * support waas wallet for cookie-auth with optional custom KeyshareRelayBaseUrl ([#9994](https://github.com/dynamic-labs/dynamic-auth/issues/9994)) ([d768378](https://github.com/dynamic-labs/dynamic-auth/commit/d768378693a1cd11e89b0f59f8219ac9fd8690f9))
23
+
2
24
  ### [4.47.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.47.2...v4.47.3) (2025-11-27)
3
25
 
4
26
  ### [4.47.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.47.1...v4.47.2) (2025-11-27)
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.47.3";
6
+ var version = "4.48.1";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.47.3";
2
+ var version = "4.48.1";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sui-core",
3
- "version": "4.47.3",
3
+ "version": "4.48.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,17 +18,17 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/sdk-api-core": "0.0.823",
21
+ "@dynamic-labs/sdk-api-core": "0.0.824",
22
22
  "@mysten/wallet-standard": "0.13.29",
23
23
  "@mysten/sui": "1.24.0",
24
24
  "text-encoding": "0.7.0",
25
- "@dynamic-labs/assert-package-version": "4.47.3",
26
- "@dynamic-labs/logger": "4.47.3",
27
- "@dynamic-labs/rpc-providers": "4.47.3",
28
- "@dynamic-labs/types": "4.47.3",
29
- "@dynamic-labs/utils": "4.47.3",
30
- "@dynamic-labs/wallet-book": "4.47.3",
31
- "@dynamic-labs/wallet-connector-core": "4.47.3"
25
+ "@dynamic-labs/assert-package-version": "4.48.1",
26
+ "@dynamic-labs/logger": "4.48.1",
27
+ "@dynamic-labs/rpc-providers": "4.48.1",
28
+ "@dynamic-labs/types": "4.48.1",
29
+ "@dynamic-labs/utils": "4.48.1",
30
+ "@dynamic-labs/wallet-book": "4.48.1",
31
+ "@dynamic-labs/wallet-connector-core": "4.48.1"
32
32
  },
33
33
  "peerDependencies": {}
34
34
  }
@@ -13,6 +13,13 @@ var SuiUiTransaction = require('./utils/SuiUiTransaction/SuiUiTransaction.cjs');
13
13
  var SuiWallet = require('./wallet/SuiWallet.cjs');
14
14
 
15
15
  class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
16
+ /** Returns the active wallet account, may be overridden */
17
+ getPrimaryAccount() {
18
+ return this.account;
19
+ }
20
+ setPrimaryAccount(account) {
21
+ this.account = account;
22
+ }
16
23
  constructor(name, opts) {
17
24
  super(opts);
18
25
  this.name = 'Sui';
@@ -41,7 +48,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
41
48
  connect() {
42
49
  return _tslib.__awaiter(this, arguments, void 0, function* ({ silent } = {}) {
43
50
  var _a, _b;
44
- if (this.account || this.isConnecting) {
51
+ if (this.getPrimaryAccount() || this.isConnecting) {
45
52
  // Account is already connected or we're already connecting
46
53
  return;
47
54
  }
@@ -54,12 +61,12 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
54
61
  }
55
62
  // Start connecting
56
63
  this.isConnecting = true;
57
- this.logger.debug('[connect] Creating new connection');
64
+ this.logger.debug(`[${this.name}] [connect] Creating new connection`);
58
65
  try {
59
66
  const response = yield connectFeature.connect(silent ? { silent } : undefined);
60
- this.logger.debug(`[connect] Connection returned accounts: ${response === null || response === void 0 ? void 0 : response.accounts.length}`);
61
- this.account = response === null || response === void 0 ? void 0 : response.accounts[0];
62
- const primaryChain = (_b = this.account) === null || _b === void 0 ? void 0 : _b.chains[0];
67
+ this.logger.debug(`[${this.name}] [connect] Connection returned accounts: ${response === null || response === void 0 ? void 0 : response.accounts.length}`);
68
+ this.setPrimaryAccount(response === null || response === void 0 ? void 0 : response.accounts[0]);
69
+ const primaryChain = (_b = this.getPrimaryAccount()) === null || _b === void 0 ? void 0 : _b.chains[0];
63
70
  if (primaryChain) {
64
71
  this.activeNetworkId = networkHelpers.getSuiNetworkIdFromName(primaryChain, this.suiNetworks);
65
72
  }
@@ -100,21 +107,22 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
100
107
  /** Get the wallet address by connecting to the current account */
101
108
  getAddress() {
102
109
  return _tslib.__awaiter(this, void 0, void 0, function* () {
103
- this.logger.debug('[getAddress] called, attempting to obtain the account address');
110
+ var _a;
111
+ this.logger.debug(`[${this.name}] [getAddress] called, attempting to obtain the account address`);
104
112
  if (this.handleInAppBrowserGetAddress()) {
105
113
  return;
106
114
  }
107
115
  yield this.connect();
108
- if (!this.account) {
109
- throw new utils.DynamicError('No account found');
116
+ if (!this.getPrimaryAccount()) {
117
+ throw new utils.DynamicError(`[${this.name}] [getAddress] No account found`);
110
118
  }
111
- return this.account.address;
119
+ return (_a = this.getPrimaryAccount()) === null || _a === void 0 ? void 0 : _a.address;
112
120
  });
113
121
  }
114
122
  /** Returns the network id of the account's active chain */
115
123
  getNetwork() {
116
124
  return _tslib.__awaiter(this, void 0, void 0, function* () {
117
- if (!this.account) {
125
+ if (!this.getPrimaryAccount()) {
118
126
  yield this.connect();
119
127
  }
120
128
  return this.activeNetworkId;
@@ -123,10 +131,10 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
123
131
  getConnectedAccounts() {
124
132
  return _tslib.__awaiter(this, void 0, void 0, function* () {
125
133
  var _a;
126
- if (!this.account) {
134
+ if (!this.getPrimaryAccount()) {
127
135
  yield this.connect({ silent: true });
128
136
  }
129
- const address = (_a = this.account) === null || _a === void 0 ? void 0 : _a.address;
137
+ const address = (_a = this.getPrimaryAccount()) === null || _a === void 0 ? void 0 : _a.address;
130
138
  if (address) {
131
139
  return [address];
132
140
  }
@@ -153,29 +161,33 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
153
161
  }
154
162
  return (_e = networkHelpers.getSuiNetworkIdFromName(suiChain, this.suiNetworks)) !== null && _e !== void 0 ? _e : '-1';
155
163
  }
164
+ handleAccountChange(event) {
165
+ var _a;
166
+ // If the event sets accounts but it's empty, we need to disconnect.
167
+ if (event.accounts.length === 0 && this.getPrimaryAccount()) {
168
+ this.setPrimaryAccount(undefined);
169
+ this.emit('disconnect');
170
+ return;
171
+ }
172
+ const [primaryAccount] = event.accounts;
173
+ if (primaryAccount.address !== ((_a = this.getPrimaryAccount()) === null || _a === void 0 ? void 0 : _a.address)) {
174
+ this.setPrimaryAccount(primaryAccount);
175
+ this.emit('accountChange', { accounts: [primaryAccount.address] });
176
+ }
177
+ }
156
178
  setupEventListeners() {
157
179
  var _a;
158
180
  if (!this.canSetEventListeners || this.eventsHandler)
159
181
  return;
160
182
  const eventsFeature = (_a = this.getFeatures()) === null || _a === void 0 ? void 0 : _a['standard:events'];
161
183
  if (!eventsFeature) {
162
- this.logger.debug('[setupEventListeners] Wallet not connected or does not support standard:events');
184
+ this.logger.debug(`[${this.name}] [setupEventListeners] Wallet not connected or does not support standard:events`);
163
185
  return;
164
186
  }
165
187
  this.eventsHandler = (event) => _tslib.__awaiter(this, void 0, void 0, function* () {
166
- var _b;
167
188
  if (event.accounts) {
168
- // If the event sets accounts but it's empty, we need to disconnect.
169
- if (event.accounts.length === 0 && this.account) {
170
- this.account = undefined;
171
- this.emit('disconnect');
172
- return;
173
- }
174
- const [primaryAccount] = event.accounts;
175
- if (primaryAccount.address !== ((_b = this.account) === null || _b === void 0 ? void 0 : _b.address)) {
176
- this.account = primaryAccount;
177
- this.emit('accountChange', { accounts: [primaryAccount.address] });
178
- }
189
+ this.handleAccountChange(event);
190
+ return;
179
191
  }
180
192
  // Some events will leave out accounts but set the chains object, so we process those
181
193
  // with the helper.
@@ -185,7 +197,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
185
197
  this.emit('chainChange', { chain: suiChainId });
186
198
  }
187
199
  });
188
- this.logger.debug('[setupEventListeners] Setting up sui wallet connector event listeners');
200
+ this.logger.debug(`[${this.name}] [setupEventListeners] Setting up sui wallet connector event listeners`);
189
201
  this.eventsUnsubscribeHandler = eventsFeature.on('change', this.eventsHandler);
190
202
  }
191
203
  /**
@@ -197,7 +209,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
197
209
  return _tslib.__awaiter(this, void 0, void 0, function* () {
198
210
  const clientNetworkId = networkId !== null && networkId !== void 0 ? networkId : (yield this.getNetwork());
199
211
  if (!clientNetworkId) {
200
- this.logger.error('[getSuiClient] Failed to get network id');
212
+ this.logger.error(`[${this.name}] [getSuiClient] Failed to get network id`);
201
213
  return undefined;
202
214
  }
203
215
  // Default to an existing client if available
@@ -207,7 +219,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
207
219
  const network = this.getEnabledNetworks().find((network) => network.networkId === clientNetworkId);
208
220
  const url = network ? networkHelpers.getPreferredRpcUrl(network) : undefined;
209
221
  if (!url) {
210
- this.logger.error('[getSuiClient] Failed to get network url');
222
+ this.logger.error(`[${this.name}] [getSuiClient] Failed to get network url`);
211
223
  return undefined;
212
224
  }
213
225
  this.suiClients[clientNetworkId] = new client.SuiClient({
@@ -220,7 +232,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
220
232
  return _tslib.__awaiter(this, void 0, void 0, function* () {
221
233
  const client = yield this.getSuiClient();
222
234
  if (!client) {
223
- this.logger.error('[getBalance] Failed to get Sui client');
235
+ this.logger.error(`[${this.name}] [getBalance] Failed to get Sui client`);
224
236
  return undefined;
225
237
  }
226
238
  const balanceResult = yield client.getBalance({
@@ -229,7 +241,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
229
241
  // Balance comes back as MIST, 1 SUI = 1e9 MIST
230
242
  const balance = Number(balanceResult === null || balanceResult === void 0 ? void 0 : balanceResult.totalBalance) / 1e9;
231
243
  if (Number.isNaN(balance)) {
232
- this.logger.error(`[getBalance] Failed to get balance for address: ${address}`);
244
+ this.logger.error(`[${this.name}] [getBalance] Failed to get balance for address: ${address}`);
233
245
  return undefined;
234
246
  }
235
247
  return balance.toFixed(6);
@@ -238,19 +250,18 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
238
250
  signMessage(messageToSign) {
239
251
  return _tslib.__awaiter(this, void 0, void 0, function* () {
240
252
  var _a;
241
- this.logger.debug('[signMessage] called, attempting to sign a message');
253
+ this.logger.debug(`[${this.name}] [signMessage] called, attempting to sign a message`);
242
254
  const signFeature = (_a = this.getFeatures()) === null || _a === void 0 ? void 0 : _a['sui:signPersonalMessage'];
243
255
  if (!signFeature) {
244
256
  throw new utils.DynamicError('Wallet does not support sui:signPersonalMessage');
245
257
  }
246
- yield this.connect();
247
- if (!this.account) {
258
+ if (!this.getPrimaryAccount()) {
248
259
  throw new utils.DynamicError('[signMessage] No account found');
249
260
  }
250
261
  let output;
251
262
  try {
252
263
  output = yield signFeature.signPersonalMessage({
253
- account: this.account,
264
+ account: this.getPrimaryAccount(),
254
265
  message: new TextEncoder().encode(messageToSign),
255
266
  });
256
267
  }
@@ -261,13 +272,13 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
261
272
  if (!output || !output.signature) {
262
273
  throw new utils.DynamicError('[signMessage] Failed to sign message');
263
274
  }
264
- this.logger.debug(`[signMessage] Signed message: ${output.signature}`);
275
+ this.logger.debug(`[${this.name}] [signMessage] Signed message: ${output.signature}`);
265
276
  return output.signature;
266
277
  });
267
278
  }
268
279
  getWalletAccount() {
269
280
  return _tslib.__awaiter(this, void 0, void 0, function* () {
270
- return this.account;
281
+ return this.getPrimaryAccount();
271
282
  });
272
283
  }
273
284
  /** Function used to create transactions in the SDK interface */
@@ -305,7 +316,7 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
305
316
  return _tslib.__awaiter(this, void 0, void 0, function* () {
306
317
  var _a;
307
318
  this.teardownEventListeners();
308
- this.account = undefined;
319
+ this.setPrimaryAccount(undefined);
309
320
  if (!this.isInstalledOnBrowser())
310
321
  return;
311
322
  const disconnectFeature = (_a = this.getFeatures()) === null || _a === void 0 ? void 0 : _a['standard:disconnect'];
@@ -325,15 +336,16 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
325
336
  }
326
337
  signAndExecuteTransactionFeature(_a) {
327
338
  return _tslib.__awaiter(this, arguments, void 0, function* ({ transaction, legacyOptions, }) {
328
- if (!this.account) {
339
+ var _b, _c;
340
+ if (!this.getPrimaryAccount()) {
329
341
  throw new utils.DynamicError('No account found');
330
342
  }
331
343
  const features = this.getFeatures();
332
344
  const signAndExecuteTransactionFeature = features === null || features === void 0 ? void 0 : features['sui:signAndExecuteTransaction'];
333
345
  if (signAndExecuteTransactionFeature) {
334
346
  return signAndExecuteTransactionFeature.signAndExecuteTransaction({
335
- account: this.account,
336
- chain: this.account.chains[0],
347
+ account: this.getPrimaryAccount(),
348
+ chain: (_b = this.getPrimaryAccount()) === null || _b === void 0 ? void 0 : _b.chains[0],
337
349
  transaction,
338
350
  });
339
351
  }
@@ -342,8 +354,8 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
342
354
  throw new utils.DynamicError('Wallet does not support sui:signAndExecuteTransaction or sui:signAndExecuteTransactionBlock');
343
355
  }
344
356
  const result = yield signAndExecuteTransactionBlockFeature.signAndExecuteTransactionBlock({
345
- account: this.account,
346
- chain: this.account.chains[0],
357
+ account: this.getPrimaryAccount(),
358
+ chain: (_c = this.getPrimaryAccount()) === null || _c === void 0 ? void 0 : _c.chains[0],
347
359
  options: legacyOptions === null || legacyOptions === void 0 ? void 0 : legacyOptions.options,
348
360
  requestType: legacyOptions === null || legacyOptions === void 0 ? void 0 : legacyOptions.requestType,
349
361
  transactionBlock: transaction,
@@ -353,15 +365,16 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
353
365
  }
354
366
  signTransactionFeature(_a) {
355
367
  return _tslib.__awaiter(this, arguments, void 0, function* ({ transaction, }) {
356
- if (!this.account) {
368
+ var _b, _c;
369
+ if (!this.getPrimaryAccount()) {
357
370
  throw new utils.DynamicError('No account found');
358
371
  }
359
372
  const features = this.getFeatures();
360
373
  const signTransactionFeature = features === null || features === void 0 ? void 0 : features['sui:signTransaction'];
361
374
  if (signTransactionFeature) {
362
375
  return signTransactionFeature === null || signTransactionFeature === void 0 ? void 0 : signTransactionFeature.signTransaction({
363
- account: this.account,
364
- chain: this.account.chains[0],
376
+ account: this.getPrimaryAccount(),
377
+ chain: (_b = this.getPrimaryAccount()) === null || _b === void 0 ? void 0 : _b.chains[0],
365
378
  transaction,
366
379
  });
367
380
  }
@@ -370,8 +383,8 @@ class SuiWalletConnector extends walletConnectorCore.WalletConnectorBase {
370
383
  throw new utils.DynamicError('Wallet does not support sui:signTransaction or sui:signTransactionBlock');
371
384
  }
372
385
  const result = yield signTransactionBlockFeature.signTransactionBlock({
373
- account: this.account,
374
- chain: this.account.chains[0],
386
+ account: this.getPrimaryAccount(),
387
+ chain: (_c = this.getPrimaryAccount()) === null || _c === void 0 ? void 0 : _c.chains[0],
375
388
  transactionBlock: transaction,
376
389
  });
377
390
  return result;
@@ -4,7 +4,7 @@ import { Transaction } from '@mysten/sui/transactions';
4
4
  import { Logger } from '@dynamic-labs/logger';
5
5
  import { GenericNetwork, IUITransaction } from '@dynamic-labs/types';
6
6
  import { Chain, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
7
- import { SuiWalletConnectorProps, SuiWalletStandardEventHandler } from './types';
7
+ import { SuiChangeEvent, SuiWalletConnectorProps, SuiWalletStandardEventHandler } from './types';
8
8
  import { SuiWallet } from './wallet/SuiWallet';
9
9
  export declare abstract class SuiWalletConnector extends WalletConnectorBase<typeof SuiWallet> {
10
10
  name: string;
@@ -20,6 +20,9 @@ export declare abstract class SuiWalletConnector extends WalletConnectorBase<typ
20
20
  eventsUnsubscribeHandler: (() => void) | undefined;
21
21
  /** Tracks the active wallet account */
22
22
  protected account: WalletAccount | undefined;
23
+ /** Returns the active wallet account, may be overridden */
24
+ getPrimaryAccount(): WalletAccount | undefined;
25
+ setPrimaryAccount(account: WalletAccount | undefined): void;
23
26
  /**
24
27
  * Tracks the active network id
25
28
  *
@@ -61,7 +64,8 @@ export declare abstract class SuiWalletConnector extends WalletConnectorBase<typ
61
64
  * @param event - The [SuiChangeEvent] to get the chain id from
62
65
  * @returns The dynamic chain id or '-1' if the chain id is not found
63
66
  */
64
- private getChainFromEvent;
67
+ protected getChainFromEvent(event: SuiChangeEvent): string;
68
+ handleAccountChange(event: SuiChangeEvent): void;
65
69
  setupEventListeners(): void;
66
70
  /**
67
71
  * Helper to get the Sui client for the current network