@n1xyz/wallet-widget 0.0.1 → 0.0.5
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/LICENSE +44 -0
- package/README.md +210 -0
- package/dist/Logic/sessionManager.d.ts +53 -0
- package/dist/Logic/sessionManager.js +178 -0
- package/dist/Logic/transactionManager.d.ts +41 -0
- package/dist/Logic/transactionManager.js +192 -0
- package/dist/Logic/utils.d.ts +1 -0
- package/dist/Logic/utils.js +47 -9
- package/dist/Modal/BackButton.js +14 -1
- package/dist/Modal/ConnectView.js +20 -23
- package/dist/Modal/CreateSessionView.js +23 -11
- package/dist/Modal/CreateUserView.js +1 -1
- package/dist/Modal/LoadingFallback.d.ts +2 -0
- package/dist/Modal/LoadingFallback.js +2 -0
- package/dist/Modal/ModalHeader.js +14 -3
- package/dist/Modal/N1WalletModal.js +91 -79
- package/dist/Modal/NTSFlow/LoadingFallback.d.ts +2 -0
- package/dist/Modal/NTSFlow/LoadingFallback.js +2 -0
- package/dist/Modal/NTSFlow/NTSFlow.d.ts +4 -0
- package/dist/Modal/NTSFlow/NTSFlow.js +30 -0
- package/dist/Modal/NTSFlow/NordFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/Modal/NTSFlow/NordFlow/WalletConnectionFlow.js +145 -0
- package/dist/Modal/NTSFlow/NordFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/Modal/NTSFlow/NordFlow/components/AnimatedButton.js +75 -0
- package/dist/Modal/NTSFlow/NordFlow/components/ChainButton.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/components/ChainButton.js +5 -0
- package/dist/Modal/NTSFlow/NordFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/Modal/NTSFlow/NordFlow/components/LoadingSquares.js +5 -0
- package/dist/Modal/NTSFlow/NordFlow/components/TransactionTable.d.ts +13 -0
- package/dist/Modal/NTSFlow/NordFlow/components/TransactionTable.js +58 -0
- package/dist/Modal/NTSFlow/NordFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/components/WaitingMessage.js +6 -0
- package/dist/Modal/NTSFlow/NordFlow/components/index.d.ts +5 -0
- package/dist/Modal/NTSFlow/NordFlow/components/index.js +5 -0
- package/dist/Modal/NTSFlow/NordFlow/constants.d.ts +37 -0
- package/dist/Modal/NTSFlow/NordFlow/constants.js +223 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/index.d.ts +8 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/index.js +8 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useButtonTyping.js +43 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useDepositFlow.d.ts +38 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useDepositFlow.js +166 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useFlowState.js +163 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useInterruptHandler.d.ts +27 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useInterruptHandler.js +101 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useNordSession.js +193 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useTableValues.js +69 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWalletConnect.d.ts +30 -0
- package/dist/Modal/NTSFlow/NordFlow/hooks/useWalletConnect.js +132 -0
- package/dist/Modal/NTSFlow/NordFlow/index.d.ts +3 -0
- package/dist/Modal/NTSFlow/NordFlow/index.js +3 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/03-ChainSelectionScreen.js +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/04-AmountInputScreen.d.ts +8 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/04-AmountInputScreen.js +20 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/05-DepositProgressScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/05-DepositProgressScreen.js +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/06-DepositSuccessScreen.js +99 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/07-NordAuthScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/07-NordAuthScreen.js +14 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/08-AuthLoadingScreen.js +20 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/09-FinalSuccessScreen.js +18 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/10-ErrorScreen.js +13 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/index.d.ts +10 -0
- package/dist/Modal/NTSFlow/NordFlow/screens/index.js +10 -0
- package/dist/Modal/NTSFlow/NordFlow/types.d.ts +105 -0
- package/dist/Modal/NTSFlow/NordFlow/types.js +34 -0
- package/dist/Modal/NTSFlow/NordFlow/utils/persistence.d.ts +24 -0
- package/dist/Modal/NTSFlow/NordFlow/utils/persistence.js +83 -0
- package/dist/Modal/NTSFlow/components/BackButton.d.ts +3 -0
- package/dist/Modal/NTSFlow/components/BackButton.js +26 -0
- package/dist/Modal/NTSFlow/components/ModalHeader.d.ts +1 -0
- package/dist/Modal/NTSFlow/components/ModalHeader.js +20 -0
- package/dist/Modal/NTSFlow/index.d.ts +1 -0
- package/dist/Modal/NTSFlow/index.js +1 -0
- package/dist/Modal/NTSFlow/views/ConnectView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/ConnectView.js +68 -0
- package/dist/Modal/NTSFlow/views/CreateSessionView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/CreateSessionView.js +245 -0
- package/dist/Modal/NTSFlow/views/CreateUserView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/CreateUserView.js +105 -0
- package/dist/Modal/NTSFlow/views/NoWhitelistView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/NoWhitelistView.js +42 -0
- package/dist/Modal/NTSFlow/views/SigningView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/SigningView.js +5 -0
- package/dist/Modal/NTSFlow/views/SuccessView.d.ts +1 -0
- package/dist/Modal/NTSFlow/views/SuccessView.js +10 -0
- package/dist/Modal/NoWhitelistView.js +14 -1
- package/dist/Modal/NordFlow/NordFlow.d.ts +9 -0
- package/dist/Modal/NordFlow/NordFlow.js +262 -0
- package/dist/Modal/NordFlow/NordFlowWrapper.d.ts +11 -0
- package/dist/Modal/NordFlow/NordFlowWrapper.js +11 -0
- package/dist/Modal/NordFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/Modal/NordFlow/WalletConnectionFlow.js +145 -0
- package/dist/Modal/NordFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/Modal/NordFlow/components/AnimatedButton.js +75 -0
- package/dist/Modal/NordFlow/components/ChainButton.d.ts +8 -0
- package/dist/Modal/NordFlow/components/ChainButton.js +21 -0
- package/dist/Modal/NordFlow/components/ImageWithFallback.d.ts +17 -0
- package/dist/Modal/NordFlow/components/ImageWithFallback.js +32 -0
- package/dist/Modal/NordFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/Modal/NordFlow/components/LoadingSquares.js +5 -0
- package/dist/Modal/NordFlow/components/TransactionTable.d.ts +13 -0
- package/dist/Modal/NordFlow/components/TransactionTable.js +83 -0
- package/dist/Modal/NordFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/Modal/NordFlow/components/WaitingMessage.js +6 -0
- package/dist/Modal/NordFlow/components/index.d.ts +5 -0
- package/dist/Modal/NordFlow/components/index.js +5 -0
- package/dist/Modal/NordFlow/constants.d.ts +37 -0
- package/dist/Modal/NordFlow/constants.js +192 -0
- package/dist/Modal/NordFlow/hoc/index.d.ts +1 -0
- package/dist/Modal/NordFlow/hoc/index.js +1 -0
- package/dist/Modal/NordFlow/hoc/withImageFallback.d.ts +7 -0
- package/dist/Modal/NordFlow/hoc/withImageFallback.js +60 -0
- package/dist/Modal/NordFlow/hooks/index.d.ts +5 -0
- package/dist/Modal/NordFlow/hooks/index.js +5 -0
- package/dist/Modal/NordFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/Modal/NordFlow/hooks/useButtonTyping.js +43 -0
- package/dist/Modal/NordFlow/hooks/useDepositFlow.d.ts +52 -0
- package/dist/Modal/NordFlow/hooks/useDepositFlow.js +365 -0
- package/dist/Modal/NordFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/Modal/NordFlow/hooks/useFlowState.js +166 -0
- package/dist/Modal/NordFlow/hooks/useInterruptHandler.d.ts +24 -0
- package/dist/Modal/NordFlow/hooks/useInterruptHandler.js +56 -0
- package/dist/Modal/NordFlow/hooks/useNordInstance.d.ts +10 -0
- package/dist/Modal/NordFlow/hooks/useNordInstance.js +310 -0
- package/dist/Modal/NordFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/Modal/NordFlow/hooks/useNordSession.js +391 -0
- package/dist/Modal/NordFlow/hooks/useNordWalletConnect.d.ts +14 -0
- package/dist/Modal/NordFlow/hooks/useNordWalletConnect.js +231 -0
- package/dist/Modal/NordFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/Modal/NordFlow/hooks/useTableValues.js +69 -0
- package/dist/Modal/NordFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/Modal/NordFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/Modal/NordFlow/hooks/useWalletConnect.d.ts +14 -0
- package/dist/Modal/NordFlow/hooks/useWalletConnect.js +221 -0
- package/dist/Modal/NordFlow/index copy.d.ts +1 -0
- package/dist/Modal/NordFlow/index copy.js +1 -0
- package/dist/Modal/NordFlow/index.d.ts +1 -0
- package/dist/Modal/NordFlow/index.js +1 -0
- package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.js +47 -0
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.d.ts +10 -0
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js +165 -0
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js +44 -0
- package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js +119 -0
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js +126 -0
- package/dist/Modal/NordFlow/screens/07-NordAuthScreen.d.ts +5 -0
- package/dist/Modal/NordFlow/screens/07-NordAuthScreen.js +17 -0
- package/dist/Modal/NordFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/08-AuthLoadingScreen.js +153 -0
- package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.d.ts +5 -0
- package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.js +36 -0
- package/dist/Modal/NordFlow/screens/09-ErrorScreen.d.ts +7 -0
- package/dist/Modal/NordFlow/screens/09-ErrorScreen.js +62 -0
- package/dist/Modal/NordFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/Modal/NordFlow/screens/09-FinalSuccessScreen.js +47 -0
- package/dist/Modal/NordFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/Modal/NordFlow/screens/10-ErrorScreen.js +62 -0
- package/dist/Modal/NordFlow/screens/index.d.ts +9 -0
- package/dist/Modal/NordFlow/screens/index.js +9 -0
- package/dist/Modal/NordFlow/types.d.ts +108 -0
- package/dist/Modal/NordFlow/types.js +32 -0
- package/dist/Modal/NordFlow/utils/imageUtils.d.ts +21 -0
- package/dist/Modal/NordFlow/utils/imageUtils.js +109 -0
- package/dist/Modal/NordFlow/utils/index.d.ts +3 -0
- package/dist/Modal/NordFlow/utils/index.js +3 -0
- package/dist/Modal/NordFlow/utils/nordUtils.d.ts +40 -0
- package/dist/Modal/NordFlow/utils/nordUtils.js +61 -0
- package/dist/Modal/NordFlow/utils/persistence.d.ts +24 -0
- package/dist/Modal/NordFlow/utils/persistence.js +83 -0
- package/dist/Modal/Sidebar/N1Sidebar.js +167 -14
- package/dist/Modal/Sidebar/NordTradingView/AccountSummary/AccountSummary.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/AccountSummary/AccountSummary.js +116 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketOverview.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketOverview.js +86 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.d.ts +6 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.js +38 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketStats.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketStats.js +15 -0
- package/dist/Modal/Sidebar/NordTradingView/NordTradingView.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/NordTradingView.js +54 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBook.d.ts +5 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBook.js +197 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookDepthVisualizer.d.ts +10 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookDepthVisualizer.js +61 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.js +28 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.d.ts +11 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.js +22 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/AmountInput.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/AmountInput.js +19 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/BuySellTabs.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/BuySellTabs.js +23 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.js +76 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.d.ts +9 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.js +103 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/PriceInput.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/PriceInput.js +29 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.d.ts +9 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.js +39 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.d.ts +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.js +7 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.d.ts +8 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.js +249 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeHistory/TradeHistory.d.ts +5 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeHistory/TradeHistory.js +138 -0
- package/dist/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.js +108 -0
- package/dist/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.js +177 -0
- package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.js +188 -0
- package/dist/Modal/SigningView.js +1 -1
- package/dist/NordFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/NordFlow/WalletConnectionFlow.js +145 -0
- package/dist/NordFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/NordFlow/components/AnimatedButton.js +75 -0
- package/dist/NordFlow/components/ChainButton.d.ts +7 -0
- package/dist/NordFlow/components/ChainButton.js +5 -0
- package/dist/NordFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/NordFlow/components/LoadingSquares.js +5 -0
- package/dist/NordFlow/components/TransactionTable.d.ts +13 -0
- package/dist/NordFlow/components/TransactionTable.js +58 -0
- package/dist/NordFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/NordFlow/components/WaitingMessage.js +6 -0
- package/dist/NordFlow/components/index.d.ts +5 -0
- package/dist/NordFlow/components/index.js +5 -0
- package/dist/NordFlow/constants.d.ts +37 -0
- package/dist/NordFlow/constants.js +223 -0
- package/dist/NordFlow/hooks/index.d.ts +8 -0
- package/dist/NordFlow/hooks/index.js +8 -0
- package/dist/NordFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/NordFlow/hooks/useButtonTyping.js +43 -0
- package/dist/NordFlow/hooks/useDepositFlow.d.ts +38 -0
- package/dist/NordFlow/hooks/useDepositFlow.js +166 -0
- package/dist/NordFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/NordFlow/hooks/useFlowState.js +163 -0
- package/dist/NordFlow/hooks/useInterruptHandler.d.ts +27 -0
- package/dist/NordFlow/hooks/useInterruptHandler.js +101 -0
- package/dist/NordFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/NordFlow/hooks/useNordSession.js +193 -0
- package/dist/NordFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/NordFlow/hooks/useTableValues.js +69 -0
- package/dist/NordFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/NordFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/NordFlow/hooks/useWalletConnect.d.ts +30 -0
- package/dist/NordFlow/hooks/useWalletConnect.js +132 -0
- package/dist/NordFlow/index.d.ts +3 -0
- package/dist/NordFlow/index.js +3 -0
- package/dist/NordFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/NordFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/NordFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/NordFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/NordFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/NordFlow/screens/03-ChainSelectionScreen.js +7 -0
- package/dist/NordFlow/screens/04-AmountInputScreen.d.ts +8 -0
- package/dist/NordFlow/screens/04-AmountInputScreen.js +20 -0
- package/dist/NordFlow/screens/05-DepositProgressScreen.d.ts +7 -0
- package/dist/NordFlow/screens/05-DepositProgressScreen.js +6 -0
- package/dist/NordFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/NordFlow/screens/06-DepositSuccessScreen.js +99 -0
- package/dist/NordFlow/screens/07-NordAuthScreen.d.ts +7 -0
- package/dist/NordFlow/screens/07-NordAuthScreen.js +14 -0
- package/dist/NordFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/NordFlow/screens/08-AuthLoadingScreen.js +20 -0
- package/dist/NordFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/NordFlow/screens/09-FinalSuccessScreen.js +18 -0
- package/dist/NordFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/NordFlow/screens/10-ErrorScreen.js +13 -0
- package/dist/NordFlow/screens/index.d.ts +10 -0
- package/dist/NordFlow/screens/index.js +10 -0
- package/dist/NordFlow/types.d.ts +105 -0
- package/dist/NordFlow/types.js +34 -0
- package/dist/NordFlow/utils/persistence.d.ts +24 -0
- package/dist/NordFlow/utils/persistence.js +83 -0
- package/dist/Provider/LazyWalletProvider.js +75 -38
- package/dist/Provider/N1WalletProvider.d.ts +1 -1
- package/dist/Provider/N1WalletProvider.js +63 -42
- package/dist/Provider/types.d.ts +69 -0
- package/dist/WalletConnectionFlow/WalletConnectionFlow.d.ts +9 -0
- package/dist/WalletConnectionFlow/WalletConnectionFlow.js +145 -0
- package/dist/WalletConnectionFlow/components/AnimatedButton.d.ts +14 -0
- package/dist/WalletConnectionFlow/components/AnimatedButton.js +75 -0
- package/dist/WalletConnectionFlow/components/ChainButton.d.ts +7 -0
- package/dist/WalletConnectionFlow/components/ChainButton.js +5 -0
- package/dist/WalletConnectionFlow/components/LoadingSquares.d.ts +1 -0
- package/dist/WalletConnectionFlow/components/LoadingSquares.js +5 -0
- package/dist/WalletConnectionFlow/components/TransactionTable.d.ts +13 -0
- package/dist/WalletConnectionFlow/components/TransactionTable.js +58 -0
- package/dist/WalletConnectionFlow/components/WaitingMessage.d.ts +6 -0
- package/dist/WalletConnectionFlow/components/WaitingMessage.js +6 -0
- package/dist/WalletConnectionFlow/components/index.d.ts +5 -0
- package/dist/WalletConnectionFlow/components/index.js +5 -0
- package/dist/WalletConnectionFlow/constants.d.ts +37 -0
- package/dist/WalletConnectionFlow/constants.js +223 -0
- package/dist/WalletConnectionFlow/hooks/index.d.ts +8 -0
- package/dist/WalletConnectionFlow/hooks/index.js +8 -0
- package/dist/WalletConnectionFlow/hooks/useButtonTyping.d.ts +7 -0
- package/dist/WalletConnectionFlow/hooks/useButtonTyping.js +43 -0
- package/dist/WalletConnectionFlow/hooks/useDepositFlow.d.ts +38 -0
- package/dist/WalletConnectionFlow/hooks/useDepositFlow.js +166 -0
- package/dist/WalletConnectionFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/WalletConnectionFlow/hooks/useFlowState.js +163 -0
- package/dist/WalletConnectionFlow/hooks/useInterruptHandler.d.ts +27 -0
- package/dist/WalletConnectionFlow/hooks/useInterruptHandler.js +101 -0
- package/dist/WalletConnectionFlow/hooks/useNordSession.d.ts +32 -0
- package/dist/WalletConnectionFlow/hooks/useNordSession.js +193 -0
- package/dist/WalletConnectionFlow/hooks/useTableValues.d.ts +2 -0
- package/dist/WalletConnectionFlow/hooks/useTableValues.js +69 -0
- package/dist/WalletConnectionFlow/hooks/useWaitingMessage.d.ts +6 -0
- package/dist/WalletConnectionFlow/hooks/useWaitingMessage.js +89 -0
- package/dist/WalletConnectionFlow/hooks/useWalletConnect.d.ts +30 -0
- package/dist/WalletConnectionFlow/hooks/useWalletConnect.js +132 -0
- package/dist/WalletConnectionFlow/index.d.ts +3 -0
- package/dist/WalletConnectionFlow/index.js +3 -0
- package/dist/WalletConnectionFlow/screens/01-ConnectWalletScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/01-ConnectWalletScreen.js +17 -0
- package/dist/WalletConnectionFlow/screens/02-EvmWalletAuthScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/02-EvmWalletAuthScreen.js +47 -0
- package/dist/WalletConnectionFlow/screens/03-ChainSelectionScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/03-ChainSelectionScreen.js +7 -0
- package/dist/WalletConnectionFlow/screens/04-AmountInputScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/04-AmountInputScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/05-DepositProgressScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/05-DepositProgressScreen.js +6 -0
- package/dist/WalletConnectionFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/06-DepositSuccessScreen.js +99 -0
- package/dist/WalletConnectionFlow/screens/07-NordAuthScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/07-NordAuthScreen.js +14 -0
- package/dist/WalletConnectionFlow/screens/08-AuthLoadingScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/08-AuthLoadingScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/09-FinalSuccessScreen.d.ts +5 -0
- package/dist/WalletConnectionFlow/screens/09-FinalSuccessScreen.js +18 -0
- package/dist/WalletConnectionFlow/screens/10-ErrorScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/10-ErrorScreen.js +13 -0
- package/dist/WalletConnectionFlow/screens/AmountInputScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/AmountInputScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/AppsTableScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/AppsTableScreen.js +28 -0
- package/dist/WalletConnectionFlow/screens/AuthLoadingScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/AuthLoadingScreen.js +20 -0
- package/dist/WalletConnectionFlow/screens/ChainSelectionScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/ChainSelectionScreen.js +7 -0
- package/dist/WalletConnectionFlow/screens/ConnectWalletScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/ConnectWalletScreen.js +17 -0
- package/dist/WalletConnectionFlow/screens/DepositProgressScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/DepositProgressScreen.js +6 -0
- package/dist/WalletConnectionFlow/screens/DepositSuccessScreen.d.ts +8 -0
- package/dist/WalletConnectionFlow/screens/DepositSuccessScreen.js +99 -0
- package/dist/WalletConnectionFlow/screens/ErrorScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/ErrorScreen.js +13 -0
- package/dist/WalletConnectionFlow/screens/EthToSolAuthScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/EthToSolAuthScreen.js +47 -0
- package/dist/WalletConnectionFlow/screens/EvmWalletAuthScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/EvmWalletAuthScreen.js +47 -0
- package/dist/WalletConnectionFlow/screens/FinalSuccessScreen.d.ts +5 -0
- package/dist/WalletConnectionFlow/screens/FinalSuccessScreen.js +18 -0
- package/dist/WalletConnectionFlow/screens/NordAuthScreen.d.ts +7 -0
- package/dist/WalletConnectionFlow/screens/NordAuthScreen.js +14 -0
- package/dist/WalletConnectionFlow/screens/SigningScreen.d.ts +6 -0
- package/dist/WalletConnectionFlow/screens/SigningScreen.js +6 -0
- package/dist/WalletConnectionFlow/screens/index.d.ts +10 -0
- package/dist/WalletConnectionFlow/screens/index.js +10 -0
- package/dist/WalletConnectionFlow/types.d.ts +105 -0
- package/dist/WalletConnectionFlow/types.js +34 -0
- package/dist/WalletConnectionFlow/utils/persistence.d.ts +24 -0
- package/dist/WalletConnectionFlow/utils/persistence.js +83 -0
- package/dist/components/Logo.d.ts +7 -0
- package/dist/components/Logo.js +118 -0
- package/dist/components/QRCodeLoader.d.ts +4 -0
- package/dist/components/QRCodeLoader.js +8 -0
- package/dist/components/WalletDeposit/AnimatedButton.d.ts +17 -0
- package/dist/components/WalletDeposit/AnimatedButton.js +29 -0
- package/dist/components/WalletDeposit/components/ChainButton.d.ts +7 -0
- package/dist/components/WalletDeposit/components/ChainButton.js +5 -0
- package/dist/components/WalletDeposit/components/LoadingSquares.d.ts +1 -0
- package/dist/components/WalletDeposit/components/LoadingSquares.js +5 -0
- package/dist/components/WalletDeposit/components/TransactionTable.d.ts +13 -0
- package/dist/components/WalletDeposit/components/TransactionTable.js +58 -0
- package/dist/components/WalletDeposit/components/WaitingMessage.d.ts +6 -0
- package/dist/components/WalletDeposit/components/WaitingMessage.js +6 -0
- package/dist/components/WalletDeposit/constants.d.ts +15 -0
- package/dist/components/WalletDeposit/constants.js +32 -0
- package/dist/components/WalletDeposit/hooks.d.ts +9 -0
- package/dist/components/WalletDeposit/hooks.js +185 -0
- package/dist/components/WalletDeposit/index.d.ts +1 -0
- package/dist/components/WalletDeposit/index.js +136 -0
- package/dist/components/WalletDeposit/screens/AmountInputScreen.d.ts +12 -0
- package/dist/components/WalletDeposit/screens/AmountInputScreen.js +18 -0
- package/dist/components/WalletDeposit/screens/AppsTableScreen.d.ts +8 -0
- package/dist/components/WalletDeposit/screens/AppsTableScreen.js +28 -0
- package/dist/components/WalletDeposit/screens/ChainSelectionScreen.d.ts +5 -0
- package/dist/components/WalletDeposit/screens/ChainSelectionScreen.js +8 -0
- package/dist/components/WalletDeposit/screens/InitialScreen.d.ts +9 -0
- package/dist/components/WalletDeposit/screens/InitialScreen.js +18 -0
- package/dist/components/WalletDeposit/screens/SigningScreen.d.ts +6 -0
- package/dist/components/WalletDeposit/screens/SigningScreen.js +6 -0
- package/dist/components/WalletDeposit/screens/SuccessScreen.d.ts +12 -0
- package/dist/components/WalletDeposit/screens/SuccessScreen.js +7 -0
- package/dist/components/WalletDeposit/types.d.ts +48 -0
- package/dist/config/dynamic.d.ts +20 -0
- package/dist/config/dynamic.js +47 -0
- package/dist/config/solana.d.ts +25 -0
- package/dist/config/solana.js +41 -0
- package/dist/errors/types.d.ts +5 -1
- package/dist/errors/types.js +12 -0
- package/dist/hooks/useSolanaSession.d.ts +17 -0
- package/dist/hooks/useSolanaSession.js +180 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/main.css +1 -1
- package/dist/utils/dynamicImports.d.ts +24 -0
- package/dist/utils/dynamicImports.js +41 -0
- package/dist/utils/shortenString.d.ts +2 -0
- package/dist/utils/shortenString.js +8 -0
- package/dist/utils/solana-session.d.ts +84 -0
- package/dist/utils/solana-session.js +230 -0
- package/package.json +24 -17
- package/.eslintrc.js +0 -29
- package/dist/Common/NIcon.js +0 -7
- package/dist/components/AnimatedButton.d.ts +0 -9
- package/dist/components/AnimatedButton.js +0 -5
- package/postcss.config.js +0 -6
- package/src/Logic/getPseudoName.ts +0 -5832
- package/src/Logic/utils.ts +0 -162
- package/src/Logic/words.ts +0 -93571
- package/src/Modal/BackButton.tsx +0 -23
- package/src/Modal/ConnectView.tsx +0 -88
- package/src/Modal/CreateSessionView.tsx +0 -242
- package/src/Modal/CreateUserView.tsx +0 -195
- package/src/Modal/ModalHeader.tsx +0 -64
- package/src/Modal/N1WalletModal.tsx +0 -275
- package/src/Modal/NoWhitelistView.tsx +0 -61
- package/src/Modal/Sidebar/N1Sidebar.tsx +0 -172
- package/src/Modal/SigningView.tsx +0 -18
- package/src/Modal/SuccessView.tsx +0 -36
- package/src/Provider/LazyWalletProvider.tsx +0 -136
- package/src/Provider/N1WalletProvider.tsx +0 -208
- package/src/Provider/context.ts +0 -11
- package/src/Provider/hooks.ts +0 -22
- package/src/Provider/icons/CoinbaseWalletIcon.tsx +0 -27
- package/src/Provider/icons/ConnectionDotsSVG.tsx +0 -19
- package/src/Provider/icons/MetamaskIcon.tsx +0 -58
- package/src/Provider/icons/PhantomIcon.tsx +0 -26
- package/src/Provider/icons/UserIcon.tsx +0 -15
- package/src/Provider/icons/WalletConnectIcon.tsx +0 -15
- package/src/Provider/index.ts +0 -3
- package/src/Provider/types.ts +0 -77
- package/src/WidgetButton/N1ConnectButton.tsx +0 -72
- package/src/components/LazyLoadWrapper.tsx +0 -19
- package/src/config.ts +0 -2
- package/src/errors/types.ts +0 -49
- package/src/index.ts +0 -5
- package/src/main.css +0 -3
- package/src/styles/main.css +0 -3
- package/src/utils/lazyLoad.ts +0 -12
- package/src/utils/logger.ts +0 -98
- package/src/utils/react-shim.js +0 -8
- package/tailwind.config.js +0 -44
- package/tsconfig.json +0 -21
- /package/dist/{Common/NIcon.d.ts → components/WalletDeposit/types.js} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function TransactionTable(_a) {
|
|
3
|
+
var tableValues = _a.tableValues, onClose = _a.onClose;
|
|
4
|
+
// Friendly labels for the keys
|
|
5
|
+
var getLabel = function (key) {
|
|
6
|
+
var labels = {
|
|
7
|
+
amount: 'Amount',
|
|
8
|
+
tx: 'Transaction ID',
|
|
9
|
+
from: 'From',
|
|
10
|
+
to: 'To',
|
|
11
|
+
network: 'Network',
|
|
12
|
+
status: 'Status'
|
|
13
|
+
};
|
|
14
|
+
return labels[key] || key;
|
|
15
|
+
};
|
|
16
|
+
// Get appropriate color for values based on key
|
|
17
|
+
var getValueStyles = function (key, value) {
|
|
18
|
+
if (key === 'status') {
|
|
19
|
+
if (value.toLowerCase().includes('success') || value.toLowerCase().includes('confirmed')) {
|
|
20
|
+
return 'text-green-500 dark:text-emerald-500 font-medium';
|
|
21
|
+
}
|
|
22
|
+
if (value.toLowerCase().includes('pending')) {
|
|
23
|
+
return 'text-amber-500 dark:text-amber-400 font-medium';
|
|
24
|
+
}
|
|
25
|
+
if (value.toLowerCase().includes('fail') || value.toLowerCase().includes('error')) {
|
|
26
|
+
return 'text-red-500 dark:text-red-400 font-medium';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (key === 'tx') {
|
|
30
|
+
return 'text-primary-600 dark:text-primary-400 text-xs ';
|
|
31
|
+
}
|
|
32
|
+
if (key === 'network') {
|
|
33
|
+
return 'text-purple-600 dark:text-purple-400 font-medium';
|
|
34
|
+
}
|
|
35
|
+
if (key === 'from' || key === 'to') {
|
|
36
|
+
return 'text-gray-800 dark:text-gray-200 text-xs ';
|
|
37
|
+
}
|
|
38
|
+
if (key === 'amount') {
|
|
39
|
+
return 'text-green-600 dark:text-emerald-500 font-semibold';
|
|
40
|
+
}
|
|
41
|
+
return 'text-gray-900 dark:text-gray-50 font-medium';
|
|
42
|
+
};
|
|
43
|
+
// Order of fields to display
|
|
44
|
+
var fieldOrder = ['amount', 'status', 'network', 'from', 'to', 'tx'];
|
|
45
|
+
// Sort entries based on fieldOrder
|
|
46
|
+
var sortedEntries = Object.entries(tableValues)
|
|
47
|
+
.sort(function (_a, _b) {
|
|
48
|
+
var keyA = _a[0];
|
|
49
|
+
var keyB = _b[0];
|
|
50
|
+
var indexA = fieldOrder.indexOf(keyA);
|
|
51
|
+
var indexB = fieldOrder.indexOf(keyB);
|
|
52
|
+
return (indexA === -1 ? 999 : indexA) - (indexB === -1 ? 999 : indexB);
|
|
53
|
+
});
|
|
54
|
+
return (_jsxs("div", { className: "relative w-full h-full bg-gray-100 dark:bg-gray-950 border border-gray-200 dark:border-gray-800 p-5 rounded-sm flex flex-col justify-center", children: [onClose && (_jsx("button", { onClick: onClose, className: "absolute top-3 right-2 text-gray-500 dark:text-gray-600 hover:text-gray-500 dark:hover:text-gray-300 transition-colors duration-200 focus:outline-none", "aria-label": "Close details", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), _jsx("div", { className: "space-y-3 text-sm pt-5", children: sortedEntries.map(function (_a) {
|
|
55
|
+
var key = _a[0], value = _a[1];
|
|
56
|
+
return (_jsxs("div", { className: "flex items-center justify-between py-2 ", children: [_jsx("span", { className: "text-gray-500 dark:text-gray-400 font-medium min-w-[120px]", children: getLabel(key) }), _jsxs("div", { className: "relative transition-all duration-300 ".concat(value.visible ? 'opacity-100' : 'opacity-0', " max-w-[65%] text-right flex-1"), children: [_jsx("span", { className: "".concat(getValueStyles(key, value.text), " break-all inline-block"), children: value.text }), value.typing && (_jsx("span", { className: "inline-block ml-1 w-[2px] h-[14px] bg-primary-500 dark:bg-primary-400 animate-pulse" }))] })] }, key));
|
|
57
|
+
}) })] }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LoadingSquares } from './LoadingSquares';
|
|
3
|
+
export function WaitingMessage(_a) {
|
|
4
|
+
var message = _a.message;
|
|
5
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center py-12 space-y-6", children: [_jsx(LoadingSquares, {}), _jsxs("div", { className: "space-y-2 text-center w-[300px]", children: [_jsxs("h3", { className: "text-xl text-gray-800 dark:text-white transition-all duration-300 h-[32px] flex items-center justify-center relative font-semibold", children: [_jsx("span", { className: "opacity-0 absolute select-none", "aria-hidden": "true", children: "Waiting for transaction" }), _jsx("div", { className: "absolute min-w-[280px]", children: message.visible && message.title })] }), _jsxs("p", { className: "text-sm text-gray-600 dark:text-neutral-400 h-[20px] flex items-center justify-center relative", children: [_jsx("span", { className: "opacity-0 absolute select-none", "aria-hidden": "true", children: "Please sign the transaction in your wallet" }), _jsx("div", { className: "absolute min-w-[280px]", children: message.visible && message.subtitle })] })] })] }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StateTransition } from './types';
|
|
2
|
+
export declare const ANIMATION_EASE = "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
3
|
+
export declare const TYPING_INTERVAL = 50;
|
|
4
|
+
export declare const ANIMATION_DURATION = 3000;
|
|
5
|
+
export declare const MIN_DEPOSIT = 1;
|
|
6
|
+
export declare const MAX_DEPOSIT = 10000;
|
|
7
|
+
export declare const INITIAL_APPS: {
|
|
8
|
+
name: string;
|
|
9
|
+
color: string;
|
|
10
|
+
progress: number;
|
|
11
|
+
}[];
|
|
12
|
+
/**
|
|
13
|
+
* Available chains for deposit
|
|
14
|
+
*/
|
|
15
|
+
export declare const AVAILABLE_CHAINS: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
logo: string;
|
|
19
|
+
}[];
|
|
20
|
+
export declare const CHAINS: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
logo: string;
|
|
24
|
+
}[];
|
|
25
|
+
/**
|
|
26
|
+
* State machine transitions
|
|
27
|
+
* Defines all possible transitions between states and their conditions
|
|
28
|
+
*/
|
|
29
|
+
export declare const STATE_TRANSITIONS: StateTransition[];
|
|
30
|
+
/**
|
|
31
|
+
* Local storage key for persisting flow state
|
|
32
|
+
*/
|
|
33
|
+
export declare const FLOW_STATE_STORAGE_KEY = "n1_wallet_connection_flow_state";
|
|
34
|
+
/**
|
|
35
|
+
* Time in milliseconds after which a persisted state is considered stale
|
|
36
|
+
*/
|
|
37
|
+
export declare const STATE_EXPIRY_TIME: number;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { FlowState } from './types';
|
|
2
|
+
export var ANIMATION_EASE = 'cubic-bezier(0.16, 1, 0.3, 1)';
|
|
3
|
+
export var TYPING_INTERVAL = 50;
|
|
4
|
+
export var ANIMATION_DURATION = 3000;
|
|
5
|
+
export var MIN_DEPOSIT = 1;
|
|
6
|
+
export var MAX_DEPOSIT = 10000;
|
|
7
|
+
export var INITIAL_APPS = Array.from({ length: 20 }, function (_, i) { return ({
|
|
8
|
+
name: "App".concat(i + 1),
|
|
9
|
+
color: '#ff2b1f',
|
|
10
|
+
progress: 0,
|
|
11
|
+
}); });
|
|
12
|
+
/**
|
|
13
|
+
* Available chains for deposit
|
|
14
|
+
*/
|
|
15
|
+
export var AVAILABLE_CHAINS = [
|
|
16
|
+
{
|
|
17
|
+
id: 'ethereum',
|
|
18
|
+
name: 'Ethereum',
|
|
19
|
+
logo: 'ethereum-logo.svg',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'solana',
|
|
23
|
+
name: 'Solana',
|
|
24
|
+
logo: 'solana-logo.svg',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
export var CHAINS = [
|
|
28
|
+
{
|
|
29
|
+
id: 'ethereum',
|
|
30
|
+
name: 'Ethereum',
|
|
31
|
+
logo: '/images/chains/ethereum.svg',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'polygon',
|
|
35
|
+
name: 'Polygon',
|
|
36
|
+
logo: '/images/chains/polygon.svg',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'arbitrum',
|
|
40
|
+
name: 'Arbitrum',
|
|
41
|
+
logo: '/images/chains/arbitrum.svg',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'optimism',
|
|
45
|
+
name: 'Optimism',
|
|
46
|
+
logo: '/images/chains/optimism.svg',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* State machine transitions
|
|
51
|
+
* Defines all possible transitions between states and their conditions
|
|
52
|
+
*/
|
|
53
|
+
export var STATE_TRANSITIONS = [
|
|
54
|
+
// From IDLE state
|
|
55
|
+
{
|
|
56
|
+
from: FlowState.IDLE,
|
|
57
|
+
to: FlowState.CONNECTING_WALLET,
|
|
58
|
+
condition: function (context) { return !context.walletType; }, // Only if wallet is not connected
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
from: FlowState.IDLE,
|
|
62
|
+
to: FlowState.WALLET_CONNECTED,
|
|
63
|
+
condition: function (context) { return !!context.walletType; }, // If wallet is already connected
|
|
64
|
+
},
|
|
65
|
+
// From CONNECTING_WALLET state
|
|
66
|
+
{
|
|
67
|
+
from: FlowState.CONNECTING_WALLET,
|
|
68
|
+
to: FlowState.WALLET_CONNECTED,
|
|
69
|
+
// When wallet connection is successful
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
from: FlowState.CONNECTING_WALLET,
|
|
73
|
+
to: FlowState.ERROR,
|
|
74
|
+
// When wallet connection fails
|
|
75
|
+
},
|
|
76
|
+
// From WALLET_CONNECTED state
|
|
77
|
+
{
|
|
78
|
+
from: FlowState.WALLET_CONNECTED,
|
|
79
|
+
to: FlowState.ETH_TO_SOL_AUTH,
|
|
80
|
+
condition: function (context) { return context.walletType === 'ethereum'; }, // If Ethereum wallet
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
from: FlowState.WALLET_CONNECTED,
|
|
84
|
+
to: FlowState.CHAIN_SELECTION,
|
|
85
|
+
condition: function (context) {
|
|
86
|
+
return context.walletType === 'solana' && !context.hasNordAccount;
|
|
87
|
+
}, // If Solana wallet and no Nord account
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
from: FlowState.WALLET_CONNECTED,
|
|
91
|
+
to: FlowState.NORD_AUTH,
|
|
92
|
+
condition: function (context) {
|
|
93
|
+
return context.walletType === 'solana' &&
|
|
94
|
+
context.hasNordAccount &&
|
|
95
|
+
!context.hasActiveSession;
|
|
96
|
+
},
|
|
97
|
+
// If Solana wallet, has Nord account but no active session
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
from: FlowState.WALLET_CONNECTED,
|
|
101
|
+
to: FlowState.FINAL_SUCCESS,
|
|
102
|
+
condition: function (context) {
|
|
103
|
+
return context.walletType === 'solana' &&
|
|
104
|
+
context.hasNordAccount &&
|
|
105
|
+
context.hasActiveSession;
|
|
106
|
+
},
|
|
107
|
+
// If Solana wallet, has Nord account and active session
|
|
108
|
+
},
|
|
109
|
+
// From ETH_TO_SOL_AUTH state
|
|
110
|
+
{
|
|
111
|
+
from: FlowState.ETH_TO_SOL_AUTH,
|
|
112
|
+
to: FlowState.CHAIN_SELECTION,
|
|
113
|
+
condition: function (context) { return !context.hasNordAccount; }, // After ETH auth, if no Nord account
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
from: FlowState.ETH_TO_SOL_AUTH,
|
|
117
|
+
to: FlowState.NORD_AUTH,
|
|
118
|
+
condition: function (context) { return context.hasNordAccount && !context.hasActiveSession; },
|
|
119
|
+
// After ETH auth, if has Nord account but no active session
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
from: FlowState.ETH_TO_SOL_AUTH,
|
|
123
|
+
to: FlowState.FINAL_SUCCESS,
|
|
124
|
+
condition: function (context) { return context.hasNordAccount && context.hasActiveSession; },
|
|
125
|
+
// After ETH auth, if has Nord account and active session
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
from: FlowState.ETH_TO_SOL_AUTH,
|
|
129
|
+
to: FlowState.ERROR,
|
|
130
|
+
// If ETH to SOL auth fails
|
|
131
|
+
},
|
|
132
|
+
// From CHAIN_SELECTION state
|
|
133
|
+
{
|
|
134
|
+
from: FlowState.CHAIN_SELECTION,
|
|
135
|
+
to: FlowState.AMOUNT_INPUT,
|
|
136
|
+
// After chain selection
|
|
137
|
+
},
|
|
138
|
+
// From AMOUNT_INPUT state
|
|
139
|
+
{
|
|
140
|
+
from: FlowState.AMOUNT_INPUT,
|
|
141
|
+
to: FlowState.DEPOSIT_PROGRESS,
|
|
142
|
+
// After amount input
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
from: FlowState.AMOUNT_INPUT,
|
|
146
|
+
to: FlowState.CHAIN_SELECTION,
|
|
147
|
+
// If user goes back to chain selection
|
|
148
|
+
},
|
|
149
|
+
// From DEPOSIT_PROGRESS state
|
|
150
|
+
{
|
|
151
|
+
from: FlowState.DEPOSIT_PROGRESS,
|
|
152
|
+
to: FlowState.DEPOSIT_SUCCESS,
|
|
153
|
+
// When deposit is successful
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
from: FlowState.DEPOSIT_PROGRESS,
|
|
157
|
+
to: FlowState.ERROR,
|
|
158
|
+
// When deposit fails
|
|
159
|
+
},
|
|
160
|
+
// From DEPOSIT_SUCCESS state
|
|
161
|
+
{
|
|
162
|
+
from: FlowState.DEPOSIT_SUCCESS,
|
|
163
|
+
to: FlowState.NORD_AUTH,
|
|
164
|
+
condition: function (context) { return !context.hasActiveSession; }, // If no active Nord session
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
from: FlowState.DEPOSIT_SUCCESS,
|
|
168
|
+
to: FlowState.FINAL_SUCCESS,
|
|
169
|
+
condition: function (context) { return context.hasActiveSession; }, // If active Nord session exists
|
|
170
|
+
},
|
|
171
|
+
// From NORD_AUTH state
|
|
172
|
+
{
|
|
173
|
+
from: FlowState.NORD_AUTH,
|
|
174
|
+
to: FlowState.AUTH_LOADING,
|
|
175
|
+
// When Nord auth starts
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
from: FlowState.NORD_AUTH,
|
|
179
|
+
to: FlowState.ERROR,
|
|
180
|
+
// When Nord auth fails to start
|
|
181
|
+
},
|
|
182
|
+
// From AUTH_LOADING state
|
|
183
|
+
{
|
|
184
|
+
from: FlowState.AUTH_LOADING,
|
|
185
|
+
to: FlowState.FINAL_SUCCESS,
|
|
186
|
+
// When auth is successful
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
from: FlowState.AUTH_LOADING,
|
|
190
|
+
to: FlowState.ERROR,
|
|
191
|
+
// When auth fails
|
|
192
|
+
},
|
|
193
|
+
// From ERROR state
|
|
194
|
+
{
|
|
195
|
+
from: FlowState.ERROR,
|
|
196
|
+
to: FlowState.IDLE,
|
|
197
|
+
// When restarting after error
|
|
198
|
+
},
|
|
199
|
+
// Global recovery transition (can happen from any state upon recovery)
|
|
200
|
+
{
|
|
201
|
+
from: [
|
|
202
|
+
FlowState.CONNECTING_WALLET,
|
|
203
|
+
FlowState.WALLET_CONNECTED,
|
|
204
|
+
FlowState.ETH_TO_SOL_AUTH,
|
|
205
|
+
FlowState.CHAIN_SELECTION,
|
|
206
|
+
FlowState.AMOUNT_INPUT,
|
|
207
|
+
FlowState.DEPOSIT_PROGRESS,
|
|
208
|
+
FlowState.DEPOSIT_SUCCESS,
|
|
209
|
+
FlowState.NORD_AUTH,
|
|
210
|
+
FlowState.AUTH_LOADING,
|
|
211
|
+
],
|
|
212
|
+
to: FlowState.IDLE,
|
|
213
|
+
// For recovery after interruption
|
|
214
|
+
},
|
|
215
|
+
];
|
|
216
|
+
/**
|
|
217
|
+
* Local storage key for persisting flow state
|
|
218
|
+
*/
|
|
219
|
+
export var FLOW_STATE_STORAGE_KEY = 'n1_wallet_connection_flow_state';
|
|
220
|
+
/**
|
|
221
|
+
* Time in milliseconds after which a persisted state is considered stale
|
|
222
|
+
*/
|
|
223
|
+
export var STATE_EXPIRY_TIME = 30 * 60 * 1000; // 30 minutes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './useNordSession';
|
|
2
|
+
export * from './useDepositFlow';
|
|
3
|
+
export * from './useWalletConnect';
|
|
4
|
+
export * from './useInterruptHandler';
|
|
5
|
+
export * from './useFlowState';
|
|
6
|
+
export * from './useWaitingMessage';
|
|
7
|
+
export * from './useTableValues';
|
|
8
|
+
export * from './useButtonTyping';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './useNordSession';
|
|
2
|
+
export * from './useDepositFlow';
|
|
3
|
+
export * from './useWalletConnect';
|
|
4
|
+
export * from './useInterruptHandler';
|
|
5
|
+
export * from './useFlowState';
|
|
6
|
+
export * from './useWaitingMessage';
|
|
7
|
+
export * from './useTableValues';
|
|
8
|
+
export * from './useButtonTyping';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { ButtonKey, ButtonStates } from '../types';
|
|
3
|
+
interface ButtonConfig {
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function useButtonTyping(buttonStates: ButtonStates, setButtonStates: Dispatch<SetStateAction<ButtonStates>>, buttonConfigs?: Record<ButtonKey, ButtonConfig>): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { useEffect } from 'react';
|
|
13
|
+
import { TYPING_INTERVAL } from '../constants';
|
|
14
|
+
var DEFAULT_BUTTON_CONFIGS = {
|
|
15
|
+
deposit: { text: 'Deposit' },
|
|
16
|
+
continue: { text: 'Continue' },
|
|
17
|
+
openApp: { text: 'Launch' },
|
|
18
|
+
};
|
|
19
|
+
export function useButtonTyping(buttonStates, setButtonStates, buttonConfigs) {
|
|
20
|
+
if (buttonConfigs === void 0) { buttonConfigs = DEFAULT_BUTTON_CONFIGS; }
|
|
21
|
+
useEffect(function () {
|
|
22
|
+
Object.entries(buttonStates).forEach(function (_a) {
|
|
23
|
+
var key = _a[0], state = _a[1];
|
|
24
|
+
if (state.isTyping) {
|
|
25
|
+
var config_1 = buttonConfigs[key];
|
|
26
|
+
var index_1 = 0;
|
|
27
|
+
var interval_1 = setInterval(function () {
|
|
28
|
+
if (index_1 <= config_1.text.length) {
|
|
29
|
+
setButtonStates(function (prev) {
|
|
30
|
+
var _a;
|
|
31
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[key] = __assign(__assign({}, prev[key]), { text: config_1.text.slice(0, index_1) }), _a)));
|
|
32
|
+
});
|
|
33
|
+
index_1++;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
clearInterval(interval_1);
|
|
37
|
+
}
|
|
38
|
+
}, TYPING_INTERVAL);
|
|
39
|
+
return function () { return clearInterval(interval_1); };
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}, [buttonStates, setButtonStates, buttonConfigs]);
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FlowContext, FlowState } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for handling the deposit flow
|
|
4
|
+
*
|
|
5
|
+
* @param options Configuration options
|
|
6
|
+
* @returns Deposit flow methods and state
|
|
7
|
+
*/
|
|
8
|
+
export declare const useDepositFlow: (options: {
|
|
9
|
+
/**
|
|
10
|
+
* Flow state
|
|
11
|
+
*/
|
|
12
|
+
state: FlowState;
|
|
13
|
+
/**
|
|
14
|
+
* Flow context
|
|
15
|
+
*/
|
|
16
|
+
context: FlowContext;
|
|
17
|
+
/**
|
|
18
|
+
* Transition to a new state
|
|
19
|
+
*/
|
|
20
|
+
transition: (newState: FlowState, contextUpdates?: Partial<FlowContext>) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Handle errors
|
|
23
|
+
*/
|
|
24
|
+
handleError: (error: Error) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Update context
|
|
27
|
+
*/
|
|
28
|
+
updateContext?: (contextUpdates: Partial<FlowContext>) => void;
|
|
29
|
+
}) => {
|
|
30
|
+
selectedChain: string | null;
|
|
31
|
+
amount: string;
|
|
32
|
+
isDepositing: boolean;
|
|
33
|
+
transactionId: string | null;
|
|
34
|
+
selectChain: (chainId: string) => void;
|
|
35
|
+
updateAmount: (newAmount: string) => void;
|
|
36
|
+
startDeposit: () => Promise<void>;
|
|
37
|
+
goBackToChainSelection: () => void;
|
|
38
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
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 { useCallback, useEffect, useState } from 'react';
|
|
38
|
+
import { FlowState } from '../types';
|
|
39
|
+
import { AVAILABLE_CHAINS } from '../constants';
|
|
40
|
+
/**
|
|
41
|
+
* Hook for handling the deposit flow
|
|
42
|
+
*
|
|
43
|
+
* @param options Configuration options
|
|
44
|
+
* @returns Deposit flow methods and state
|
|
45
|
+
*/
|
|
46
|
+
export var useDepositFlow = function (options) {
|
|
47
|
+
var state = options.state, context = options.context, transition = options.transition, handleError = options.handleError;
|
|
48
|
+
var _a = useState(context.selectedChain), selectedChain = _a[0], setSelectedChain = _a[1];
|
|
49
|
+
var _b = useState(context.amount), amount = _b[0], setAmount = _b[1];
|
|
50
|
+
var _c = useState(false), isDepositing = _c[0], setIsDepositing = _c[1];
|
|
51
|
+
var _d = useState(context.transactionId), transactionId = _d[0], setTransactionId = _d[1];
|
|
52
|
+
/**
|
|
53
|
+
* Select a chain for deposit
|
|
54
|
+
*/
|
|
55
|
+
var selectChain = useCallback(function (chainId) {
|
|
56
|
+
var validChain = AVAILABLE_CHAINS.find(function (chain) { return chain.id === chainId; });
|
|
57
|
+
if (!validChain) {
|
|
58
|
+
handleError(new Error("Invalid chain: ".concat(chainId)));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setSelectedChain(chainId);
|
|
62
|
+
transition(FlowState.AMOUNT_INPUT, { selectedChain: chainId });
|
|
63
|
+
}, [transition, handleError]);
|
|
64
|
+
/**
|
|
65
|
+
* Update amount for deposit
|
|
66
|
+
*/
|
|
67
|
+
var updateAmount = useCallback(function (newAmount) {
|
|
68
|
+
setAmount(newAmount);
|
|
69
|
+
// Only update the context without transitioning to the same state
|
|
70
|
+
// This prevents the "Transition from AMOUNT_INPUT to AMOUNT_INPUT is not allowed" error
|
|
71
|
+
if (state === FlowState.AMOUNT_INPUT) {
|
|
72
|
+
// Use updateContext function if available to update without state transition
|
|
73
|
+
if (options.updateContext) {
|
|
74
|
+
options.updateContext({ amount: newAmount });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
transition(state, { amount: newAmount });
|
|
79
|
+
}
|
|
80
|
+
}, [state, transition, options.updateContext]);
|
|
81
|
+
/**
|
|
82
|
+
* Start deposit process
|
|
83
|
+
*/
|
|
84
|
+
var startDeposit = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
if (isDepositing)
|
|
87
|
+
return [2 /*return*/];
|
|
88
|
+
// Validate input
|
|
89
|
+
if (!selectedChain) {
|
|
90
|
+
handleError(new Error('No chain selected'));
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
if (!amount || parseFloat(amount) <= 0) {
|
|
94
|
+
handleError(new Error('Invalid amount'));
|
|
95
|
+
return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
setIsDepositing(true);
|
|
98
|
+
transition(FlowState.DEPOSIT_PROGRESS);
|
|
99
|
+
try {
|
|
100
|
+
// In the real implementation, this would call the API to initiate the deposit
|
|
101
|
+
// For now, simulate the deposit with a timeout
|
|
102
|
+
setTimeout(function () {
|
|
103
|
+
// Generate a mock transaction ID
|
|
104
|
+
var mockTxId = "tx_".concat(Math.random().toString(36).substr(2, 9));
|
|
105
|
+
setTransactionId(mockTxId);
|
|
106
|
+
// Update context and transition to success
|
|
107
|
+
transition(FlowState.DEPOSIT_SUCCESS, { transactionId: mockTxId });
|
|
108
|
+
setIsDepositing(false);
|
|
109
|
+
}, 3000);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
setIsDepositing(false);
|
|
113
|
+
handleError(error instanceof Error ? error : new Error('Failed to process deposit'));
|
|
114
|
+
}
|
|
115
|
+
return [2 /*return*/];
|
|
116
|
+
});
|
|
117
|
+
}); }, [isDepositing, selectedChain, amount, transition, handleError]);
|
|
118
|
+
/**
|
|
119
|
+
* Go back to chain selection
|
|
120
|
+
*/
|
|
121
|
+
var goBackToChainSelection = useCallback(function () {
|
|
122
|
+
setAmount('');
|
|
123
|
+
transition(FlowState.CHAIN_SELECTION, { amount: '' });
|
|
124
|
+
}, [transition]);
|
|
125
|
+
/**
|
|
126
|
+
* Update state based on context changes
|
|
127
|
+
*/
|
|
128
|
+
useEffect(function () {
|
|
129
|
+
if (context.selectedChain !== selectedChain) {
|
|
130
|
+
setSelectedChain(context.selectedChain);
|
|
131
|
+
}
|
|
132
|
+
if (context.amount !== amount) {
|
|
133
|
+
setAmount(context.amount);
|
|
134
|
+
}
|
|
135
|
+
if (context.transactionId !== transactionId) {
|
|
136
|
+
setTransactionId(context.transactionId);
|
|
137
|
+
}
|
|
138
|
+
}, [
|
|
139
|
+
context.selectedChain,
|
|
140
|
+
context.amount,
|
|
141
|
+
context.transactionId,
|
|
142
|
+
selectedChain,
|
|
143
|
+
amount,
|
|
144
|
+
transactionId,
|
|
145
|
+
]);
|
|
146
|
+
/**
|
|
147
|
+
* Auto-start deposit if in deposit progress state
|
|
148
|
+
*/
|
|
149
|
+
useEffect(function () {
|
|
150
|
+
if (state === FlowState.DEPOSIT_PROGRESS &&
|
|
151
|
+
!isDepositing &&
|
|
152
|
+
!transactionId) {
|
|
153
|
+
startDeposit();
|
|
154
|
+
}
|
|
155
|
+
}, [state, isDepositing, transactionId, startDeposit]);
|
|
156
|
+
return {
|
|
157
|
+
selectedChain: selectedChain,
|
|
158
|
+
amount: amount,
|
|
159
|
+
isDepositing: isDepositing,
|
|
160
|
+
transactionId: transactionId,
|
|
161
|
+
selectChain: selectChain,
|
|
162
|
+
updateAmount: updateAmount,
|
|
163
|
+
startDeposit: startDeposit,
|
|
164
|
+
goBackToChainSelection: goBackToChainSelection,
|
|
165
|
+
};
|
|
166
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FlowContext, FlowState } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook for managing the wallet connection flow state machine
|
|
4
|
+
* @param options Configuration options
|
|
5
|
+
* @returns Flow state management methods and properties
|
|
6
|
+
*/
|
|
7
|
+
export declare const useFlowState: (options: {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to automatically recover saved state on initialization
|
|
10
|
+
*/
|
|
11
|
+
autoRecover?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback when state changes
|
|
14
|
+
*/
|
|
15
|
+
onStateChange?: (newState: FlowState, prevState: FlowState | null) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Callback when an error occurs
|
|
18
|
+
*/
|
|
19
|
+
onError?: (error: Error) => void;
|
|
20
|
+
}) => {
|
|
21
|
+
state: FlowState;
|
|
22
|
+
prevState: FlowState | null;
|
|
23
|
+
context: FlowContext;
|
|
24
|
+
isTransitioning: boolean;
|
|
25
|
+
isRecoveryAvailable: boolean;
|
|
26
|
+
transition: (targetState: FlowState, contextUpdates?: Partial<FlowContext>) => boolean;
|
|
27
|
+
updateContext: (updates: Partial<FlowContext>) => void;
|
|
28
|
+
reset: () => void;
|
|
29
|
+
recover: () => boolean;
|
|
30
|
+
recordInterruption: () => void;
|
|
31
|
+
handleError: (error: Error) => void;
|
|
32
|
+
};
|