@n1xyz/wallet-widget 0.0.29 → 0.0.30

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 (131) hide show
  1. package/README.md +89 -11
  2. package/dist/Logic/sessionManager.js +8 -8
  3. package/dist/Logic/sessionManager.js.map +1 -1
  4. package/dist/Logic/transactionManager.d.ts +0 -22
  5. package/dist/Logic/transactionManager.js +0 -189
  6. package/dist/Logic/transactionManager.js.map +1 -1
  7. package/dist/Logic/utils.d.ts +3 -7
  8. package/dist/Logic/utils.js +3 -186
  9. package/dist/Logic/utils.js.map +1 -1
  10. package/dist/Modal/LoadingFallback.js +1 -1
  11. package/dist/Modal/LoadingFallback.js.map +1 -1
  12. package/dist/Modal/N1WalletModal.d.ts +1 -1
  13. package/dist/Modal/N1WalletModal.js +50 -205
  14. package/dist/Modal/N1WalletModal.js.map +1 -1
  15. package/dist/Modal/NTSFlow/views/CreateSessionView.d.ts +1 -1
  16. package/dist/Modal/NordFlow/NordFlow.js +44 -17
  17. package/dist/Modal/NordFlow/NordFlow.js.map +1 -1
  18. package/dist/Modal/NordFlow/components/ChainButton.d.ts +5 -2
  19. package/dist/Modal/NordFlow/components/ChainButton.js +16 -13
  20. package/dist/Modal/NordFlow/components/ChainButton.js.map +1 -1
  21. package/dist/Modal/NordFlow/components/EVMChainsButton.d.ts +2 -1
  22. package/dist/Modal/NordFlow/components/EVMChainsButton.js +11 -9
  23. package/dist/Modal/NordFlow/components/EVMChainsButton.js.map +1 -1
  24. package/dist/Modal/NordFlow/components/Header.d.ts +3 -1
  25. package/dist/Modal/NordFlow/components/Header.js +38 -4
  26. package/dist/Modal/NordFlow/components/Header.js.map +1 -1
  27. package/dist/Modal/NordFlow/components/ImageWithFallback.js +1 -1
  28. package/dist/Modal/NordFlow/components/ImageWithFallback.js.map +1 -1
  29. package/dist/Modal/NordFlow/components/MoreButton.d.ts +1 -1
  30. package/dist/Modal/NordFlow/components/MoreButton.js +4 -4
  31. package/dist/Modal/NordFlow/components/MoreButton.js.map +1 -1
  32. package/dist/Modal/NordFlow/components/TransactionTable.d.ts +1 -1
  33. package/dist/Modal/NordFlow/components/TransactionTable.js +11 -11
  34. package/dist/Modal/NordFlow/components/TransactionTable.js.map +1 -1
  35. package/dist/Modal/NordFlow/components/WaitingMessage.d.ts +3 -1
  36. package/dist/Modal/NordFlow/components/WaitingMessage.js +14 -3
  37. package/dist/Modal/NordFlow/components/WaitingMessage.js.map +1 -1
  38. package/dist/Modal/NordFlow/components/index.d.ts +0 -1
  39. package/dist/Modal/NordFlow/components/index.js +0 -1
  40. package/dist/Modal/NordFlow/components/index.js.map +1 -1
  41. package/dist/Modal/NordFlow/constants.js +12 -48
  42. package/dist/Modal/NordFlow/constants.js.map +1 -1
  43. package/dist/Modal/NordFlow/context/DepositContext.js +112 -41
  44. package/dist/Modal/NordFlow/context/DepositContext.js.map +1 -1
  45. package/dist/Modal/NordFlow/context/FlowContext.d.ts +1 -0
  46. package/dist/Modal/NordFlow/context/FlowContext.js +99 -6
  47. package/dist/Modal/NordFlow/context/FlowContext.js.map +1 -1
  48. package/dist/Modal/NordFlow/context/WalletConnectContext.js +76 -20
  49. package/dist/Modal/NordFlow/context/WalletConnectContext.js.map +1 -1
  50. package/dist/Modal/NordFlow/hoc/withImageFallback.js.map +1 -1
  51. package/dist/Modal/NordFlow/hooks/useTestnetFaucet.d.ts +2 -1
  52. package/dist/Modal/NordFlow/hooks/useTestnetFaucet.js +26 -7
  53. package/dist/Modal/NordFlow/hooks/useTestnetFaucet.js.map +1 -1
  54. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.d.ts +1 -1
  55. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js +10 -15
  56. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js.map +1 -1
  57. package/dist/Modal/NordFlow/screens/02-ChainSelectionScreen.js +103 -54
  58. package/dist/Modal/NordFlow/screens/02-ChainSelectionScreen.js.map +1 -1
  59. package/dist/Modal/NordFlow/screens/03-AmountInputScreen.d.ts +1 -2
  60. package/dist/Modal/NordFlow/screens/03-AmountInputScreen.js +284 -60
  61. package/dist/Modal/NordFlow/screens/03-AmountInputScreen.js.map +1 -1
  62. package/dist/Modal/NordFlow/screens/04-DepositProgressScreen.js +2 -2
  63. package/dist/Modal/NordFlow/screens/04-DepositProgressScreen.js.map +1 -1
  64. package/dist/Modal/NordFlow/screens/05-DepositSuccessScreen.js +97 -110
  65. package/dist/Modal/NordFlow/screens/05-DepositSuccessScreen.js.map +1 -1
  66. package/dist/Modal/NordFlow/screens/06-AuthLoadingScreen.js +10 -8
  67. package/dist/Modal/NordFlow/screens/06-AuthLoadingScreen.js.map +1 -1
  68. package/dist/Modal/NordFlow/screens/index.d.ts +5 -9
  69. package/dist/Modal/NordFlow/screens/index.js +5 -9
  70. package/dist/Modal/NordFlow/screens/index.js.map +1 -1
  71. package/dist/Modal/NordFlow/types.d.ts +13 -3
  72. package/dist/Modal/NordFlow/types.js +4 -3
  73. package/dist/Modal/NordFlow/types.js.map +1 -1
  74. package/dist/Modal/NordFlow/utils/depositStorage.d.ts +4 -0
  75. package/dist/Modal/NordFlow/utils/depositStorage.js +48 -0
  76. package/dist/Modal/NordFlow/utils/depositStorage.js.map +1 -0
  77. package/dist/Modal/NordFlow/utils/nordUtils.d.ts +1 -1
  78. package/dist/Modal/NordFlow/utils/nordUtils.js +1 -1
  79. package/dist/Modal/NordFlow/utils/nordUtils.js.map +1 -1
  80. package/dist/Provider/LazyWalletProvider.d.ts +1 -1
  81. package/dist/Provider/LazyWalletProvider.js +38 -38
  82. package/dist/Provider/LazyWalletProvider.js.map +1 -1
  83. package/dist/Provider/N1WalletProvider.d.ts +2 -1
  84. package/dist/Provider/N1WalletProvider.js +85 -82
  85. package/dist/Provider/N1WalletProvider.js.map +1 -1
  86. package/dist/Provider/ShadowRootWrapper.d.ts +1 -1
  87. package/dist/Provider/WalletErrorBoundary.d.ts +9 -2
  88. package/dist/Provider/WalletErrorBoundary.js +19 -1
  89. package/dist/Provider/WalletErrorBoundary.js.map +1 -1
  90. package/dist/Provider/hooks/useNordUserInitialization.js +87 -35
  91. package/dist/Provider/hooks/useNordUserInitialization.js.map +1 -1
  92. package/dist/Provider/icons/CoinbaseWalletIcon.d.ts +1 -1
  93. package/dist/Provider/icons/ConnectionDotsSVG.d.ts +1 -1
  94. package/dist/Provider/icons/MetamaskIcon.d.ts +1 -1
  95. package/dist/Provider/icons/PhantomIcon.d.ts +1 -1
  96. package/dist/Provider/icons/UserIcon.d.ts +1 -1
  97. package/dist/Provider/icons/WalletConnectIcon.d.ts +1 -1
  98. package/dist/Provider/types.d.ts +18 -16
  99. package/dist/Provider/types.js +8 -2
  100. package/dist/Provider/types.js.map +1 -1
  101. package/dist/WidgetButton/N1ConnectButton.d.ts +1 -1
  102. package/dist/WidgetButton/N1ConnectButton.js +29 -10
  103. package/dist/WidgetButton/N1ConnectButton.js.map +1 -1
  104. package/dist/components/Logo.d.ts +2 -1
  105. package/dist/components/Logo.js +5 -2
  106. package/dist/components/Logo.js.map +1 -1
  107. package/dist/components/QRCodeLoader.d.ts +1 -1
  108. package/dist/components/QRCodeLoader.js +1 -1
  109. package/dist/components/QRCodeLoader.js.map +1 -1
  110. package/dist/components/logos/EVMChainsGroup.js +1 -1
  111. package/dist/components/logos/EVMChainsGroup.js.map +1 -1
  112. package/dist/components/logos/MoreChainsGroup.js +1 -1
  113. package/dist/components/logos/MoreChainsGroup.js.map +1 -1
  114. package/dist/components/logos/index.d.ts +0 -2
  115. package/dist/components/logos/index.js +0 -2
  116. package/dist/components/logos/index.js.map +1 -1
  117. package/dist/config/solana.d.ts +3 -15
  118. package/dist/config/solana.js +6 -29
  119. package/dist/config/solana.js.map +1 -1
  120. package/dist/embedded-main-css.d.ts +1 -1
  121. package/dist/embedded-main-css.js +1 -1
  122. package/dist/embedded-main-css.js.map +1 -1
  123. package/dist/index.d.ts +2 -0
  124. package/dist/index.js +2 -0
  125. package/dist/index.js.map +1 -1
  126. package/dist/main.css +2 -2
  127. package/dist/polyfills/windowEthereumGuard.d.ts +6 -0
  128. package/dist/polyfills/windowEthereumGuard.js +28 -0
  129. package/dist/polyfills/windowEthereumGuard.js.map +1 -0
  130. package/package.json +26 -11
  131. package/dist/utils/dynamicImports.d.ts +0 -25
