@dynamic-labs/midnight 4.90.0 → 4.91.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 +36 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +8 -6
  5. package/src/MidnightWalletConnectors.cjs +6 -0
  6. package/src/MidnightWalletConnectors.js +6 -0
  7. package/src/connectors/MidnightWalletConnector.cjs +41 -0
  8. package/src/connectors/MidnightWalletConnector.d.ts +42 -1
  9. package/src/connectors/MidnightWalletConnector.js +41 -0
  10. package/src/index.cjs +8 -6
  11. package/src/index.d.ts +1 -1
  12. package/src/index.js +4 -2
  13. package/src/types.d.ts +11 -2
  14. package/src/utils/MidnightUiTransaction/MidnightUiTransaction.cjs +109 -0
  15. package/src/utils/MidnightUiTransaction/MidnightUiTransaction.d.ts +2 -2
  16. package/src/utils/MidnightUiTransaction/MidnightUiTransaction.js +105 -0
  17. package/src/waas/DynamicWaasMidnightConnectors.cjs +16 -0
  18. package/src/waas/DynamicWaasMidnightConnectors.d.ts +6 -0
  19. package/src/waas/DynamicWaasMidnightConnectors.js +12 -0
  20. package/src/waas/WaasMidnightWalletConnector.cjs +109 -0
  21. package/src/waas/WaasMidnightWalletConnector.d.ts +44 -0
  22. package/src/waas/WaasMidnightWalletConnector.js +105 -0
  23. package/src/waas/connector/DynamicWaasMidnightConnector.cjs +584 -0
  24. package/src/waas/connector/DynamicWaasMidnightConnector.d.ts +470 -0
  25. package/src/waas/connector/DynamicWaasMidnightConnector.js +580 -0
  26. package/src/waas/connector/buildMidnightWaasConnectedApi.cjs +48 -0
  27. package/src/waas/connector/buildMidnightWaasConnectedApi.d.ts +26 -0
  28. package/src/waas/connector/buildMidnightWaasConnectedApi.js +42 -0
  29. package/src/waas/connector/index.d.ts +1 -0
  30. package/src/waas/index.d.ts +4 -0
  31. package/src/waas/isMidnightWallet.cjs +15 -0
  32. package/src/waas/isMidnightWallet.d.ts +7 -0
  33. package/src/waas/isMidnightWallet.js +11 -0
  34. package/src/wallet/MidnightWallet.cjs +31 -0
  35. package/src/wallet/MidnightWallet.d.ts +15 -0
  36. package/src/wallet/MidnightWallet.js +31 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,40 @@
1
1
 
