@n1xyz/wallet-widget 0.0.4 → 0.0.7
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 +182 -0
- package/dist/Logic/transactionManager.d.ts +41 -0
- package/dist/Logic/transactionManager.js +196 -0
- package/dist/Logic/utils.js +9 -12
- 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 -82
- 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 +34 -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 +25 -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 +267 -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/EVMChainsButton.d.ts +8 -0
- package/dist/Modal/NordFlow/components/EVMChainsButton.js +18 -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/MoreButton.d.ts +8 -0
- package/dist/Modal/NordFlow/components/MoreButton.js +18 -0
- package/dist/Modal/NordFlow/components/TransactionTable.d.ts +13 -0
- package/dist/Modal/NordFlow/components/TransactionTable.js +85 -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 +380 -0
- package/dist/Modal/NordFlow/hooks/useFlowState.d.ts +32 -0
- package/dist/Modal/NordFlow/hooks/useFlowState.js +167 -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 +319 -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 +239 -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 +63 -0
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.d.ts +12 -0
- package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js +186 -0
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js +45 -0
- package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.d.ts +8 -0
- package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js +121 -0
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.d.ts +6 -0
- package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js +135 -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 +67 -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 +110 -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 +63 -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 +38 -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 +42 -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 +208 -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 +29 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.d.ts +11 -0
- package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.js +21 -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 +79 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.d.ts +9 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.js +109 -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 +9 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.d.ts +8 -0
- package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.js +259 -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 +182 -0
- package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.d.ts +1 -0
- package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.js +195 -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 +81 -42
- package/dist/Provider/N1WalletProvider.d.ts +1 -1
- package/dist/Provider/N1WalletProvider.js +65 -46
- 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/components/logos/ArbitrumLogo.d.ts +8 -0
- package/dist/components/logos/ArbitrumLogo.js +5 -0
- package/dist/components/logos/BaseLogo.d.ts +8 -0
- package/dist/components/logos/BaseLogo.js +5 -0
- package/dist/components/logos/BeraLogo.d.ts +8 -0
- package/dist/components/logos/BeraLogo.js +5 -0
- package/dist/components/logos/BitcoinLogo.d.ts +8 -0
- package/dist/components/logos/BitcoinLogo.js +5 -0
- package/dist/components/logos/EVMChainsGroup.d.ts +7 -0
- package/dist/components/logos/EVMChainsGroup.js +18 -0
- package/dist/components/logos/EthereumLogo.d.ts +8 -0
- package/dist/components/logos/EthereumLogo.js +5 -0
- package/dist/components/logos/HyperliquidLogo.d.ts +8 -0
- package/dist/components/logos/HyperliquidLogo.js +5 -0
- package/dist/components/logos/MoreChainsGroup.d.ts +7 -0
- package/dist/components/logos/MoreChainsGroup.js +18 -0
- package/dist/components/logos/OptimismLogo.d.ts +8 -0
- package/dist/components/logos/OptimismLogo.js +5 -0
- package/dist/components/logos/SolanaLogo.d.ts +8 -0
- package/dist/components/logos/SolanaLogo.js +5 -0
- package/dist/components/logos/index.d.ts +10 -0
- package/dist/components/logos/index.js +10 -0
- package/dist/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
package/README.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# N1 Wallet Widget
|
|
2
2
|
|
|
3
|
-
A React
|
|
3
|
+
A React component library for integrating N1 wallet functionality into your application. This widget provides a seamless way to connect to blockchain wallets, manage sessions, and perform wallet operations.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Wallet connection and authentication
|
|
8
|
+
- Session management (Nord and NTS modes)
|
|
9
|
+
- Transaction signing
|
|
10
|
+
- Message signing
|
|
11
|
+
- Balance display
|
|
12
|
+
- Error handling
|
|
13
|
+
- Dark/light mode support
|
|
14
|
+
- Customizable UI
|
|
4
15
|
|
|
5
16
|
## Installation
|
|
6
17
|
|
|
@@ -8,38 +19,192 @@ A React wallet widget component for N1 applications that provides a seamless int
|
|
|
8
19
|
npm install @n1xyz/wallet-widget
|
|
9
20
|
# or
|
|
10
21
|
yarn add @n1xyz/wallet-widget
|
|
11
|
-
# or
|
|
12
|
-
pnpm add @n1xyz/wallet-widget
|
|
13
22
|
```
|
|
14
23
|
|
|
15
|
-
##
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```jsx
|
|
27
|
+
import { N1WalletProvider, N1SessionMode } from '@n1xyz/wallet-widget';
|
|
28
|
+
import { Nord } from '@n1xyz/nord-ts';
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
// Initialize Nord client
|
|
31
|
+
const nord = new Nord({
|
|
32
|
+
// Your Nord configuration
|
|
33
|
+
});
|
|
20
34
|
|
|
21
35
|
function App() {
|
|
36
|
+
return (
|
|
37
|
+
<N1WalletProvider
|
|
38
|
+
providedSessionMode={N1SessionMode.Nord}
|
|
39
|
+
appId="your-app-id"
|
|
40
|
+
nord={nord}
|
|
41
|
+
>
|
|
42
|
+
{/* Your application components */}
|
|
43
|
+
</N1WalletProvider>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
The wallet widget provides a React context that can be accessed throughout your application to interact with the wallet functionality.
|
|
51
|
+
|
|
52
|
+
### Accessing Wallet Context
|
|
53
|
+
|
|
54
|
+
```jsx
|
|
55
|
+
import { useN1WalletContext } from '@n1xyz/wallet-widget';
|
|
56
|
+
|
|
57
|
+
function WalletInfo() {
|
|
58
|
+
const {
|
|
59
|
+
address,
|
|
60
|
+
isConnected,
|
|
61
|
+
balances,
|
|
62
|
+
username,
|
|
63
|
+
setShowLogin
|
|
64
|
+
} = useN1WalletContext();
|
|
65
|
+
|
|
22
66
|
return (
|
|
23
67
|
<div>
|
|
24
|
-
|
|
68
|
+
{isConnected ? (
|
|
69
|
+
<>
|
|
70
|
+
<p>Connected as: {username}</p>
|
|
71
|
+
<p>Address: {address}</p>
|
|
72
|
+
<p>Balances: {balances.map(b => `${b.balance} ${b.appType}`).join(', ')}</p>
|
|
73
|
+
</>
|
|
74
|
+
) : (
|
|
75
|
+
<button onClick={() => setShowLogin(true)}>Connect Wallet</button>
|
|
76
|
+
)}
|
|
25
77
|
</div>
|
|
26
78
|
);
|
|
27
79
|
}
|
|
28
80
|
```
|
|
29
81
|
|
|
30
|
-
|
|
82
|
+
### Signing Messages and Transactions
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
import { useN1WalletContext } from '@n1xyz/wallet-widget';
|
|
31
86
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
87
|
+
function SigningExample() {
|
|
88
|
+
const {
|
|
89
|
+
signMessageWithSessionKey,
|
|
90
|
+
signMessageWithWalletKey,
|
|
91
|
+
signTransactionWithWalletKey
|
|
92
|
+
} = useN1WalletContext();
|
|
93
|
+
|
|
94
|
+
const handleSignMessage = async () => {
|
|
95
|
+
if (signMessageWithSessionKey) {
|
|
96
|
+
const message = { content: "Hello, world!" };
|
|
97
|
+
const signature = await signMessageWithSessionKey(message);
|
|
98
|
+
console.log("Signature:", signature);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<button onClick={handleSignMessage}>Sign Message</button>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
37
107
|
|
|
38
|
-
##
|
|
108
|
+
## API Reference
|
|
39
109
|
|
|
40
|
-
|
|
41
|
-
|
|
110
|
+
### N1WalletProvider Props
|
|
111
|
+
|
|
112
|
+
| Prop | Type | Required | Default | Description |
|
|
113
|
+
|------|------|----------|---------|-------------|
|
|
114
|
+
| children | React.ReactNode | Yes | - | Child components |
|
|
115
|
+
| providedSessionMode | N1SessionMode | Yes | - | Session mode (Nord or NTS) |
|
|
116
|
+
| appId | string | Yes | - | Your application ID |
|
|
117
|
+
| darkMode | boolean | No | true | Enable dark mode UI |
|
|
118
|
+
| onError | (error: WalletError) => void | No | - | Error handler callback |
|
|
119
|
+
| faucetUrl | string | No | - | URL for faucet service |
|
|
120
|
+
| nord | Nord | No | - | Nord instance (required for Nord mode) |
|
|
121
|
+
|
|
122
|
+
### N1SessionMode
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
enum N1SessionMode {
|
|
126
|
+
Nord,
|
|
127
|
+
NTS
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### N1WalletContext
|
|
132
|
+
|
|
133
|
+
The context provides the following values:
|
|
134
|
+
|
|
135
|
+
| Property | Type | Description |
|
|
136
|
+
|----------|------|-------------|
|
|
137
|
+
| address | string | User's wallet address |
|
|
138
|
+
| appId | string | Application ID |
|
|
139
|
+
| balances | Balance[] | User's token balances |
|
|
140
|
+
| chain | string | Current blockchain |
|
|
141
|
+
| isConnected | boolean | Connection status |
|
|
142
|
+
| sessionMode | N1SessionMode | Current session mode |
|
|
143
|
+
| sessionPubKey | Uint8Array | Session public key |
|
|
144
|
+
| setShowLogin | (show: boolean) => void | Show/hide login modal |
|
|
145
|
+
| showLogin | boolean | Login modal visibility state |
|
|
146
|
+
| signMessageWithSessionKey | (message: any) => Promise<any> | Sign message with session key |
|
|
147
|
+
| signMessageWithWalletKey | (message: any) => Promise<any> | Sign message with wallet key |
|
|
148
|
+
| signTransactionWithWalletKey | (transaction: any) => Promise<any> | Sign transaction with wallet key |
|
|
149
|
+
| username | string | User's username |
|
|
150
|
+
| walletPubKey | Uint8Array | Wallet public key |
|
|
151
|
+
|
|
152
|
+
## Error Handling
|
|
153
|
+
|
|
154
|
+
The wallet widget includes a built-in error boundary that catches and processes wallet-related errors. You can provide a custom error handler through the `onError` prop:
|
|
155
|
+
|
|
156
|
+
```jsx
|
|
157
|
+
<N1WalletProvider
|
|
158
|
+
providedSessionMode={N1SessionMode.Nord}
|
|
159
|
+
appId="your-app-id"
|
|
160
|
+
onError={(error) => {
|
|
161
|
+
console.error("Wallet error:", error.code, error.message);
|
|
162
|
+
// Handle error appropriately
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
{/* Your application */}
|
|
166
|
+
</N1WalletProvider>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Examples
|
|
170
|
+
|
|
171
|
+
### Nord Mode Integration
|
|
172
|
+
|
|
173
|
+
```jsx
|
|
174
|
+
import { useEffect, useState } from 'react';
|
|
175
|
+
import { N1WalletProvider, N1SessionMode } from '@n1xyz/wallet-widget';
|
|
176
|
+
import { Nord } from '@n1xyz/nord-ts';
|
|
177
|
+
|
|
178
|
+
function App() {
|
|
179
|
+
const [nord, setNord] = useState(null);
|
|
180
|
+
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
async function initNord() {
|
|
183
|
+
const nordClient = new Nord({
|
|
184
|
+
// Your Nord configuration
|
|
185
|
+
});
|
|
186
|
+
await nordClient.initialize();
|
|
187
|
+
setNord(nordClient);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
initNord();
|
|
191
|
+
}, []);
|
|
192
|
+
|
|
193
|
+
if (!nord) return <div>Loading...</div>;
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<N1WalletProvider
|
|
197
|
+
providedSessionMode={N1SessionMode.Nord}
|
|
198
|
+
appId="your-app-id"
|
|
199
|
+
faucetUrl="https://your-faucet-url.com/api/faucet"
|
|
200
|
+
nord={nord}
|
|
201
|
+
>
|
|
202
|
+
<YourApplication />
|
|
203
|
+
</N1WalletProvider>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
```
|
|
42
207
|
|
|
43
208
|
## License
|
|
44
209
|
|
|
45
|
-
|
|
210
|
+
[MIT License](LICENSE)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { N1SessionMode } from '../Provider/types';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for session key data stored in local storage
|
|
4
|
+
*/
|
|
5
|
+
export interface SessionKeyData {
|
|
6
|
+
ed25519PrivateKey: Uint8Array;
|
|
7
|
+
walletPublicKey: string;
|
|
8
|
+
chainName: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
sessionMode: N1SessionMode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generate a new session key pair
|
|
14
|
+
* @returns Promise resolving to the generated key pair
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateSessionKeys(): Promise<{
|
|
17
|
+
publicKey: Uint8Array;
|
|
18
|
+
privateKey: Uint8Array;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a signing function for the given key pair
|
|
22
|
+
* @param privateKey The private key to use for signing
|
|
23
|
+
* @returns A function that signs messages with the private key
|
|
24
|
+
*/
|
|
25
|
+
export declare function createSigningFunction(privateKey: Uint8Array): (message: Uint8Array) => Promise<Uint8Array>;
|
|
26
|
+
/**
|
|
27
|
+
* Store session keys in local storage
|
|
28
|
+
* @param data The session key data to store
|
|
29
|
+
*/
|
|
30
|
+
export declare function storeSessionKeys({ privKey, walletPublicKey, chainName, sessionMode, }: {
|
|
31
|
+
privKey: Uint8Array;
|
|
32
|
+
walletPublicKey: string;
|
|
33
|
+
chainName: string;
|
|
34
|
+
sessionMode: N1SessionMode;
|
|
35
|
+
}): void;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve session keys from local storage
|
|
38
|
+
* @param walletPublicKey The wallet public key to retrieve session keys for
|
|
39
|
+
* @returns The session key data or null if not found
|
|
40
|
+
*/
|
|
41
|
+
export declare function getSessionKeys(walletPublicKey: string): SessionKeyData | null;
|
|
42
|
+
/**
|
|
43
|
+
* Remove session keys from local storage
|
|
44
|
+
* @param walletPublicKey The wallet public key to remove session keys for
|
|
45
|
+
*/
|
|
46
|
+
export declare function removeSessionKeys(walletPublicKey: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a session exists and is valid
|
|
49
|
+
* @param walletPublicKey The wallet public key to check
|
|
50
|
+
* @param sessionMode The session mode to check
|
|
51
|
+
* @returns Whether a valid session exists
|
|
52
|
+
*/
|
|
53
|
+
export declare function hasValidSession(walletPublicKey: string, sessionMode: N1SessionMode): Promise<boolean>;
|
|
@@ -0,0 +1,182 @@
|
|
|
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 { generateSessionKeyPair, signEd25519 } from '@n1xyz/nts-sdk';
|
|
38
|
+
import { N1SessionMode } from '../Provider/types';
|
|
39
|
+
import { logger } from '../utils/logger';
|
|
40
|
+
import { arrayBufferToBase64, base64ToUint8Array } from './utils';
|
|
41
|
+
/**
|
|
42
|
+
* Generate a new session key pair
|
|
43
|
+
* @returns Promise resolving to the generated key pair
|
|
44
|
+
*/
|
|
45
|
+
export function generateSessionKeys() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
var error_1;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
_a.trys.push([0, 2, , 3]);
|
|
52
|
+
return [4 /*yield*/, generateSessionKeyPair()];
|
|
53
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
54
|
+
case 2:
|
|
55
|
+
error_1 = _a.sent();
|
|
56
|
+
logger.error('Failed to generate session keys', error_1);
|
|
57
|
+
throw error_1;
|
|
58
|
+
case 3: return [2 /*return*/];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a signing function for the given key pair
|
|
65
|
+
* @param privateKey The private key to use for signing
|
|
66
|
+
* @returns A function that signs messages with the private key
|
|
67
|
+
*/
|
|
68
|
+
export function createSigningFunction(privateKey) {
|
|
69
|
+
var _this = this;
|
|
70
|
+
return function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
71
|
+
var error_2;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
_a.trys.push([0, 2, , 3]);
|
|
76
|
+
return [4 /*yield*/, signEd25519(message, privateKey)];
|
|
77
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
78
|
+
case 2:
|
|
79
|
+
error_2 = _a.sent();
|
|
80
|
+
logger.error('Error signing with session key', error_2);
|
|
81
|
+
throw error_2;
|
|
82
|
+
case 3: return [2 /*return*/];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}); };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Store session keys in local storage
|
|
89
|
+
* @param data The session key data to store
|
|
90
|
+
*/
|
|
91
|
+
export function storeSessionKeys(_a) {
|
|
92
|
+
var privKey = _a.privKey, walletPublicKey = _a.walletPublicKey, chainName = _a.chainName, sessionMode = _a.sessionMode;
|
|
93
|
+
var storageKey = "n1_sessionKey_".concat(walletPublicKey);
|
|
94
|
+
var data = {
|
|
95
|
+
ed25519PrivateKey: arrayBufferToBase64(privKey),
|
|
96
|
+
walletPublicKey: walletPublicKey,
|
|
97
|
+
chainName: chainName,
|
|
98
|
+
createdAt: new Date().toISOString(),
|
|
99
|
+
sessionMode: sessionMode.toString(),
|
|
100
|
+
};
|
|
101
|
+
localStorage.setItem(storageKey, JSON.stringify(data));
|
|
102
|
+
logger.debug('Session keys stored in local storage', {
|
|
103
|
+
walletPublicKey: walletPublicKey,
|
|
104
|
+
sessionMode: sessionMode,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Retrieve session keys from local storage
|
|
109
|
+
* @param walletPublicKey The wallet public key to retrieve session keys for
|
|
110
|
+
* @returns The session key data or null if not found
|
|
111
|
+
*/
|
|
112
|
+
export function getSessionKeys(walletPublicKey) {
|
|
113
|
+
var storageKey = "n1_sessionKey_".concat(walletPublicKey);
|
|
114
|
+
var data = localStorage.getItem(storageKey);
|
|
115
|
+
if (!data) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
var parsedData = JSON.parse(data);
|
|
120
|
+
if (parsedData.ed25519PrivateKey) {
|
|
121
|
+
parsedData.ed25519PrivateKey = base64ToUint8Array(parsedData.ed25519PrivateKey);
|
|
122
|
+
}
|
|
123
|
+
// Convert sessionMode string to enum value
|
|
124
|
+
if (typeof parsedData.sessionMode === 'string') {
|
|
125
|
+
parsedData.sessionMode =
|
|
126
|
+
parsedData.sessionMode === N1SessionMode.Nord.toString()
|
|
127
|
+
? N1SessionMode.Nord
|
|
128
|
+
: N1SessionMode.NTS;
|
|
129
|
+
}
|
|
130
|
+
else if (parsedData.sessionMode === undefined) {
|
|
131
|
+
// For backward compatibility, default to NTS mode if not specified
|
|
132
|
+
parsedData.sessionMode = N1SessionMode.NTS;
|
|
133
|
+
}
|
|
134
|
+
return parsedData;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
logger.error('Failed to parse session key data', error);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Remove session keys from local storage
|
|
143
|
+
* @param walletPublicKey The wallet public key to remove session keys for
|
|
144
|
+
*/
|
|
145
|
+
export function removeSessionKeys(walletPublicKey) {
|
|
146
|
+
var storageKey = "n1_sessionKey_".concat(walletPublicKey);
|
|
147
|
+
localStorage.removeItem(storageKey);
|
|
148
|
+
logger.debug('Session keys removed from local storage', { walletPublicKey: walletPublicKey });
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if a session exists and is valid
|
|
152
|
+
* @param walletPublicKey The wallet public key to check
|
|
153
|
+
* @param sessionMode The session mode to check
|
|
154
|
+
* @returns Whether a valid session exists
|
|
155
|
+
*/
|
|
156
|
+
export function hasValidSession(walletPublicKey, sessionMode) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var sessionData, createdAt, now, sessionAgeMs, maxSessionAgeMs;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
sessionData = getSessionKeys(walletPublicKey);
|
|
161
|
+
if (!sessionData) {
|
|
162
|
+
return [2 /*return*/, false];
|
|
163
|
+
}
|
|
164
|
+
// Check if the session mode matches
|
|
165
|
+
if (sessionData.sessionMode !== sessionMode) {
|
|
166
|
+
return [2 /*return*/, false];
|
|
167
|
+
}
|
|
168
|
+
createdAt = new Date(sessionData.createdAt);
|
|
169
|
+
now = new Date();
|
|
170
|
+
sessionAgeMs = now.getTime() - createdAt.getTime();
|
|
171
|
+
maxSessionAgeMs = 7 * 24 * 60 * 60 * 1000;
|
|
172
|
+
if (sessionAgeMs > maxSessionAgeMs) {
|
|
173
|
+
// Session is expired, remove it
|
|
174
|
+
removeSessionKeys(walletPublicKey);
|
|
175
|
+
return [2 /*return*/, false];
|
|
176
|
+
}
|
|
177
|
+
// TODO: Add additional validation based on session mode
|
|
178
|
+
// For example, verify the session with the backend
|
|
179
|
+
return [2 /*return*/, true];
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { N1SessionMode } from '../Provider/types';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for transaction data
|
|
4
|
+
*/
|
|
5
|
+
export interface TransactionData {
|
|
6
|
+
chainId: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
tokenSymbol: string;
|
|
9
|
+
walletAddress: string;
|
|
10
|
+
sessionMode: N1SessionMode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface for transaction result
|
|
14
|
+
*/
|
|
15
|
+
export interface TransactionResult {
|
|
16
|
+
success: boolean;
|
|
17
|
+
transactionId: string;
|
|
18
|
+
amount: string;
|
|
19
|
+
tokenSymbol: string;
|
|
20
|
+
fromAddress: string;
|
|
21
|
+
toAddress: string;
|
|
22
|
+
networkName: string;
|
|
23
|
+
status: 'Completed' | 'Failed' | 'Pending';
|
|
24
|
+
explorerUrl?: string;
|
|
25
|
+
error?: Error;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create and send a transaction
|
|
29
|
+
* @param data Transaction data
|
|
30
|
+
* @param signMessage Function to sign messages with wallet
|
|
31
|
+
* @returns Transaction result
|
|
32
|
+
*/
|
|
33
|
+
export declare function createAndSendTransaction(data: TransactionData, signMessage: (message: Uint8Array) => Promise<Uint8Array>): Promise<TransactionResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Get explorer URL for a transaction
|
|
36
|
+
*/
|
|
37
|
+
export declare function getExplorerUrl(transactionId: string, chainId: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Check transaction status
|
|
40
|
+
*/
|
|
41
|
+
export declare function checkTransactionStatus(transactionId: string, chainId: string, sessionMode: N1SessionMode): Promise<'Completed' | 'Failed' | 'Pending'>;
|