@n1xyz/wallet-widget 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Logic/sessionManager.d.ts +1 -1
- package/dist/Logic/sessionManager.js +9 -5
- package/dist/Logic/transactionManager.js +7 -3
- package/dist/Logic/utils.js +9 -12
- package/dist/Modal/N1WalletModal.js +2 -3
- package/dist/Modal/NTSFlow/NTSFlow.js +7 -3
- package/dist/Modal/NTSFlow/components/BackButton.js +0 -1
- package/dist/Modal/NTSFlow/views/CreateSessionView.js +1 -1
- package/dist/Modal/NordFlow/NordFlow.js +27 -22
- package/dist/Modal/NordFlow/components/ChainButton.d.ts +1 -1
- package/dist/Modal/NordFlow/components/ChainButton.js +8 -8
- package/dist/Modal/NordFlow/components/EVMChainsButton.d.ts +8 -0
- package/dist/Modal/NordFlow/components/EVMChainsButton.js +18 -0
- package/dist/Modal/NordFlow/components/MoreButton.d.ts +8 -0
- package/dist/Modal/NordFlow/components/MoreButton.js +18 -0
- package/dist/Modal/NordFlow/components/TransactionTable.d.ts +1 -1
- package/dist/Modal/NordFlow/components/TransactionTable.js +8 -6
- package/dist/Modal/NordFlow/constants.js +9 -4
- package/dist/Modal/NordFlow/hooks/useDepositFlow.js +39 -18
- package/dist/Modal/NordFlow/hooks/useFlowState.js +5 -4
- package/dist/Modal/NordFlow/hooks/useNordInstance.js +17 -8
- package/dist/Modal/NordFlow/hooks/useNordWalletConnect.js +28 -20
- package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.js +1 -1
- package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.js +39 -23
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.d.ts +4 -1
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js +38 -16
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.d.ts +1 -1
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js +3 -2
- package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js +3 -1
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.d.ts +1 -1
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js +19 -10
- package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.d.ts +1 -1
- package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.js +3 -3
- package/dist/Modal/NordFlow/screens/09-ErrorScreen.d.ts +1 -1
- package/dist/Modal/NordFlow/screens/09-ErrorScreen.js +11 -6
- package/dist/Modal/NordFlow/types.d.ts +4 -1
- package/dist/Modal/NordFlow/types.js +1 -0
- package/dist/Modal/NordFlow/utils/imageUtils.js +3 -3
- package/dist/Modal/NordFlow/utils/nordUtils.js +3 -1
- package/dist/Modal/Sidebar/N1Sidebar.js +11 -5
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketOverview.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.js +7 -3
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketStats.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/NordTradingView.js +7 -7
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBook.js +27 -16
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookDepthVisualizer.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.js +3 -2
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.js +2 -3
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/AmountInput.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/BuySellTabs.js +2 -2
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.js +16 -13
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.js +17 -11
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/PriceInput.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.js +2 -2
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.d.ts +1 -1
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.js +3 -1
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.js +21 -11
- package/dist/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.js +1 -1
- package/dist/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.js +11 -6
- package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.js +14 -7
- package/dist/Provider/LazyWalletProvider.js +11 -5
- package/dist/Provider/N1WalletProvider.js +6 -5
- package/dist/components/logos/ArbitrumLogo.d.ts +8 -0
- package/dist/components/logos/ArbitrumLogo.js +5 -0
- package/dist/components/logos/BaseLogo.d.ts +8 -0
- package/dist/components/logos/BaseLogo.js +5 -0
- package/dist/components/logos/BeraLogo.d.ts +8 -0
- package/dist/components/logos/BeraLogo.js +5 -0
- package/dist/components/logos/BitcoinLogo.d.ts +8 -0
- package/dist/components/logos/BitcoinLogo.js +5 -0
- package/dist/components/logos/EVMChainsGroup.d.ts +7 -0
- package/dist/components/logos/EVMChainsGroup.js +18 -0
- package/dist/components/logos/EthereumLogo.d.ts +8 -0
- package/dist/components/logos/EthereumLogo.js +5 -0
- package/dist/components/logos/HyperliquidLogo.d.ts +8 -0
- package/dist/components/logos/HyperliquidLogo.js +5 -0
- package/dist/components/logos/MoreChainsGroup.d.ts +7 -0
- package/dist/components/logos/MoreChainsGroup.js +18 -0
- package/dist/components/logos/OptimismLogo.d.ts +8 -0
- package/dist/components/logos/OptimismLogo.js +5 -0
- package/dist/components/logos/SolanaLogo.d.ts +8 -0
- package/dist/components/logos/SolanaLogo.js +5 -0
- package/dist/components/logos/index.d.ts +10 -0
- package/dist/components/logos/index.js +10 -0
- package/dist/main.css +1 -1
- package/package.json +1 -1
|
@@ -37,11 +37,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { useCallback, useEffect, useState } from 'react';
|
|
38
38
|
import { FlowState } from '../types';
|
|
39
39
|
import { AVAILABLE_CHAINS } from '../constants';
|
|
40
|
-
import { getExplorerUrl } from '../../../Logic/transactionManager';
|
|
41
|
-
import { useN1WalletContext, useN1WalletInternalContext } from '../../../Provider/hooks';
|
|
40
|
+
import { getExplorerUrl, } from '../../../Logic/transactionManager';
|
|
41
|
+
import { useN1WalletContext, useN1WalletInternalContext, } from '../../../Provider/hooks';
|
|
42
42
|
import { N1SessionMode } from '../../../Provider/types';
|
|
43
43
|
import { isNordConfigured } from '../utils/nordUtils';
|
|
44
44
|
import { useNordInstance } from './useNordInstance';
|
|
45
|
+
import { logger } from '../../../utils/logger';
|
|
45
46
|
/**
|
|
46
47
|
* Hook for handling the deposit flow
|
|
47
48
|
*
|
|
@@ -117,14 +118,14 @@ export var useDepositFlow = function (options) {
|
|
|
117
118
|
* Start deposit process
|
|
118
119
|
*/
|
|
119
120
|
var startDeposit = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
|
-
var currentSessionMode, txId_1, usdcToken, accountInitialized, i, exists, result, depositError_1, error_1, error_2;
|
|
121
|
+
var currentSessionMode, txId_1, usdcToken, accountInitialized, i, exists, result, depositError_1, errorMessage, error_1, error_2;
|
|
121
122
|
var _a;
|
|
122
123
|
return __generator(this, function (_b) {
|
|
123
124
|
switch (_b.label) {
|
|
124
125
|
case 0:
|
|
125
126
|
if (isDepositing)
|
|
126
127
|
return [2 /*return*/];
|
|
127
|
-
|
|
128
|
+
logger.debug('tah dah!');
|
|
128
129
|
// Validate input
|
|
129
130
|
if (!selectedChain) {
|
|
130
131
|
handleError(new Error('No chain selected'));
|
|
@@ -183,7 +184,7 @@ export var useDepositFlow = function (options) {
|
|
|
183
184
|
if (!accountInitialized) {
|
|
184
185
|
throw new Error('Account failed to intialize on N1.');
|
|
185
186
|
}
|
|
186
|
-
|
|
187
|
+
logger.debug('Deposit successful using Nord-TS', txId_1);
|
|
187
188
|
// Make sure we have a valid chain ID
|
|
188
189
|
if (selectedChain) {
|
|
189
190
|
result = {
|
|
@@ -192,15 +193,17 @@ export var useDepositFlow = function (options) {
|
|
|
192
193
|
amount: amount,
|
|
193
194
|
tokenSymbol: 'USDC', // Default to USDC for now
|
|
194
195
|
fromAddress: address || 'Your Wallet',
|
|
195
|
-
toAddress: currentSessionMode === N1SessionMode.Nord
|
|
196
|
+
toAddress: currentSessionMode === N1SessionMode.Nord
|
|
197
|
+
? 'Exchange Account'
|
|
198
|
+
: 'NTS Account',
|
|
196
199
|
networkName: ((_a = AVAILABLE_CHAINS.find(function (chain) { return chain.id === selectedChain; })) === null || _a === void 0 ? void 0 : _a.name) || selectedChain,
|
|
197
200
|
status: 'Completed',
|
|
198
|
-
explorerUrl: getExplorerUrl(txId_1, selectedChain)
|
|
201
|
+
explorerUrl: getExplorerUrl(txId_1, selectedChain),
|
|
199
202
|
};
|
|
200
203
|
// Update state with transaction result
|
|
201
204
|
setTransactionId(txId_1);
|
|
202
205
|
setTransactionResult(result);
|
|
203
|
-
|
|
206
|
+
logger.debug('yayayyay');
|
|
204
207
|
setTxId(txId_1);
|
|
205
208
|
return [2 /*return*/]; // Exit the function early since we've handled everything
|
|
206
209
|
}
|
|
@@ -214,22 +217,28 @@ export var useDepositFlow = function (options) {
|
|
|
214
217
|
case 11: return [3 /*break*/, 13];
|
|
215
218
|
case 12:
|
|
216
219
|
depositError_1 = _b.sent();
|
|
217
|
-
|
|
220
|
+
logger.warn('Error using depositSpl, falling back to mock implementation:', depositError_1);
|
|
218
221
|
setIsDepositing(false);
|
|
219
|
-
|
|
222
|
+
errorMessage = depositError_1 instanceof Error
|
|
223
|
+
? depositError_1.message
|
|
224
|
+
: 'Failed to process deposit';
|
|
225
|
+
transition(FlowState.AMOUNT_INPUT, {
|
|
226
|
+
depositError: errorMessage
|
|
227
|
+
});
|
|
228
|
+
return [2 /*return*/]; // Exit early
|
|
220
229
|
case 13: return [3 /*break*/, 15];
|
|
221
230
|
case 14:
|
|
222
231
|
error_1 = _b.sent();
|
|
223
|
-
|
|
232
|
+
logger.error('Error using Nord-TS for deposit:', error_1);
|
|
224
233
|
throw error_1;
|
|
225
234
|
case 15: return [3 /*break*/, 17];
|
|
226
235
|
case 16:
|
|
227
|
-
|
|
236
|
+
logger.debug('Nord configuration issue:', {
|
|
228
237
|
hasNord: !!nord,
|
|
229
238
|
isConfigured: nord ? isNordConfigured(nord) : false,
|
|
230
239
|
hasAddress: !!address,
|
|
231
240
|
hasWalletSignFn: !!signMessageWithWalletKey,
|
|
232
|
-
hasSessionSignFn: !!signMessageWithSessionKey
|
|
241
|
+
hasSessionSignFn: !!signMessageWithSessionKey,
|
|
233
242
|
});
|
|
234
243
|
throw new Error('Nord is not configured or user is not initialized');
|
|
235
244
|
case 17: return [3 /*break*/, 19];
|
|
@@ -252,7 +261,7 @@ export var useDepositFlow = function (options) {
|
|
|
252
261
|
nord,
|
|
253
262
|
signMessageWithWalletKey,
|
|
254
263
|
signMessageWithSessionKey,
|
|
255
|
-
currentNordUser
|
|
264
|
+
currentNordUser,
|
|
256
265
|
]);
|
|
257
266
|
/**
|
|
258
267
|
* Complete the deposit process and move to the next screen
|
|
@@ -323,7 +332,9 @@ export var useDepositFlow = function (options) {
|
|
|
323
332
|
// Ensure we have a valid session mode
|
|
324
333
|
var currentSessionMode = sessionMode !== null && sessionMode !== void 0 ? sessionMode : N1SessionMode.NTS;
|
|
325
334
|
// Determine account type based on session mode
|
|
326
|
-
var accountType = currentSessionMode === N1SessionMode.Nord
|
|
335
|
+
var accountType = currentSessionMode === N1SessionMode.Nord
|
|
336
|
+
? 'Exchange Account'
|
|
337
|
+
: 'NTS Account';
|
|
327
338
|
if (!transactionResult) {
|
|
328
339
|
// If we don't have a transaction result yet, return default values
|
|
329
340
|
return {
|
|
@@ -331,7 +342,9 @@ export var useDepositFlow = function (options) {
|
|
|
331
342
|
tx: transactionId || 'Processing...',
|
|
332
343
|
from: address || 'Your Wallet',
|
|
333
344
|
to: accountType,
|
|
334
|
-
network: selectedChain
|
|
345
|
+
network: selectedChain
|
|
346
|
+
? ((_a = AVAILABLE_CHAINS.find(function (chain) { return chain.id === selectedChain; })) === null || _a === void 0 ? void 0 : _a.name) || selectedChain
|
|
347
|
+
: 'Unknown',
|
|
335
348
|
status: 'Processing',
|
|
336
349
|
explorerUrl: '',
|
|
337
350
|
};
|
|
@@ -344,9 +357,17 @@ export var useDepositFlow = function (options) {
|
|
|
344
357
|
to: transactionResult.toAddress,
|
|
345
358
|
network: transactionResult.networkName,
|
|
346
359
|
status: transactionResult.status,
|
|
347
|
-
explorerUrl: transactionResult.explorerUrl ||
|
|
360
|
+
explorerUrl: transactionResult.explorerUrl ||
|
|
361
|
+
getExplorerUrl(transactionResult.transactionId, selectedChain || ''),
|
|
348
362
|
};
|
|
349
|
-
}, [
|
|
363
|
+
}, [
|
|
364
|
+
transactionResult,
|
|
365
|
+
amount,
|
|
366
|
+
transactionId,
|
|
367
|
+
address,
|
|
368
|
+
sessionMode,
|
|
369
|
+
selectedChain,
|
|
370
|
+
]);
|
|
350
371
|
return {
|
|
351
372
|
selectedChain: selectedChain,
|
|
352
373
|
setSelectedChain: setSelectedChain,
|
|
@@ -13,6 +13,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
13
13
|
import { FlowState, initialFlowContext } from '../types';
|
|
14
14
|
import { STATE_TRANSITIONS } from '../constants';
|
|
15
15
|
import { clearStoredState, loadStateFromLocalStorage, saveStateToLocalStorage, } from '../utils/persistence';
|
|
16
|
+
import { logger } from '../../../utils/logger';
|
|
16
17
|
/**
|
|
17
18
|
* Custom hook for managing the wallet connection flow state machine
|
|
18
19
|
* @param options Configuration options
|
|
@@ -49,7 +50,7 @@ export var useFlowState = function (options) {
|
|
|
49
50
|
var transition = useCallback(function (targetState, contextUpdates) {
|
|
50
51
|
if (contextUpdates === void 0) { contextUpdates = {}; }
|
|
51
52
|
if (!canTransition(targetState, __assign(__assign({}, context), contextUpdates))) {
|
|
52
|
-
|
|
53
|
+
logger.warn("Transition from ".concat(state, " to ").concat(targetState, " is not allowed"));
|
|
53
54
|
return false;
|
|
54
55
|
}
|
|
55
56
|
setIsTransitioning(true);
|
|
@@ -62,7 +63,7 @@ export var useFlowState = function (options) {
|
|
|
62
63
|
});
|
|
63
64
|
// Then update state
|
|
64
65
|
setPrevState(state);
|
|
65
|
-
|
|
66
|
+
logger.debug(targetState, 'targetState');
|
|
66
67
|
setState(targetState);
|
|
67
68
|
if (onStateChange) {
|
|
68
69
|
onStateChange(targetState, state);
|
|
@@ -77,7 +78,7 @@ export var useFlowState = function (options) {
|
|
|
77
78
|
clearStoredState();
|
|
78
79
|
setContext(initialFlowContext);
|
|
79
80
|
setPrevState(null);
|
|
80
|
-
|
|
81
|
+
logger.debug('resetting');
|
|
81
82
|
setState(FlowState.IDLE);
|
|
82
83
|
if (onStateChange) {
|
|
83
84
|
onStateChange(FlowState.IDLE, state);
|
|
@@ -103,7 +104,7 @@ export var useFlowState = function (options) {
|
|
|
103
104
|
}
|
|
104
105
|
setContext(savedState.context);
|
|
105
106
|
setPrevState(state);
|
|
106
|
-
|
|
107
|
+
logger.debug(savedState.state, 'savedState.state');
|
|
107
108
|
setState(savedState.state);
|
|
108
109
|
if (onStateChange) {
|
|
109
110
|
onStateChange(savedState.state, state);
|
|
@@ -39,8 +39,8 @@ import { generateSessionKeyPair, signEd25519 } from '@n1xyz/nts-sdk';
|
|
|
39
39
|
import { PublicKey } from '@solana/web3.js';
|
|
40
40
|
import { useEffect } from 'react';
|
|
41
41
|
import { WalletError, WalletErrorCode } from '../../../errors/types';
|
|
42
|
-
import { getSessionKeysFromLocalStorage, storeSessionKeysInLocalStorage } from '../../../Logic/utils';
|
|
43
|
-
import { useN1WalletContext, useN1WalletInternalContext } from '../../../Provider/hooks';
|
|
42
|
+
import { getSessionKeysFromLocalStorage, storeSessionKeysInLocalStorage, } from '../../../Logic/utils';
|
|
43
|
+
import { useN1WalletContext, useN1WalletInternalContext, } from '../../../Provider/hooks';
|
|
44
44
|
import { logger } from '../../../utils/logger';
|
|
45
45
|
// Utility function to convert Uint8Array to base64 string
|
|
46
46
|
function arrayBufferToBase64(buffer) {
|
|
@@ -138,7 +138,7 @@ export var useNordInstance = function () {
|
|
|
138
138
|
sessionKeyPair_1 = {
|
|
139
139
|
privateKey: storedKeys.ed25519PrivateKey,
|
|
140
140
|
// For Ed25519, the public key is the second half of the private key
|
|
141
|
-
publicKey: tempKeyPair.publicKey
|
|
141
|
+
publicKey: tempKeyPair.publicKey,
|
|
142
142
|
};
|
|
143
143
|
return [3 /*break*/, 4];
|
|
144
144
|
case 3:
|
|
@@ -232,7 +232,9 @@ export var useNordInstance = function () {
|
|
|
232
232
|
if (storedSessionId !== null) {
|
|
233
233
|
// Convert the stored sessionId to BigInt
|
|
234
234
|
sessionId = BigInt(storedSessionId);
|
|
235
|
-
logger.debug('Found existing sessionId in localStorage', {
|
|
235
|
+
logger.debug('Found existing sessionId in localStorage', {
|
|
236
|
+
sessionId: storedSessionId,
|
|
237
|
+
});
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
240
|
}
|
|
@@ -248,7 +250,7 @@ export var useNordInstance = function () {
|
|
|
248
250
|
transactionSignFn: signTransactionWithWalletKey,
|
|
249
251
|
sessionId: sessionId, // Pass the sessionId if it exists
|
|
250
252
|
sessionPubKey: sessionPubKey,
|
|
251
|
-
publicKey: new PublicKey(address)
|
|
253
|
+
publicKey: new PublicKey(address),
|
|
252
254
|
});
|
|
253
255
|
_a.label = 3;
|
|
254
256
|
case 3:
|
|
@@ -289,7 +291,10 @@ export var useNordInstance = function () {
|
|
|
289
291
|
return __generator(this, function (_a) {
|
|
290
292
|
switch (_a.label) {
|
|
291
293
|
case 0:
|
|
292
|
-
if (!(signMessageWithWalletKey &&
|
|
294
|
+
if (!(signMessageWithWalletKey &&
|
|
295
|
+
signMessageWithSessionKey &&
|
|
296
|
+
signTransactionWithWalletKey &&
|
|
297
|
+
nordUser == null)) return [3 /*break*/, 2];
|
|
293
298
|
logger.debug('Dependencies available, initializing NordUser');
|
|
294
299
|
return [4 /*yield*/, createNordUser()];
|
|
295
300
|
case 1:
|
|
@@ -300,11 +305,15 @@ export var useNordInstance = function () {
|
|
|
300
305
|
});
|
|
301
306
|
}); };
|
|
302
307
|
initNordUser();
|
|
303
|
-
}, [
|
|
308
|
+
}, [
|
|
309
|
+
signMessageWithWalletKey,
|
|
310
|
+
signMessageWithSessionKey,
|
|
311
|
+
signTransactionWithWalletKey,
|
|
312
|
+
]);
|
|
304
313
|
return {
|
|
305
314
|
nord: nord,
|
|
306
315
|
createNordUser: createNordUser,
|
|
307
316
|
nordUser: nordUser,
|
|
308
|
-
createTransactionSignFunction: createTransactionSignFunction
|
|
317
|
+
createTransactionSignFunction: createTransactionSignFunction,
|
|
309
318
|
};
|
|
310
319
|
};
|
|
@@ -35,8 +35,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { useCallback, useEffect, useState, useRef } from 'react';
|
|
38
|
-
import { useN1WalletContext, useN1WalletInternalContext } from '../../../Provider/hooks';
|
|
38
|
+
import { useN1WalletContext, useN1WalletInternalContext, } from '../../../Provider/hooks';
|
|
39
39
|
import { N1SessionMode } from '../../../Provider/types';
|
|
40
|
+
import { logger } from '../../../utils/logger';
|
|
40
41
|
import { FlowState } from '../types';
|
|
41
42
|
/**
|
|
42
43
|
* Hook for handling wallet connection
|
|
@@ -81,7 +82,7 @@ export var useNordWalletConnect = function (state, transition, context, updateCo
|
|
|
81
82
|
return [2 /*return*/];
|
|
82
83
|
setIsConnecting(true);
|
|
83
84
|
setHasProcessedWallet(false);
|
|
84
|
-
|
|
85
|
+
logger.debug('Starting wallet connection process');
|
|
85
86
|
_a.label = 1;
|
|
86
87
|
case 1:
|
|
87
88
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -90,13 +91,13 @@ export var useNordWalletConnect = function (state, transition, context, updateCo
|
|
|
90
91
|
case 2:
|
|
91
92
|
// Show Dynamic widget to connect wallet
|
|
92
93
|
_a.sent();
|
|
93
|
-
|
|
94
|
+
logger.debug('Dynamic widget shown');
|
|
94
95
|
return [3 /*break*/, 4];
|
|
95
96
|
case 3:
|
|
96
97
|
error_1 = _a.sent();
|
|
97
98
|
setIsConnecting(false);
|
|
98
99
|
updateContext({ walletType: null });
|
|
99
|
-
|
|
100
|
+
logger.error('Error showing Dynamic widget:', error_1);
|
|
100
101
|
return [3 /*break*/, 4];
|
|
101
102
|
case 4: return [2 /*return*/];
|
|
102
103
|
}
|
|
@@ -106,7 +107,7 @@ export var useNordWalletConnect = function (state, transition, context, updateCo
|
|
|
106
107
|
* Disconnect wallet
|
|
107
108
|
*/
|
|
108
109
|
var disconnectWallet = useCallback(function () {
|
|
109
|
-
|
|
110
|
+
logger.debug('Disconnecting wallet');
|
|
110
111
|
setWalletType(null);
|
|
111
112
|
setHasProcessedWallet(false);
|
|
112
113
|
updateContext({ walletType: null });
|
|
@@ -123,32 +124,36 @@ export var useNordWalletConnect = function (state, transition, context, updateCo
|
|
|
123
124
|
sessionId = nordUser.sessionId;
|
|
124
125
|
hasActiveSession = sessionId != null;
|
|
125
126
|
updateContext({ hasNordAccount: hasNordAccount, hasActiveSession: hasActiveSession });
|
|
126
|
-
transitionDestination = hasNordAccount
|
|
127
|
+
transitionDestination = hasNordAccount
|
|
128
|
+
? sessionId != null
|
|
129
|
+
? FlowState.FINAL_SUCCESS
|
|
130
|
+
: FlowState.AUTH_LOADING
|
|
131
|
+
: FlowState.CHAIN_SELECTION;
|
|
127
132
|
if (hasNordAccount && sessionId != null) {
|
|
128
133
|
setIsConnected(true);
|
|
129
134
|
}
|
|
130
135
|
// Force a small delay to ensure UI updates properly
|
|
131
136
|
setTimeout(function () {
|
|
132
137
|
try {
|
|
133
|
-
|
|
138
|
+
logger.debug('Attempting transition to ' + transitionDestination);
|
|
134
139
|
transition(transitionDestination, {
|
|
135
140
|
walletType: 'solana',
|
|
136
141
|
hasNordAccount: hasNordAccount,
|
|
137
|
-
hasActiveSession: hasActiveSession
|
|
142
|
+
hasActiveSession: hasActiveSession,
|
|
138
143
|
});
|
|
139
|
-
|
|
144
|
+
logger.debug('Transition to ' + transitionDestination + ' completed');
|
|
140
145
|
// Try again with a longer delay as a fallback
|
|
141
146
|
setTimeout(function () {
|
|
142
|
-
|
|
147
|
+
logger.debug('Trying fallback transition after delay');
|
|
143
148
|
transition(transitionDestination, {
|
|
144
149
|
walletType: 'solana',
|
|
145
150
|
hasNordAccount: hasNordAccount,
|
|
146
|
-
hasActiveSession: hasActiveSession
|
|
151
|
+
hasActiveSession: hasActiveSession,
|
|
147
152
|
});
|
|
148
153
|
}, 500);
|
|
149
154
|
}
|
|
150
155
|
catch (error) {
|
|
151
|
-
|
|
156
|
+
logger.error('Error during transition:', error);
|
|
152
157
|
}
|
|
153
158
|
finally {
|
|
154
159
|
setIsConnecting(false);
|
|
@@ -170,8 +175,9 @@ export var useNordWalletConnect = function (state, transition, context, updateCo
|
|
|
170
175
|
return;
|
|
171
176
|
}
|
|
172
177
|
// If we've already processed this specific wallet address, don't process again
|
|
173
|
-
if (hasProcessedWallet &&
|
|
174
|
-
|
|
178
|
+
if (hasProcessedWallet &&
|
|
179
|
+
processedWalletAddressRef.current === dynamicWallet.address) {
|
|
180
|
+
logger.debug('Skipping wallet processing - already processed this address');
|
|
175
181
|
return;
|
|
176
182
|
}
|
|
177
183
|
// Use an IIFE to handle the async processing
|
|
@@ -181,14 +187,14 @@ export var useNordWalletConnect = function (state, transition, context, updateCo
|
|
|
181
187
|
return __generator(this, function (_c) {
|
|
182
188
|
// Prevent processing if already in progress
|
|
183
189
|
if (hasProcessedWallet) {
|
|
184
|
-
|
|
190
|
+
logger.debug('Skipping wallet processing - hasProcessedWallet is true');
|
|
185
191
|
return [2 /*return*/];
|
|
186
192
|
}
|
|
187
|
-
|
|
193
|
+
logger.debug('Processing wallet connection:', {
|
|
188
194
|
wallet: (_a = dynamicWallet.connector) === null || _a === void 0 ? void 0 : _a.name,
|
|
189
195
|
address: (_b = dynamicWallet.address) === null || _b === void 0 ? void 0 : _b.slice(0, 8),
|
|
190
196
|
state: state,
|
|
191
|
-
isNordMode: isNordMode
|
|
197
|
+
isNordMode: isNordMode,
|
|
192
198
|
});
|
|
193
199
|
// Set processed flag first to prevent re-entry
|
|
194
200
|
setHasProcessedWallet(true);
|
|
@@ -200,20 +206,22 @@ export var useNordWalletConnect = function (state, transition, context, updateCo
|
|
|
200
206
|
}); })();
|
|
201
207
|
// Cleanup function to handle component unmount
|
|
202
208
|
return function () {
|
|
203
|
-
|
|
209
|
+
logger.debug('Wallet connection effect cleanup');
|
|
204
210
|
};
|
|
205
211
|
}, [dynamicWallet, determineWalletType]);
|
|
206
212
|
// Handle wallet disconnection in a separate effect
|
|
207
213
|
useEffect(function () {
|
|
208
214
|
if (!dynamicWallet && hasProcessedWallet) {
|
|
209
|
-
|
|
215
|
+
logger.debug('Wallet disconnected, resetting processed flag');
|
|
210
216
|
processedWalletAddressRef.current = null;
|
|
211
217
|
setHasProcessedWallet(false);
|
|
212
218
|
}
|
|
213
219
|
}, [dynamicWallet, hasProcessedWallet]);
|
|
214
220
|
// Handle connecting state changes in a separate effect
|
|
215
221
|
useEffect(function () {
|
|
216
|
-
if (state === FlowState.CONNECTING_WALLET &&
|
|
222
|
+
if (state === FlowState.CONNECTING_WALLET &&
|
|
223
|
+
!dynamicWallet &&
|
|
224
|
+
isConnecting) {
|
|
217
225
|
// Only keep isConnecting true if we're in the connecting state and don't have a wallet yet
|
|
218
226
|
// This prevents an infinite loop of setting isConnecting
|
|
219
227
|
}
|
|
@@ -15,7 +15,7 @@ export function EvmWalletAuthScreen(_a) {
|
|
|
15
15
|
// Handle signature request
|
|
16
16
|
var handleSignatureRequest = function () {
|
|
17
17
|
setAuthState(AuthState.WAITING_FOR_SIGNATURE);
|
|
18
|
-
// Simulate signature process - in a real implementation,
|
|
18
|
+
// Simulate signature process - in a real implementation,
|
|
19
19
|
// this would be replaced with actual wallet signature logic
|
|
20
20
|
setTimeout(function () {
|
|
21
21
|
setAuthState(AuthState.SUCCESS);
|
|
@@ -2,46 +2,62 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { SolanaNetwork } from '../../../config/solana';
|
|
4
4
|
import { ChainButton } from '../components/ChainButton';
|
|
5
|
+
import { EVMChainsButton } from '../components/EVMChainsButton';
|
|
6
|
+
import { MoreButton } from '../components/MoreButton';
|
|
7
|
+
import { SolanaLogo } from '../../../components/logos';
|
|
8
|
+
import Logo from '../../../components/Logo';
|
|
9
|
+
import { logger } from '../../../utils/logger';
|
|
10
|
+
// Custom N1Logo wrapper that responds to the group hover state
|
|
11
|
+
var N1Logo = function (_a) {
|
|
12
|
+
var _b = _a.size, size = _b === void 0 ? 38 : _b;
|
|
13
|
+
return (_jsx("div", { className: "text-gray-800 dark:text-white group-hover:text-red-500 dark:group-hover:text-red-500 transition-colors duration-200", children: _jsx(Logo, { size: size }) }));
|
|
14
|
+
};
|
|
5
15
|
export function ChainSelectionScreen(_a) {
|
|
6
16
|
var onChainSelect = _a.onChainSelect;
|
|
7
17
|
var _b = useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
8
|
-
// Only allow
|
|
18
|
+
// Only allow devnet, gray out other chains
|
|
9
19
|
var handleChainSelect = function (chainId) {
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
if (chainId === '
|
|
20
|
+
logger.debug('Chain selected in ChainSelectionScreen:', chainId);
|
|
21
|
+
// Only allow devnet to be selected
|
|
22
|
+
if (chainId === 'devnet') {
|
|
13
23
|
setIsLoading(true);
|
|
14
24
|
onChainSelect(chainId);
|
|
15
25
|
}
|
|
16
26
|
else {
|
|
17
|
-
|
|
27
|
+
logger.debug('Chain not allowed:', chainId);
|
|
18
28
|
// Could show a toast or message here
|
|
19
29
|
}
|
|
20
30
|
};
|
|
21
|
-
//
|
|
22
|
-
// Add network information to chains
|
|
31
|
+
// Define the 4 options as requested
|
|
23
32
|
var chainsWithNetworkInfo = [
|
|
24
33
|
{
|
|
25
|
-
id: '
|
|
26
|
-
name: '
|
|
27
|
-
logo:
|
|
34
|
+
id: 'devnet',
|
|
35
|
+
name: 'Devnet',
|
|
36
|
+
logo: (_jsx("div", { className: "flex items-center justify-center", style: { width: 48, height: 48 }, children: _jsx(N1Logo, {}) })),
|
|
37
|
+
network: SolanaNetwork.DEVNET,
|
|
38
|
+
disabled: false, // Only devnet is clickable
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'solana',
|
|
42
|
+
name: 'Solana',
|
|
43
|
+
logo: (_jsx("div", { className: "flex items-center justify-center", style: { width: 48, height: 48 }, children: _jsx(SolanaLogo, { width: 36, height: 36 }) })),
|
|
28
44
|
network: SolanaNetwork.MAINNET,
|
|
29
|
-
disabled: true
|
|
45
|
+
disabled: true,
|
|
30
46
|
},
|
|
31
47
|
{
|
|
32
|
-
id: '
|
|
33
|
-
name: '
|
|
34
|
-
logo: '
|
|
35
|
-
network:
|
|
36
|
-
disabled:
|
|
48
|
+
id: 'evm-chains',
|
|
49
|
+
name: 'EVM Chains',
|
|
50
|
+
logo: '', // Not needed as we're using EVMChainsButton
|
|
51
|
+
network: '', // Empty string instead of null
|
|
52
|
+
disabled: true,
|
|
37
53
|
},
|
|
38
54
|
{
|
|
39
|
-
id: '
|
|
40
|
-
name: '
|
|
41
|
-
logo: '
|
|
42
|
-
network:
|
|
43
|
-
disabled: true
|
|
44
|
-
}
|
|
55
|
+
id: 'more',
|
|
56
|
+
name: 'More',
|
|
57
|
+
logo: '', // Not needed as we're using MoreButton
|
|
58
|
+
network: '', // Empty string instead of null
|
|
59
|
+
disabled: true,
|
|
60
|
+
},
|
|
45
61
|
];
|
|
46
|
-
return (_jsxs("div", { className: "overflow-hidden relative", children: [_jsx("h2", { className: "text-xl text-gray-800 dark:text-white font-semibold mb-6 text-center", children: "Select Network" }), isLoading ? (_jsx("div", { className: "flex justify-center items-center py-8", children: _jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-main" }) })) : (
|
|
62
|
+
return (_jsxs("div", { className: "overflow-hidden relative", children: [_jsx("h2", { className: "text-xl text-gray-800 dark:text-white font-semibold mb-6 text-center", children: "Select Origin Network" }), isLoading ? (_jsx("div", { className: "flex justify-center items-center py-8", children: _jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-main" }) })) : (_jsxs("div", { className: "space-y-8", children: [_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx(ChainButton, { chain: chainsWithNetworkInfo[0], onClick: function () { return handleChainSelect(chainsWithNetworkInfo[0].id); }, disabled: chainsWithNetworkInfo[0].disabled }, chainsWithNetworkInfo[0].id), _jsx(ChainButton, { chain: chainsWithNetworkInfo[1], onClick: function () { return handleChainSelect(chainsWithNetworkInfo[1].id); }, disabled: chainsWithNetworkInfo[1].disabled }, chainsWithNetworkInfo[1].id)] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx(EVMChainsButton, { chain: chainsWithNetworkInfo[2], onClick: function () { return handleChainSelect(chainsWithNetworkInfo[2].id); }, disabled: chainsWithNetworkInfo[2].disabled }, chainsWithNetworkInfo[2].id), _jsx(MoreButton, { chain: chainsWithNetworkInfo[3], onClick: function () { return handleChainSelect(chainsWithNetworkInfo[3].id); }, disabled: chainsWithNetworkInfo[3].disabled }, chainsWithNetworkInfo[3].id)] })] }))] }));
|
|
47
63
|
}
|
|
@@ -5,6 +5,9 @@ interface AmountInputScreenProps {
|
|
|
5
5
|
balance: number;
|
|
6
6
|
faucetUrl?: string;
|
|
7
7
|
refreshBalance?: () => Promise<void>;
|
|
8
|
+
depositError?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare function AmountInputScreen({ amount
|
|
10
|
+
export declare function AmountInputScreen({ amount: _amount, // Renamed to _amount since we're not using the prop
|
|
11
|
+
onAmountChange, onContinue, balance: _balance, // Renamed to _balance since we're overriding it
|
|
12
|
+
faucetUrl: propFaucetUrl, refreshBalance, depositError, }: AmountInputScreenProps): import("react/jsx-runtime").JSX.Element;
|
|
10
13
|
export {};
|