2
+ ### [4.91.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.0...v4.91.1) (2026-06-24)
3
+
4
+
5
+ ### Features
6
+
7
+ * **aleo:** update sendBalance with individual and marketplace logic ([#11709](https://github.com/dynamic-labs/dynamic-auth/issues/11709)) ([f8dfc48](https://github.com/dynamic-labs/dynamic-auth/commit/f8dfc488ae607fbbbcc3432a3ef69f746f0b7df0))
8
+ * **sdk-react-core:** surface shielded address in Midnight deposit view ([#11698](https://github.com/dynamic-labs/dynamic-auth/issues/11698)) ([79c5402](https://github.com/dynamic-labs/dynamic-auth/commit/79c54029b1d8f722cf9f1d8b4c11977898442ac0))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * display actual error message for WaaS export failures instead of generic fallback ([#11498](https://github.com/dynamic-labs/dynamic-auth/issues/11498)) ([373c931](https://github.com/dynamic-labs/dynamic-auth/commit/373c931eb96c88e484c557ee8f2934660d028f97))
14
+ * **wallet-book:** guard replaceKey and remove stale override ([#11682](https://github.com/dynamic-labs/dynamic-auth/issues/11682)) ([13947d9](https://github.com/dynamic-labs/dynamic-auth/commit/13947d972ed1f8227712bfc01af9cc2be616a78a))
15
+
16
+
17
+ ### Performance Improvements
18
+
19
+ * **e2e:** prebuild Expo web bundle for RN e2e tests ([#11674](https://github.com/dynamic-labs/dynamic-auth/issues/11674)) ([16e002d](https://github.com/dynamic-labs/dynamic-auth/commit/16e002d59b2035e3f2c116879a78418a959da8bc))
20
+
21
+ ## [4.91.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.90.0...v4.91.0) (2026-06-23)
22
+
23
+
24
+ ### Features
25
+
26
+ * **midnight:** add WaaS layer to @dynamic-labs/midnight ([#11006](https://github.com/dynamic-labs/dynamic-auth/issues/11006)) ([01b9d16](https://github.com/dynamic-labs/dynamic-auth/commit/01b9d16d0ba92a141a9be546ca00cca4029894d5))
27
+ * **sdk-react-core:** widget support for Midnight multi-address display + export hiding ([#11008](https://github.com/dynamic-labs/dynamic-auth/issues/11008)) ([87320b4](https://github.com/dynamic-labs/dynamic-auth/commit/87320b4d6e286b88e17f144641346e16a27e9e71))
28
+ * **waas:** wire session public key through host backup ops for keyshare diagnostics [DYNT-1280] ([#11675](https://github.com/dynamic-labs/dynamic-auth/issues/11675)) ([4f7981c](https://github.com/dynamic-labs/dynamic-auth/commit/4f7981c009930469dec7b3dec93f20f99bbe5498))
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **ethereum-aa:** make ZeroDevConnector inert instead of throwing when ZeroDev config is absent ([#11610](https://github.com/dynamic-labs/dynamic-auth/issues/11610)) ([a3aab6a](https://github.com/dynamic-labs/dynamic-auth/commit/a3aab6a97e2e996f96b725f9336704b844f79603))
34
+ * **react-native-extension:** fall back to react-native-webview when embedded native module is unavailable ([#11683](https://github.com/dynamic-labs/dynamic-auth/issues/11683)) ([3f8d92c](https://github.com/dynamic-labs/dynamic-auth/commit/3f8d92ca0c327128b16e3355ab2f4e63d2c8e731))
35
+ * **sdk-react-core:** warn instead of throwing when ZeroDev connector is absent ([#11611](https://github.com/dynamic-labs/dynamic-auth/issues/11611)) ([5836252](https://github.com/dynamic-labs/dynamic-auth/commit/58362524e45205399c0fdc5b92414190d1929e0b))
36
+ * **waas-evm:** sign EOA transactions with the resolved chainId, not the connector default ([#11653](https://github.com/dynamic-labs/dynamic-auth/issues/11653)) ([e634098](https://github.com/dynamic-labs/dynamic-auth/commit/e634098f0f23f4c53f92a580db6f4aacbd6b1f92))
37
+
2
38
  ## [4.90.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.89.0...v4.90.0) (2026-06-19)
3
39
 
4
40
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.90.0";
6
+ var version = "4.91.1";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.90.0";
2
+ var version = "4.91.1";
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.90.0",
3
+ "version": "4.91.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,13 +18,15 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/assert-package-version": "4.90.0",
21
+ "@dynamic-labs/assert-package-version": "4.91.1",
22
22
  "@dynamic-labs/sdk-api-core": "0.0.1046",
23
23
  "@midnight-ntwrk/dapp-connector-api": "4.0.1",
24
- "@dynamic-labs/types": "4.90.0",
25
- "@dynamic-labs/utils": "4.90.0",
26
- "@dynamic-labs/wallet-book": "4.90.0",
27
- "@dynamic-labs/wallet-connector-core": "4.90.0"
24
+ "@dynamic-labs/logger": "4.91.1",
25
+ "@dynamic-labs/types": "4.91.1",
26
+ "@dynamic-labs/utils": "4.91.1",
27
+ "@dynamic-labs/waas": "4.91.1",
28
+ "@dynamic-labs/wallet-book": "4.91.1",
29
+ "@dynamic-labs/wallet-connector-core": "4.91.1"
28
30
  },
29
31
  "peerDependencies": {}
30
32
  }
@@ -4,10 +4,16 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors/fetchInjectedWalletConnectors.cjs');
7
+ require('./waas/connector/DynamicWaasMidnightConnector.cjs');
8
+ var DynamicWaasMidnightConnectors = require('./waas/DynamicWaasMidnightConnectors.cjs');
9
+ require('../_virtual/_tslib.cjs');
10
+ require('@dynamic-labs/logger');
11
+ require('@dynamic-labs/wallet-connector-core');
7
12
 
8
13
  const MidnightWalletConnectors = (props) => [
9
14
  ...fetchInjectedWalletConnectors.injectedWalletOverrides,
10
15
  ...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(Object.assign(Object.assign({}, props), { walletsWithCustomConnectors: [] })),
16
+ ...DynamicWaasMidnightConnectors.DynamicWaasMidnightConnectors(),
11
17
  ];
12
18
 
13
19
  exports.MidnightWalletConnectors = MidnightWalletConnectors;
@@ -1,9 +1,15 @@
1
1
  'use client'
2
2
  import { injectedWalletOverrides, fetchInjectedWalletConnectors } from './injected/fetchInjectedWalletConnectors/fetchInjectedWalletConnectors.js';
3
+ import './waas/connector/DynamicWaasMidnightConnector.js';
4
+ import { DynamicWaasMidnightConnectors } from './waas/DynamicWaasMidnightConnectors.js';
5
+ import '../_virtual/_tslib.js';
6
+ import '@dynamic-labs/logger';
7
+ import '@dynamic-labs/wallet-connector-core';
3
8
 
4
9
  const MidnightWalletConnectors = (props) => [
5
10
  ...injectedWalletOverrides,
6
11
  ...fetchInjectedWalletConnectors(Object.assign(Object.assign({}, props), { walletsWithCustomConnectors: [] })),
12
+ ...DynamicWaasMidnightConnectors(),
7
13
  ];
8
14
 
9
15
  export { MidnightWalletConnectors };
@@ -28,6 +28,15 @@ class MidnightWalletConnector extends walletConnectorCore.WalletConnectorBase {
28
28
  getEnabledNetworks() {
29
29
  return this.midnightNetworks;
30
30
  }
31
+ getBlockExplorerUrlsForCurrentNetwork() {
32
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
33
+ // Midnight is preview-only today and the env/network config can carry a
34
+ // stale or incorrect explorer URL, so always return the known-correct
35
+ // preview explorer rather than deferring to config. Detail pages live at
36
+ // `${origin}/transactions/{canonicalTxHash}`.
37
+ return ['https://explorer.preview.midnight.network'];
38
+ });
39
+ }
31
40
  getConnectedAPI() {
32
41
  return _tslib.__awaiter(this, void 0, void 0, function* () {
33
42
  return undefined;
@@ -65,6 +74,35 @@ class MidnightWalletConnector extends walletConnectorCore.WalletConnectorBase {
65
74
  throw new Error('signTransaction is not supported by this connector');
66
75
  });
67
76
  }
77
+ createTransferTransaction(
78
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
79
+ params) {
80
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
81
+ throw new Error('createTransferTransaction is not supported by this connector');
82
+ });
83
+ }
84
+ registerDust() {
85
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
86
+ throw new Error('registerDust is not supported by this connector');
87
+ });
88
+ }
89
+ revertTransaction(
90
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
91
+ serializedTransaction) {
92
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
93
+ throw new Error('revertTransaction is not supported by this connector');
94
+ });
95
+ }
96
+ revertAllPending() {
97
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
98
+ throw new Error('revertAllPending is not supported by this connector');
99
+ });
100
+ }
101
+ resetWalletCache() {
102
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
103
+ throw new Error('resetWalletCache is not supported by this connector');
104
+ });
105
+ }
68
106
  getShieldedBalances() {
69
107
  return _tslib.__awaiter(this, void 0, void 0, function* () {
70
108
  const api = yield this.getConnectedAPI();
@@ -119,6 +157,9 @@ class MidnightWalletConnector extends walletConnectorCore.WalletConnectorBase {
119
157
  return api.getDustAddress();
120
158
  });
121
159
  }
160
+ // Return type is a union so WaaS connectors can override with a richer
161
+ // `{ txHash, balanceAfter }` result while injected/external connectors keep
162
+ // the simple fire-and-forget `void` behavior.
122
163
  submitTransaction(serializedTransaction) {
123
164
  return _tslib.__awaiter(this, void 0, void 0, function* () {
124
165
  const api = yield this.getConnectedAPI();
@@ -17,8 +17,10 @@ export declare abstract class MidnightWalletConnector extends WalletConnectorBas
17
17
  cap: bigint;
18
18
  balance: bigint;
19
19
  };
20
+ dustSyncing?: boolean;
20
21
  }>;
21
22
  getEnabledNetworks(): GenericNetwork[];
23
+ getBlockExplorerUrlsForCurrentNetwork(): Promise<string[]>;
22
24
  protected getConnectedAPI(): Promise<ConnectedAPI | undefined>;
23
25
  createTransfer(params: {
24
26
  transfers: Array<{
@@ -29,6 +31,42 @@ export declare abstract class MidnightWalletConnector extends WalletConnectorBas
29
31
  }>;
30
32
  }): Promise<string>;
31
33
  signTransaction(serializedTransaction: string): Promise<string>;
34
+ createTransferTransaction(params: {
35
+ transfers: Array<{
36
+ type: 'unshielded' | 'shielded';
37
+ recipientAddress: string;
38
+ amount: string;
39
+ tokenType?: string;
40
+ }>;
41
+ ttlMinutes?: number;
42
+ }): Promise<{
43
+ serializedTransaction: string;
44
+ }>;
45
+ registerDust(): Promise<{
46
+ dustBalance: string;
47
+ txId?: string;
48
+ status: 'registered' | 'already_registered' | 'already_has_dust' | 'no_utxos';
49
+ message: string;
50
+ registeredCount: number;
51
+ }>;
52
+ revertTransaction(serializedTransaction: string): Promise<{
53
+ reverted: boolean;
54
+ count: number;
55
+ cacheCleared: boolean;
56
+ message: string;
57
+ }>;
58
+ revertAllPending(): Promise<{
59
+ reverted: boolean;
60
+ count: number;
61
+ cacheCleared: boolean;
62
+ message: string;
63
+ }>;
64
+ resetWalletCache(): Promise<{
65
+ reverted: boolean;
66
+ count: number;
67
+ cacheCleared: boolean;
68
+ message: string;
69
+ }>;
32
70
  getShieldedBalances(): Promise<Record<TokenType, bigint>>;
33
71
  getUnshieldedBalances(): Promise<Record<TokenType, bigint>>;
34
72
  getDustBalance(): Promise<{
@@ -46,5 +84,8 @@ export declare abstract class MidnightWalletConnector extends WalletConnectorBas
46
84
  getDustAddress(): Promise<{
47
85
  dustAddress: string;
48
86
  }>;
49
- submitTransaction(serializedTransaction: string): Promise<void>;
87
+ submitTransaction(serializedTransaction: string): Promise<void | {
88
+ txHash: string;
89
+ balanceAfter?: string;
90
+ }>;
50
91
  }
@@ -24,6 +24,15 @@ class MidnightWalletConnector extends WalletConnectorBase {
24
24
  getEnabledNetworks() {
25
25
  return this.midnightNetworks;
26
26
  }
27
+ getBlockExplorerUrlsForCurrentNetwork() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ // Midnight is preview-only today and the env/network config can carry a
30
+ // stale or incorrect explorer URL, so always return the known-correct
31
+ // preview explorer rather than deferring to config. Detail pages live at
32
+ // `${origin}/transactions/{canonicalTxHash}`.
33
+ return ['https://explorer.preview.midnight.network'];
34
+ });
35
+ }
27
36
  getConnectedAPI() {
28
37
  return __awaiter(this, void 0, void 0, function* () {
29
38
  return undefined;
@@ -61,6 +70,35 @@ class MidnightWalletConnector extends WalletConnectorBase {
61
70
  throw new Error('signTransaction is not supported by this connector');
62
71
  });
63
72
  }
73
+ createTransferTransaction(
74
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
+ params) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ throw new Error('createTransferTransaction is not supported by this connector');
78
+ });
79
+ }
80
+ registerDust() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ throw new Error('registerDust is not supported by this connector');
83
+ });
84
+ }
85
+ revertTransaction(
86
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
87
+ serializedTransaction) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ throw new Error('revertTransaction is not supported by this connector');
90
+ });
91
+ }
92
+ revertAllPending() {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ throw new Error('revertAllPending is not supported by this connector');
95
+ });
96
+ }
97
+ resetWalletCache() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ throw new Error('resetWalletCache is not supported by this connector');
100
+ });
101
+ }
64
102
  getShieldedBalances() {
65
103
  return __awaiter(this, void 0, void 0, function* () {
66
104
  const api = yield this.getConnectedAPI();
@@ -115,6 +153,9 @@ class MidnightWalletConnector extends WalletConnectorBase {
115
153
  return api.getDustAddress();
116
154
  });
117
155
  }
156
+ // Return type is a union so WaaS connectors can override with a richer
157
+ // `{ txHash, balanceAfter }` result while injected/external connectors keep
158
+ // the simple fire-and-forget `void` behavior.
118
159
  submitTransaction(serializedTransaction) {
119
160
  return __awaiter(this, void 0, void 0, function* () {
120
161
  const api = yield this.getConnectedAPI();
package/src/index.cjs CHANGED
@@ -16,10 +16,12 @@ var toMidnightNetworks = require('./utils/toMidnightNetworks/toMidnightNetworks.
16
16
  var constants = require('./constants.cjs');
17
17
  var formatMidnightNativeUnshieldedBalance = require('./utils/formatMidnightNativeUnshieldedBalance/formatMidnightNativeUnshieldedBalance.cjs');
18
18
  var formatMidnightConnectorDustBalance = require('./utils/formatMidnightConnectorDustBalance/formatMidnightConnectorDustBalance.cjs');
19
- var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
19
+ var DynamicWaasMidnightConnector = require('./waas/connector/DynamicWaasMidnightConnector.cjs');
20
+ var DynamicWaasMidnightConnectors = require('./waas/DynamicWaasMidnightConnectors.cjs');
21
+ var WaasMidnightWalletConnector = require('./waas/WaasMidnightWalletConnector.cjs');
22
+ var isMidnightWallet = require('./waas/isMidnightWallet.cjs');
20
23
 
21
24
  /* istanbul ignore file */
22
- /* istanbul ignore next */
23
25
  assertPackageVersion.assertPackageVersion('@dynamic-labs/midnight', _package.version);
24
26
 
25
27
  exports.MidnightWalletConnectors = MidnightWalletConnectors.MidnightWalletConnectors;
@@ -39,7 +41,7 @@ exports.MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS = constants.MIDNIGHT_NATIVE_UNSHIELD
39
41
  exports.MIDNIGHT_NETWORKS = constants.MIDNIGHT_NETWORKS;
40
42
  exports.formatMidnightNativeUnshieldedBalance = formatMidnightNativeUnshieldedBalance.formatMidnightNativeUnshieldedBalance;
41
43
  exports.formatMidnightConnectorDustBalance = formatMidnightConnectorDustBalance.formatMidnightConnectorDustBalance;
42
- Object.defineProperty(exports, 'isMidnightWallet', {
43
- enumerable: true,
44
- get: function () { return walletConnectorCore.isMidnightWallet; }
45
- });
44
+ exports.DynamicWaasMidnightConnector = DynamicWaasMidnightConnector.DynamicWaasMidnightConnector;
45
+ exports.DynamicWaasMidnightConnectors = DynamicWaasMidnightConnectors.DynamicWaasMidnightConnectors;
46
+ exports.WaasMidnightWalletConnector = WaasMidnightWalletConnector.WaasMidnightWalletConnector;
47
+ exports.isMidnightWallet = isMidnightWallet.isMidnightWallet;
package/src/index.d.ts CHANGED
@@ -10,4 +10,4 @@ export * from './constants';
10
10
  export { formatMidnightNativeUnshieldedBalance } from './utils/formatMidnightNativeUnshieldedBalance';
11
11
  export { formatMidnightConnectorDustBalance } from './utils/formatMidnightConnectorDustBalance';
12
12
  export * from './types';
13
- export { isMidnightWallet } from './wallet/isMidnightWallet';
13
+ export * from './waas';
package/src/index.js CHANGED
@@ -12,8 +12,10 @@ export { toMidnightNetworks } from './utils/toMidnightNetworks/toMidnightNetwork
12
12
  export { MIDNIGHT_CHAIN, MIDNIGHT_DUST_BALANCE_SPECK_DECIMALS, MIDNIGHT_NATIVE_SHIELDED_TOKEN_TYPE, MIDNIGHT_NATIVE_TOKEN_TYPE, MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS, MIDNIGHT_NETWORKS } from './constants.js';
13
13
  export { formatMidnightNativeUnshieldedBalance } from './utils/formatMidnightNativeUnshieldedBalance/formatMidnightNativeUnshieldedBalance.js';
14
14
  export { formatMidnightConnectorDustBalance } from './utils/formatMidnightConnectorDustBalance/formatMidnightConnectorDustBalance.js';
15
- export { isMidnightWallet } from '@dynamic-labs/wallet-connector-core';
15
+ export { DynamicWaasMidnightConnector } from './waas/connector/DynamicWaasMidnightConnector.js';
16
+ export { DynamicWaasMidnightConnectors } from './waas/DynamicWaasMidnightConnectors.js';
17
+ export { WaasMidnightWalletConnector } from './waas/WaasMidnightWalletConnector.js';
18
+ export { isMidnightWallet } from './waas/isMidnightWallet.js';
16
19
 
17
20
  /* istanbul ignore file */
18
- /* istanbul ignore next */
19
21
  assertPackageVersion('@dynamic-labs/midnight', version);
package/src/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { GenericNetwork, WalletMetadata } from '@dynamic-labs/types';
2
- import { WalletBookSchema } from '@dynamic-labs/wallet-book';
1
+ import type { GenericNetwork, WalletMetadata, WalletUiUtils } from '@dynamic-labs/types';
2
+ import type { WalletBookSchema } from '@dynamic-labs/wallet-book';
3
+ import type { InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
3
4
  import { MIDNIGHT_NETWORKS } from './constants';
4
5
  export type MidnightNetwork = Omit<GenericNetwork, 'chainId'> & {
5
6
  chainId: string;
@@ -44,3 +45,11 @@ export type MidnightWalletConnectorOpts = {
44
45
  walletBook: WalletBookSchema;
45
46
  metadata?: WalletMetadata;
46
47
  };
48
+ export interface MidnightWalletConnectorProps {
49
+ metadata?: WalletMetadata;
50
+ walletBook: WalletBookSchema;
51
+ midnightNetworks?: GenericNetwork[];
52
+ }
53
+ export interface DynamicWaasMidnightConnectorProps extends MidnightWalletConnectorProps {
54
+ walletUiUtils: WalletUiUtils<InternalWalletConnector>;
55
+ }
@@ -0,0 +1,109 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var constants = require('../../constants.cjs');
8
+ var formatMidnightAtomicBalance = require('../formatMidnightAtomicBalance/formatMidnightAtomicBalance.cjs');
9
+ var parseMidnightAtomicAmount = require('../parseMidnightAtomicAmount/parseMidnightAtomicAmount.cjs');
10
+
11
+ class MidnightUiTransaction {
12
+ constructor(opts) {
13
+ this.to = undefined;
14
+ this.value = undefined;
15
+ this.data = undefined;
16
+ this.receipt = undefined;
17
+ this.chain = 'MIDNIGHT';
18
+ this.fee = { gas: undefined };
19
+ this.feeTokenSymbol = 'DUST';
20
+ this.pool = 'unshielded';
21
+ this.from = opts.from;
22
+ this.onSubmitFn = opts.onSubmit;
23
+ this.getUnshieldedBalanceFn = opts.getUnshieldedBalance;
24
+ this.getShieldedBalanceFn = opts.getShieldedBalance;
25
+ this.fetchDustFeeFn = opts.fetchDustFee;
26
+ }
27
+ get activePool() {
28
+ return this.pool;
29
+ }
30
+ setSelectedToken(contractAddress) {
31
+ this.pool =
32
+ contractAddress === constants.MIDNIGHT_NATIVE_SHIELDED_TOKEN_TYPE
33
+ ? 'shielded'
34
+ : 'unshielded';
35
+ this.to = undefined;
36
+ this.value = undefined;
37
+ }
38
+ getSendableTokenBalances() {
39
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
40
+ const [unshieldedRaw, shieldedRaw] = yield Promise.all([
41
+ this.getUnshieldedBalanceFn(),
42
+ this.getShieldedBalanceFn(),
43
+ ]);
44
+ const toDisplay = (raw) => Number(formatMidnightAtomicBalance.formatMidnightAtomicBalance(raw, constants.MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS));
45
+ return [
46
+ {
47
+ address: constants.MIDNIGHT_NATIVE_TOKEN_TYPE,
48
+ balance: toDisplay(unshieldedRaw),
49
+ decimals: constants.MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS,
50
+ isNative: true,
51
+ logoURI: '',
52
+ name: 'NIGHT (Unshielded)',
53
+ rawBalance: Number(unshieldedRaw),
54
+ rawBalanceString: unshieldedRaw.toString(),
55
+ symbol: 'NIGHT',
56
+ },
57
+ {
58
+ address: constants.MIDNIGHT_NATIVE_SHIELDED_TOKEN_TYPE,
59
+ balance: toDisplay(shieldedRaw),
60
+ decimals: constants.MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS,
61
+ isNative: true,
62
+ logoURI: '',
63
+ name: 'NIGHT (Shielded)',
64
+ rawBalance: Number(shieldedRaw),
65
+ rawBalanceString: shieldedRaw.toString(),
66
+ symbol: 'NIGHT',
67
+ },
68
+ ];
69
+ });
70
+ }
71
+ parse(input) {
72
+ return parseMidnightAtomicAmount.parseMidnightAtomicAmount(input, constants.MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS);
73
+ }
74
+ format(value) {
75
+ return formatMidnightAtomicBalance.formatMidnightAtomicBalance(value, constants.MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS);
76
+ }
77
+ getBalance() {
78
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
79
+ return this.pool === 'shielded'
80
+ ? this.getShieldedBalanceFn()
81
+ : this.getUnshieldedBalanceFn();
82
+ });
83
+ }
84
+ fetchFee() {
85
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
86
+ this.fee.gas = yield this.fetchDustFeeFn();
87
+ });
88
+ }
89
+ validateAddressFormat(address) {
90
+ if (this.pool === 'shielded') {
91
+ return address.startsWith('mn_shield');
92
+ }
93
+ return address.length > 0 && !address.startsWith('mn_shield');
94
+ }
95
+ submit() {
96
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
97
+ if (this.to === undefined || this.value === undefined) {
98
+ throw new Error('MidnightUiTransaction: to and value must be set before submitting');
99
+ }
100
+ // Return the tx hash so the Send flow's onSuccess(txHash) advances to the
101
+ // success view (it bails on a falsy hash and stays on the confirm screen).
102
+ const receipt = yield this.onSubmitFn(this);
103
+ this.receipt = receipt;
104
+ return receipt;
105
+ });
106
+ }
107
+ }
108
+
109
+ exports.MidnightUiTransaction = MidnightUiTransaction;
@@ -3,7 +3,7 @@ import type { IUITransaction } from '@dynamic-labs/types';
3
3
  type MidnightPool = 'unshielded' | 'shielded';
