@dynamic-labs/midnight 4.92.3 → 4.93.0

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,28 @@
1
1
 
2
+ ## [4.93.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.4...v4.93.0) (2026-07-20)
3
+
4
+
5
+ ### Features
6
+
7
+ * **react-native:** add retry API and granular loading state ([#11938](https://github.com/dynamic-labs/dynamic-auth/issues/11938)) ([#11999](https://github.com/dynamic-labs/dynamic-auth/issues/11999)) ([8f4e6aa](https://github.com/dynamic-labs/dynamic-auth/commit/8f4e6aa2466da5e6b4d8ee802c814c51e79cf27c))
8
+
9
+ ### [4.92.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.3...v4.92.4) (2026-07-16)
10
+
11
+
12
+ ### Features
13
+
14
+ * **bitcoin:** per-network address switching and dust-limit send validation [v4] ([#11970](https://github.com/dynamic-labs/dynamic-auth/issues/11970)) ([76a4a9a](https://github.com/dynamic-labs/dynamic-auth/commit/76a4a9a5025d78798ebd1beffe6c0af59d2d029a)), closes [#11896](https://github.com/dynamic-labs/dynamic-auth/issues/11896) [#11800](https://github.com/dynamic-labs/dynamic-auth/issues/11800)
15
+ * **midnight:** per-network addresses in deposit and wallet info views [v4] ([#11949](https://github.com/dynamic-labs/dynamic-auth/issues/11949)) ([978446a](https://github.com/dynamic-labs/dynamic-auth/commit/978446aca8546eb038ba9ed3be0503d10594ee15))
16
+ * **midnight:** resolve wallet address per selected network [v4] ([#11948](https://github.com/dynamic-labs/dynamic-auth/issues/11948)) ([d6f858c](https://github.com/dynamic-labs/dynamic-auth/commit/d6f858c5e35defda7ed73cf97b3fdbe5ed9d131d))
17
+ * set useMetamaskSdk to true by default ([#11926](https://github.com/dynamic-labs/dynamic-auth/issues/11926)) ([75b5a4a](https://github.com/dynamic-labs/dynamic-auth/commit/75b5a4a0fe8b1a375afce145c0b8bdc3ce761117))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **midnight:** align per-network code with the final main iteration [v4] ([#11971](https://github.com/dynamic-labs/dynamic-auth/issues/11971)) ([3ef3ba8](https://github.com/dynamic-labs/dynamic-auth/commit/3ef3ba8c090dfd9e4286b4e51bf350ea5e6feac7))
23
+ * settle social sign-in when captcha is backed out or oauth popup never responds (v4) ([#11956](https://github.com/dynamic-labs/dynamic-auth/issues/11956)) ([ad49477](https://github.com/dynamic-labs/dynamic-auth/commit/ad49477f2acf61a154bb79cbe26b24f803cdb0e2))
24
+ * validate that private key is not empty before upgrading to WaaS ([#11952](https://github.com/dynamic-labs/dynamic-auth/issues/11952)) ([21dfb83](https://github.com/dynamic-labs/dynamic-auth/commit/21dfb83cb29e42b335bc94a0cdd2062cf14a262a))
25
+
2
26
  ### [4.92.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.2...v4.92.3) (2026-07-10)
3
27
 
4
28
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.92.3";
6
+ var version = "4.93.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.92.3";
2
+ var version = "4.93.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/midnight",
3
- "version": "4.92.3",
3
+ "version": "4.93.0",
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,15 +18,15 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/assert-package-version": "4.92.3",
22
- "@dynamic-labs/sdk-api-core": "0.0.1067",
21
+ "@dynamic-labs/assert-package-version": "4.93.0",
22
+ "@dynamic-labs/sdk-api-core": "0.0.1082",
23
23
  "@midnight-ntwrk/dapp-connector-api": "4.0.1",
24
- "@dynamic-labs/logger": "4.92.3",
25
- "@dynamic-labs/types": "4.92.3",
26
- "@dynamic-labs/utils": "4.92.3",
27
- "@dynamic-labs/waas": "4.92.3",
28
- "@dynamic-labs/wallet-book": "4.92.3",
29
- "@dynamic-labs/wallet-connector-core": "4.92.3"
24
+ "@dynamic-labs/logger": "4.93.0",
25
+ "@dynamic-labs/types": "4.93.0",
26
+ "@dynamic-labs/utils": "4.93.0",
27
+ "@dynamic-labs/waas": "4.93.0",
28
+ "@dynamic-labs/wallet-book": "4.93.0",
29
+ "@dynamic-labs/wallet-connector-core": "4.93.0"
30
30
  },
31
31
  "peerDependencies": {}
32
32
  }
@@ -144,14 +144,48 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
144
144
  }
145
145
  }
146
146
  /**
147
- * Gets the active wallet address
148
- * Falls back to verified credential address if no active account is set
149
- * @returns The wallet address or empty string if not found
147
+ * Maps the connector's currently selected network to the Midnight network tag
148
+ * used on additional addresses ('preview' | 'mainnet'). Public: the widget
149
+ * resolves per-network display (deposit address, wallet info) through this
150
+ * single source instead of duplicating the heuristic (IMidnightWalletConnector).
151
+ */
152
+ getSelectedMidnightNetwork() {
153
+ var _a, _b, _c;
154
+ const name = (_c = (_b = (_a = this.getSelectedNetwork()) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : '';
155
+ return name.includes('mainnet') ? 'mainnet' : 'preview';
156
+ }
157
+ /**
158
+ * Spread into wallet-client calls. Published browser-wallet-client builds
159
+ * that predate per-network support don't declare `networkId` — spreading a
160
+ * non-literal keeps this compiling against those types; older clients drop
161
+ * the field and default to preview.
162
+ */
163
+ midnightNetworkParam() {
164
+ return { networkId: this.getSelectedMidnightNetwork() };
165
+ }
166
+ /**
167
+ * Gets the active wallet address for the selected network.
168
+ *
169
+ * Midnight is one wallet (one MPC key) that exposes a per-network unshielded
170
+ * address — stored as `additionalAddresses` tagged with `network`. We return
171
+ * the address matching the selected network so receive/display uses the right
172
+ * encoding (mn_addr… on mainnet, mn_addr_preview… on preview). The key itself
173
+ * is network-agnostic and is resolved internally via `activeAccountAddress`,
174
+ * so signing/key lookups are unaffected by the switch.
175
+ *
176
+ * Falls back to the active/primary address when no network-tagged match is
177
+ * available (e.g. before the additional addresses are populated).
150
178
  */
151
179
  getAddress() {
152
180
  return _tslib.__awaiter(this, void 0, void 0, function* () {
181
+ var _a, _b, _c;
153
182
  this.ensureActiveAccountFromVerifiedCredentials();
154
- return this.activeAccountAddress || '';
183
+ const network = this.getSelectedMidnightNetwork();
184
+ const networkAddress = (_b = ((_a = this.verifiedCredentials) !== null && _a !== void 0 ? _a : [])
185
+ .flatMap((cred) => { var _a; return (_a = cred.walletAdditionalAddresses) !== null && _a !== void 0 ? _a : []; })
186
+ .find((addr) => addr.type === 'midnight_unshielded' &&
187
+ addr.network === network)) === null || _b === void 0 ? void 0 : _b.address;
188
+ return (_c = networkAddress !== null && networkAddress !== void 0 ? networkAddress : this.activeAccountAddress) !== null && _c !== void 0 ? _c : '';
155
189
  });
156
190
  }
157
191
  /**
@@ -240,7 +274,7 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
240
274
  */
241
275
  signTransaction(serializedTransaction) {
242
276
  return _tslib.__awaiter(this, void 0, void 0, function* () {
243
- var _a, _b, _c, _d;
277
+ var _a, _b;
244
278
  if (!this.activeAccountAddress) {
245
279
  throw new utils.DynamicError('Active account address is required', 'active_account_address_is_required');
246
280
  }
@@ -252,16 +286,14 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
252
286
  const password = yield this.getPasswordIfNeeded({
253
287
  accountAddress: this.activeAccountAddress,
254
288
  });
255
- // Derive the chain name (e.g. "mainnet" / "preview") — not the numeric
256
- // network ID — because `chainId` is typed as a string and resolved by
257
- // name on the wallet-client side. Passing a stringified numeric id
258
- // (`"1"`) reaches `getNetworkIdFromChainId`, which doesn't recognize it.
259
- const selectedNetwork = this.getSelectedNetwork();
260
- const isTestnet = (_c = (_b = selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('testnet')) !== null && _c !== void 0 ? _c : false;
261
- const chainId = isTestnet ? 'preview' : 'mainnet';
289
+ // Derive the chain name ('preview' | 'mainnet') — not the numeric network
290
+ // ID — because `chainId` is resolved by name on the wallet-client side.
291
+ // Single source of truth shared with balance/dust/transfer calls so display
292
+ // and signing stay on the same network.
293
+ const chainId = this.getSelectedMidnightNetwork();
262
294
  // Sign the transaction using MPC
263
295
  const signature = yield walletClient.signTransaction({
264
- authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
296
+ authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
265
297
  chainId,
266
298
  mfaToken,
267
299
  password,
@@ -282,11 +314,17 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
282
314
  // public-balance endpoint, which rejects Midnight addresses. Reused from the
283
315
  // short-lived cache across recreations (see field doc).
284
316
  const now = Date.now();
317
+ const network = this.getSelectedMidnightNetwork();
285
318
  if (!this.sendBalanceCache ||
319
+ this.sendBalanceCache.network !== network ||
286
320
  now - this.sendBalanceCache.at >
287
321
  DynamicWaasMidnightConnector.SEND_BALANCE_TTL_MS) {
288
322
  const { shielded, unshielded } = yield this.getBalances();
289
- this.sendBalanceCache = { at: now, maps: { shielded, unshielded } };
323
+ this.sendBalanceCache = {
324
+ at: now,
325
+ maps: { shielded, unshielded },
326
+ network,
327
+ };
290
328
  }
291
329
  const balances = this.sendBalanceCache.maps;
292
330
  return new MidnightUiTransaction.MidnightUiTransaction({
@@ -377,13 +415,8 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
377
415
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
378
416
  scope: sdkApiCore.TokenScope.Walletsign,
379
417
  }));
380
- const result = yield walletClient.getPrivateBalance({
381
- accountAddress: this.activeAccountAddress,
382
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
383
- elevatedAccessToken,
384
- mfaToken,
385
- signedSessionId,
386
- });
418
+ const result = yield walletClient.getPrivateBalance(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
419
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId }));
387
420
  // Defensive: wallet-client builds that predate the dust decouple don't
388
421
  // return `dustSynced` — treat those as already-synced (no loading state),
389
422
  // preserving prior behavior until the client is republished.
@@ -441,13 +474,8 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
441
474
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
442
475
  scope: sdkApiCore.TokenScope.Walletsign,
443
476
  }));
444
- return walletClient.registerDust({
445
- accountAddress: this.activeAccountAddress,
446
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
447
- elevatedAccessToken,
448
- mfaToken,
449
- signedSessionId,
450
- });
477
+ return walletClient.registerDust(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
478
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId }));
451
479
  });
452
480
  }
453
481
  /**
@@ -486,15 +514,8 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
486
514
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
487
515
  scope: sdkApiCore.TokenScope.Walletsign,
488
516
  }));
489
- return walletClient.createTransferTransaction({
490
- accountAddress: this.activeAccountAddress,
491
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
492
- elevatedAccessToken,
493
- mfaToken,
494
- signedSessionId,
495
- transfers: params.transfers,
496
- ttlMinutes: params.ttlMinutes,
497
- });
517
+ return walletClient.createTransferTransaction(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
518
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId, transfers: params.transfers, ttlMinutes: params.ttlMinutes }));
498
519
  });
499
520
  }
500
521
  /**
@@ -545,16 +566,8 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
545
566
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
546
567
  scope: sdkApiCore.TokenScope.Walletsign,
547
568
  }));
548
- return walletClient.revertTransaction({
549
- accountAddress: this.activeAccountAddress,
550
- all: args.all,
551
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
552
- elevatedAccessToken,
553
- mfaToken,
554
- resetCache: args.resetCache,
555
- signedSessionId,
556
- transaction: args.transaction,
557
- });
569
+ return walletClient.revertTransaction(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, all: args.all, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
570
+ mfaToken }, this.midnightNetworkParam()), { resetCache: args.resetCache, signedSessionId, transaction: args.transaction }));
558
571
  });
559
572
  }
560
573
  /**
@@ -577,17 +590,8 @@ class DynamicWaasMidnightConnector extends waas.withDynamicWaas(WaasMidnightWall
577
590
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
578
591
  scope: sdkApiCore.TokenScope.Walletsign,
579
592
  }));
580
- return walletClient.submitTransaction({
581
- accountAddress: this.activeAccountAddress,
582
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
583
- balanceBefore: options === null || options === void 0 ? void 0 : options.balanceBefore,
584
- elevatedAccessToken,
585
- mfaToken,
586
- signedSessionId,
587
- tokenType: options === null || options === void 0 ? void 0 : options.tokenType,
588
- transaction: serializedFinalizedTransaction,
589
- waitForBalance: options === null || options === void 0 ? void 0 : options.waitForBalance,
590
- });
593
+ return walletClient.submitTransaction(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), balanceBefore: options === null || options === void 0 ? void 0 : options.balanceBefore, elevatedAccessToken,
594
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId, tokenType: options === null || options === void 0 ? void 0 : options.tokenType, transaction: serializedFinalizedTransaction, waitForBalance: options === null || options === void 0 ? void 0 : options.waitForBalance }));
591
595
  });
592
596
  }
593
597
  }
@@ -137,6 +137,12 @@ declare const DynamicWaasMidnightConnector_base: (abstract new (...args: any[])
137
137
  displayContainer: HTMLElement;
138
138
  }): Promise<void>;
139
139
  hideICloudSignIn(): Promise<void>;
140
+ /**
141
+ * Spread into wallet-client calls. Published browser-wallet-client builds
142
+ * that predate per-network support don't declare `networkId` — spreading a
143
+ * non-literal keeps this compiling against those types; older clients drop
144
+ * the field and default to preview.
145
+ */
140
146
  isICloudAuthenticated(): Promise<boolean>;
141
147
  refreshWalletAccountShares({ accountAddress, password, }: {
142
148
  accountAddress: string;
@@ -283,9 +289,31 @@ export declare class DynamicWaasMidnightConnector extends DynamicWaasMidnightCon
283
289
  */
284
290
  private ensureActiveAccountFromVerifiedCredentials;
285
291
  /**
286
- * Gets the active wallet address
287
- * Falls back to verified credential address if no active account is set
288
- * @returns The wallet address or empty string if not found
292
+ * Maps the connector's currently selected network to the Midnight network tag
293
+ * used on additional addresses ('preview' | 'mainnet'). Public: the widget
294
+ * resolves per-network display (deposit address, wallet info) through this
295
+ * single source instead of duplicating the heuristic (IMidnightWalletConnector).
296
+ */
297
+ getSelectedMidnightNetwork(): 'preview' | 'mainnet';
298
+ /**
299
+ * Spread into wallet-client calls. Published browser-wallet-client builds
300
+ * that predate per-network support don't declare `networkId` — spreading a
301
+ * non-literal keeps this compiling against those types; older clients drop
302
+ * the field and default to preview.
303
+ */
304
+ private midnightNetworkParam;
305
+ /**
306
+ * Gets the active wallet address for the selected network.
307
+ *
308
+ * Midnight is one wallet (one MPC key) that exposes a per-network unshielded
309
+ * address — stored as `additionalAddresses` tagged with `network`. We return
310
+ * the address matching the selected network so receive/display uses the right
311
+ * encoding (mn_addr… on mainnet, mn_addr_preview… on preview). The key itself
312
+ * is network-agnostic and is resolved internally via `activeAccountAddress`,
313
+ * so signing/key lookups are unaffected by the switch.
314
+ *
315
+ * Falls back to the active/primary address when no network-tagged match is
316
+ * available (e.g. before the additional addresses are populated).
289
317
  */
290
318
  getAddress(): Promise<string>;
291
319
  /**
@@ -140,14 +140,48 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
140
140
  }
141
141
  }
142
142
  /**
143
- * Gets the active wallet address
144
- * Falls back to verified credential address if no active account is set
145
- * @returns The wallet address or empty string if not found
143
+ * Maps the connector's currently selected network to the Midnight network tag
144
+ * used on additional addresses ('preview' | 'mainnet'). Public: the widget
145
+ * resolves per-network display (deposit address, wallet info) through this
146
+ * single source instead of duplicating the heuristic (IMidnightWalletConnector).
147
+ */
148
+ getSelectedMidnightNetwork() {
149
+ var _a, _b, _c;
150
+ const name = (_c = (_b = (_a = this.getSelectedNetwork()) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : '';
151
+ return name.includes('mainnet') ? 'mainnet' : 'preview';
152
+ }
153
+ /**
154
+ * Spread into wallet-client calls. Published browser-wallet-client builds
155
+ * that predate per-network support don't declare `networkId` — spreading a
156
+ * non-literal keeps this compiling against those types; older clients drop
157
+ * the field and default to preview.
158
+ */
159
+ midnightNetworkParam() {
160
+ return { networkId: this.getSelectedMidnightNetwork() };
161
+ }
162
+ /**
163
+ * Gets the active wallet address for the selected network.
164
+ *
165
+ * Midnight is one wallet (one MPC key) that exposes a per-network unshielded
166
+ * address — stored as `additionalAddresses` tagged with `network`. We return
167
+ * the address matching the selected network so receive/display uses the right
168
+ * encoding (mn_addr… on mainnet, mn_addr_preview… on preview). The key itself
169
+ * is network-agnostic and is resolved internally via `activeAccountAddress`,
170
+ * so signing/key lookups are unaffected by the switch.
171
+ *
172
+ * Falls back to the active/primary address when no network-tagged match is
173
+ * available (e.g. before the additional addresses are populated).
146
174
  */
147
175
  getAddress() {
148
176
  return __awaiter(this, void 0, void 0, function* () {
177
+ var _a, _b, _c;
149
178
  this.ensureActiveAccountFromVerifiedCredentials();
150
- return this.activeAccountAddress || '';
179
+ const network = this.getSelectedMidnightNetwork();
180
+ const networkAddress = (_b = ((_a = this.verifiedCredentials) !== null && _a !== void 0 ? _a : [])
181
+ .flatMap((cred) => { var _a; return (_a = cred.walletAdditionalAddresses) !== null && _a !== void 0 ? _a : []; })
182
+ .find((addr) => addr.type === 'midnight_unshielded' &&
183
+ addr.network === network)) === null || _b === void 0 ? void 0 : _b.address;
184
+ return (_c = networkAddress !== null && networkAddress !== void 0 ? networkAddress : this.activeAccountAddress) !== null && _c !== void 0 ? _c : '';
151
185
  });
152
186
  }
153
187
  /**
@@ -236,7 +270,7 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
236
270
  */
237
271
  signTransaction(serializedTransaction) {
238
272
  return __awaiter(this, void 0, void 0, function* () {
239
- var _a, _b, _c, _d;
273
+ var _a, _b;
240
274
  if (!this.activeAccountAddress) {
241
275
  throw new DynamicError('Active account address is required', 'active_account_address_is_required');
242
276
  }
@@ -248,16 +282,14 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
248
282
  const password = yield this.getPasswordIfNeeded({
249
283
  accountAddress: this.activeAccountAddress,
250
284
  });
251
- // Derive the chain name (e.g. "mainnet" / "preview") — not the numeric
252
- // network ID — because `chainId` is typed as a string and resolved by
253
- // name on the wallet-client side. Passing a stringified numeric id
254
- // (`"1"`) reaches `getNetworkIdFromChainId`, which doesn't recognize it.
255
- const selectedNetwork = this.getSelectedNetwork();
256
- const isTestnet = (_c = (_b = selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('testnet')) !== null && _c !== void 0 ? _c : false;
257
- const chainId = isTestnet ? 'preview' : 'mainnet';
285
+ // Derive the chain name ('preview' | 'mainnet') — not the numeric network
286
+ // ID — because `chainId` is resolved by name on the wallet-client side.
287
+ // Single source of truth shared with balance/dust/transfer calls so display
288
+ // and signing stay on the same network.
289
+ const chainId = this.getSelectedMidnightNetwork();
258
290
  // Sign the transaction using MPC
259
291
  const signature = yield walletClient.signTransaction({
260
- authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
292
+ authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
261
293
  chainId,
262
294
  mfaToken,
263
295
  password,
@@ -278,11 +310,17 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
278
310
  // public-balance endpoint, which rejects Midnight addresses. Reused from the
279
311
  // short-lived cache across recreations (see field doc).
280
312
  const now = Date.now();
313
+ const network = this.getSelectedMidnightNetwork();
281
314
  if (!this.sendBalanceCache ||
315
+ this.sendBalanceCache.network !== network ||
282
316
  now - this.sendBalanceCache.at >
283
317
  DynamicWaasMidnightConnector.SEND_BALANCE_TTL_MS) {
284
318
  const { shielded, unshielded } = yield this.getBalances();
285
- this.sendBalanceCache = { at: now, maps: { shielded, unshielded } };
319
+ this.sendBalanceCache = {
320
+ at: now,
321
+ maps: { shielded, unshielded },
322
+ network,
323
+ };
286
324
  }
287
325
  const balances = this.sendBalanceCache.maps;
288
326
  return new MidnightUiTransaction({
@@ -373,13 +411,8 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
373
411
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
374
412
  scope: TokenScope.Walletsign,
375
413
  }));
376
- const result = yield walletClient.getPrivateBalance({
377
- accountAddress: this.activeAccountAddress,
378
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
379
- elevatedAccessToken,
380
- mfaToken,
381
- signedSessionId,
382
- });
414
+ const result = yield walletClient.getPrivateBalance(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
415
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId }));
383
416
  // Defensive: wallet-client builds that predate the dust decouple don't
384
417
  // return `dustSynced` — treat those as already-synced (no loading state),
385
418
  // preserving prior behavior until the client is republished.
@@ -437,13 +470,8 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
437
470
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
438
471
  scope: TokenScope.Walletsign,
439
472
  }));
440
- return walletClient.registerDust({
441
- accountAddress: this.activeAccountAddress,
442
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
443
- elevatedAccessToken,
444
- mfaToken,
445
- signedSessionId,
446
- });
473
+ return walletClient.registerDust(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
474
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId }));
447
475
  });
448
476
  }
449
477
  /**
@@ -482,15 +510,8 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
482
510
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
483
511
  scope: TokenScope.Walletsign,
484
512
  }));
485
- return walletClient.createTransferTransaction({
486
- accountAddress: this.activeAccountAddress,
487
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
488
- elevatedAccessToken,
489
- mfaToken,
490
- signedSessionId,
491
- transfers: params.transfers,
492
- ttlMinutes: params.ttlMinutes,
493
- });
513
+ return walletClient.createTransferTransaction(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
514
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId, transfers: params.transfers, ttlMinutes: params.ttlMinutes }));
494
515
  });
495
516
  }
496
517
  /**
@@ -541,16 +562,8 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
541
562
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
542
563
  scope: TokenScope.Walletsign,
543
564
  }));
544
- return walletClient.revertTransaction({
545
- accountAddress: this.activeAccountAddress,
546
- all: args.all,
547
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
548
- elevatedAccessToken,
549
- mfaToken,
550
- resetCache: args.resetCache,
551
- signedSessionId,
552
- transaction: args.transaction,
553
- });
565
+ return walletClient.revertTransaction(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, all: args.all, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), elevatedAccessToken,
566
+ mfaToken }, this.midnightNetworkParam()), { resetCache: args.resetCache, signedSessionId, transaction: args.transaction }));
554
567
  });
555
568
  }
556
569
  /**
@@ -573,17 +586,8 @@ class DynamicWaasMidnightConnector extends withDynamicWaas(WaasMidnightWalletCon
573
586
  const elevatedAccessToken = yield ((_b = this.getElevatedAccessToken) === null || _b === void 0 ? void 0 : _b.call(this, {
574
587
  scope: TokenScope.Walletsign,
575
588
  }));
576
- return walletClient.submitTransaction({
577
- accountAddress: this.activeAccountAddress,
578
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
579
- balanceBefore: options === null || options === void 0 ? void 0 : options.balanceBefore,
580
- elevatedAccessToken,
581
- mfaToken,
582
- signedSessionId,
583
- tokenType: options === null || options === void 0 ? void 0 : options.tokenType,
584
- transaction: serializedFinalizedTransaction,
585
- waitForBalance: options === null || options === void 0 ? void 0 : options.waitForBalance,
586
- });
589
+ return walletClient.submitTransaction(Object.assign(Object.assign({ accountAddress: this.activeAccountAddress, authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this), balanceBefore: options === null || options === void 0 ? void 0 : options.balanceBefore, elevatedAccessToken,
590
+ mfaToken }, this.midnightNetworkParam()), { signedSessionId, tokenType: options === null || options === void 0 ? void 0 : options.tokenType, transaction: serializedFinalizedTransaction, waitForBalance: options === null || options === void 0 ? void 0 : options.waitForBalance }));
587
591
  });
588
592
  }
589
593
  }