@n1xyz/wallet-widget 0.0.4 → 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/README.md +184 -19
- 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/Modal/BackButton.js +1 -1
- package/dist/Modal/ConnectView.js +1 -1
- package/dist/Modal/CreateSessionView.js +1 -1
- package/dist/Modal/LoadingFallback.d.ts +2 -0
- package/dist/Modal/LoadingFallback.js +2 -0
- package/dist/Modal/ModalHeader.js +1 -1
- package/dist/Modal/N1WalletModal.js +88 -81
- 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 +1 -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 +32 -18
- 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/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 -42
- package/dist/Provider/N1WalletProvider.d.ts +1 -1
- package/dist/Provider/N1WalletProvider.js +61 -43
- package/dist/Provider/types.d.ts +61 -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/WalletDeposit/components/TransactionTable.d.ts +9 -2
- package/dist/components/WalletDeposit/components/TransactionTable.js +55 -5
- package/dist/components/WalletDeposit/types.d.ts +5 -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 +1 -2
- package/dist/index.js +1 -2
- package/dist/main.css +1 -1
- package/dist/utils/solana-session.d.ts +84 -0
- package/dist/utils/solana-session.js +230 -0
- package/package.json +14 -11
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
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 { useCallback, useEffect, useState } from 'react';
|
|
13
|
+
import { FlowState, initialFlowContext } from '../types';
|
|
14
|
+
import { STATE_TRANSITIONS } from '../constants';
|
|
15
|
+
import { clearStoredState, loadStateFromLocalStorage, saveStateToLocalStorage, } from '../utils/persistence';
|
|
16
|
+
/**
|
|
17
|
+
* Custom hook for managing the wallet connection flow state machine
|
|
18
|
+
* @param options Configuration options
|
|
19
|
+
* @returns Flow state management methods and properties
|
|
20
|
+
*/
|
|
21
|
+
export var useFlowState = function (options) {
|
|
22
|
+
var _a = options.autoRecover, autoRecover = _a === void 0 ? true : _a, onStateChange = options.onStateChange, onError = options.onError;
|
|
23
|
+
// Flow state
|
|
24
|
+
var _b = useState(FlowState.IDLE), state = _b[0], setState = _b[1];
|
|
25
|
+
var _c = useState(null), prevState = _c[0], setPrevState = _c[1];
|
|
26
|
+
var _d = useState(initialFlowContext), context = _d[0], setContext = _d[1];
|
|
27
|
+
var _e = useState(false), isTransitioning = _e[0], setIsTransitioning = _e[1];
|
|
28
|
+
var _f = useState(false), isRecoveryAvailable = _f[0], setIsRecoveryAvailable = _f[1];
|
|
29
|
+
/**
|
|
30
|
+
* Check if a transition is allowed based on current state and context
|
|
31
|
+
*/
|
|
32
|
+
var canTransition = useCallback(function (targetState) {
|
|
33
|
+
return STATE_TRANSITIONS.some(function (transition) {
|
|
34
|
+
var fromMatches = Array.isArray(transition.from)
|
|
35
|
+
? transition.from.includes(state)
|
|
36
|
+
: transition.from === state;
|
|
37
|
+
if (!fromMatches || transition.to !== targetState) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (transition.condition) {
|
|
41
|
+
return transition.condition(context);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
});
|
|
45
|
+
}, [state, context]);
|
|
46
|
+
/**
|
|
47
|
+
* Transition to a new state if allowed
|
|
48
|
+
*/
|
|
49
|
+
var transition = useCallback(function (targetState, contextUpdates) {
|
|
50
|
+
if (contextUpdates === void 0) { contextUpdates = {}; }
|
|
51
|
+
if (!canTransition(targetState)) {
|
|
52
|
+
console.warn("Transition from ".concat(state, " to ").concat(targetState, " is not allowed"));
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
setIsTransitioning(true);
|
|
56
|
+
// Update context first
|
|
57
|
+
setContext(function (prevContext) {
|
|
58
|
+
var newContext = __assign(__assign({}, prevContext), contextUpdates);
|
|
59
|
+
// Save new state and context to localStorage for recovery
|
|
60
|
+
saveStateToLocalStorage(targetState, newContext);
|
|
61
|
+
return newContext;
|
|
62
|
+
});
|
|
63
|
+
// Then update state
|
|
64
|
+
setPrevState(state);
|
|
65
|
+
setState(targetState);
|
|
66
|
+
if (onStateChange) {
|
|
67
|
+
onStateChange(targetState, state);
|
|
68
|
+
}
|
|
69
|
+
setIsTransitioning(false);
|
|
70
|
+
return true;
|
|
71
|
+
}, [canTransition, state, onStateChange]);
|
|
72
|
+
/**
|
|
73
|
+
* Reset flow to initial state
|
|
74
|
+
*/
|
|
75
|
+
var reset = useCallback(function () {
|
|
76
|
+
clearStoredState();
|
|
77
|
+
setContext(initialFlowContext);
|
|
78
|
+
setPrevState(null);
|
|
79
|
+
setState(FlowState.IDLE);
|
|
80
|
+
if (onStateChange) {
|
|
81
|
+
onStateChange(FlowState.IDLE, state);
|
|
82
|
+
}
|
|
83
|
+
}, [state, onStateChange]);
|
|
84
|
+
/**
|
|
85
|
+
* Handle an error by transitioning to error state
|
|
86
|
+
*/
|
|
87
|
+
var handleError = useCallback(function (error) {
|
|
88
|
+
if (onError) {
|
|
89
|
+
onError(error);
|
|
90
|
+
}
|
|
91
|
+
transition(FlowState.ERROR, { error: error });
|
|
92
|
+
}, [transition, onError]);
|
|
93
|
+
/**
|
|
94
|
+
* Recover state from localStorage
|
|
95
|
+
*/
|
|
96
|
+
var recover = useCallback(function () {
|
|
97
|
+
var savedState = loadStateFromLocalStorage();
|
|
98
|
+
if (!savedState) {
|
|
99
|
+
setIsRecoveryAvailable(false);
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
setContext(savedState.context);
|
|
103
|
+
setPrevState(state);
|
|
104
|
+
setState(savedState.state);
|
|
105
|
+
if (onStateChange) {
|
|
106
|
+
onStateChange(savedState.state, state);
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}, [state, onStateChange]);
|
|
110
|
+
/**
|
|
111
|
+
* Update context without state transition
|
|
112
|
+
*/
|
|
113
|
+
var updateContext = useCallback(function (updates) {
|
|
114
|
+
setContext(function (prevContext) {
|
|
115
|
+
var newContext = __assign(__assign({}, prevContext), updates);
|
|
116
|
+
saveStateToLocalStorage(state, newContext);
|
|
117
|
+
return newContext;
|
|
118
|
+
});
|
|
119
|
+
}, [state]);
|
|
120
|
+
/**
|
|
121
|
+
* Record an interruption in the flow (e.g., modal close, page reload)
|
|
122
|
+
*/
|
|
123
|
+
var recordInterruption = useCallback(function () {
|
|
124
|
+
updateContext({
|
|
125
|
+
lastInterruption: {
|
|
126
|
+
timestamp: Date.now(),
|
|
127
|
+
state: state,
|
|
128
|
+
context: __assign({}, context),
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}, [state, context, updateContext]);
|
|
132
|
+
// Check for recoverable state on mount
|
|
133
|
+
useEffect(function () {
|
|
134
|
+
var hasRecoverable = loadStateFromLocalStorage() !== null;
|
|
135
|
+
setIsRecoveryAvailable(hasRecoverable);
|
|
136
|
+
if (autoRecover && hasRecoverable) {
|
|
137
|
+
recover();
|
|
138
|
+
}
|
|
139
|
+
}, [autoRecover, recover]);
|
|
140
|
+
// Register unload handler to record interruptions
|
|
141
|
+
useEffect(function () {
|
|
142
|
+
var handleBeforeUnload = function () {
|
|
143
|
+
recordInterruption();
|
|
144
|
+
};
|
|
145
|
+
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
146
|
+
return function () {
|
|
147
|
+
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
148
|
+
};
|
|
149
|
+
}, [recordInterruption]);
|
|
150
|
+
return {
|
|
151
|
+
state: state,
|
|
152
|
+
prevState: prevState,
|
|
153
|
+
context: context,
|
|
154
|
+
isTransitioning: isTransitioning,
|
|
155
|
+
isRecoveryAvailable: isRecoveryAvailable,
|
|
156
|
+
transition: transition,
|
|
157
|
+
updateContext: updateContext,
|
|
158
|
+
reset: reset,
|
|
159
|
+
recover: recover,
|
|
160
|
+
recordInterruption: recordInterruption,
|
|
161
|
+
handleError: handleError,
|
|
162
|
+
};
|
|
163
|
+
};
|