4
4
  type MidnightUiTransactionOpts = {
5
5
  from: string;
6
- onSubmit: (tx: MidnightUiTransaction) => Promise<void>;
6
+ onSubmit: (tx: MidnightUiTransaction) => Promise<string>;
7
7
  getUnshieldedBalance: () => Promise<bigint>;
8
8
  getShieldedBalance: () => Promise<bigint>;
9
9
  fetchDustFee: () => Promise<bigint>;
@@ -33,6 +33,6 @@ export declare class MidnightUiTransaction implements IUITransaction {
33
33
  getBalance(): Promise<bigint>;
34
34
  fetchFee(): Promise<void>;
35
35
  validateAddressFormat(address: string): boolean;
36
- submit(): Promise<void>;
36
+ submit(): Promise<string>;
37
37
  }
38
38
  export {};
@@ -0,0 +1,105 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { MIDNIGHT_NATIVE_SHIELDED_TOKEN_TYPE, MIDNIGHT_NATIVE_TOKEN_TYPE, MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS } from '../../constants.js';
4
+ import { formatMidnightAtomicBalance } from '../formatMidnightAtomicBalance/formatMidnightAtomicBalance.js';
5
+ import { parseMidnightAtomicAmount } from '../parseMidnightAtomicAmount/parseMidnightAtomicAmount.js';
6
+
7
+ class MidnightUiTransaction {
8
+ constructor(opts) {
9
+ this.to = undefined;
10
+ this.value = undefined;
11
+ this.data = undefined;
12
+ this.receipt = undefined;
13
+ this.chain = 'MIDNIGHT';
14
+ this.fee = { gas: undefined };
15
+ this.feeTokenSymbol = 'DUST';
16
+ this.pool = 'unshielded';
17
+ this.from = opts.from;
18
+ this.onSubmitFn = opts.onSubmit;
19
+ this.getUnshieldedBalanceFn = opts.getUnshieldedBalance;
20
+ this.getShieldedBalanceFn = opts.getShieldedBalance;
21
+ this.fetchDustFeeFn = opts.fetchDustFee;
22
+ }
23
+ get activePool() {
24
+ return this.pool;
25
+ }
26
+ setSelectedToken(contractAddress) {
27
+ this.pool =
28
+ contractAddress === MIDNIGHT_NATIVE_SHIELDED_TOKEN_TYPE
29
+ ? 'shielded'
30
+ : 'unshielded';
31
+ this.to = undefined;
32
+ this.value = undefined;
33
+ }
34
+ getSendableTokenBalances() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const [unshieldedRaw, shieldedRaw] = yield Promise.all([
37
+ this.getUnshieldedBalanceFn(),
38
+ this.getShieldedBalanceFn(),
39
+ ]);
40
+ const toDisplay = (raw) => Number(formatMidnightAtomicBalance(raw, MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS));
41
+ return [
42
+ {
43
+ address: MIDNIGHT_NATIVE_TOKEN_TYPE,
44
+ balance: toDisplay(unshieldedRaw),
45
+ decimals: MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS,
46
+ isNative: true,
47
+ logoURI: '',
48
+ name: 'NIGHT (Unshielded)',
49
+ rawBalance: Number(unshieldedRaw),
50
+ rawBalanceString: unshieldedRaw.toString(),
51
+ symbol: 'NIGHT',
52
+ },
53
+ {
54
+ address: MIDNIGHT_NATIVE_SHIELDED_TOKEN_TYPE,
55
+ balance: toDisplay(shieldedRaw),
56
+ decimals: MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS,
57
+ isNative: true,
58
+ logoURI: '',
59
+ name: 'NIGHT (Shielded)',
60
+ rawBalance: Number(shieldedRaw),
61
+ rawBalanceString: shieldedRaw.toString(),
62
+ symbol: 'NIGHT',
63
+ },
64
+ ];
65
+ });
66
+ }
67
+ parse(input) {
68
+ return parseMidnightAtomicAmount(input, MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS);
69
+ }
70
+ format(value) {
71
+ return formatMidnightAtomicBalance(value, MIDNIGHT_NATIVE_UNSHIELDED_DECIMALS);
72
+ }
73
+ getBalance() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ return this.pool === 'shielded'
76
+ ? this.getShieldedBalanceFn()
77
+ : this.getUnshieldedBalanceFn();
78
+ });
79
+ }
80
+ fetchFee() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ this.fee.gas = yield this.fetchDustFeeFn();
83
+ });
84
+ }
85
+ validateAddressFormat(address) {
86
+ if (this.pool === 'shielded') {
87
+ return address.startsWith('mn_shield');
88
+ }
89
+ return address.length > 0 && !address.startsWith('mn_shield');
90
+ }
91
+ submit() {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ if (this.to === undefined || this.value === undefined) {
94
+ throw new Error('MidnightUiTransaction: to and value must be set before submitting');
95
+ }
96
+ // Return the tx hash so the Send flow's onSuccess(txHash) advances to the
97
+ // success view (it bails on a falsy hash and stays on the confirm screen).
98
+ const receipt = yield this.onSubmitFn(this);
99
+ this.receipt = receipt;
100
+ return receipt;
101
+ });
102
+ }
103
+ }
104
+
105
+ export { MidnightUiTransaction };
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicWaasMidnightConnector = require('./connector/DynamicWaasMidnightConnector.cjs');
7
+
8
+ /**
9
+ * Factory function to create Midnight WaaS connectors.
10
+ * Returns an array of connector classes for use with the Dynamic SDK.
11
+ */
12
+ const DynamicWaasMidnightConnectors = () => [
13
+ DynamicWaasMidnightConnector.DynamicWaasMidnightConnector,
14
+ ];
15
+
16
+ exports.DynamicWaasMidnightConnectors = DynamicWaasMidnightConnectors;
@@ -0,0 +1,6 @@
1
+ import { DynamicWaasMidnightConnector } from './connector/DynamicWaasMidnightConnector';
2
+ /**
3
+ * Factory function to create Midnight WaaS connectors.
4
+ * Returns an array of connector classes for use with the Dynamic SDK.
5
+ */
6
+ export declare const DynamicWaasMidnightConnectors: () => (typeof DynamicWaasMidnightConnector)[];
@@ -0,0 +1,12 @@
1
+ 'use client'
2
+ import { DynamicWaasMidnightConnector } from './connector/DynamicWaasMidnightConnector.js';
3
+
4
+ /**
5
+ * Factory function to create Midnight WaaS connectors.
6
+ * Returns an array of connector classes for use with the Dynamic SDK.
7
+ */
8
+ const DynamicWaasMidnightConnectors = () => [
9
+ DynamicWaasMidnightConnector,
10
+ ];
11
+
12
+ export { DynamicWaasMidnightConnectors };