@n1xyz/wallet-widget 0.0.10 → 0.0.12

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 (104) hide show
  1. package/dist/Logic/transactionManager.d.ts +1 -1
  2. package/dist/Logic/transactionManager.js +1 -1
  3. package/dist/Logic/transactionManager.js.map +1 -1
  4. package/dist/Modal/NordFlow/NordFlow.js +22 -228
  5. package/dist/Modal/NordFlow/NordFlow.js.map +1 -1
  6. package/dist/Modal/NordFlow/components/Header.d.ts +10 -0
  7. package/dist/Modal/NordFlow/components/Header.js +11 -0
  8. package/dist/Modal/NordFlow/components/Header.js.map +1 -0
  9. package/dist/Modal/NordFlow/components/TransactionTable.js +4 -7
  10. package/dist/Modal/NordFlow/components/TransactionTable.js.map +1 -1
  11. package/dist/Modal/NordFlow/components/index.d.ts +1 -0
  12. package/dist/Modal/NordFlow/components/index.js +1 -0
  13. package/dist/Modal/NordFlow/components/index.js.map +1 -1
  14. package/dist/Modal/NordFlow/constants.js +116 -95
  15. package/dist/Modal/NordFlow/constants.js.map +1 -1
  16. package/dist/Modal/NordFlow/context/DepositContext.d.ts +27 -0
  17. package/dist/Modal/NordFlow/context/DepositContext.js +308 -0
  18. package/dist/Modal/NordFlow/context/DepositContext.js.map +1 -0
  19. package/dist/Modal/NordFlow/context/FlowContext.d.ts +23 -0
  20. package/dist/Modal/NordFlow/context/FlowContext.js +125 -0
  21. package/dist/Modal/NordFlow/context/FlowContext.js.map +1 -0
  22. package/dist/Modal/NordFlow/context/NordProvider.d.ts +10 -0
  23. package/dist/Modal/NordFlow/context/NordProvider.js +14 -0
  24. package/dist/Modal/NordFlow/context/NordProvider.js.map +1 -0
  25. package/dist/Modal/NordFlow/context/WalletConnectContext.d.ts +20 -0
  26. package/dist/Modal/NordFlow/context/WalletConnectContext.js +214 -0
  27. package/dist/Modal/NordFlow/context/WalletConnectContext.js.map +1 -0
  28. package/dist/Modal/NordFlow/context/deposit/types.d.ts +26 -0
  29. package/dist/Modal/NordFlow/context/deposit/types.js +2 -0
  30. package/dist/Modal/NordFlow/context/deposit/types.js.map +1 -0
  31. package/dist/Modal/NordFlow/context/deposit/useDepositAuth.d.ts +7 -0
  32. package/dist/Modal/NordFlow/context/deposit/useDepositAuth.js +113 -0
  33. package/dist/Modal/NordFlow/context/deposit/useDepositAuth.js.map +1 -0
  34. package/dist/Modal/NordFlow/context/deposit/useDepositTransaction.d.ts +20 -0
  35. package/dist/Modal/NordFlow/context/deposit/useDepositTransaction.js +235 -0
  36. package/dist/Modal/NordFlow/context/deposit/useDepositTransaction.js.map +1 -0
  37. package/dist/Modal/NordFlow/context/index.d.ts +5 -0
  38. package/dist/Modal/NordFlow/context/index.js +8 -0
  39. package/dist/Modal/NordFlow/context/index.js.map +1 -0
  40. package/dist/Modal/NordFlow/hooks/index.d.ts +3 -5
  41. package/dist/Modal/NordFlow/hooks/index.js +3 -5
  42. package/dist/Modal/NordFlow/hooks/index.js.map +1 -1
  43. package/dist/Modal/NordFlow/hooks/useDepositFlow.js +2 -4
  44. package/dist/Modal/NordFlow/hooks/useDepositFlow.js.map +1 -1
  45. package/dist/Modal/NordFlow/hooks/useNordInstance.d.ts +0 -6
  46. package/dist/Modal/NordFlow/hooks/useNordInstance.js +2 -358
  47. package/dist/Modal/NordFlow/hooks/useNordInstance.js.map +1 -1
  48. package/dist/Modal/NordFlow/hooks/useNordWalletConnect.d.ts +0 -1
  49. package/dist/Modal/NordFlow/hooks/useNordWalletConnect.js +0 -1
  50. package/dist/Modal/NordFlow/hooks/useNordWalletConnect.js.map +1 -1
  51. package/dist/Modal/NordFlow/screens/00-IdleScreen.d.ts +6 -0
  52. package/dist/Modal/NordFlow/screens/00-IdleScreen.js +9 -0
  53. package/dist/Modal/NordFlow/screens/00-IdleScreen.js.map +1 -0
  54. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.d.ts +1 -6
  55. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js +10 -4
  56. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js.map +1 -1
  57. package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.d.ts +1 -5
  58. package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.js +9 -12
  59. package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.js.map +1 -1
  60. package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.d.ts +1 -7
  61. package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.js +9 -7
  62. package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.js.map +1 -1
  63. package/dist/Modal/NordFlow/screens/04-AmountInputScreen.d.ts +1 -13
  64. package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js +59 -31
  65. package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js.map +1 -1
  66. package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.d.ts +1 -6
  67. package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js +8 -3
  68. package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js.map +1 -1
  69. package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.d.ts +1 -8
  70. package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js +15 -4
  71. package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js.map +1 -1
  72. package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.d.ts +1 -6
  73. package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js +14 -120
  74. package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js.map +1 -1
  75. package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.d.ts +1 -1
  76. package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.js +9 -4
  77. package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.js.map +1 -1
  78. package/dist/Modal/NordFlow/screens/09-ErrorScreen.d.ts +1 -7
  79. package/dist/Modal/NordFlow/screens/09-ErrorScreen.js +9 -9
  80. package/dist/Modal/NordFlow/screens/09-ErrorScreen.js.map +1 -1
  81. package/dist/Modal/NordFlow/screens/index.d.ts +1 -0
  82. package/dist/Modal/NordFlow/screens/index.js +1 -0
  83. package/dist/Modal/NordFlow/screens/index.js.map +1 -1
  84. package/dist/Modal/NordFlow/types.d.ts +0 -5
  85. package/dist/Modal/NordFlow/types.js +0 -1
  86. package/dist/Modal/NordFlow/types.js.map +1 -1
  87. package/dist/Modal/NordFlow/utils/index.d.ts +0 -1
  88. package/dist/Modal/NordFlow/utils/index.js +0 -1
  89. package/dist/Modal/NordFlow/utils/index.js.map +1 -1
  90. package/dist/Provider/LazyWalletProvider.js +2 -0
  91. package/dist/Provider/LazyWalletProvider.js.map +1 -1
  92. package/dist/Provider/N1WalletProvider.js +48 -63
  93. package/dist/Provider/N1WalletProvider.js.map +1 -1
  94. package/dist/Provider/WalletErrorBoundary.d.ts +10 -0
  95. package/dist/Provider/WalletErrorBoundary.js +39 -0
  96. package/dist/Provider/WalletErrorBoundary.js.map +1 -0
  97. package/dist/Provider/hooks/useNordUserInitialization.d.ts +20 -0
  98. package/dist/Provider/hooks/useNordUserInitialization.js +293 -0
  99. package/dist/Provider/hooks/useNordUserInitialization.js.map +1 -0
  100. package/dist/Provider/useN1WalletProvider.d.ts +37 -0
  101. package/dist/Provider/useN1WalletProvider.js +398 -0
  102. package/dist/Provider/useN1WalletProvider.js.map +1 -0
  103. package/dist/main.css +1 -1
  104. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DepositContext.js","sourceRoot":"","sources":["../../../../src/Modal/NordFlow/context/DepositContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnG,OAAO,EACL,cAAc,GAEf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,kBAAkB,E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AA;QACZ,eAAe,iBAAA;QACf,WAAW,aAAA;KACZ,CAAC;IAGF;;OAEG;IACH,SAAS,CAAC;QACR,IAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC;QAE3C,yEAAyE;QACzE,IAAI,OAAO,CAAC,aAAa,KAAK,WAAW,CAAC,aAAa,EAAE,CAAC;YACxD,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;YAC1C,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,OAAO,CAAC,aAAa,KAAK,WAAW,CAAC,aAAa,EAAE,CAAC;YACxD,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC1C,CAAC;QAED,wCAAwC;QACxC,cAAc,CAAC,OAAO,GAAG,OAAO,CAAC;IACnC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAId,OAAO,CACL,KAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YACzC,QAAQ,GACe,CAC3B,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG;IAC/B,IAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport {\n getExplorerUrl,\n TransactionResult,\n} from '../../../Logic/transactionManager';\nimport {\n useN1WalletContext,\n useN1WalletInternalContext,\n} from '../../../Provider/hooks';\nimport { N1SessionMode } from '../../../Provider/types';\nimport { logger } from '../../../utils/logger';\nimport { AVAILABLE_CHAINS } from '../constants';\nimport { FlowState } from '../types';\nimport { isNordConfigured } from '../utils/nordUtils';\nimport { useFlowStateContext } from './FlowContext';\n\n// Define the shape of the deposit context value\nexport interface DepositContextValue {\n amount: string;\n isDepositing: boolean;\n transactionId: string | null;\n transactionResult: TransactionResult | null;\n authStatus: 'loading' | 'success' | 'error';\n authErrorMessage: string | null;\n authStatusMessage: string | null;\n updateAmount: (newAmount: string) => void;\n startDeposit: () => Promise<void>;\n completeDeposit: () => void;\n performAuth: () => Promise<void>;\n}\n\n// Create the context with a default value\nconst DepositContext = createContext<DepositContextValue | undefined>(undefined);\n\n// Props for the provider component\ninterface DepositProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Provider component for the deposit context\n */\nexport const DepositProvider: React.FC<DepositProviderProps> = ({\n children,\n}) => {\n // Get flow state context\n const {\n state,\n context,\n transition,\n updateContext,\n } = useFlowStateContext();\n\n // Get wallet context\n const {\n address,\n nord,\n signMessageWithWalletKey,\n signMessageWithSessionKey,\n nordUser,\n } = useN1WalletContext();\n const { sessionMode } = useN1WalletInternalContext();\n\n // chain\n const [selectedChain, setSelectedChain] = useState<string | null>(\n context.selectedChain\n );\n\n // transaction & deposit\n const [amount, setAmount] = useState(context.amount);\n const [isDepositing, setIsDepositing] = useState(false);\n const [transactionId, setTransactionId] = useState<string | null>(context.transactionId);\n const [transactionResult, setTransactionResult] = useState<TransactionResult | null>(null);\n\n\n // auth\n const [authStatus, setAuthStatus] = useState<'loading' | 'success' | 'error'>('loading');\n const [authErrorMessage, setAuthErrorMessage] = useState<string | null>(null);\n const [authStatusMessage, setAuthStatusMessage] = useState<string | null>(null);\n\n // Use refs to track previous values\n const prevContextRef = useRef(context);\n\n\n /**\n * Handle an error by transitioning to error state\n */\n const handleError = useCallback(\n (error: Error) => {\n logger.error('Flow error:', error);\n transition(FlowState.ERROR, { error });\n },\n [transition]\n );\n\n /**\n * Authenticate session\n */\n const performAuth = useCallback(async () => {\n try {\n // Step 1: Tell user to sign transaction\n setAuthStatusMessage(\n 'Please sign the transaction to authenticate your session'\n );\n\n if (!nordUser) {\n throw new Error('Nord user is not initialized');\n }\n\n // Step 2: Call nordUser.refreshSession and get sessionId\n setAuthStatusMessage('Session is being authenticated...');\n\n // Get the session public key from the nordUser\n const sessionPubKey = nordUser.sessionPubKey;\n if (!sessionPubKey) {\n throw new Error('Session public key is not available');\n }\n\n // Refresh the session\n await nordUser.refreshSession(sessionPubKey);\n await nordUser.updateAccountId();\n\n // Get the sessionId after refresh\n const sessionId = nordUser.sessionId;\n if (!sessionId) {\n throw new Error('Failed to get session ID after refresh');\n }\n\n logger.debug('Session refreshed successfully', {\n sessionId: sessionId.toString(),\n });\n\n // Step 3: Store sessionId in localStorage\n if (address) {\n const sessionIdKey = `n1_sessionId_${address}`;\n localStorage.setItem(sessionIdKey, sessionId.toString());\n logger.debug('Stored sessionId in localStorage', { key: sessionIdKey });\n }\n\n // Step 4: Update status to success\n setAuthStatus('success');\n\n // Step 5: Update context and transition to success\n console.log('hasActiveSession', \"asdasdsadsa\");\n // updateContext({ hasActiveSession: true });\n setTimeout(() => {\n transition(FlowState.FINAL_SUCCESS, { hasActiveSession: true, hasNordAccount: true });\n }, 100);\n\n } catch (error) {\n console.error('Authentication error:', error);\n setAuthStatus('error');\n setAuthErrorMessage(\n error instanceof Error ? error.message : 'Unknown error occurred'\n );\n }\n }, [updateContext, transition, address, nordUser]);\n\n /**\n * Update amount for deposit\n */\n const updateAmount = useCallback(\n (newAmount: string) => {\n setAmount(newAmount);\n if (state === FlowState.AMOUNT_INPUT) {\n updateContext({ amount: newAmount });\n } else {\n transition(state, { amount: newAmount });\n }\n },\n [state, transition, updateContext]\n );\n\n /**\n * Start deposit process\n */\n const startDeposit = useCallback(async () => {\n if (isDepositing) return;\n\n logger.debug('Starting deposit process');\n\n if (!amount || parseFloat(amount) <= 0) {\n handleError(new Error('Invalid amount'));\n return;\n }\n\n setIsDepositing(true);\n transition(FlowState.DEPOSIT_PROGRESS);\n\n try {\n const usdcToken = nord!.tokens.find((t: any) => t.symbol === 'USDC');\n\n const txId = await nordUser.depositSpl(\n parseFloat(amount),\n usdcToken!.tokenId\n );\n\n let accountInitialized = false;\n for (let i = 0; i < 70; i++) {\n const exists = await nord?.accountExists(address);\n if (exists) {\n accountInitialized = true;\n break;\n }\n await new Promise((resolve) => setTimeout(resolve, 5000));\n }\n\n if (!accountInitialized) {\n throw new Error('Account failed to intialize on N1.');\n }\n\n logger.debug('Deposit successful using Nord-TS', txId);\n\n // Create transaction result object immediately after successful deposit\n const result: TransactionResult = {\n success: true,\n transactionId: txId,\n amount,\n tokenSymbol: 'USDC',\n fromAddress: address || 'Your Wallet',\n toAddress: 'Exchange Account',\n networkName: selectedChain!,\n status: 'Completed',\n explorerUrl: getExplorerUrl(txId),\n };\n\n // Update state with transaction result\n setTransactionId(txId);\n setTransactionResult(result);\n logger.debug('Transaction completed successfully');\n transition(FlowState.DEPOSIT_SUCCESS, { transactionId: txId, hasNordAccount: true });\n } catch (depositError) {\n logger.warn('Error using depositSpl, falling back to mock implementation:', depositError);\n setIsDepositing(false);\n const errorMessage = depositError instanceof Error\n ? depositError.message\n : 'Failed to process deposit';\n\n transition(FlowState.AMOUNT_INPUT, {\n depositError: errorMessage\n });\n return; // Exit early\n }\n }, [\n isDepositing,\n selectedChain,\n amount,\n address,\n sessionMode,\n transition,\n handleError,\n nord,\n signMessageWithWalletKey,\n signMessageWithSessionKey,\n nordUser,\n ]);\n\n /**\n * Complete the deposit process and move to the next screen\n */\n const completeDeposit = useCallback(() => {\n // Check if user has an active session to determine the next state\n if (context.hasActiveSession) {\n // If user has an active session, go directly to FINAL_SUCCESS\n transition(FlowState.FINAL_SUCCESS, { hasNordAccount: true, hasActiveSession: true });\n } else {\n // Check if there's a sessionId stored in localStorage\n const sessionIdKey = `n1_sessionId_${address}`;\n const storedSessionId = localStorage.getItem(sessionIdKey);\n console.log('storedSessionId', storedSessionId, sessionIdKey);\n\n if (storedSessionId !== null) {\n // If we have a sessionId in localStorage (even if it's 0), go directly to FINAL_SUCCESS\n transition(FlowState.FINAL_SUCCESS, { hasNordAccount: true, hasActiveSession: true });\n } else {\n // If user doesn't have an active session and no sessionId in localStorage, go to NORD_AUTH\n transition(FlowState.AUTH_LOADING, { hasActiveSession: true });\n }\n }\n }, [context.hasActiveSession, transition, address]);\n\n\n\n\n\n // Create the context value\n const contextValue: DepositContextValue = {\n amount,\n isDepositing,\n transactionId,\n transactionResult,\n authStatus,\n authErrorMessage,\n authStatusMessage,\n updateAmount,\n startDeposit,\n completeDeposit,\n performAuth,\n };\n\n\n /**\n * Update state based on context changes\n */\n useEffect(() => {\n const prevContext = prevContextRef.current;\n\n // Only update state if the relevant context values have actually changed\n if (context.selectedChain !== prevContext.selectedChain) {\n setSelectedChain(context.selectedChain);\n }\n\n if (context.amount !== prevContext.amount) {\n setAmount(context.amount);\n }\n\n if (context.transactionId !== prevContext.transactionId) {\n setTransactionId(context.transactionId);\n }\n\n // Update the ref to the current context\n prevContextRef.current = context;\n }, [context]);\n\n\n\n return (\n <DepositContext.Provider value={contextValue}>\n {children}\n </DepositContext.Provider>\n );\n};\n\n/**\n * Hook to use the deposit context\n */\nexport const useDepositContext = (): DepositContextValue => {\n const context = useContext(DepositContext);\n if (context === undefined) {\n throw new Error('useDepositContext must be used within a DepositProvider');\n }\n return context;\n}; "]}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { FlowContext as FlowContextType, FlowState } from '../types';