package/README.md CHANGED
@@ -5,7 +5,7 @@ A React component library for integrating N1 wallet functionality into your appl
5
5
  ## Features
6
6
 
7
7
  - Wallet connection and authentication
8
- - Session management (Nord and NTS modes)
8
+ - Session management (Nord mode)
9
9
  - Transaction signing
10
10
  - Message signing
11
11
  - Balance display
@@ -13,6 +13,8 @@ A React component library for integrating N1 wallet functionality into your appl
13
13
  - Dark/light mode support
14
14
  - Customizable UI
15
15
 
16
+ > **Note:** As of this release the NTS flow and related SDK have been removed. The widget now targets the Nord experience exclusively.
17
+
16
18
  ## Installation
17
19
 
18
20
  ```bash
@@ -24,15 +26,39 @@ yarn add @n1xyz/wallet-widget
24
26
  ## Quick Start
25
27
 
26
28
  ```jsx
29
+ import { useEffect, useState } from 'react';
30
+ import { Connection } from '@solana/web3.js';
27
31
  import { N1WalletProvider, N1SessionMode } from '@n1xyz/wallet-widget';
28
32
  import { Nord } from '@n1xyz/nord-ts';
29
33
 
30
- // Initialize Nord client
31
- const nord = new Nord({
32
- // Your Nord configuration
33
- });
34
-
35
34
  function App() {
35
+ const [nord, setNord] = useState(null);
36
+
37
+ useEffect(() => {
38
+ let cancelled = false;
39
+
40
+ async function initNord() {
41
+ const client = await Nord.new({
42
+ webServerUrl: 'https://your-nord-web-server',
43
+ solanaConnection: new Connection('https://your-solana-rpc'),
44
+ app: 'bridge-verification-key',
45
+ });
46
+
47
+ if (!cancelled) {
48
+ setNord(client);
49
+ }
50
+ }
51
+
52
+ initNord();
53
+ return () => {
54
+ cancelled = true;
55
+ };
56
+ }, []);
57
+
58
+ if (!nord) {
59
+ return null;
60
+ }
61
+
36
62
  return (
37
63
  <N1WalletProvider
38
64
  providedSessionMode={N1SessionMode.Nord}
@@ -45,6 +71,14 @@ function App() {
45
71
  }
46
72
  ```
47
73
 
74
+ ## Nord Configuration
75
+
76
+ The widget expects a fully initialized `Nord` client. When using the example app (or wiring your own integration) configure:
77
+
78
+ - `NEXT_PUBLIC_NORD_SOLANA_URL`: the Solana RPC endpoint Nord will use.
79
+ - `NEXT_PUBLIC_NORD_WEB_SERVER_URL`: the Nord REST/web server host (used for all HTTP + WebSocket calls).
80
+ - `NEXT_PUBLIC_NORD_BRIDGE_VK`: the bridge verification key for your target environment.
81
+
48
82
  ## Usage
49
83
 
50
84
  The wallet widget provides a React context that can be accessed throughout your application to interact with the wallet functionality.
@@ -105,6 +139,31 @@ function SigningExample() {
105
139
  }
106
140
  ```
107
141
 
142
+ ### Starting the Deposit Flow After Authentication
143
+
144
+ When a user already has an authenticated Nord session you can bypass the connection/auth screens and jump straight into the deposit experience (chain selection → amount → progress → success) by calling `startDepositFlow()`:
145
+
146
+ ```tsx
147
+ import { useN1WalletContext } from '@n1xyz/wallet-widget';
148
+
149
+ function DepositButton() {
150
+ const { startDepositFlow } = useN1WalletContext();
151
+
152
+ const handleClick = () => {
153
+ const started = startDepositFlow();
154
+ if (!started) {
155
+ console.warn('Unable to start deposit flow until the user is authenticated.');
156
+ }
157
+ };
158
+
159
+ return (
160
+ <button onClick={handleClick}>Fund Account</button>
161
+ );
162
+ }
163
+ ```
164
+
165
+ This helper opens the modal (if it is not already visible), begins at the chain-selection screen, skips the auth loading step, and swaps the Deposit Success action button to `Close` so the user can exit immediately. No cache or `localStorage` entries are touched during this fast-path flow.
166
+
108
167
  ## API Reference
109
168
 
110
169
  ### N1WalletProvider Props
@@ -112,11 +171,12 @@ function SigningExample() {
112
171
  | Prop | Type | Required | Default | Description |
113
172
  |---------------------|------------------------------|----------|---------|----------------------------------------|
114
173
  | children | React.ReactNode | Yes | - | Child components |
115
- | providedSessionMode | N1SessionMode | Yes | - | Session mode (Nord or NTS) |
174
+ | providedSessionMode | N1SessionMode | Yes | - | Session mode (Nord only) |
116
175
  | appId | string | Yes | - | Your application ID |
117
176
  | darkMode | boolean | No | true | Enable dark mode UI |
118
177
  | onError | (error: WalletError) => void | No | - | Error handler callback |
119
178
  | faucetUrl | string | No | - | URL for faucet service |
179
+ | isTestnet | boolean | No | false | Enable testnet UX (faucet, warnings) |
120
180
  | nord | Nord | No | - | Nord instance (required for Nord mode) |
121
181
 
122
182
  ### N1SessionMode
@@ -124,7 +184,6 @@ function SigningExample() {
124
184
  ```typescript
125
185
  enum N1SessionMode {
126
186
  Nord,
127
- NTS
128
187
  }
129
188
  ```
130
189
 
@@ -142,12 +201,14 @@ The context provides the following values:
142
201
  | sessionMode | N1SessionMode | Current session mode |
143
202
  | sessionPubKey | Uint8Array | Session public key |
144
203
  | setShowLogin | (show: boolean) => void | Show/hide login modal |
204
+ | startDepositFlow | () => boolean | Start deposit-only flow once authenticated |
145
205
  | showLogin | boolean | Login modal visibility state |
146
206
  | signMessageWithSessionKey | (message: any) => Promise<any> | Sign message with session key |
147
207
  | signMessageWithWalletKey | (message: any) => Promise<any> | Sign message with wallet key |
148
208
  | signTransactionWithWalletKey | (transaction: any) => Promise<any> | Sign transaction with wallet key |
149
209
  | username | string | User's username |
150
210
  | walletPubKey | Uint8Array | Wallet public key |
211
+ | isTestnet | boolean | Indicates if widget runs on testnet |
151
212
 
152
213
  ## Error Handling
153
214
 
@@ -168,10 +229,26 @@ The wallet widget includes a built-in error boundary that catches and processes
168
229
 
169
230
  ## Examples
170
231
 
232
+ ### Next.js sandbox
233
+
234
+ An interactive Next.js playground lives in `examples/nextjs-wallet`. It lets you:
235
+
236
+ - launch the Nord modal via the floating connect button;
237
+ - inspect live wallet context state across routes;
238
+ - tweak the widget source in `src/` and watch the app hot-reload.
239
+
240
+ ```bash
241
+ pnpm install
242
+ cp examples/nextjs-wallet/.env.local.example examples/nextjs-wallet/.env.local
243
+ pnpm dev:example:next
244
+ # open http://localhost:4000
245
+ ```
246
+
171
247
  ### Nord Mode Integration
172
248
 
173
249
  ```jsx
174
250
  import { useEffect, useState } from 'react';
251
+ import { Connection } from '@solana/web3.js';
175
252
  import { N1WalletProvider, N1SessionMode } from '@n1xyz/wallet-widget';
176
253
  import { Nord } from '@n1xyz/nord-ts';
177
254
 
@@ -180,10 +257,11 @@ function App() {
180
257
 
181
258
  useEffect(() => {
182
259
  async function initNord() {
183
- const nordClient = new Nord({
184
- // Your Nord configuration
260
+ const nordClient = await Nord.new({
261
+ webServerUrl: 'https://your-nord-web-server',
262
+ solanaConnection: new Connection('https://your-solana-rpc'),
263
+ app: 'bridge-verification-key',
185
264
  });
186
- await nordClient.initialize();
187
265
  setNord(nordClient);
188
266
  }
189
267
 
@@ -18,15 +18,15 @@ export function getSessionKeys(walletPublicKey) {
18
18
  parsedData.ed25519PrivateKey = base64ToUint8Array(parsedData.ed25519PrivateKey);
19
19
  }
20
20
  // Convert sessionMode string to enum value
21
- if (typeof parsedData.sessionMode === 'string') {
22
- parsedData.sessionMode =
23
- parsedData.sessionMode === N1SessionMode.Nord.toString()
24
- ? N1SessionMode.Nord
25
- : N1SessionMode.NTS;
21
+ var storedSessionMode = parsedData.sessionMode;
22
+ if (storedSessionMode === N1SessionMode.Nord ||
23
+ storedSessionMode === N1SessionMode.Nord.toString() ||
24
+ storedSessionMode === 'Nord') {
25
+ parsedData.sessionMode = N1SessionMode.Nord;
26
26
  }
27
- else if (parsedData.sessionMode === undefined) {
28
- // For backward compatibility, default to NTS mode if not specified
29
- parsedData.sessionMode = N1SessionMode.NTS;
27
+ else {
28
+ logger.warn('Encountered legacy session mode. Defaulting to Nord session mode.');
29
+ parsedData.sessionMode = N1SessionMode.Nord;
30
30
  }
31
31
  return parsedData;
32
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sessionManager.js","sourceRoot":"","sources":["../../src/Logic/sessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAa7C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,eAAuB;IACpD,IAAM,UAAU,GAAG,wBAAiB,eAAe,CAAE,CAAC;IAEtD,IAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,iBAAiB,EAAE,CAAC;YACjC,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAC/C,UAAU,CAAC,iBAAiB,CAC7B,CAAC;QACJ,CAAC;QAED,2CAA2C;QAC3C,IAAI,OAAO,UAAU,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC/C,UAAU,CAAC,WAAW;gBACpB,UAAU,CAAC,WAAW,KAAK,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE;oBACtD,CAAC,CAAC,aAAa,CAAC,IAAI;oBACpB,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC;QAC1B,CAAC;aAAM,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAChD,mEAAmE;YACnE,UAAU,CAAC,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;QAC7C,CAAC;QAED,OAAO,UAA4B,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { N1SessionMode } from '../Provider/types';\nimport { logger } from '../utils/logger';\nimport { base64ToUint8Array } from './utils';\n\n/**\n * Interface for session key data stored in local storage\n */\nexport interface SessionKeyData {\n ed25519PrivateKey: Uint8Array;\n walletPublicKey: string;\n chainName: string;\n createdAt: string;\n sessionMode: N1SessionMode;\n}\n\n/**\n * Retrieve session keys from local storage\n * @param walletPublicKey The wallet public key to retrieve session keys for\n * @returns The session key data or null if not found\n */\nexport function getSessionKeys(walletPublicKey: string): SessionKeyData | null {\n const storageKey = `n1_sessionKey_${walletPublicKey}`;\n\n const data = localStorage.getItem(storageKey);\n if (!data) {\n return null;\n }\n\n try {\n const parsedData = JSON.parse(data);\n if (parsedData.ed25519PrivateKey) {\n parsedData.ed25519PrivateKey = base64ToUint8Array(\n parsedData.ed25519PrivateKey\n );\n }\n\n // Convert sessionMode string to enum value\n if (typeof parsedData.sessionMode === 'string') {\n parsedData.sessionMode =\n parsedData.sessionMode === N1SessionMode.Nord.toString()\n ? N1SessionMode.Nord\n : N1SessionMode.NTS;\n } else if (parsedData.sessionMode === undefined) {\n // For backward compatibility, default to NTS mode if not specified\n parsedData.sessionMode = N1SessionMode.NTS;\n }\n\n return parsedData as SessionKeyData;\n } catch (error) {\n logger.error('Failed to parse session key data', error);\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"sessionManager.js","sourceRoot":"","sources":["../../src/Logic/sessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAa7C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,eAAuB;IACpD,IAAM,UAAU,GAAG,wBAAiB,eAAe,CAAE,CAAC;IAEtD,IAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,iBAAiB,EAAE,CAAC;YACjC,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAC/C,UAAU,CAAC,iBAAiB,CAC7B,CAAC;QACJ,CAAC;QAED,2CAA2C;QAC3C,IAAM,iBAAiB,GAAG,UAAU,CAAC,WAAW,CAAC;QACjD,IACE,iBAAiB,KAAK,aAAa,CAAC,IAAI;YACxC,iBAAiB,KAAK,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE;YACnD,iBAAiB,KAAK,MAAM,EAC5B,CAAC;YACD,UAAU,CAAC,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CACT,mEAAmE,CACpE,CAAC;YACF,UAAU,CAAC,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;QAC9C,CAAC;QAED,OAAO,UAA4B,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { N1SessionMode } from '../Provider/types';\nimport { logger } from '../utils/logger';\nimport { base64ToUint8Array } from './utils';\n\n/**\n * Interface for session key data stored in local storage\n */\nexport interface SessionKeyData {\n ed25519PrivateKey: Uint8Array;\n walletPublicKey: string;\n chainName: string;\n createdAt: string;\n sessionMode: N1SessionMode;\n}\n\n/**\n * Retrieve session keys from local storage\n * @param walletPublicKey The wallet public key to retrieve session keys for\n * @returns The session key data or null if not found\n */\nexport function getSessionKeys(walletPublicKey: string): SessionKeyData | null {\n const storageKey = `n1_sessionKey_${walletPublicKey}`;\n\n const data = localStorage.getItem(storageKey);\n if (!data) {\n return null;\n }\n\n try {\n const parsedData = JSON.parse(data);\n if (parsedData.ed25519PrivateKey) {\n parsedData.ed25519PrivateKey = base64ToUint8Array(\n parsedData.ed25519PrivateKey\n );\n }\n\n // Convert sessionMode string to enum value\n const storedSessionMode = parsedData.sessionMode;\n if (\n storedSessionMode === N1SessionMode.Nord ||\n storedSessionMode === N1SessionMode.Nord.toString() ||\n storedSessionMode === 'Nord'\n ) {\n parsedData.sessionMode = N1SessionMode.Nord;\n } else {\n logger.warn(\n 'Encountered legacy session mode. Defaulting to Nord session mode.'\n );\n parsedData.sessionMode = N1SessionMode.Nord;\n }\n\n return parsedData as SessionKeyData;\n } catch (error) {\n logger.error('Failed to parse session key data', error);\n return null;\n }\n}\n"]}
@@ -1,14 +1,3 @@
1
- import { N1SessionMode } from '../Provider/types';
2
- /**
3
- * Interface for transaction data
4
- */
5
- export interface TransactionData {
6
- chainId: string;
7
- amount: string;
8
- tokenSymbol: string;
9
- walletAddress: string;
10
- sessionMode: N1SessionMode;
11
- }
12
1
  /**
13
2
  * Interface for transaction result
14
3
  */
@@ -24,18 +13,7 @@ export interface TransactionResult {
24
13
  explorerUrl?: string;
25
14
  error?: Error;
26
15
  }
27
- /**
28
- * Create and send a transaction
29
- * @param data Transaction data
30
- * @param signMessage Function to sign messages with wallet
31
- * @returns Transaction result
32
- */
33
- export declare function createAndSendTransaction(data: TransactionData, signMessage: (message: Uint8Array) => Promise<Uint8Array>): Promise<TransactionResult>;
34
16
  /**
35
17
  * Get explorer URL for a transaction
36
18
  */
37
19
  export declare function getExplorerUrl(transactionId: string): string;
38
- /**
39
- * Check transaction status
40
- */
41
- export declare function checkTransactionStatus(transactionId: string, chainId: string, sessionMode: N1SessionMode): Promise<'Completed' | 'Failed' | 'Pending'>;
@@ -1,165 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { N1SessionMode } from '../Provider/types';
38
- import { logger } from '../utils/logger';
39
- import { WalletError, WalletErrorCode } from '../errors/types';
40
- import { getSessionKeys } from './sessionManager';
41
- /**
42
- * Create and send a transaction
43
- * @param data Transaction data
44
- * @param signMessage Function to sign messages with wallet
45
- * @returns Transaction result
46
- */
47
- export function createAndSendTransaction(data, signMessage) {
48
- return __awaiter(this, void 0, void 0, function () {
49
- var sessionKeys, error_1;
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0:
53
- logger.debug('Creating and sending transaction', data);
54
- _a.label = 1;
55
- case 1:
56
- _a.trys.push([1, 6, , 7]);
57
- sessionKeys = getSessionKeys(data.walletAddress);
58
- if (!sessionKeys) {
59
- throw new WalletError(WalletErrorCode.SESSION_INITIALIZATION_FAILED, 'No valid session keys found');
60
- }
61
- // Ensure session mode matches
62
- if (sessionKeys.sessionMode !== data.sessionMode) {
63
- throw new WalletError(WalletErrorCode.INVALID_CHAIN, "Session mode mismatch: expected ".concat(data.sessionMode, ", got ").concat(sessionKeys.sessionMode));
64
- }
65
- if (!(data.sessionMode === N1SessionMode.Nord)) return [3 /*break*/, 3];
66
- return [4 /*yield*/, createAndSendNordTransaction(data, signMessage)];
67
- case 2: return [2 /*return*/, _a.sent()];
68
- case 3: return [4 /*yield*/, createAndSendNTSTransaction(data, signMessage)];
69
- case 4: return [2 /*return*/, _a.sent()];
70
- case 5: return [3 /*break*/, 7];
71
- case 6:
72
- error_1 = _a.sent();
73
- logger.error('Failed to create and send transaction', error_1);
74
- throw error_1 instanceof WalletError
75
- ? error_1
76
- : new WalletError(WalletErrorCode.TRANSACTION_FAILED, 'Failed to create and send transaction', { originalError: error_1 });
77
- case 7: return [2 /*return*/];
78
- }
79
- });
80
- });
81
- }
82
- /**
83
- * Create and send a Nord transaction
84
- * This is a placeholder implementation that will be replaced with the actual Nord transaction logic
85
- */
86
- function createAndSendNordTransaction(data, signMessage) {
87
- return __awaiter(this, void 0, void 0, function () {
88
- var transactionId;
89
- return __generator(this, function (_a) {
90
- logger.debug('Creating and sending Nord transaction', data);
91
- transactionId = "nord_".concat(Math.random().toString(36).substring(2, 15));
92
- // In a real implementation, this would:
93
- // 1. Build a transaction for the Nord network
94
- // 2. Sign it with the session key
95
- // 3. Send it to the Nord API
96
- // 4. Wait for confirmation
97
- return [2 /*return*/, {
98
- success: true,
99
- transactionId: transactionId,
100
- amount: data.amount,
101
- tokenSymbol: data.tokenSymbol,
102
- fromAddress: data.walletAddress,
103
- toAddress: 'Your Account',
104
- networkName: getNetworkName(data.chainId),
105
- status: 'Completed',
106
- explorerUrl: "https://explorer.nord.network/tx/".concat(transactionId),
107
- }];
108
- });
109
- });
110
- }
111
- /**
112
- * Create and send an NTS transaction
113
- * This is a placeholder implementation that will be replaced with the actual NTS transaction logic
114
- */
115
- function createAndSendNTSTransaction(data, signMessage) {
116
- return __awaiter(this, void 0, void 0, function () {
117
- var transactionId;
118
- return __generator(this, function (_a) {
119
- switch (_a.label) {
120
- case 0:
121
- logger.debug('Creating and sending NTS transaction', data);
122
- // Simulate transaction processing time
123
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
124
- case 1:
125
- // Simulate transaction processing time
126
- _a.sent();
127
- transactionId = "nts_".concat(Math.random().toString(36).substring(2, 15));
128
- // In a real implementation, this would:
129
- // 1. Build a transaction for the NTS network
130
- // 2. Sign it with the session key
131
- // 3. Send it to the NTS API
132
- // 4. Wait for confirmation
133
- return [2 /*return*/, {
134
- success: true,
135
- transactionId: transactionId,
136
- amount: data.amount,
137
- tokenSymbol: data.tokenSymbol,
138
- fromAddress: data.walletAddress,
139
- toAddress: 'NTS Account',
140
- networkName: getNetworkName(data.chainId),
141
- status: 'Completed',
142
- explorerUrl: "https://explorer.nts.network/tx/".concat(transactionId),
143
- }];
144
- }
145
- });
146
- });
147
- }
148
- /**
149
- * Get network name from chain ID
150
- */
151
- function getNetworkName(chainId) {
152
- // Map chain IDs to network names
153
- var networkMap = {
154
- 'solana-mainnet': 'Solana Mainnet',
155
- 'solana-devnet': 'Solana Devnet',
156
- 'solana-testnet': 'Solana Testnet',
157
- 'ethereum-mainnet': 'Ethereum Mainnet',
158
- 'ethereum-goerli': 'Ethereum Goerli',
159
- 'ethereum-sepolia': 'Ethereum Sepolia',
160
- };
161
- return networkMap[chainId] || chainId;
162
- }
163
1
  /**
164
2
  * Get explorer URL for a transaction
165
3
  */
@@ -167,31 +5,4 @@ export function getExplorerUrl(transactionId) {
167
5
  var baseUrl = 'https://explorer.solana.com/tx/';
168
6
  return "".concat(baseUrl).concat(transactionId, "?cluster=devnet");
169
7
  }
170
- /**
171
- * Check transaction status
172
- */
173
- export function checkTransactionStatus(transactionId, chainId, sessionMode) {
174
- return __awaiter(this, void 0, void 0, function () {
175
- return __generator(this, function (_a) {
176
- switch (_a.label) {
177
- case 0:
178
- logger.debug('Checking transaction status', {
179
- transactionId: transactionId,
180
- chainId: chainId,
181
- sessionMode: sessionMode,
182
- });
183
- // In a real implementation, this would query the appropriate API based on session mode
184
- // For now, we'll simulate a successful transaction
185
- // Simulate processing time
186
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1000); })];
187
- case 1:
188
- // In a real implementation, this would query the appropriate API based on session mode
189
- // For now, we'll simulate a successful transaction
190
- // Simulate processing time
191
- _a.sent();
192
- return [2 /*return*/, 'Completed'];
193
- }
194
- });
195
- });
196
- }
197
8
  //# sourceMappingURL=transactionManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transactionManager.js","sourceRoot":"","sources":["../../src/Logic/transactionManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA6BlD;;;;;GAKG;AACH,MAAM,UAAgB,wBAAwB,CAC5C,IAAqB,EACrB,WAAyD;;;;;;oBAEzD,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;;;;oBAI/C,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;oBACvD,IAAI,CAAC,WAAW,EAAE,CAAC;wBACjB,MAAM,IAAI,WAAW,CACnB,eAAe,CAAC,6BAA6B,EAC7C,6BAA6B,CAC9B,CAAC;oBACJ,CAAC;oBAED,8BAA8B;oBAC9B,IAAI,WAAW,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;wBACjD,MAAM,IAAI,WAAW,CACnB,eAAe,CAAC,aAAa,EAC7B,0CAAmC,IAAI,CAAC,WAAW,mBAAS,WAAW,CAAC,WAAW,CAAE,CACtF,CAAC;oBACJ,CAAC;yBAGG,CAAA,IAAI,CAAC,WAAW,KAAK,aAAa,CAAC,IAAI,CAAA,EAAvC,wBAAuC;oBAClC,qBAAM,4BAA4B,CAAC,IAAI,EAAE,WAAW,CAAC,EAAA;wBAA5D,sBAAO,SAAqD,EAAC;wBAEtD,qBAAM,2BAA2B,CAAC,IAAI,EAAE,WAAW,CAAC,EAAA;wBAA3D,sBAAO,SAAoD,EAAC;;;;oBAG9D,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,OAAK,CAAC,CAAC;oBAC7D,MAAM,OAAK,YAAY,WAAW;wBAChC,CAAC,CAAC,OAAK;wBACP,CAAC,CAAC,IAAI,WAAW,CACb,eAAe,CAAC,kBAAkB,EAClC,uCAAuC,EACvC,EAAE,aAAa,EAAE,OAAK,EAAE,CACzB,CAAC;;;;;CAET;AAED;;;GAGG;AACH,SAAe,4BAA4B,CACzC,IAAqB,EACrB,WAAyD;;;;YAEzD,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,IAAI,CAAC,CAAC;YAGtD,aAAa,GAAG,eAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAE,CAAC;YAE5E,wCAAwC;YACxC,8CAA8C;YAC9C,kCAAkC;YAClC,6BAA6B;YAC7B,2BAA2B;YAE3B,sBAAO;oBACL,OAAO,EAAE,IAAI;oBACb,aAAa,eAAA;oBACb,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,WAAW,EAAE,IAAI,CAAC,WAAW;oBAC7B,WAAW,EAAE,IAAI,CAAC,aAAa;oBAC/B,SAAS,EAAE,cAAc;oBACzB,WAAW,EAAE,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;oBACzC,MAAM,EAAE,WAAW;oBACnB,WAAW,EAAE,2CAAoC,aAAa,CAAE;iBACjE,EAAC;;;CACH;AAED;;;GAGG;AACH,SAAe,2BAA2B,CACxC,IAAqB,EACrB,WAAyD;;;;;;oBAEzD,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAAC,CAAC;oBAE3D,uCAAuC;oBACvC,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAzB,CAAyB,CAAC,EAAA;;oBADzD,uCAAuC;oBACvC,SAAyD,CAAC;oBAGpD,aAAa,GAAG,cAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAE,CAAC;oBAE3E,wCAAwC;oBACxC,6CAA6C;oBAC7C,kCAAkC;oBAClC,4BAA4B;oBAC5B,2BAA2B;oBAE3B,sBAAO;4BACL,OAAO,EAAE,IAAI;4BACb,aAAa,eAAA;4BACb,MAAM,EAAE,IAAI,CAAC,MAAM;4BACnB,WAAW,EAAE,IAAI,CAAC,WAAW;4BAC7B,WAAW,EAAE,IAAI,CAAC,aAAa;4BAC/B,SAAS,EAAE,aAAa;4BACxB,WAAW,EAAE,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;4BACzC,MAAM,EAAE,WAAW;4BACnB,WAAW,EAAE,0CAAmC,aAAa,CAAE;yBAChE,EAAC;;;;CACH;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,iCAAiC;IACjC,IAAM,UAAU,GAA2B;QACzC,gBAAgB,EAAE,gBAAgB;QAClC,eAAe,EAAE,eAAe;QAChC,gBAAgB,EAAE,gBAAgB;QAClC,kBAAkB,EAAE,kBAAkB;QACtC,iBAAiB,EAAE,iBAAiB;QACpC,kBAAkB,EAAE,kBAAkB;KACvC,CAAC;IAEF,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,aAAqB;IAClD,IAAM,OAAO,GAAG,iCAAiC,CAAC;IAClD,OAAO,UAAG,OAAO,SAAG,aAAa,oBAAiB,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAgB,sBAAsB,CAC1C,aAAqB,EACrB,OAAe,EACf,WAA0B;;;;;oBAE1B,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE;wBAC1C,aAAa,eAAA;wBACb,OAAO,SAAA;wBACP,WAAW,aAAA;qBACZ,CAAC,CAAC;oBAEH,uFAAuF;oBACvF,mDAAmD;oBAEnD,2BAA2B;oBAC3B,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAzB,CAAyB,CAAC,EAAA;;oBAJzD,uFAAuF;oBACvF,mDAAmD;oBAEnD,2BAA2B;oBAC3B,SAAyD,CAAC;oBAE1D,sBAAO,WAAW,EAAC;;;;CACpB","sourcesContent":["import { N1SessionMode } from '../Provider/types';\nimport { logger } from '../utils/logger';\nimport { WalletError, WalletErrorCode } from '../errors/types';\nimport { getSessionKeys } from './sessionManager';\n\n/**\n * Interface for transaction data\n */\nexport interface TransactionData {\n chainId: string;\n amount: string;\n tokenSymbol: string;\n walletAddress: string;\n sessionMode: N1SessionMode;\n}\n\n/**\n * Interface for transaction result\n */\nexport interface TransactionResult {\n success: boolean;\n transactionId: string;\n amount: string;\n tokenSymbol: string;\n fromAddress: string;\n toAddress: string;\n networkName: string;\n status: 'Completed' | 'Failed' | 'Pending';\n explorerUrl?: string;\n error?: Error;\n}\n\n/**\n * Create and send a transaction\n * @param data Transaction data\n * @param signMessage Function to sign messages with wallet\n * @returns Transaction result\n */\nexport async function createAndSendTransaction(\n data: TransactionData,\n signMessage: (message: Uint8Array) => Promise<Uint8Array>\n): Promise<TransactionResult> {\n logger.debug('Creating and sending transaction', data);\n\n try {\n // Check if we have valid session keys\n const sessionKeys = getSessionKeys(data.walletAddress);\n if (!sessionKeys) {\n throw new WalletError(\n WalletErrorCode.SESSION_INITIALIZATION_FAILED,\n 'No valid session keys found'\n );\n }\n\n // Ensure session mode matches\n if (sessionKeys.sessionMode !== data.sessionMode) {\n throw new WalletError(\n WalletErrorCode.INVALID_CHAIN,\n `Session mode mismatch: expected ${data.sessionMode}, got ${sessionKeys.sessionMode}`\n );\n }\n\n // Handle transaction based on session mode\n if (data.sessionMode === N1SessionMode.Nord) {\n return await createAndSendNordTransaction(data, signMessage);\n } else {\n return await createAndSendNTSTransaction(data, signMessage);\n }\n } catch (error) {\n logger.error('Failed to create and send transaction', error);\n throw error instanceof WalletError\n ? error\n : new WalletError(\n WalletErrorCode.TRANSACTION_FAILED,\n 'Failed to create and send transaction',\n { originalError: error }\n );\n }\n}\n\n/**\n * Create and send a Nord transaction\n * This is a placeholder implementation that will be replaced with the actual Nord transaction logic\n */\nasync function createAndSendNordTransaction(\n data: TransactionData,\n signMessage: (message: Uint8Array) => Promise<Uint8Array>\n): Promise<TransactionResult> {\n logger.debug('Creating and sending Nord transaction', data);\n\n // Generate a transaction ID\n const transactionId = `nord_${Math.random().toString(36).substring(2, 15)}`;\n\n // In a real implementation, this would:\n // 1. Build a transaction for the Nord network\n // 2. Sign it with the session key\n // 3. Send it to the Nord API\n // 4. Wait for confirmation\n\n return {\n success: true,\n transactionId,\n amount: data.amount,\n tokenSymbol: data.tokenSymbol,\n fromAddress: data.walletAddress,\n toAddress: 'Your Account',\n networkName: getNetworkName(data.chainId),\n status: 'Completed',\n explorerUrl: `https://explorer.nord.network/tx/${transactionId}`,\n };\n}\n\n/**\n * Create and send an NTS transaction\n * This is a placeholder implementation that will be replaced with the actual NTS transaction logic\n */\nasync function createAndSendNTSTransaction(\n data: TransactionData,\n signMessage: (message: Uint8Array) => Promise<Uint8Array>\n): Promise<TransactionResult> {\n logger.debug('Creating and sending NTS transaction', data);\n\n // Simulate transaction processing time\n await new Promise((resolve) => setTimeout(resolve, 2000));\n\n // Generate a transaction ID\n const transactionId = `nts_${Math.random().toString(36).substring(2, 15)}`;\n\n // In a real implementation, this would:\n // 1. Build a transaction for the NTS network\n // 2. Sign it with the session key\n // 3. Send it to the NTS API\n // 4. Wait for confirmation\n\n return {\n success: true,\n transactionId,\n amount: data.amount,\n tokenSymbol: data.tokenSymbol,\n fromAddress: data.walletAddress,\n toAddress: 'NTS Account',\n networkName: getNetworkName(data.chainId),\n status: 'Completed',\n explorerUrl: `https://explorer.nts.network/tx/${transactionId}`,\n };\n}\n\n/**\n * Get network name from chain ID\n */\nfunction getNetworkName(chainId: string): string {\n // Map chain IDs to network names\n const networkMap: Record<string, string> = {\n 'solana-mainnet': 'Solana Mainnet',\n 'solana-devnet': 'Solana Devnet',\n 'solana-testnet': 'Solana Testnet',\n 'ethereum-mainnet': 'Ethereum Mainnet',\n 'ethereum-goerli': 'Ethereum Goerli',\n 'ethereum-sepolia': 'Ethereum Sepolia',\n };\n\n return networkMap[chainId] || chainId;\n}\n\n/**\n * Get explorer URL for a transaction\n */\nexport function getExplorerUrl(transactionId: string) {\n const baseUrl = 'https://explorer.solana.com/tx/';\n return `${baseUrl}${transactionId}?cluster=devnet`;\n}\n\n/**\n * Check transaction status\n */\nexport async function checkTransactionStatus(\n transactionId: string,\n chainId: string,\n sessionMode: N1SessionMode\n): Promise<'Completed' | 'Failed' | 'Pending'> {\n logger.debug('Checking transaction status', {\n transactionId,\n chainId,\n sessionMode,\n });\n\n // In a real implementation, this would query the appropriate API based on session mode\n // For now, we'll simulate a successful transaction\n\n // Simulate processing time\n await new Promise((resolve) => setTimeout(resolve, 1000));\n\n return 'Completed';\n}\n"]}
1
+ {"version":3,"file":"transactionManager.js","sourceRoot":"","sources":["../../src/Logic/transactionManager.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,aAAqB;IAClD,IAAM,OAAO,GAAG,iCAAiC,CAAC;IAClD,OAAO,UAAG,OAAO,SAAG,aAAa,oBAAiB,CAAC;AACrD,CAAC","sourcesContent":["/**\n * Interface for transaction result\n */\nexport interface TransactionResult {\n success: boolean;\n transactionId: string;\n amount: string;\n tokenSymbol: string;\n fromAddress: string;\n toAddress: string;\n networkName: string;\n status: 'Completed' | 'Failed' | 'Pending';\n explorerUrl?: string;\n error?: Error;\n}\n\n/**\n * Get explorer URL for a transaction\n */\nexport function getExplorerUrl(transactionId: string) {\n const baseUrl = 'https://explorer.solana.com/tx/';\n return `${baseUrl}${transactionId}?cluster=devnet`;\n}\n"]}
@@ -1,5 +1,6 @@
1
- import { generateSessionKeyPair, generateRandomUint8Array } from '@n1xyz/nts-sdk';
2
- export { generateSessionKeyPair, generateRandomUint8Array };
1
+ import { generateEd25519KeyPair, generateRandomUint8Array as createRandomUint8Array } from '../utils/ed25519';
2
+ export declare const generateSessionKeyPair: typeof generateEd25519KeyPair;
3
+ export declare const generateRandomUint8Array: typeof createRandomUint8Array;
3
4
  export declare function arrayBufferToBase64(buffer: Uint8Array): string;
4
5
  export declare function base64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
5
6
  export declare function storeSessionKeysInLocalStorage({ privKey, publicKey, walletPublicKey, chainName, }: {
@@ -16,8 +17,3 @@ export declare function getSessionKeysFromLocalStorage(walletPublicKey: string):
16
17
  createdAt: string;
17
18
  } | null;
18
19
  export declare function removeKeysFromLocalStorage(walletPublicKey: string): void;
19
- export declare function hexToUint8Array(hex: string): Uint8Array<ArrayBuffer>;
20
- export declare function createWebSession(signMessageWithSessionKey: any, sessionPubKey: any, walletPubKey: any): Promise<void>;
21
- export declare function createUser(username: any): Promise<void>;
22
- export declare function getUser(): Promise<any>;
23
- export declare function getUserBalances(address: string): Promise<any>;