3
+ export interface FlowStateContextValue {
4
+ state: FlowState;
5
+ context: FlowContextType;
6
+ isClosing: boolean;
7
+ transition: (targetState: FlowState, contextUpdates?: Partial<FlowContextType>) => boolean;
8
+ updateContext: (updates: Partial<FlowContextType>) => void;
9
+ }
10
+ interface FlowStateProviderProps {
11
+ children: React.ReactNode;
12
+ }
13
+ /**
14
+ * Provider component for the flow state context
15
+ */
16
+ export declare const FlowStateProvider: React.FC<FlowStateProviderProps>;
17
+ /**
18
+ * Custom hook to use the flow state context
19
+ * @returns The flow state context value
20
+ * @throws Error if used outside of a FlowStateProvider
21
+ */
22
+ export declare const useFlowStateContext: () => FlowStateContextValue;
23
+ export {};
@@ -0,0 +1,125 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { createContext, useCallback, useContext, useRef, useState } from 'react';
14
+ import { FlowState, initialFlowContext } from '../types';
15
+ import { STATE_TRANSITIONS } from '../constants';
16
+ import { logger } from '../../../utils/logger';
17
+ import { useN1WalletContext, useN1WalletInternalContext } from '../../../Provider';
18
+ // Create the context with a default value
19
+ var FlowStateContext = createContext(undefined);
20
+ /**
21
+ * Provider component for the flow state context
22
+ */
23
+ export var FlowStateProvider = function (_a) {
24
+ var children = _a.children;
25
+ // Flow state
26
+ var _b = useState(FlowState.IDLE), state = _b[0], setState = _b[1];
27
+ var _c = useState(initialFlowContext), context = _c[0], setContext = _c[1];
28
+ var _d = useState(false), isClosing = _d[0], setIsClosing = _d[1];
29
+ var nordUser = useN1WalletContext().nordUser;
30
+ var dynamicSdkHasLoaded = useN1WalletInternalContext().dynamicSdkHasLoaded;
31
+ var prevContextRef = useRef(initialFlowContext);
32
+ // Default handlers
33
+ var handleStateChange = useCallback(function (newState, currState) {
34
+ logger.debug("State changed from ".concat(currState, " to ").concat(newState));
35
+ }, []);
36
+ /**
37
+ * Check if a transition is allowed based on current state and context
38
+ */
39
+ var canTransition = useCallback(function (targetState, contextData) {
40
+ if (dynamicSdkHasLoaded)
41
+ return STATE_TRANSITIONS.some(function (transition) {
42
+ var fromMatches = Array.isArray(transition.from)
43
+ ? transition.from.includes(state)
44
+ : transition.from === state;
45
+ if (!fromMatches || transition.to !== targetState) {
46
+ return false;
47
+ }
48
+ if (transition.condition) {
49
+ return transition.condition(contextData);
50
+ }
51
+ return true;
52
+ });
53
+ return false;
54
+ }, [state, nordUser, dynamicSdkHasLoaded]);
55
+ /**
56
+ * Transition to a new state if allowed
57
+ */
58
+ var transition = useCallback(function (targetState, contextUpdates) {
59
+ if (contextUpdates === void 0) { contextUpdates = {}; }
60
+ // Skip if we're already in the target state and no context updates
61
+ if (targetState === state && Object.keys(contextUpdates).length === 0) {
62
+ return true;
63
+ }
64
+ if (!canTransition(targetState, __assign(__assign({}, context), contextUpdates))) {
65
+ logger.warn("Transition from ".concat(state, " to ").concat(targetState, " is not allowed"));
66
+ return false;
67
+ }
68
+ // Update context first
69
+ setContext(function (prevContext) {
70
+ return __assign(__assign({}, prevContext), contextUpdates);
71
+ });
72
+ logger.debug("Transitioning from ".concat(state, " to ").concat(targetState));
73
+ setState(targetState);
74
+ handleStateChange(targetState, state);
75
+ return true;
76
+ }, [canTransition, state, context, handleStateChange]);
77
+ /**
78
+ * Update context without state transition
79
+ */
80
+ var updateContext = useCallback(function (updates) {
81
+ // Skip if no actual updates
82
+ if (Object.keys(updates).length === 0) {
83
+ return;
84
+ }
85
+ setContext(function (prevContext) {
86
+ // Check if any values are actually changing
87
+ var hasChanges = false;
88
+ // Type-safe way to check for changes
89
+ Object.keys(updates).forEach(function (key) {
90
+ if (updates[key] !== prevContext[key]) {
91
+ hasChanges = true;
92
+ }
93
+ });
94
+ // If nothing is changing, return the previous context
95
+ if (!hasChanges) {
96
+ return prevContext;
97
+ }
98
+ var newContext = __assign(__assign({}, prevContext), updates);
99
+ prevContextRef.current = newContext;
100
+ return newContext;
101
+ });
102
+ }, [state]);
103
+ // Create the context value
104
+ var contextValue = {
105
+ state: state,
106
+ context: context,
107
+ isClosing: isClosing,
108
+ transition: transition,
109
+ updateContext: updateContext,
110
+ };
111
+ return (_jsx(FlowStateContext.Provider, { value: contextValue, children: children }));
112
+ };
113
+ /**
114
+ * Custom hook to use the flow state context
115
+ * @returns The flow state context value
116
+ * @throws Error if used outside of a FlowStateProvider
117
+ */
118
+ export var useFlowStateContext = function () {
119
+ var context = useContext(FlowStateContext);
120
+ if (context === undefined) {
121
+ throw new Error('useFlowStateContext must be used within a FlowStateProvider');
122
+ }
123
+ return context;
124
+ };
125
+ //# sourceMappingURL=FlowContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowContext.js","sourceRoot":"","sources":["../../../../src/Modal/NordFlow/context/FlowContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAc,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAa,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnG,OAAO,EAAkC,SAAS,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAWnF,0CAA0C;AAC1C,IAAM,gBAAgB,GAAG,aAAa,CAAoC,SAAS,CAAC,CAAC;AAOrF;;GAEG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAqC,UAAC,EAEnE;QADC,QAAQ,cAAA;IAER,aAAa;IACP,IAAA,KAAoB,QAAQ,CAAY,SAAS,CAAC,IAAI,CAAC,EAAtD,KAAK,QAAA,EAAE,QAAQ,QAAuC,CAAC;IACxD,IAAA,KAAwB,QAAQ,CAAkB,kBAAkB,CAAC,EAApE,OAAO,QAAA,EAAE,UAAU,QAAiD,CAAC;IACtE,IAAA,KAA4B,QAAQ,CAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAC;IAE1C,IAAA,QAAQ,GAAK,kBAAkB,EAAE,SAAzB,CAA0B;IAClC,IAAA,mBAAmB,GAAK,0BAA0B,EAAE,oBAAjC,CAAkC;IAC7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G,UAAU,CAAC;YACpC,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAGF,2BAA2B;IAC3B,IAAM,YAAY,GAA0B;QAC1C,KAAK,OAAA;QACL,OAAO,SAAA;QACP,SAAS,WAAA;QACT,UAAU,YAAA;QACV,aAAa,eAAA;KACd,CAAC;IAIF,OAAO,CACL,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC3C,QAAQ,GACiB,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAG;IACjC,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAE7C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { FlowContext as FlowContextType, FlowState, initialFlowContext } from '../types';\nimport { STATE_TRANSITIONS } from '../constants';\nimport { logger } from '../../../utils/logger';\nimport { useN1WalletContext, useN1WalletInternalContext } from '../../../Provider';\n\n// Define the shape of the context value\nexport interface FlowStateContextValue {\n state: FlowState;\n context: FlowContextType;\n isClosing: boolean;\n transition: (targetState: FlowState, contextUpdates?: Partial<FlowContextType>) => boolean;\n updateContext: (updates: Partial<FlowContextType>) => void;\n}\n\n// Create the context with a default value\nconst FlowStateContext = createContext<FlowStateContextValue | undefined>(undefined);\n\n// Props for the provider component\ninterface FlowStateProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Provider component for the flow state context\n */\nexport const FlowStateProvider: React.FC<FlowStateProviderProps> = ({\n children,\n}) => {\n // Flow state\n const [state, setState] = useState<FlowState>(FlowState.IDLE);\n const [context, setContext] = useState<FlowContextType>(initialFlowContext);\n const [isClosing, setIsClosing] = useState(false);\n\n const { nordUser } = useN1WalletContext();\n const { dynamicSdkHasLoaded } = useN1WalletInternalContext();\n const prevContextRef = useRef<FlowContextType>(initialFlowContext);\n\n\n // Default handlers\n const handleStateChange = useCallback((newState: FlowState, currState: FlowState | null) => {\n logger.debug(`State changed from ${currState} to ${newState}`);\n }, []);\n /**\n * Check if a transition is allowed based on current state and context\n */\n const canTransition = useCallback(\n (targetState: FlowState, contextData: FlowContextType): boolean => {\n if (dynamicSdkHasLoaded)\n return STATE_TRANSITIONS.some((transition) => {\n const fromMatches = Array.isArray(transition.from)\n ? transition.from.includes(state)\n : transition.from === state;\n\n if (!fromMatches || transition.to !== targetState) {\n return false;\n }\n\n if (transition.condition) {\n return transition.condition(contextData);\n }\n\n return true;\n });\n return false;\n },\n [state, nordUser, dynamicSdkHasLoaded]\n );\n\n /**\n * Transition to a new state if allowed\n */\n const transition = useCallback(\n (\n targetState: FlowState,\n contextUpdates: Partial<FlowContextType> = {}\n ): boolean => {\n // Skip if we're already in the target state and no context updates\n if (targetState === state && Object.keys(contextUpdates).length === 0) {\n return true;\n }\n\n if (!canTransition(targetState, { ...context, ...contextUpdates })) {\n logger.warn(\n `Transition from ${state} to ${targetState} is not allowed`\n );\n return false;\n }\n\n\n // Update context first\n setContext((prevContext) => {\n return { ...prevContext, ...contextUpdates };\n });\n\n logger.debug(`Transitioning from ${state} to ${targetState}`);\n setState(targetState);\n\n handleStateChange(targetState, state);\n return true;\n },\n [canTransition, state, context, handleStateChange]\n );\n\n\n\n /**\n * Update context without state transition\n */\n const updateContext = useCallback(\n (updates: Partial<FlowContextType>) => {\n // Skip if no actual updates\n if (Object.keys(updates).length === 0) {\n return;\n }\n\n setContext((prevContext) => {\n // Check if any values are actually changing\n let hasChanges = false;\n\n // Type-safe way to check for changes\n (Object.keys(updates) as Array<keyof Partial<FlowContextType>>).forEach(key => {\n if (updates[key] !== prevContext[key]) {\n hasChanges = true;\n }\n });\n\n // If nothing is changing, return the previous context\n if (!hasChanges) {\n return prevContext;\n }\n\n const newContext = { ...prevContext, ...updates };\n prevContextRef.current = newContext;\n return newContext;\n });\n },\n [state]\n );\n\n\n // Create the context value\n const contextValue: FlowStateContextValue = {\n state,\n context,\n isClosing,\n transition,\n updateContext,\n };\n\n\n\n return (\n <FlowStateContext.Provider value={contextValue}>\n {children}\n </FlowStateContext.Provider>\n );\n};\n\n/**\n * Custom hook to use the flow state context\n * @returns The flow state context value\n * @throws Error if used outside of a FlowStateProvider\n */\nexport const useFlowStateContext = (): FlowStateContextValue => {\n const context = useContext(FlowStateContext);\n\n if (context === undefined) {\n throw new Error('useFlowStateContext must be used within a FlowStateProvider');\n }\n\n return context;\n};\n"]}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface NordProviderProps {
3
+ children: React.ReactNode;
4
+ }
5
+ /**
6
+ * A provider component that combines FlowStateProvider, WalletConnectProvider, and DepositProvider
7
+ * into a single wrapper component for easier implementation.
8
+ */
9
+ export declare const NordProvider: React.FC<NordProviderProps>;
10
+ export default NordProvider;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FlowStateProvider } from './FlowContext';
3
+ import { WalletConnectProvider } from './WalletConnectContext';
4
+ import { DepositProvider } from './DepositContext';
5
+ /**
6
+ * A provider component that combines FlowStateProvider, WalletConnectProvider, and DepositProvider
7
+ * into a single wrapper component for easier implementation.
8
+ */
9
+ export var NordProvider = function (_a) {
10
+ var children = _a.children;
11
+ return (_jsx(FlowStateProvider, { children: _jsx(WalletConnectProvider, { children: _jsx(DepositProvider, { children: children }) }) }));
12
+ };
13
+ export default NordProvider;
14
+ //# sourceMappingURL=NordProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NordProvider.js","sourceRoot":"","sources":["../../../../src/Modal/NordFlow/context/NordProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMnD;;;GAGG;AACH,MAAM,CAAC,IAAM,YAAY,GAAgC,UAAC,EAAY;QAAV,QAAQ,cAAA;IAClE,OAAO,CACL,KAAC,iBAAiB,cAChB,KAAC,qBAAqB,cACpB,KAAC,eAAe,cACb,QAAQ,GACO,GACI,GACN,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import React from 'react';\nimport { FlowStateProvider } from './FlowContext';\nimport { WalletConnectProvider } from './WalletConnectContext';\nimport { DepositProvider } from './DepositContext';\n\ninterface NordProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * A provider component that combines FlowStateProvider, WalletConnectProvider, and DepositProvider\n * into a single wrapper component for easier implementation.\n */\nexport const NordProvider: React.FC<NordProviderProps> = ({ children }) => {\n return (\n <FlowStateProvider>\n <WalletConnectProvider>\n <DepositProvider>\n {children}\n </DepositProvider>\n </WalletConnectProvider>\n </FlowStateProvider>\n );\n};\n\nexport default NordProvider; "]}
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ export interface WalletConnectContextValue {
3
+ isConnecting: boolean;
4
+ connectWallet: () => Promise<void>;
5
+ disconnectWallet: () => void;
6
+ }
7
+ interface WalletConnectProviderProps {
8
+ children: React.ReactNode;
9
+ }
10
+ /**
11
+ * Provider component for the wallet connect context
12
+ */
13
+ export declare const WalletConnectProvider: React.FC<WalletConnectProviderProps>;
14
+ /**
15
+ * Custom hook to use the wallet connect context
16
+ * @returns The wallet connect context value
17
+ * @throws Error if used outside of a WalletConnectProvider
18
+ */
19
+ export declare const useWalletConnectContext: () => WalletConnectContextValue;
20
+ export {};
@@ -0,0 +1,214 @@
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 { jsx as _jsx } from "react/jsx-runtime";
38
+ import { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
39
+ import { useN1WalletContext, useN1WalletInternalContext } from '../../../Provider/hooks';
40
+ import { logger } from '../../../utils/logger';
41
+ import { FlowState } from '../types';
42
+ import { useFlowStateContext } from './FlowContext';
43
+ // Create the context with a default value
44
+ var WalletConnectContext = createContext(undefined);
45
+ /**
46
+ * Provider component for the wallet connect context
47
+ */
48
+ export var WalletConnectProvider = function (_a) {
49
+ var children = _a.children;
50
+ var _b = useN1WalletContext(), nord = _b.nord, nordUser = _b.nordUser;
51
+ var _c = useN1WalletInternalContext(), showDynamicWidget = _c.showDynamicWidget, dynamicWallet = _c.dynamicWallet, setIsConnected = _c.setIsConnected, dynamicSdkHasLoaded = _c.dynamicSdkHasLoaded;
52
+ var dynamicHandleLogOut = useN1WalletInternalContext().dynamicHandleLogOut;
53
+ // Get flow context
54
+ var _d = useFlowStateContext(), state = _d.state, transition = _d.transition, updateContext = _d.updateContext;
55
+ var _e = useState(false), isConnecting = _e[0], setIsConnecting = _e[1];
56
+ // Use refs to track previous values
57
+ var processedWalletAddressRef = useRef(null);
58
+ var prevNordUserRef = useRef(nordUser);
59
+ var prevStateRef = useRef(state);
60
+ /**
61
+ * Disconnect wallet
62
+ */
63
+ var disconnectWallet = useCallback(function () {
64
+ logger.debug('Disconnecting wallet');
65
+ try {
66
+ dynamicHandleLogOut();
67
+ }
68
+ catch (_) {
69
+ //
70
+ }
71
+ processedWalletAddressRef.current = null;
72
+ updateContext({ walletType: null });
73
+ // todo: delete sessionId from localStorage
74
+ window.location.reload();
75
+ }, [updateContext]);
76
+ /**
77
+ * Connect wallet using Dynamic widget
78
+ */
79
+ var connectWallet = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
80
+ var error_1;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0:
84
+ if (isConnecting || !showDynamicWidget || !dynamicSdkHasLoaded)
85
+ return [2 /*return*/];
86
+ setIsConnecting(true);
87
+ logger.debug('Starting wallet connection process');
88
+ _a.label = 1;
89
+ case 1:
90
+ _a.trys.push([1, 3, , 4]);
91
+ return [4 /*yield*/, showDynamicWidget(true)];
92
+ case 2:
93
+ _a.sent();
94
+ logger.debug('Dynamic widget shown');
95
+ return [3 /*break*/, 4];
96
+ case 3:
97
+ error_1 = _a.sent();
98
+ setIsConnecting(false);
99
+ updateContext({ walletType: null });
100
+ logger.error('Error showing Dynamic widget:', error_1);
101
+ return [3 /*break*/, 4];
102
+ case 4: return [2 /*return*/];
103
+ }
104
+ });
105
+ }); }, [isConnecting, showDynamicWidget, updateContext, dynamicSdkHasLoaded]);
106
+ // Process nordUser changes
107
+ useEffect(function () {
108
+ if (!dynamicSdkHasLoaded)
109
+ return;
110
+ var currentNordUser = nordUser;
111
+ var prevNordUser = prevNordUserRef.current;
112
+ // Only run if nordUser has changed and we have processed a wallet
113
+ if (currentNordUser && currentNordUser !== prevNordUser) {
114
+ logger.debug('NordUser changed, checking account status');
115
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
116
+ var hasNordAccount_1, sessionId, hasActiveSession_1, transitionDestination_1, error_2;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0:
120
+ _a.trys.push([0, 2, , 3]);
121
+ if (!dynamicWallet)
122
+ return [2 /*return*/];
123
+ return [4 /*yield*/, nord.accountExists(dynamicWallet.address)];
124
+ case 1:
125
+ hasNordAccount_1 = _a.sent();
126
+ sessionId = currentNordUser.sessionId;
127
+ hasActiveSession_1 = sessionId != null;
128
+ console.log('hasNordAccount', hasNordAccount_1, 'hasActiveSession', hasActiveSession_1, 'sessionId', sessionId, 'dynamicWallet', dynamicWallet, 'zzzzzzzzzzzz');
129
+ updateContext({ hasNordAccount: hasNordAccount_1, hasActiveSession: hasActiveSession_1 });
130
+ console.log('hasNordAccount', hasNordAccount_1, 'hasActiveSession', hasActiveSession_1, 'sessionId', sessionId, 'dynamicWallet', dynamicWallet);
131
+ transitionDestination_1 = hasNordAccount_1
132
+ ? sessionId != null
133
+ ? FlowState.FINAL_SUCCESS
134
+ : FlowState.AUTH_LOADING
135
+ : FlowState.CHAIN_SELECTION;
136
+ if (hasNordAccount_1 && sessionId != null) {
137
+ setIsConnected(true);
138
+ }
139
+ // Force a small delay to ensure UI updates properly
140
+ setTimeout(function () {
141
+ try {
142
+ logger.debug('Attempting transition to ' + transitionDestination_1);
143
+ transition(transitionDestination_1, {
144
+ walletType: 'solana',
145
+ hasNordAccount: hasNordAccount_1,
146
+ hasActiveSession: hasActiveSession_1,
147
+ });
148
+ logger.debug('Transition to ' + transitionDestination_1 + ' completed');
149
+ }
150
+ catch (error) {
151
+ logger.error('Error during transition:', error);
152
+ }
153
+ finally {
154
+ setIsConnecting(false);
155
+ }
156
+ }, 100);
157
+ return [3 /*break*/, 3];
158
+ case 2:
159
+ error_2 = _a.sent();
160
+ logger.error('Error checking account status:', error_2);
161
+ setIsConnecting(false);
162
+ return [3 /*break*/, 3];
163
+ case 3: return [2 /*return*/];
164
+ }
165
+ });
166
+ }); })();
167
+ }
168
+ else {
169
+ transition(FlowState.CONNECTING_WALLET);
170
+ }
171
+ // Update ref
172
+ prevNordUserRef.current = currentNordUser;
173
+ }, [
174
+ nordUser,
175
+ dynamicWallet,
176
+ updateContext,
177
+ transition,
178
+ setIsConnected
179
+ ]);
180
+ // Handle connecting state changes in a separate effect
181
+ useEffect(function () {
182
+ var currentState = state;
183
+ var prevState = prevStateRef.current;
184
+ // Only run if state has changed
185
+ if (currentState !== prevState) {
186
+ if (currentState !== FlowState.CONNECTING_WALLET && isConnecting) {
187
+ // If we're no longer in the connecting state, reset the connecting flag
188
+ setIsConnecting(false);
189
+ }
190
+ // Update ref
191
+ prevStateRef.current = currentState;
192
+ }
193
+ }, [state, isConnecting]);
194
+ // Create the context value
195
+ var contextValue = {
196
+ isConnecting: isConnecting,
197
+ connectWallet: connectWallet,
198
+ disconnectWallet: disconnectWallet,
199
+ };
200
+ return (_jsx(WalletConnectContext.Provider, { value: contextValue, children: children }));
201
+ };
202
+ /**
203
+ * Custom hook to use the wallet connect context
204
+ * @returns The wallet connect context value
205
+ * @throws Error if used outside of a WalletConnectProvider
206
+ */
207
+ export var useWalletConnectContext = function () {
208
+ var context = useContext(WalletConnectContext);
209
+ if (context === undefined) {
210
+ throw new Error('useWalletConnectContext must be used within a WalletConnectProvider');
211
+ }
212
+ return context;
213
+ };
214
+ //# sourceMappingURL=WalletConnectContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletConnectContext.js","sourceRoot":"","sources":["../../../../src/Modal/NordFlow/context/WalletConnectContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAEzF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AASpD,0CAA0C;AAC1C,IAAM,oBAAoB,GAAG,aAAa,CAAwC,SAAS,CAAC,CAAC;AAO7F;;GAEG;AACH,MAAM,CAAC,IAAM,qBAAqB,GAAyC,UAAC,EAE3E;QADC,QAAQ,cAAA;IAEF,IAAA,KAAqB,kBAAkB,EAAE,EAAvC,IAAI,UAAA,EAAE,QAAQ,cAAyB,CAAC;IAC1C,IAAA,KAA4E,0BAA0B,EAAE,EAAtG,iBAAiB,uBAAA,EAAE,aAAa,mBAAA,EAAE,cAAc,oBAAA,EAAE,mBAAmB,yBAAiC,CAAC;I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K,SAAS,EAAE,CAAC;YAC/B,IAAI,YAAY,KAAK,SAAS,CAAC,iBAAiB,IAAI,YAAY,EAAE,CAAC;gBACjE,wEAAwE;gBACxE,eAAe,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;YAED,aAAa;YACb,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC;QACtC,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IAE1B,2BAA2B;IAC3B,IAAM,YAAY,GAA8B;QAC9C,YAAY,cAAA;QACZ,aAAa,eAAA;QACb,gBAAgB,kBAAA;KACjB,CAAC;IAEF,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC/C,QAAQ,GACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,IAAM,uBAAuB,GAAG;IACrC,IAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAEjD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { useN1WalletContext, useN1WalletInternalContext } from '../../../Provider/hooks';\nimport { N1SessionMode } from '../../../Provider/types';\nimport { logger } from '../../../utils/logger';\nimport { FlowState, initialFlowContext } from '../types';\nimport { useFlowStateContext } from './FlowContext';\n\n// Define the shape of the context value\nexport interface WalletConnectContextValue {\n isConnecting: boolean;\n connectWallet: () => Promise<void>;\n disconnectWallet: () => void;\n}\n\n// Create the context with a default value\nconst WalletConnectContext = createContext<WalletConnectContextValue | undefined>(undefined);\n\n// Props for the provider component\ninterface WalletConnectProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Provider component for the wallet connect context\n */\nexport const WalletConnectProvider: React.FC<WalletConnectProviderProps> = ({\n children,\n}) => {\n const { nord, nordUser } = useN1WalletContext();\n const { showDynamicWidget, dynamicWallet, setIsConnected, dynamicSdkHasLoaded } = useN1WalletInternalContext();\n const { dynamicHandleLogOut } = useN1WalletInternalContext();\n\n // Get flow context\n const {\n state,\n transition,\n updateContext,\n } = useFlowStateContext();\n\n const [isConnecting, setIsConnecting] = useState(false);\n\n // Use refs to track previous values\n const processedWalletAddressRef = useRef<string | null>(null);\n const prevNordUserRef = useRef(nordUser);\n const prevStateRef = useRef(state);\n\n\n /**\n * Disconnect wallet\n */\n const disconnectWallet = useCallback(() => {\n logger.debug('Disconnecting wallet');\n try {\n dynamicHandleLogOut()\n } catch (_) {\n // \n }\n processedWalletAddressRef.current = null;\n updateContext({ walletType: null });\n // todo: delete sessionId from localStorage\n window.location.reload();\n }, [updateContext]);\n\n /**\n * Connect wallet using Dynamic widget\n */\n const connectWallet = useCallback(async () => {\n if (isConnecting || !showDynamicWidget || !dynamicSdkHasLoaded) return;\n\n setIsConnecting(true);\n logger.debug('Starting wallet connection process');\n\n try {\n await showDynamicWidget(true);\n logger.debug('Dynamic widget shown');\n } catch (error) {\n setIsConnecting(false);\n updateContext({ walletType: null });\n logger.error('Error showing Dynamic widget:', error);\n }\n }, [isConnecting, showDynamicWidget, updateContext, dynamicSdkHasLoaded]);\n\n // Process nordUser changes\n useEffect(() => {\n if (!dynamicSdkHasLoaded) return\n\n const currentNordUser = nordUser;\n const prevNordUser = prevNordUserRef.current;\n\n // Only run if nordUser has changed and we have processed a wallet\n if (currentNordUser && currentNordUser !== prevNordUser) {\n logger.debug('NordUser changed, checking account status');\n\n (async () => {\n try {\n if (!dynamicWallet) return;\n\n const hasNordAccount = await nord!.accountExists(dynamicWallet.address);\n const sessionId = currentNordUser.sessionId;\n const hasActiveSession = sessionId != null;\n console.log('hasNordAccount', hasNordAccount, 'hasActiveSession', hasActiveSession, 'sessionId', sessionId, 'dynamicWallet', dynamicWallet,'zzzzzzzzzzzz')\n\n updateContext({ hasNordAccount, hasActiveSession });\n\n console.log('hasNordAccount', hasNordAccount, 'hasActiveSession', hasActiveSession, 'sessionId', sessionId, 'dynamicWallet', dynamicWallet)\n\n const transitionDestination = hasNordAccount\n ? sessionId != null\n ? FlowState.FINAL_SUCCESS\n : FlowState.AUTH_LOADING\n : FlowState.CHAIN_SELECTION;\n\n if (hasNordAccount && sessionId != null) {\n setIsConnected(true);\n }\n\n // Force a small delay to ensure UI updates properly\n setTimeout(() => {\n try {\n logger.debug('Attempting transition to ' + transitionDestination);\n transition(transitionDestination, {\n walletType: 'solana',\n hasNordAccount,\n hasActiveSession,\n });\n logger.debug(\n 'Transition to ' + transitionDestination + ' completed'\n );\n } catch (error) {\n logger.error('Error during transition:', error);\n } finally {\n setIsConnecting(false);\n }\n }, 100);\n } catch (error) {\n logger.error('Error checking account status:', error);\n setIsConnecting(false);\n }\n })();\n }else{\n transition(FlowState.CONNECTING_WALLET)\n }\n\n // Update ref\n prevNordUserRef.current = currentNordUser;\n }, [\n nordUser,\n dynamicWallet,\n updateContext,\n transition,\n setIsConnected\n ]);\n\n\n\n\n // Handle connecting state changes in a separate effect\n useEffect(() => {\n const currentState = state;\n const prevState = prevStateRef.current;\n\n // Only run if state has changed\n if (currentState !== prevState) {\n if (currentState !== FlowState.CONNECTING_WALLET && isConnecting) {\n // If we're no longer in the connecting state, reset the connecting flag\n setIsConnecting(false);\n }\n\n // Update ref\n prevStateRef.current = currentState;\n }\n }, [state, isConnecting]);\n\n // Create the context value\n const contextValue: WalletConnectContextValue = {\n isConnecting,\n connectWallet,\n disconnectWallet,\n };\n\n return (\n <WalletConnectContext.Provider value={contextValue}>\n {children}\n </WalletConnectContext.Provider>\n );\n};\n\n/**\n * Custom hook to use the wallet connect context\n * @returns The wallet connect context value\n * @throws Error if used outside of a WalletConnectProvider\n */\nexport const useWalletConnectContext = (): WalletConnectContextValue => {\n const context = useContext(WalletConnectContext);\n\n if (context === undefined) {\n throw new Error('useWalletConnectContext must be used within a WalletConnectProvider');\n }\n\n return context;\n}; "]}
@@ -0,0 +1,26 @@
1
+ import { TransactionResult } from '../../../../Logic/transactionManager';
2
+ export interface DepositContextValue {
3
+ amount: string;
4
+ isDepositing: boolean;
5
+ transactionId: string | null;
6
+ transactionResult: TransactionResult | null;
7
+ authStatus: 'loading' | 'success' | 'error';
8
+ authErrorMessage: string | null;
9
+ authStatusMessage: string | null;
10
+ updateAmount: (newAmount: string) => void;
11
+ startDeposit: () => Promise<void>;
12
+ completeDeposit: () => void;
13
+ performAuth: () => Promise<void>;
14
+ getTransactionDetails: () => {
15
+ amount: string;
16
+ tx: string;
17
+ from: string;
18
+ to: string;
19
+ network: string;
20
+ status: string;
21
+ explorerUrl: string;
22
+ };
23
+ }
24
+ export interface DepositProviderProps {
25
+ children: React.ReactNode;
26
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/Modal/NordFlow/context/deposit/types.ts"],"names":[],"mappings":"","sourcesContent":["import { TransactionResult } from '../../../../Logic/transactionManager';\n\n// Define the shape of the deposit context value\nexport interface DepositContextValue {\n amount: string;\n isDepositing: boolean;\n transactionId: string | null;\n transactionResult: TransactionResult | null;\n authStatus: 'loading' | 'success' | 'error';\n authErrorMessage: string | null;\n authStatusMessage: string | null;\n updateAmount: (newAmount: string) => void;\n startDeposit: () => Promise<void>;\n completeDeposit: () => void;\n performAuth: () => Promise<void>;\n getTransactionDetails: () => {\n amount: string;\n tx: string;\n from: string;\n to: string;\n network: string;\n status: string;\n explorerUrl: string;\n };\n}\n\n// Props for the provider component\nexport interface DepositProviderProps {\n children: React.ReactNode;\n} "]}
@@ -0,0 +1,7 @@
1
+ import { FlowState } from '../../types';
2
+ export declare const useDepositAuth: (updateContext: (context: any) => void, transition: (state: FlowState, context?: any) => void, address: string | null) => {
3
+ authStatus: "error" | "loading" | "success";
4
+ authErrorMessage: string | null;
5
+ authStatusMessage: string | null;
6
+ performAuth: () => Promise<void>;
7
+ };