@openfort/react 0.3.2 → 1.0.0
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/build/assets/browsers.js +13 -0
- package/build/assets/browsers.js.map +1 -0
- package/build/assets/chains.js +139 -0
- package/build/assets/chains.js.map +1 -0
- package/build/assets/icons.js +41 -0
- package/build/assets/icons.js.map +1 -0
- package/build/assets/logos.js +173 -0
- package/build/assets/logos.js.map +1 -0
- package/build/assets/wave.js +6 -0
- package/build/assets/wave.js.map +1 -0
- package/build/components/BalanceButton/index.js +89 -0
- package/build/components/BalanceButton/index.js.map +1 -0
- package/build/components/Common/Alert/index.js +10 -0
- package/build/components/Common/Alert/index.js.map +1 -0
- package/build/components/Common/Alert/styles.js +55 -0
- package/build/components/Common/Alert/styles.js.map +1 -0
- package/build/components/Common/Avatar/index.d.ts +11 -3
- package/build/components/Common/Avatar/index.js +100 -0
- package/build/components/Common/Avatar/index.js.map +1 -0
- package/build/components/Common/Avatar/styles.js +59 -0
- package/build/components/Common/Avatar/styles.js.map +1 -0
- package/build/components/Common/BrowserIcon/index.js +28 -0
- package/build/components/Common/BrowserIcon/index.js.map +1 -0
- package/build/components/Common/BrowserIcon/styles.js +20 -0
- package/build/components/Common/BrowserIcon/styles.js.map +1 -0
- package/build/components/Common/Button/index.js +36 -0
- package/build/components/Common/Button/index.js.map +1 -0
- package/build/components/Common/Button/styles.js +302 -0
- package/build/components/Common/Button/styles.js.map +1 -0
- package/build/components/Common/Button/types.d.ts +1 -0
- package/build/components/Common/Chain/index.d.ts +8 -0
- package/build/components/Common/Chain/index.js +38 -0
- package/build/components/Common/Chain/index.js.map +1 -0
- package/build/components/Common/Chain/styles.js +94 -0
- package/build/components/Common/Chain/styles.js.map +1 -0
- package/build/components/Common/ConnectorList/index.js +58 -0
- package/build/components/Common/ConnectorList/index.js.map +1 -0
- package/build/components/Common/ConnectorList/styles.js +324 -0
- package/build/components/Common/ConnectorList/styles.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyButton.js +12 -0
- package/build/components/Common/CopyToClipboard/CopyButton.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyIcon.js +76 -0
- package/build/components/Common/CopyToClipboard/CopyIcon.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyIconButton.js +38 -0
- package/build/components/Common/CopyToClipboard/CopyIconButton.js.map +1 -0
- package/build/components/Common/CopyToClipboard/CopyText.js +26 -0
- package/build/components/Common/CopyToClipboard/CopyText.js.map +1 -0
- package/build/components/Common/CustomQRCode/QRCode.js +60 -0
- package/build/components/Common/CustomQRCode/QRCode.js.map +1 -0
- package/build/components/Common/CustomQRCode/index.js +22 -0
- package/build/components/Common/CustomQRCode/index.js.map +1 -0
- package/build/components/Common/CustomQRCode/styles.js +155 -0
- package/build/components/Common/CustomQRCode/styles.js.map +1 -0
- package/build/components/Common/FitText/index.js +28 -0
- package/build/components/Common/FitText/index.js.map +1 -0
- package/build/components/Common/Input/index.js +17 -0
- package/build/components/Common/Input/index.js.map +1 -0
- package/build/components/Common/Input/styles.js +53 -0
- package/build/components/Common/Input/styles.js.map +1 -0
- package/build/components/Common/LargeButton/index.js +10 -0
- package/build/components/Common/LargeButton/index.js.map +1 -0
- package/build/components/Common/LargeButton/styles.js +69 -0
- package/build/components/Common/LargeButton/styles.js.map +1 -0
- package/build/components/Common/Loading/index.js +96 -0
- package/build/components/Common/Loading/index.js.map +1 -0
- package/build/components/Common/Modal/index.js +272 -0
- package/build/components/Common/Modal/index.js.map +1 -0
- package/build/components/Common/Modal/styles.d.ts +0 -1
- package/build/components/Common/Modal/styles.js +657 -0
- package/build/components/Common/Modal/styles.js.map +1 -0
- package/build/components/Common/OTPInput/index.js +108 -0
- package/build/components/Common/OTPInput/index.js.map +1 -0
- package/build/components/Common/OTPInput/styles.js +153 -0
- package/build/components/Common/OTPInput/styles.js.map +1 -0
- package/build/components/Common/Portal/index.js +31 -0
- package/build/components/Common/Portal/index.js.map +1 -0
- package/build/components/Common/PoweredByFooter/index.js +103 -0
- package/build/components/Common/PoweredByFooter/index.js.map +1 -0
- package/build/components/Common/Providers/ProviderHeader.d.ts +2 -2
- package/build/components/Common/Providers/ProviderHeader.js +55 -0
- package/build/components/Common/Providers/ProviderHeader.js.map +1 -0
- package/build/components/Common/Providers/ProviderIcon.d.ts +2 -2
- package/build/components/Common/Providers/ProviderIcon.js +41 -0
- package/build/components/Common/Providers/ProviderIcon.js.map +1 -0
- package/build/components/Common/Providers/getProviderName.d.ts +1 -1
- package/build/components/Common/Providers/getProviderName.js +15 -0
- package/build/components/Common/Providers/getProviderName.js.map +1 -0
- package/build/components/Common/ScrollArea/index.js +58 -0
- package/build/components/Common/ScrollArea/index.js.map +1 -0
- package/build/components/Common/ScrollArea/styles.js +168 -0
- package/build/components/Common/ScrollArea/styles.js.map +1 -0
- package/build/components/Common/Spinner/index.js +24 -0
- package/build/components/Common/Spinner/index.js.map +1 -0
- package/build/components/Common/Spinner/styles.js +22 -0
- package/build/components/Common/Spinner/styles.js.map +1 -0
- package/build/components/Common/SquircleSpinner/index.js +15 -0
- package/build/components/Common/SquircleSpinner/index.js.map +1 -0
- package/build/components/Common/SquircleSpinner/styles.js +66 -0
- package/build/components/Common/SquircleSpinner/styles.js.map +1 -0
- package/build/components/Common/ThemedButton/index.js +25 -0
- package/build/components/Common/ThemedButton/index.js.map +1 -0
- package/build/components/Common/ThemedButton/styles.js +152 -0
- package/build/components/Common/ThemedButton/styles.js.map +1 -0
- package/build/components/Common/TickList/index.js +11 -0
- package/build/components/Common/TickList/index.js.map +1 -0
- package/build/components/Common/TickList/styles.js +28 -0
- package/build/components/Common/TickList/styles.js.map +1 -0
- package/build/components/Common/Tooltip/index.js +91 -0
- package/build/components/Common/Tooltip/index.js.map +1 -0
- package/build/components/Common/Tooltip/styles.js +81 -0
- package/build/components/Common/Tooltip/styles.js.map +1 -0
- package/build/components/Common/WalletRecoveryIcon/index.d.ts +4 -0
- package/build/components/Common/WalletRecoveryIcon/index.js +19 -0
- package/build/components/Common/WalletRecoveryIcon/index.js.map +1 -0
- package/build/components/ConnectButton/index.d.ts +12 -4
- package/build/components/ConnectButton/index.js +266 -0
- package/build/components/ConnectButton/index.js.map +1 -0
- package/build/components/ConnectButton/styles.js +50 -0
- package/build/components/ConnectButton/styles.js.map +1 -0
- package/build/components/ConnectKitThemeProvider/ConnectKitThemeProvider.js +20 -0
- package/build/components/ConnectKitThemeProvider/ConnectKitThemeProvider.js.map +1 -0
- package/build/components/ConnectModal/ConnectUsing.d.ts +1 -1
- package/build/components/ConnectModal/ConnectUsing.js +68 -0
- package/build/components/ConnectModal/ConnectUsing.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/index.js +17 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/index.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/styles.js +118 -0
- package/build/components/ConnectModal/ConnectWithInjector/CircleSpinner/styles.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/index.d.ts +0 -2
- package/build/components/ConnectModal/ConnectWithInjector/index.js +295 -0
- package/build/components/ConnectModal/ConnectWithInjector/index.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithInjector/styles.js +133 -0
- package/build/components/ConnectModal/ConnectWithInjector/styles.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithMobile.js +99 -0
- package/build/components/ConnectModal/ConnectWithMobile.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithOAuth.js +128 -0
- package/build/components/ConnectModal/ConnectWithOAuth.js.map +1 -0
- package/build/components/ConnectModal/ConnectWithQRCode.js +78 -0
- package/build/components/ConnectModal/ConnectWithQRCode.js.map +1 -0
- package/build/components/ConnectModal/index.js +230 -0
- package/build/components/ConnectModal/index.js.map +1 -0
- package/build/components/FloatingGraphic/index.js +13 -0
- package/build/components/FloatingGraphic/index.js.map +1 -0
- package/build/components/FloatingGraphic/styles.js +175 -0
- package/build/components/FloatingGraphic/styles.js.map +1 -0
- package/build/components/Openfort/OpenfortProvider.d.ts +10 -25
- package/build/components/Openfort/OpenfortProvider.js +351 -0
- package/build/components/Openfort/OpenfortProvider.js.map +1 -0
- package/build/components/Openfort/context.d.ts +48 -5
- package/build/components/Openfort/context.js +7 -0
- package/build/components/Openfort/context.js.map +1 -0
- package/build/components/Openfort/routeHelpers.d.ts +5 -0
- package/build/components/Openfort/routeHelpers.js +20 -0
- package/build/components/Openfort/routeHelpers.js.map +1 -0
- package/build/components/Openfort/types.d.ts +57 -23
- package/build/components/Openfort/types.js +119 -0
- package/build/components/Openfort/types.js.map +1 -0
- package/build/components/Openfort/useOpenfort.d.ts +2 -0
- package/build/components/Openfort/useOpenfort.js +12 -0
- package/build/components/Openfort/useOpenfort.js.map +1 -0
- package/build/components/PageContent/index.js +55 -0
- package/build/components/PageContent/index.js.map +1 -0
- package/build/components/PageContent/styles.js +11 -0
- package/build/components/PageContent/styles.js.map +1 -0
- package/build/components/Pages/About/graphics.js +193 -0
- package/build/components/Pages/About/graphics.js.map +1 -0
- package/build/components/Pages/About/index.js +142 -0
- package/build/components/Pages/About/index.js.map +1 -0
- package/build/components/Pages/About/styles.js +142 -0
- package/build/components/Pages/About/styles.js.map +1 -0
- package/build/components/Pages/AssetInventory/index.js +66 -0
- package/build/components/Pages/AssetInventory/index.js.map +1 -0
- package/build/components/Pages/Buy/coinbaseApi.js +106 -0
- package/build/components/Pages/Buy/coinbaseApi.js.map +1 -0
- package/build/components/Pages/Buy/index.js +88 -0
- package/build/components/Pages/Buy/index.js.map +1 -0
- package/build/components/Pages/Buy/onrampApi.js +57 -0
- package/build/components/Pages/Buy/onrampApi.js.map +1 -0
- package/build/components/Pages/Buy/providers.js +39 -0
- package/build/components/Pages/Buy/providers.js.map +1 -0
- package/build/components/Pages/Buy/stripeApi.js +74 -0
- package/build/components/Pages/Buy/stripeApi.js.map +1 -0
- package/build/components/Pages/Buy/styles.js +230 -0
- package/build/components/Pages/Buy/styles.js.map +1 -0
- package/build/components/Pages/Buy/utils.js +71 -0
- package/build/components/Pages/Buy/utils.js.map +1 -0
- package/build/components/Pages/BuyComplete/index.js +47 -0
- package/build/components/Pages/BuyComplete/index.js.map +1 -0
- package/build/components/Pages/BuyProcessing/index.js +231 -0
- package/build/components/Pages/BuyProcessing/index.js.map +1 -0
- package/build/components/Pages/BuyProviderSelect/index.js +55 -0
- package/build/components/Pages/BuyProviderSelect/index.js.map +1 -0
- package/build/components/Pages/BuyProviderSelect/styles.js +103 -0
- package/build/components/Pages/BuyProviderSelect/styles.js.map +1 -0
- package/build/components/Pages/BuySelectProvider/index.js +245 -0
- package/build/components/Pages/BuySelectProvider/index.js.map +1 -0
- package/build/components/Pages/Connected/ConnectedPageLayout.d.ts +22 -0
- package/build/components/Pages/Connected/ConnectedPageLayout.js +11 -0
- package/build/components/Pages/Connected/ConnectedPageLayout.js.map +1 -0
- package/build/components/Pages/Connected/EthereumConnected.d.ts +3 -0
- package/build/components/Pages/Connected/EthereumConnected.js +133 -0
- package/build/components/Pages/Connected/EthereumConnected.js.map +1 -0
- package/build/components/Pages/Connected/SolanaConnected.d.ts +3 -0
- package/build/components/Pages/Connected/SolanaConnected.js +96 -0
- package/build/components/Pages/Connected/SolanaConnected.js.map +1 -0
- package/build/components/Pages/Connected/index.d.ts +2 -2
- package/build/components/Pages/Connected/index.js +18 -0
- package/build/components/Pages/Connected/index.js.map +1 -0
- package/build/components/Pages/Connected/styles.js +122 -0
- package/build/components/Pages/Connected/styles.js.map +1 -0
- package/build/components/Pages/ConnectedSuccess/index.js +19 -0
- package/build/components/Pages/ConnectedSuccess/index.js.map +1 -0
- package/build/components/Pages/Connectors/index.js +73 -0
- package/build/components/Pages/Connectors/index.js.map +1 -0
- package/build/components/Pages/CreateGuestUserPage/index.js +28 -0
- package/build/components/Pages/CreateGuestUserPage/index.js.map +1 -0
- package/build/components/Pages/CreateWallet/SolanaCreateWallet.d.ts +6 -0
- package/build/components/Pages/CreateWallet/SolanaCreateWallet.js +241 -0
- package/build/components/Pages/CreateWallet/SolanaCreateWallet.js.map +1 -0
- package/build/components/Pages/CreateWallet/index.js +303 -0
- package/build/components/Pages/CreateWallet/index.js.map +1 -0
- package/build/components/Pages/CreateWallet/styles.js +17 -0
- package/build/components/Pages/CreateWallet/styles.js.map +1 -0
- package/build/components/Pages/DownloadApp/index.js +32 -0
- package/build/components/Pages/DownloadApp/index.js.map +1 -0
- package/build/components/Pages/EmailLogin/index.js +118 -0
- package/build/components/Pages/EmailLogin/index.js.map +1 -0
- package/build/components/Pages/EmailLogin/styles.js +24 -0
- package/build/components/Pages/EmailLogin/styles.js.map +1 -0
- package/build/components/Pages/EmailOTP/index.js +116 -0
- package/build/components/Pages/EmailOTP/index.js.map +1 -0
- package/build/components/Pages/EmailOTP/styles.js +38 -0
- package/build/components/Pages/EmailOTP/styles.js.map +1 -0
- package/build/components/Pages/EmailVerification/index.js +86 -0
- package/build/components/Pages/EmailVerification/index.js.map +1 -0
- package/build/components/Pages/ExportKey/index.js +44 -0
- package/build/components/Pages/ExportKey/index.js.map +1 -0
- package/build/components/Pages/ForgotPassword/index.js +129 -0
- package/build/components/Pages/ForgotPassword/index.js.map +1 -0
- package/build/components/Pages/LinkEmail/index.js +63 -0
- package/build/components/Pages/LinkEmail/index.js.map +1 -0
- package/build/components/Pages/LinkedProvider/index.d.ts +3 -0
- package/build/components/Pages/LinkedProvider/index.js +90 -0
- package/build/components/Pages/LinkedProvider/index.js.map +1 -0
- package/build/components/Pages/LinkedProviders/index.js +45 -0
- package/build/components/Pages/LinkedProviders/index.js.map +1 -0
- package/build/components/Pages/LinkedProviders/styles.js +51 -0
- package/build/components/Pages/LinkedProviders/styles.js.map +1 -0
- package/build/components/Pages/LoadWallets/index.js +91 -0
- package/build/components/Pages/LoadWallets/index.js.map +1 -0
- package/build/components/Pages/Loading/index.js +61 -0
- package/build/components/Pages/Loading/index.js.map +1 -0
- package/build/components/Pages/MobileConnectors/index.js +71 -0
- package/build/components/Pages/MobileConnectors/index.js.map +1 -0
- package/build/components/Pages/MobileConnectors/styles.js +65 -0
- package/build/components/Pages/MobileConnectors/styles.js.map +1 -0
- package/build/components/Pages/NoAssetsAvailable/index.js +45 -0
- package/build/components/Pages/NoAssetsAvailable/index.js.map +1 -0
- package/build/components/Pages/NoAssetsAvailable/styles.js +10 -0
- package/build/components/Pages/NoAssetsAvailable/styles.js.map +1 -0
- package/build/components/Pages/Onboarding/index.js +20 -0
- package/build/components/Pages/Onboarding/index.js.map +1 -0
- package/build/components/Pages/PhoneOTP/index.js +128 -0
- package/build/components/Pages/PhoneOTP/index.js.map +1 -0
- package/build/components/Pages/PhoneOTP/styles.js +38 -0
- package/build/components/Pages/PhoneOTP/styles.js.map +1 -0
- package/build/components/Pages/Profile/index.js +35 -0
- package/build/components/Pages/Profile/index.js.map +1 -0
- package/build/components/Pages/Providers/index.js +157 -0
- package/build/components/Pages/Providers/index.js.map +1 -0
- package/build/components/Pages/Providers/styles.js +156 -0
- package/build/components/Pages/Providers/styles.js.map +1 -0
- package/build/components/Pages/Receive/index.js +61 -0
- package/build/components/Pages/Receive/index.js.map +1 -0
- package/build/components/Pages/Receive/styles.d.ts +1 -0
- package/build/components/Pages/Receive/styles.js +52 -0
- package/build/components/Pages/Receive/styles.js.map +1 -0
- package/build/components/Pages/Recover/index.js +252 -0
- package/build/components/Pages/Recover/index.js.map +1 -0
- package/build/components/Pages/Recover/recoveryRegistry.d.ts +32 -0
- package/build/components/Pages/Recover/recoveryRegistry.js +61 -0
- package/build/components/Pages/Recover/recoveryRegistry.js.map +1 -0
- package/build/components/Pages/RemoveLinkedProvider/index.js +104 -0
- package/build/components/Pages/RemoveLinkedProvider/index.js.map +1 -0
- package/build/components/Pages/SelectToken/index.js +102 -0
- package/build/components/Pages/SelectToken/index.js.map +1 -0
- package/build/components/Pages/SelectToken/styles.js +78 -0
- package/build/components/Pages/SelectToken/styles.js.map +1 -0
- package/build/components/Pages/SelectWalletToRecover/index.d.ts +1 -2
- package/build/components/Pages/SelectWalletToRecover/index.js +70 -0
- package/build/components/Pages/SelectWalletToRecover/index.js.map +1 -0
- package/build/components/Pages/Send/EthereumSend.d.ts +1 -0
- package/build/components/Pages/Send/EthereumSend.js +88 -0
- package/build/components/Pages/Send/EthereumSend.js.map +1 -0
- package/build/components/Pages/Send/SolanaSend.d.ts +1 -0
- package/build/components/Pages/Send/SolanaSend.js +93 -0
- package/build/components/Pages/Send/SolanaSend.js.map +1 -0
- package/build/components/Pages/Send/index.d.ts +7 -1
- package/build/components/Pages/Send/index.js +18 -0
- package/build/components/Pages/Send/index.js.map +1 -0
- package/build/components/Pages/Send/styles.js +112 -0
- package/build/components/Pages/Send/styles.js.map +1 -0
- package/build/components/Pages/Send/utils.d.ts +1 -1
- package/build/components/Pages/Send/utils.js +63 -0
- package/build/components/Pages/Send/utils.js.map +1 -0
- package/build/components/Pages/SendConfirmation/EstimatedFees.js +66 -0
- package/build/components/Pages/SendConfirmation/EstimatedFees.js.map +1 -0
- package/build/components/Pages/SendConfirmation/index.js +331 -0
- package/build/components/Pages/SendConfirmation/index.js.map +1 -0
- package/build/components/Pages/SendConfirmation/styles.js +129 -0
- package/build/components/Pages/SendConfirmation/styles.js.map +1 -0
- package/build/components/Pages/SocialProviders/index.js +15 -0
- package/build/components/Pages/SocialProviders/index.js.map +1 -0
- package/build/components/Pages/SolanaSendConfirmation/index.d.ts +1 -0
- package/build/components/Pages/SolanaSendConfirmation/index.js +152 -0
- package/build/components/Pages/SolanaSendConfirmation/index.js.map +1 -0
- package/build/components/Pages/SolanaWallets/index.d.ts +1 -0
- package/build/components/Pages/SolanaWallets/index.js +36 -0
- package/build/components/Pages/SolanaWallets/index.js.map +1 -0
- package/build/components/PasswordStrength/PasswordStrengthIndicator.js +62 -0
- package/build/components/PasswordStrength/PasswordStrengthIndicator.js.map +1 -0
- package/build/components/PasswordStrength/password-utility.js +128 -0
- package/build/components/PasswordStrength/password-utility.js.map +1 -0
- package/build/constants/chainConfigs.js +316 -0
- package/build/constants/chainConfigs.js.map +1 -0
- package/build/constants/defaultTheme.js +6 -0
- package/build/constants/defaultTheme.js.map +1 -0
- package/build/constants/openfort.d.ts +4 -0
- package/build/constants/openfort.js +8 -0
- package/build/constants/openfort.js.map +1 -0
- package/build/core/ConnectionStrategy.d.ts +31 -0
- package/build/core/ConnectionStrategy.js +9 -0
- package/build/core/ConnectionStrategy.js.map +1 -0
- package/build/core/ConnectionStrategyContext.d.ts +16 -0
- package/build/core/ConnectionStrategyContext.js +22 -0
- package/build/core/ConnectionStrategyContext.js.map +1 -0
- package/build/core/errors.d.ts +1 -0
- package/build/core/strategies/EthereumBridgeStrategy.d.ts +11 -0
- package/build/core/strategies/EthereumBridgeStrategy.js +83 -0
- package/build/core/strategies/EthereumBridgeStrategy.js.map +1 -0
- package/build/core/strategies/EthereumEmbeddedStrategy.d.ts +8 -0
- package/build/core/strategies/EthereumEmbeddedStrategy.js +85 -0
- package/build/core/strategies/EthereumEmbeddedStrategy.js.map +1 -0
- package/build/core/strategies/SolanaEmbeddedStrategy.d.ts +9 -0
- package/build/core/strategies/SolanaEmbeddedStrategy.js +53 -0
- package/build/core/strategies/SolanaEmbeddedStrategy.js.map +1 -0
- package/build/core/strategyUtils.d.ts +6 -0
- package/build/core/strategyUtils.js +31 -0
- package/build/core/strategyUtils.js.map +1 -0
- package/build/ethereum/OpenfortEthereumBridgeContext.d.ts +87 -0
- package/build/ethereum/OpenfortEthereumBridgeContext.js +18 -0
- package/build/ethereum/OpenfortEthereumBridgeContext.js.map +1 -0
- package/build/ethereum/hooks/getEmbeddedWalletClient.d.ts +14 -0
- package/build/ethereum/hooks/getEmbeddedWalletClient.js +24 -0
- package/build/ethereum/hooks/getEmbeddedWalletClient.js.map +1 -0
- package/build/ethereum/hooks/useEthereumEmbeddedWallet.d.ts +17 -0
- package/build/ethereum/hooks/useEthereumEmbeddedWallet.js +425 -0
- package/build/ethereum/hooks/useEthereumEmbeddedWallet.js.map +1 -0
- package/build/ethereum/hooks/useEthereumWalletAssets.d.ts +29 -0
- package/build/ethereum/hooks/useEthereumWalletAssets.js +204 -0
- package/build/ethereum/hooks/useEthereumWalletAssets.js.map +1 -0
- package/build/ethereum/index.d.ts +11 -0
- package/build/ethereum/index.js +3 -0
- package/build/ethereum/index.js.map +1 -0
- package/build/ethereum/types.d.ts +140 -0
- package/build/hooks/openfort/auth/requestEmailVerification.js +21 -0
- package/build/hooks/openfort/auth/requestEmailVerification.js.map +1 -0
- package/build/hooks/openfort/auth/status.js +11 -0
- package/build/hooks/openfort/auth/status.js.map +1 -0
- package/build/hooks/openfort/auth/useAuthCallback.d.ts +2 -1
- package/build/hooks/openfort/auth/useAuthCallback.js +197 -0
- package/build/hooks/openfort/auth/useAuthCallback.js.map +1 -0
- package/build/hooks/openfort/auth/useConnectToWalletPostAuth.d.ts +2 -2
- package/build/hooks/openfort/auth/useConnectToWalletPostAuth.js +161 -0
- package/build/hooks/openfort/auth/useConnectToWalletPostAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useEmailAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useEmailAuth.js +496 -0
- package/build/hooks/openfort/auth/useEmailAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useEmailOtpAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useEmailOtpAuth.js +151 -0
- package/build/hooks/openfort/auth/useEmailOtpAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useGuestAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useGuestAuth.js +142 -0
- package/build/hooks/openfort/auth/useGuestAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useOAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/useOAuth.js +217 -0
- package/build/hooks/openfort/auth/useOAuth.js.map +1 -0
- package/build/hooks/openfort/auth/usePhoneOtpAuth.d.ts +4 -3
- package/build/hooks/openfort/auth/usePhoneOtpAuth.js +174 -0
- package/build/hooks/openfort/auth/usePhoneOtpAuth.js.map +1 -0
- package/build/hooks/openfort/auth/useSignOut.d.ts +2 -1
- package/build/hooks/openfort/auth/useSignOut.js +104 -0
- package/build/hooks/openfort/auth/useSignOut.js.map +1 -0
- package/build/hooks/openfort/hookConsistency.js +17 -0
- package/build/hooks/openfort/hookConsistency.js.map +1 -0
- package/build/hooks/openfort/use7702Authorization.js +73 -0
- package/build/hooks/openfort/use7702Authorization.js.map +1 -0
- package/build/hooks/openfort/useGrantPermissions.d.ts +7 -76
- package/build/hooks/openfort/useGrantPermissions.js +221 -0
- package/build/hooks/openfort/useGrantPermissions.js.map +1 -0
- package/build/hooks/openfort/useProviders.js +75 -0
- package/build/hooks/openfort/useProviders.js.map +1 -0
- package/build/hooks/openfort/useRevokePermissions.d.ts +2 -1
- package/build/hooks/openfort/useRevokePermissions.js +126 -0
- package/build/hooks/openfort/useRevokePermissions.js.map +1 -0
- package/build/hooks/openfort/useUI.d.ts +4 -45
- package/build/hooks/openfort/useUI.js +122 -0
- package/build/hooks/openfort/useUI.js.map +1 -0
- package/build/hooks/openfort/useUser.d.ts +12 -35
- package/build/hooks/openfort/useUser.js +61 -0
- package/build/hooks/openfort/useUser.js.map +1 -0
- package/build/hooks/openfort/walletTypes.d.ts +32 -0
- package/build/hooks/openfort/walletTypes.js +53 -0
- package/build/hooks/openfort/walletTypes.js.map +1 -0
- package/build/hooks/useBalance.d.ts +50 -0
- package/build/hooks/useBalance.js +80 -0
- package/build/hooks/useBalance.js.map +1 -0
- package/build/hooks/useConnectLifecycle.d.ts +7 -0
- package/build/hooks/useConnectLifecycle.js +43 -0
- package/build/hooks/useConnectLifecycle.js.map +1 -0
- package/build/hooks/useConnectors.d.ts +3 -5
- package/build/hooks/useConnectors.js +26 -0
- package/build/hooks/useConnectors.js.map +1 -0
- package/build/hooks/useCopyToClipboard.js +29 -0
- package/build/hooks/useCopyToClipboard.js.map +1 -0
- package/build/hooks/useFitText.js +125 -0
- package/build/hooks/useFitText.js.map +1 -0
- package/build/hooks/useFocusTrap.d.ts +4 -1
- package/build/hooks/useFocusTrap.js +60 -0
- package/build/hooks/useFocusTrap.js.map +1 -0
- package/build/hooks/useGoogleFont.js +43 -0
- package/build/hooks/useGoogleFont.js.map +1 -0
- package/build/hooks/useIsMobile.js +17 -0
- package/build/hooks/useIsMobile.js.map +1 -0
- package/build/hooks/useIsMounted.js +10 -0
- package/build/hooks/useIsMounted.js.map +1 -0
- package/build/hooks/useLastConnector.js +39 -0
- package/build/hooks/useLastConnector.js.map +1 -0
- package/build/hooks/useLocales.d.ts +1 -1
- package/build/hooks/useLocales.js +68 -0
- package/build/hooks/useLocales.js.map +1 -0
- package/build/hooks/useLockBodyScroll.js +53 -0
- package/build/hooks/useLockBodyScroll.js.map +1 -0
- package/build/hooks/usePrevious.js +14 -0
- package/build/hooks/usePrevious.js.map +1 -0
- package/build/hooks/useResolvedIdentity.d.ts +70 -0
- package/build/hooks/useResolvedIdentity.js +90 -0
- package/build/hooks/useResolvedIdentity.js.map +1 -0
- package/build/hooks/useRouteProps.d.ts +10 -5
- package/build/hooks/useRouteProps.js +27 -0
- package/build/hooks/useRouteProps.js.map +1 -0
- package/build/hooks/useWalletConnectModal.js +59 -0
- package/build/hooks/useWalletConnectModal.js.map +1 -0
- package/build/hooks/useWindowSize.js +23 -0
- package/build/hooks/useWindowSize.js.map +1 -0
- package/build/index.d.ts +61 -16
- package/build/index.js +31 -0
- package/build/index.js.map +1 -0
- package/build/localizations/index.js +57 -0
- package/build/localizations/index.js.map +1 -0
- package/build/localizations/locales/ar-AE.js +100 -0
- package/build/localizations/locales/ar-AE.js.map +1 -0
- package/build/localizations/locales/ca-AD.js +98 -0
- package/build/localizations/locales/ca-AD.js.map +1 -0
- package/build/localizations/locales/ee-EE.js +98 -0
- package/build/localizations/locales/ee-EE.js.map +1 -0
- package/build/localizations/locales/en-US.js +115 -0
- package/build/localizations/locales/en-US.js.map +1 -0
- package/build/localizations/locales/es-ES.js +98 -0
- package/build/localizations/locales/es-ES.js.map +1 -0
- package/build/localizations/locales/fa-IR.js +98 -0
- package/build/localizations/locales/fa-IR.js.map +1 -0
- package/build/localizations/locales/fr-FR.js +98 -0
- package/build/localizations/locales/fr-FR.js.map +1 -0
- package/build/localizations/locales/ja-JP.js +98 -0
- package/build/localizations/locales/ja-JP.js.map +1 -0
- package/build/localizations/locales/pt-BR.js +98 -0
- package/build/localizations/locales/pt-BR.js.map +1 -0
- package/build/localizations/locales/ru-RU.js +98 -0
- package/build/localizations/locales/ru-RU.js.map +1 -0
- package/build/localizations/locales/tr-TR.js +98 -0
- package/build/localizations/locales/tr-TR.js.map +1 -0
- package/build/localizations/locales/vi-VN.js +98 -0
- package/build/localizations/locales/vi-VN.js.map +1 -0
- package/build/localizations/locales/zh-CN.js +98 -0
- package/build/localizations/locales/zh-CN.js.map +1 -0
- package/build/openfort/CoreOpenfortProvider.d.ts +9 -22
- package/build/openfort/CoreOpenfortProvider.js +389 -0
- package/build/openfort/CoreOpenfortProvider.js.map +1 -0
- package/build/{hooks/useConnectCallback.d.ts → openfort/connectCallbackTypes.d.ts} +2 -2
- package/build/openfort/context.d.ts +3 -2
- package/build/openfort/context.js +6 -0
- package/build/openfort/context.js.map +1 -0
- package/build/openfort/core/client.d.ts +2 -1
- package/build/openfort/core/client.js +23 -0
- package/build/openfort/core/client.js.map +1 -0
- package/build/openfort/hooks/useActiveAddressSync.d.ts +20 -0
- package/build/openfort/hooks/useActiveAddressSync.js +76 -0
- package/build/openfort/hooks/useActiveAddressSync.js.map +1 -0
- package/build/openfort/hooks/useAutoRecovery.d.ts +26 -0
- package/build/openfort/hooks/useAutoRecovery.js +102 -0
- package/build/openfort/hooks/useAutoRecovery.js.map +1 -0
- package/build/openfort/hooks/useEmbeddedStateMachine.d.ts +31 -0
- package/build/openfort/hooks/useEmbeddedStateMachine.js +77 -0
- package/build/openfort/hooks/useEmbeddedStateMachine.js.map +1 -0
- package/build/openfort/selectors.d.ts +9 -0
- package/build/openfort/selectors.js +15 -0
- package/build/openfort/selectors.js.map +1 -0
- package/build/openfort/store.d.ts +46 -0
- package/build/openfort/store.js +116 -0
- package/build/openfort/store.js.map +1 -0
- package/build/openfort/useOpenfort.d.ts +9 -3
- package/build/openfort/useOpenfort.js +15 -0
- package/build/openfort/useOpenfort.js.map +1 -0
- package/build/openfort/useOpenfortStore.d.ts +2 -0
- package/build/openfort/useOpenfortStore.js +13 -0
- package/build/openfort/useOpenfortStore.js.map +1 -0
- package/build/query/index.d.ts +2 -0
- package/build/query/queryKeys.d.ts +12 -0
- package/build/query/queryKeys.js +15 -0
- package/build/query/queryKeys.js.map +1 -0
- package/build/query/queryOptions.d.ts +23 -0
- package/build/query/queryOptions.js +31 -0
- package/build/query/queryOptions.js.map +1 -0
- package/build/shared/hooks/useAsyncData.d.ts +19 -0
- package/build/shared/hooks/useAsyncData.js +69 -0
- package/build/shared/hooks/useAsyncData.js.map +1 -0
- package/build/shared/hooks/useRecoveryOTP.d.ts +11 -0
- package/build/shared/hooks/useRecoveryOTP.js +64 -0
- package/build/shared/hooks/useRecoveryOTP.js.map +1 -0
- package/build/shared/types.d.ts +65 -0
- package/build/shared/utils/embeddedWalletStatusMapper.d.ts +15 -0
- package/build/shared/utils/embeddedWalletStatusMapper.js +22 -0
- package/build/shared/utils/embeddedWalletStatusMapper.js.map +1 -0
- package/build/shared/utils/explorer.d.ts +24 -0
- package/build/shared/utils/explorer.js +71 -0
- package/build/shared/utils/explorer.js.map +1 -0
- package/build/shared/utils/otpError.d.ts +8 -0
- package/build/shared/utils/otpError.js +17 -0
- package/build/shared/utils/otpError.js.map +1 -0
- package/build/shared/utils/recovery.d.ts +15 -0
- package/build/shared/utils/recovery.js +96 -0
- package/build/shared/utils/recovery.js.map +1 -0
- package/build/shared/utils/validation.d.ts +15 -0
- package/build/shared/utils/validation.js +27 -0
- package/build/shared/utils/validation.js.map +1 -0
- package/build/shared/utils/walletStatusProps.d.ts +18 -0
- package/build/shared/utils/walletStatusProps.js +45 -0
- package/build/shared/utils/walletStatusProps.js.map +1 -0
- package/build/siwe/create-siwe-message.d.ts +15 -1
- package/build/siwe/create-siwe-message.js +32 -0
- package/build/siwe/create-siwe-message.js.map +1 -0
- package/build/solana/SolanaContext.d.ts +43 -0
- package/build/solana/SolanaContext.js +87 -0
- package/build/solana/SolanaContext.js.map +1 -0
- package/build/solana/constants.d.ts +21 -0
- package/build/solana/constants.js +24 -0
- package/build/solana/constants.js.map +1 -0
- package/build/solana/hooks/recoveryResolver.d.ts +16 -0
- package/build/solana/hooks/recoveryResolver.js +39 -0
- package/build/solana/hooks/recoveryResolver.js.map +1 -0
- package/build/solana/hooks/useSolanaEmbeddedWallet.d.ts +17 -0
- package/build/solana/hooks/useSolanaEmbeddedWallet.js +389 -0
- package/build/solana/hooks/useSolanaEmbeddedWallet.js.map +1 -0
- package/build/solana/hooks/utils.d.ts +2 -0
- package/build/solana/hooks/utils.js +18 -0
- package/build/solana/hooks/utils.js.map +1 -0
- package/build/solana/index.d.ts +12 -0
- package/build/solana/index.js +2 -0
- package/build/solana/index.js.map +1 -0
- package/build/solana/operations.d.ts +22 -0
- package/build/solana/operations.js +40 -0
- package/build/solana/operations.js.map +1 -0
- package/build/solana/provider.d.ts +131 -0
- package/build/solana/provider.js +126 -0
- package/build/solana/provider.js.map +1 -0
- package/build/solana/types.d.ts +253 -0
- package/build/solana/utils/transfer.d.ts +9 -0
- package/build/solana/utils/transfer.js +20 -0
- package/build/solana/utils/transfer.js.map +1 -0
- package/build/styles/index.js +334 -0
- package/build/styles/index.js.map +1 -0
- package/build/styles/styled/index.js +14 -0
- package/build/styles/styled/index.js.map +1 -0
- package/build/styles/themes/base.js +147 -0
- package/build/styles/themes/base.js.map +1 -0
- package/build/styles/themes/index.js +13 -0
- package/build/styles/themes/index.js.map +1 -0
- package/build/styles/themes/midnight.js +78 -0
- package/build/styles/themes/midnight.js.map +1 -0
- package/build/styles/themes/minimal.js +100 -0
- package/build/styles/themes/minimal.js.map +1 -0
- package/build/styles/themes/nouns.js +83 -0
- package/build/styles/themes/nouns.js.map +1 -0
- package/build/styles/themes/retro.js +110 -0
- package/build/styles/themes/retro.js.map +1 -0
- package/build/styles/themes/rounded.js +110 -0
- package/build/styles/themes/rounded.js.map +1 -0
- package/build/styles/themes/soft.js +73 -0
- package/build/styles/themes/soft.js.map +1 -0
- package/build/styles/themes/web95.js +136 -0
- package/build/styles/themes/web95.js.map +1 -0
- package/build/types.d.ts +5 -6
- package/build/types.js +33 -0
- package/build/types.js.map +1 -0
- package/build/utils/banner.d.ts +1 -0
- package/build/utils/banner.js +14 -0
- package/build/utils/banner.js.map +1 -0
- package/build/utils/errorHandling.js +331 -0
- package/build/utils/errorHandling.js.map +1 -0
- package/build/utils/format.d.ts +18 -0
- package/build/utils/format.js +59 -0
- package/build/utils/format.js.map +1 -0
- package/build/utils/index.d.ts +2 -3
- package/build/utils/index.js +67 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/logger.js +13 -0
- package/build/utils/logger.js.map +1 -0
- package/build/utils/oauthErrorHandler.d.ts +1 -1
- package/build/utils/oauthErrorHandler.js +42 -0
- package/build/utils/oauthErrorHandler.js.map +1 -0
- package/build/utils/p3.js +14 -0
- package/build/utils/p3.js.map +1 -0
- package/build/utils/rpc.d.ts +34 -0
- package/build/utils/rpc.js +93 -0
- package/build/utils/rpc.js.map +1 -0
- package/build/utils/useOnUserReturn.js +25 -0
- package/build/utils/useOnUserReturn.js.map +1 -0
- package/build/utils/validation.js +7 -0
- package/build/utils/validation.js.map +1 -0
- package/build/utils/wallets.d.ts +6 -0
- package/build/utils/wallets.js +14 -0
- package/build/utils/wallets.js.map +1 -0
- package/build/version.d.ts +1 -1
- package/build/version.js +4 -0
- package/build/version.js.map +1 -0
- package/build/wagmi/OpenfortWagmiBridge.d.ts +3 -0
- package/build/wagmi/OpenfortWagmiBridge.js +166 -0
- package/build/wagmi/OpenfortWagmiBridge.js.map +1 -0
- package/build/wagmi/components/ChainSelect/index.js +140 -0
- package/build/wagmi/components/ChainSelect/index.js.map +1 -0
- package/build/wagmi/components/ChainSelectDropdown/index.js +144 -0
- package/build/wagmi/components/ChainSelectDropdown/index.js.map +1 -0
- package/build/wagmi/components/ChainSelectDropdown/styles.js +47 -0
- package/build/wagmi/components/ChainSelectDropdown/styles.js.map +1 -0
- package/build/wagmi/components/ChainSelectList/index.js +109 -0
- package/build/wagmi/components/ChainSelectList/index.js.map +1 -0
- package/build/wagmi/components/ChainSelectList/styles.js +225 -0
- package/build/wagmi/components/ChainSelectList/styles.js.map +1 -0
- package/build/wagmi/components/SwitchNetworks/index.js +22 -0
- package/build/wagmi/components/SwitchNetworks/index.js.map +1 -0
- package/build/wagmi/connectorFilter.d.ts +6 -0
- package/build/wagmi/connectorFilter.js +16 -0
- package/build/wagmi/connectorFilter.js.map +1 -0
- package/build/{defaultConfig.d.ts → wagmi/defaultConfig.d.ts} +1 -2
- package/build/wagmi/defaultConfig.js +27 -0
- package/build/wagmi/defaultConfig.js.map +1 -0
- package/build/wagmi/defaultConnectors.js +36 -0
- package/build/wagmi/defaultConnectors.js.map +1 -0
- package/build/wagmi/embeddedConnector.d.ts +4 -0
- package/build/wagmi/embeddedConnector.js +80 -0
- package/build/wagmi/embeddedConnector.js.map +1 -0
- package/build/wagmi/index.d.ts +10 -0
- package/build/wagmi/index.js +10 -0
- package/build/wagmi/index.js.map +1 -0
- package/build/wagmi/useChainIsSupported.d.ts +20 -0
- package/build/wagmi/useChainIsSupported.js +30 -0
- package/build/wagmi/useChainIsSupported.js.map +1 -0
- package/build/wagmi/useChains.d.ts +29 -0
- package/build/wagmi/useChains.js +38 -0
- package/build/wagmi/useChains.js.map +1 -0
- package/build/wagmi/useConnectWithSiwe.d.ts +22 -0
- package/build/wagmi/useConnectWithSiwe.js +115 -0
- package/build/wagmi/useConnectWithSiwe.js.map +1 -0
- package/build/wagmi/useEmbeddedWalletWagmiSync.d.ts +2 -0
- package/build/wagmi/useEmbeddedWalletWagmiSync.js +55 -0
- package/build/wagmi/useEmbeddedWalletWagmiSync.js.map +1 -0
- package/build/wagmi/useWalletAuth.d.ts +24 -0
- package/build/wagmi/useWalletAuth.js +180 -0
- package/build/wagmi/useWalletAuth.js.map +1 -0
- package/build/wallets/useExternalConnectors.d.ts +17 -0
- package/build/wallets/useExternalConnectors.js +98 -0
- package/build/wallets/useExternalConnectors.js.map +1 -0
- package/build/wallets/walletConfigs.js +344 -0
- package/build/wallets/walletConfigs.js.map +1 -0
- package/package.json +62 -11
- package/build/components/PageLayout/index.d.ts +0 -6
- package/build/components/contexts/web3/index.d.ts +0 -13
- package/build/constants/erc20.d.ts +0 -42
- package/build/hooks/openfort/auth/useWalletAuth.d.ts +0 -20
- package/build/hooks/openfort/useConnectWithSiwe.d.ts +0 -8
- package/build/hooks/openfort/useWalletAssets.d.ts +0 -16
- package/build/hooks/openfort/useWallets.d.ts +0 -134
- package/build/hooks/useChainIsSupported.d.ts +0 -24
- package/build/hooks/useChains.d.ts +0 -41
- package/build/hooks/useConnect.d.ts +0 -24
- package/build/hooks/useEnsFallbackConfig.d.ts +0 -1
- package/build/index.es.js +0 -19627
- package/build/index.es.js.map +0 -1
- package/build/openfortCustomTypes.d.ts +0 -10
- package/build/wallets/index.d.ts +0 -7
- package/build/wallets/useWagmiWallets.d.ts +0 -9
- /package/build/components/Pages/{SoicalProviders → SocialProviders}/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelect/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectDropdown/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectDropdown/styles.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectList/index.d.ts +0 -0
- /package/build/{components/Common → wagmi/components}/ChainSelectList/styles.d.ts +0 -0
- /package/build/{components/Pages → wagmi/components}/SwitchNetworks/index.d.ts +0 -0
- /package/build/{defaultConnectors.d.ts → wagmi/defaultConnectors.d.ts} +0 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import { ChainTypeEnum, AccountTypeEnum, EmbeddedState, RecoveryMethod } from '@openfort/openfort-js';
|
|
2
|
+
import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
|
|
3
|
+
import { baseSepolia } from 'viem/chains';
|
|
4
|
+
import { useOpenfort } from '../../components/Openfort/useOpenfort.js';
|
|
5
|
+
import { useConnectionStrategy } from '../../core/ConnectionStrategyContext.js';
|
|
6
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
|
|
7
|
+
import { useOpenfortCore } from '../../openfort/useOpenfort.js';
|
|
8
|
+
import { buildEmbeddedWalletStatusResult } from '../../shared/utils/embeddedWalletStatusMapper.js';
|
|
9
|
+
import { buildRecoveryParams } from '../../shared/utils/recovery.js';
|
|
10
|
+
import { toConnectedStateProperties } from '../../shared/utils/walletStatusProps.js';
|
|
11
|
+
import { formatAddress } from '../../utils/format.js';
|
|
12
|
+
|
|
13
|
+
/** Base Sepolia — fallback chain when no strategy or config provides a chain ID. */
|
|
14
|
+
const DEFAULT_TESTNET_CHAIN_ID = baseSepolia.id;
|
|
15
|
+
function buildConnectedWallet(acc, index, getProvider, overrides) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
return {
|
|
18
|
+
id: acc.id,
|
|
19
|
+
address: acc.address,
|
|
20
|
+
ownerAddress: acc.ownerAddress,
|
|
21
|
+
implementationType: acc.implementationType,
|
|
22
|
+
chainType: ChainTypeEnum.EVM,
|
|
23
|
+
walletIndex: index,
|
|
24
|
+
recoveryMethod: acc.recoveryMethod,
|
|
25
|
+
getProvider: (_a = overrides === null || overrides === void 0 ? void 0 : overrides.getProvider) !== null && _a !== void 0 ? _a : getProvider,
|
|
26
|
+
isAvailable: true,
|
|
27
|
+
isActive: (_b = overrides === null || overrides === void 0 ? void 0 : overrides.isActive) !== null && _b !== void 0 ? _b : false,
|
|
28
|
+
isConnecting: (_c = overrides === null || overrides === void 0 ? void 0 : overrides.isConnecting) !== null && _c !== void 0 ? _c : false,
|
|
29
|
+
accounts: [{ id: acc.id, chainId: acc.chainId }],
|
|
30
|
+
connectorType: 'embedded',
|
|
31
|
+
walletClientType: 'openfort',
|
|
32
|
+
accountId: acc.id,
|
|
33
|
+
accountType: acc.accountType,
|
|
34
|
+
createdAt: acc.createdAt,
|
|
35
|
+
salt: acc.salt,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns state for EVM embedded wallets: create, recover, list, active wallet, and provider.
|
|
40
|
+
* Use for creating accounts, recovering existing ones, and signing transactions.
|
|
41
|
+
*
|
|
42
|
+
* @param options - Optional chainId override for multi-chain
|
|
43
|
+
* @returns State with status, wallets, activeWallet, create, recover, setActive, provider
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const evm = useEthereumEmbeddedWallet()
|
|
48
|
+
* if (evm.status === 'connected') {
|
|
49
|
+
* const sig = await evm.provider?.request({ method: 'personal_sign', params: [hash, address] })
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
function useEthereumEmbeddedWallet(options) {
|
|
54
|
+
var _a, _b, _c, _d, _e, _f;
|
|
55
|
+
const { client, embeddedAccounts, embeddedState, isLoadingAccounts, updateEmbeddedAccounts, setActiveEmbeddedAddress, setWalletStatus, activeEmbeddedAddress, } = useOpenfortCore();
|
|
56
|
+
const { walletConfig, chainType } = useOpenfort();
|
|
57
|
+
const strategy = useConnectionStrategy();
|
|
58
|
+
const creationChainId = (_b = (_a = options === null || options === void 0 ? void 0 : options.chainId) !== null && _a !== void 0 ? _a : strategy === null || strategy === void 0 ? void 0 : strategy.getChainId()) !== null && _b !== void 0 ? _b : DEFAULT_TESTNET_CHAIN_ID;
|
|
59
|
+
const activeReturnChainId = (_c = strategy === null || strategy === void 0 ? void 0 : strategy.getChainId()) !== null && _c !== void 0 ? _c : DEFAULT_TESTNET_CHAIN_ID;
|
|
60
|
+
const setActiveInProgressRef = useRef(null);
|
|
61
|
+
const ethereumAccountsRef = useRef([]);
|
|
62
|
+
const [state, setState] = useState({
|
|
63
|
+
status: 'disconnected',
|
|
64
|
+
activeWallet: null,
|
|
65
|
+
provider: null,
|
|
66
|
+
error: null,
|
|
67
|
+
});
|
|
68
|
+
const ethereumAccounts = useMemo(() => {
|
|
69
|
+
if (!embeddedAccounts)
|
|
70
|
+
return [];
|
|
71
|
+
return embeddedAccounts.filter((acc) => acc.chainType === ChainTypeEnum.EVM);
|
|
72
|
+
}, [embeddedAccounts]);
|
|
73
|
+
ethereumAccountsRef.current = ethereumAccounts;
|
|
74
|
+
const getEmbeddedEthereumProvider = useCallback(async () => {
|
|
75
|
+
const provider = await client.embeddedWallet.getEthereumProvider();
|
|
76
|
+
// Ensure the current account is authorized on the provider.
|
|
77
|
+
// Without this, signing after password recovery can fail with
|
|
78
|
+
// "Unauthorized - call eth_requestAccounts first" because the provider
|
|
79
|
+
// was obtained before initProvider ran with proper config.
|
|
80
|
+
await provider.request({ method: 'eth_requestAccounts' });
|
|
81
|
+
return provider;
|
|
82
|
+
}, [client]);
|
|
83
|
+
const wallets = useMemo(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
const uniqueAddresses = new Map();
|
|
86
|
+
for (const acc of ethereumAccounts) {
|
|
87
|
+
const key = acc.address.toLowerCase();
|
|
88
|
+
if (!uniqueAddresses.has(key)) {
|
|
89
|
+
uniqueAddresses.set(key, acc);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const activeAddr = (_a = state.activeWallet) === null || _a === void 0 ? void 0 : _a.address.toLowerCase();
|
|
93
|
+
const isConnecting = state.status === 'connecting' || state.status === 'reconnecting';
|
|
94
|
+
return Array.from(uniqueAddresses.values()).map((acc, index) => {
|
|
95
|
+
const addr = acc.address.toLowerCase();
|
|
96
|
+
return buildConnectedWallet(acc, index, getEmbeddedEthereumProvider, {
|
|
97
|
+
isActive: state.status === 'connected' && activeAddr === addr,
|
|
98
|
+
isConnecting: isConnecting && activeAddr === addr,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}, [ethereumAccounts, getEmbeddedEthereumProvider, state.status, state.activeWallet]);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (state.status === 'creating') {
|
|
104
|
+
setWalletStatus({ status: 'creating' });
|
|
105
|
+
}
|
|
106
|
+
else if (state.status === 'connecting' && state.activeWallet) {
|
|
107
|
+
setWalletStatus({ status: 'connecting', address: state.activeWallet.address });
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
setWalletStatus({ status: 'idle' });
|
|
111
|
+
}
|
|
112
|
+
}, [state.status, (_d = state.activeWallet) === null || _d === void 0 ? void 0 : _d.address, setWalletStatus]);
|
|
113
|
+
const create = useCallback(async (createOptions) => {
|
|
114
|
+
var _a, _b, _c, _d, _e, _f;
|
|
115
|
+
setState((s) => ({ ...s, status: 'creating', error: null }));
|
|
116
|
+
try {
|
|
117
|
+
if (!walletConfig) {
|
|
118
|
+
throw new OpenfortError('Wallet config not found', OpenfortReactErrorType.CONFIGURATION_ERROR);
|
|
119
|
+
}
|
|
120
|
+
const recoveryParams = await buildRecoveryParams({
|
|
121
|
+
recoveryMethod: createOptions === null || createOptions === void 0 ? void 0 : createOptions.recoveryMethod,
|
|
122
|
+
passkeyId: createOptions === null || createOptions === void 0 ? void 0 : createOptions.passkeyId,
|
|
123
|
+
password: createOptions === null || createOptions === void 0 ? void 0 : createOptions.password,
|
|
124
|
+
otpCode: createOptions === null || createOptions === void 0 ? void 0 : createOptions.otpCode,
|
|
125
|
+
}, {
|
|
126
|
+
walletConfig,
|
|
127
|
+
getAccessToken: () => client.getAccessToken(),
|
|
128
|
+
getUserId: async () => {
|
|
129
|
+
const user = await client.user.get();
|
|
130
|
+
return user === null || user === void 0 ? void 0 : user.id;
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
// Determine account type (use createOptions, then walletConfig, else default to Smart Account)
|
|
134
|
+
const accountType = (_c = (_a = createOptions === null || createOptions === void 0 ? void 0 : createOptions.accountType) !== null && _a !== void 0 ? _a : (_b = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _b === void 0 ? void 0 : _b.accountType) !== null && _c !== void 0 ? _c : AccountTypeEnum.SMART_ACCOUNT;
|
|
135
|
+
const account = await client.embeddedWallet.create({
|
|
136
|
+
chainType: ChainTypeEnum.EVM,
|
|
137
|
+
accountType,
|
|
138
|
+
...(accountType !== AccountTypeEnum.EOA && { chainId: (_d = createOptions === null || createOptions === void 0 ? void 0 : createOptions.chainId) !== null && _d !== void 0 ? _d : creationChainId }),
|
|
139
|
+
recoveryParams,
|
|
140
|
+
});
|
|
141
|
+
await updateEmbeddedAccounts({ silent: true });
|
|
142
|
+
const provider = await getEmbeddedEthereumProvider();
|
|
143
|
+
const connectedWallet = buildConnectedWallet(account, 0, async () => provider, {
|
|
144
|
+
isActive: true,
|
|
145
|
+
isConnecting: false,
|
|
146
|
+
});
|
|
147
|
+
setState({
|
|
148
|
+
status: 'connected',
|
|
149
|
+
activeWallet: connectedWallet,
|
|
150
|
+
provider,
|
|
151
|
+
error: null,
|
|
152
|
+
});
|
|
153
|
+
setActiveEmbeddedAddress(account.address);
|
|
154
|
+
(_e = createOptions === null || createOptions === void 0 ? void 0 : createOptions.onSuccess) === null || _e === void 0 ? void 0 : _e.call(createOptions, { account });
|
|
155
|
+
return account;
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
const error = err instanceof OpenfortError
|
|
159
|
+
? err
|
|
160
|
+
: new OpenfortError('Failed to create Ethereum wallet', OpenfortReactErrorType.WALLET_ERROR, { error: err });
|
|
161
|
+
setState((s) => ({
|
|
162
|
+
...s,
|
|
163
|
+
status: 'error',
|
|
164
|
+
error: error.message,
|
|
165
|
+
}));
|
|
166
|
+
(_f = createOptions === null || createOptions === void 0 ? void 0 : createOptions.onError) === null || _f === void 0 ? void 0 : _f.call(createOptions, error);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}, [
|
|
170
|
+
client,
|
|
171
|
+
walletConfig,
|
|
172
|
+
creationChainId,
|
|
173
|
+
getEmbeddedEthereumProvider,
|
|
174
|
+
updateEmbeddedAccounts,
|
|
175
|
+
setActiveEmbeddedAddress,
|
|
176
|
+
]);
|
|
177
|
+
const setActive = useCallback(async (activeOptions) => {
|
|
178
|
+
const run = async () => {
|
|
179
|
+
var _a, _b, _c, _d, _e;
|
|
180
|
+
const accounts = ethereumAccountsRef.current;
|
|
181
|
+
const account = accounts.find((acc) => acc.address.toLowerCase() === activeOptions.address.toLowerCase());
|
|
182
|
+
if (!account) {
|
|
183
|
+
throw new OpenfortError('Embedded wallet not found', OpenfortReactErrorType.WALLET_ERROR, {
|
|
184
|
+
address: activeOptions.address,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const connectingStub = buildConnectedWallet(account, accounts.indexOf(account), getEmbeddedEthereumProvider, {
|
|
188
|
+
isActive: false,
|
|
189
|
+
isConnecting: true,
|
|
190
|
+
getProvider: async () => {
|
|
191
|
+
throw new OpenfortError('Provider not ready yet', OpenfortReactErrorType.WALLET_ERROR);
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
setState((s) => ({ ...s, status: 'connecting', activeWallet: connectingStub, error: null }));
|
|
195
|
+
try {
|
|
196
|
+
const password = activeOptions.password;
|
|
197
|
+
const hasExplicitRecovery = activeOptions.recoveryParams != null || password != null || activeOptions.recoveryMethod !== undefined;
|
|
198
|
+
let recoveryParams = activeOptions.recoveryParams;
|
|
199
|
+
if (!recoveryParams && !hasExplicitRecovery) {
|
|
200
|
+
if (account.recoveryMethod === RecoveryMethod.PASSKEY) {
|
|
201
|
+
const passkeyId = (_a = activeOptions.passkeyId) !== null && _a !== void 0 ? _a : (_b = account.recoveryMethodDetails) === null || _b === void 0 ? void 0 : _b.passkeyId;
|
|
202
|
+
recoveryParams = {
|
|
203
|
+
recoveryMethod: RecoveryMethod.PASSKEY,
|
|
204
|
+
...(passkeyId && { passkeyInfo: { passkeyId } }),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
else if (account.recoveryMethod === RecoveryMethod.PASSWORD) {
|
|
208
|
+
setState((s) => ({ ...s, status: 'needs-recovery', error: null }));
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
recoveryParams = await buildRecoveryParams({ recoveryMethod: undefined, otpCode: activeOptions.otpCode }, {
|
|
213
|
+
walletConfig,
|
|
214
|
+
getAccessToken: () => client.getAccessToken(),
|
|
215
|
+
getUserId: async () => { var _a; return (_a = (await client.user.get())) === null || _a === void 0 ? void 0 : _a.id; },
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else if (!recoveryParams && hasExplicitRecovery) {
|
|
220
|
+
recoveryParams = await buildRecoveryParams({
|
|
221
|
+
recoveryMethod: (_c = activeOptions.recoveryMethod) !== null && _c !== void 0 ? _c : (password != null ? RecoveryMethod.PASSWORD : undefined),
|
|
222
|
+
passkeyId: (_d = activeOptions.passkeyId) !== null && _d !== void 0 ? _d : (_e = account.recoveryMethodDetails) === null || _e === void 0 ? void 0 : _e.passkeyId,
|
|
223
|
+
password,
|
|
224
|
+
otpCode: activeOptions.otpCode,
|
|
225
|
+
}, {
|
|
226
|
+
walletConfig,
|
|
227
|
+
getAccessToken: () => client.getAccessToken(),
|
|
228
|
+
getUserId: async () => { var _a; return (_a = (await client.user.get())) === null || _a === void 0 ? void 0 : _a.id; },
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (recoveryParams) {
|
|
232
|
+
await client.embeddedWallet.recover({
|
|
233
|
+
account: account.id,
|
|
234
|
+
recoveryParams,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const provider = await getEmbeddedEthereumProvider();
|
|
238
|
+
const connectedWallet = buildConnectedWallet(account, accounts.indexOf(account), async () => provider, {
|
|
239
|
+
isActive: true,
|
|
240
|
+
isConnecting: false,
|
|
241
|
+
});
|
|
242
|
+
setState({
|
|
243
|
+
status: 'connected',
|
|
244
|
+
activeWallet: connectedWallet,
|
|
245
|
+
provider,
|
|
246
|
+
error: null,
|
|
247
|
+
});
|
|
248
|
+
setActiveEmbeddedAddress(account.address);
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
const error = err instanceof OpenfortError
|
|
252
|
+
? err
|
|
253
|
+
: new OpenfortError('Failed to set active Ethereum wallet', OpenfortReactErrorType.WALLET_ERROR, {
|
|
254
|
+
error: err,
|
|
255
|
+
});
|
|
256
|
+
setState((s) => ({
|
|
257
|
+
...s,
|
|
258
|
+
status: 'error',
|
|
259
|
+
error: error.message,
|
|
260
|
+
}));
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const prev = setActiveInProgressRef.current;
|
|
265
|
+
if (prev) {
|
|
266
|
+
try {
|
|
267
|
+
await prev;
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
/* ignore previous operation's error */
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const promise = run();
|
|
274
|
+
setActiveInProgressRef.current = promise;
|
|
275
|
+
try {
|
|
276
|
+
await promise;
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
if (setActiveInProgressRef.current === promise)
|
|
280
|
+
setActiveInProgressRef.current = null;
|
|
281
|
+
}
|
|
282
|
+
}, [client, walletConfig, getEmbeddedEthereumProvider, setActiveEmbeddedAddress]);
|
|
283
|
+
const setRecovery = useCallback(async (recoveryOptions) => {
|
|
284
|
+
try {
|
|
285
|
+
await client.embeddedWallet.setRecoveryMethod(recoveryOptions.previousRecovery, recoveryOptions.newRecovery);
|
|
286
|
+
await updateEmbeddedAccounts({ silent: true });
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
const error = err instanceof OpenfortError
|
|
290
|
+
? err
|
|
291
|
+
: new OpenfortError('Failed to set recovery method', OpenfortReactErrorType.WALLET_ERROR, { error: err });
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
}, [client, updateEmbeddedAccounts]);
|
|
295
|
+
const exportPrivateKey = useCallback(async () => {
|
|
296
|
+
return await client.embeddedWallet.exportPrivateKey();
|
|
297
|
+
}, [client]);
|
|
298
|
+
const actions = useMemo(() => ({
|
|
299
|
+
create,
|
|
300
|
+
wallets,
|
|
301
|
+
setActive,
|
|
302
|
+
setRecovery,
|
|
303
|
+
exportPrivateKey,
|
|
304
|
+
}), [create, wallets, setActive, setRecovery, exportPrivateKey]);
|
|
305
|
+
// Use refs for values that should NOT re-trigger the sync effect.
|
|
306
|
+
const stateRef = useRef(state);
|
|
307
|
+
stateRef.current = state;
|
|
308
|
+
// Prevents the sync effect from firing multiple async getProvider calls concurrently.
|
|
309
|
+
const syncInProgressRef = useRef(null);
|
|
310
|
+
// Sync local state from core's activeEmbeddedAddress (single source of truth).
|
|
311
|
+
// Only re-runs when the three meaningful inputs change: activeEmbeddedAddress, embeddedState, accounts list.
|
|
312
|
+
useEffect(() => {
|
|
313
|
+
var _a;
|
|
314
|
+
const s = stateRef.current;
|
|
315
|
+
// Not ready to sync yet
|
|
316
|
+
if (isLoadingAccounts || ethereumAccounts.length === 0 || embeddedState !== EmbeddedState.READY) {
|
|
317
|
+
// Clear state if address was removed (logout) while we're in a connected state
|
|
318
|
+
if (!activeEmbeddedAddress && (s.status === 'connected' || s.status === 'needs-recovery')) {
|
|
319
|
+
setState({ status: 'disconnected', activeWallet: null, provider: null, error: null });
|
|
320
|
+
}
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
// Don't interrupt in-progress operations
|
|
324
|
+
if (s.status === 'connecting' || s.status === 'reconnecting' || s.status === 'creating') {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// Logout / address cleared
|
|
328
|
+
if (!activeEmbeddedAddress && s.status === 'connected') {
|
|
329
|
+
setState({ status: 'disconnected', activeWallet: null, provider: null, error: null });
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
// Find matching account
|
|
333
|
+
const accountByAddress = activeEmbeddedAddress
|
|
334
|
+
? ethereumAccounts.find((acc) => acc.address.toLowerCase() === activeEmbeddedAddress.toLowerCase())
|
|
335
|
+
: undefined;
|
|
336
|
+
// Already synced to the right address
|
|
337
|
+
if (s.status === 'connected' && ((_a = s.activeWallet) === null || _a === void 0 ? void 0 : _a.address.toLowerCase()) === (activeEmbeddedAddress === null || activeEmbeddedAddress === void 0 ? void 0 : activeEmbeddedAddress.toLowerCase())) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
// Activate the matching account
|
|
341
|
+
if (accountByAddress) {
|
|
342
|
+
// Already syncing this address — skip duplicate async work
|
|
343
|
+
if (syncInProgressRef.current === accountByAddress.address.toLowerCase()) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
syncInProgressRef.current = accountByAddress.address.toLowerCase();
|
|
347
|
+
let cancelled = false;
|
|
348
|
+
getEmbeddedEthereumProvider()
|
|
349
|
+
.then((provider) => {
|
|
350
|
+
if (cancelled)
|
|
351
|
+
return;
|
|
352
|
+
const connectedWallet = buildConnectedWallet(accountByAddress, ethereumAccounts.indexOf(accountByAddress), async () => provider, { isActive: true, isConnecting: false });
|
|
353
|
+
setState({ status: 'connected', activeWallet: connectedWallet, provider, error: null });
|
|
354
|
+
})
|
|
355
|
+
.catch(() => { })
|
|
356
|
+
.finally(() => {
|
|
357
|
+
if (!cancelled)
|
|
358
|
+
syncInProgressRef.current = null;
|
|
359
|
+
});
|
|
360
|
+
return () => {
|
|
361
|
+
cancelled = true;
|
|
362
|
+
syncInProgressRef.current = null;
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
// activeEmbeddedAddress is from another chain (e.g. SVM); auto-activate first EVM wallet.
|
|
366
|
+
// Also fires from 'error': if setActive failed and address still points to a SVM wallet,
|
|
367
|
+
// re-point to the EVM wallet so the sync can self-heal.
|
|
368
|
+
if (chainType === ChainTypeEnum.EVM &&
|
|
369
|
+
activeEmbeddedAddress &&
|
|
370
|
+
ethereumAccounts.length > 0 &&
|
|
371
|
+
(s.status === 'disconnected' || s.status === 'error')) {
|
|
372
|
+
setActiveEmbeddedAddress(ethereumAccounts[0].address);
|
|
373
|
+
}
|
|
374
|
+
}, [
|
|
375
|
+
activeEmbeddedAddress,
|
|
376
|
+
embeddedState,
|
|
377
|
+
ethereumAccounts,
|
|
378
|
+
isLoadingAccounts,
|
|
379
|
+
chainType,
|
|
380
|
+
getEmbeddedEthereumProvider,
|
|
381
|
+
setActiveEmbeddedAddress,
|
|
382
|
+
]);
|
|
383
|
+
const derived = useMemo(() => ({
|
|
384
|
+
isLoading: state.status === 'fetching-wallets' ||
|
|
385
|
+
state.status === 'connecting' ||
|
|
386
|
+
state.status === 'creating' ||
|
|
387
|
+
state.status === 'reconnecting',
|
|
388
|
+
isError: state.status === 'error',
|
|
389
|
+
isSuccess: state.status === 'connected',
|
|
390
|
+
}), [state.status]);
|
|
391
|
+
const connectedStateProps = useMemo(() => toConnectedStateProperties(state.status, state.activeWallet), [state.status, state.activeWallet]);
|
|
392
|
+
// Compute displayAddress when connected
|
|
393
|
+
const displayAddress = useMemo(() => {
|
|
394
|
+
var _a;
|
|
395
|
+
return ((_a = state.activeWallet) === null || _a === void 0 ? void 0 : _a.address) && (state.status === 'connected' || state.status === 'connecting')
|
|
396
|
+
? formatAddress(state.activeWallet.address, ChainTypeEnum.EVM)
|
|
397
|
+
: undefined;
|
|
398
|
+
}, [(_e = state.activeWallet) === null || _e === void 0 ? void 0 : _e.address, state.status]);
|
|
399
|
+
if (isLoadingAccounts) {
|
|
400
|
+
return {
|
|
401
|
+
...actions,
|
|
402
|
+
status: 'fetching-wallets',
|
|
403
|
+
activeWallet: null,
|
|
404
|
+
isLoading: true,
|
|
405
|
+
isError: false,
|
|
406
|
+
isSuccess: false,
|
|
407
|
+
embeddedWalletId: undefined,
|
|
408
|
+
isConnected: false,
|
|
409
|
+
isConnecting: true,
|
|
410
|
+
isDisconnected: false,
|
|
411
|
+
isReconnecting: false,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
...buildEmbeddedWalletStatusResult(state, actions),
|
|
416
|
+
...derived,
|
|
417
|
+
...connectedStateProps,
|
|
418
|
+
...(displayAddress && { displayAddress }),
|
|
419
|
+
...(((_f = state.activeWallet) === null || _f === void 0 ? void 0 : _f.address) && { address: state.activeWallet.address }),
|
|
420
|
+
chainId: activeReturnChainId,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export { useEthereumEmbeddedWallet };
|
|
425
|
+
//# sourceMappingURL=useEthereumEmbeddedWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEthereumEmbeddedWallet.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Asset } from '../../components/Openfort/types';
|
|
2
|
+
import { OpenfortError } from '../../core/errors';
|
|
3
|
+
import type { EthereumConfig } from '../../ethereum/types';
|
|
4
|
+
type UseEthereumWalletAssetsOptions = {
|
|
5
|
+
assets?: EthereumConfig['assets'];
|
|
6
|
+
staleTime?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Returns wallet assets (tokens, NFTs) for the connected Ethereum address.
|
|
10
|
+
* Uses ERC-7811 via Openfort's authenticated RPC proxy.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Optional custom assets config and staleTime
|
|
13
|
+
* @returns assets, isLoading, error, refetch
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const { data: assets, isLoading } = useEthereumWalletAssets()
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const useEthereumWalletAssets: ({ assets: hookCustomAssets, staleTime, }?: UseEthereumWalletAssetsOptions) => {
|
|
21
|
+
data: readonly Asset[] | null;
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
isError: boolean;
|
|
24
|
+
isSuccess: boolean;
|
|
25
|
+
isIdle: boolean;
|
|
26
|
+
error: OpenfortError | undefined;
|
|
27
|
+
refetch: () => Promise<readonly Asset[] | undefined>;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { custom, createWalletClient, numberToHex } from 'viem';
|
|
3
|
+
import { erc7811Actions } from 'viem/experimental';
|
|
4
|
+
import { useOpenfort } from '../../components/Openfort/useOpenfort.js';
|
|
5
|
+
import { OpenfortError, OpenfortReactErrorType } from '../../types.js';
|
|
6
|
+
import { useUser } from '../../hooks/openfort/useUser.js';
|
|
7
|
+
import { openfortKeys } from '../../query/queryKeys.js';
|
|
8
|
+
import { useAsyncData } from '../../shared/hooks/useAsyncData.js';
|
|
9
|
+
import { useEthereumEmbeddedWallet } from './useEthereumEmbeddedWallet.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns wallet assets (tokens, NFTs) for the connected Ethereum address.
|
|
13
|
+
* Uses ERC-7811 via Openfort's authenticated RPC proxy.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Optional custom assets config and staleTime
|
|
16
|
+
* @returns assets, isLoading, error, refetch
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const { data: assets, isLoading } = useEthereumWalletAssets()
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const useEthereumWalletAssets = ({ assets: hookCustomAssets, staleTime = 30000, } = {}) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const wallet = useEthereumEmbeddedWallet();
|
|
26
|
+
const isConnected = wallet.status === 'connected';
|
|
27
|
+
const address = isConnected ? wallet.address : undefined;
|
|
28
|
+
const chainId = isConnected ? wallet.chainId : undefined;
|
|
29
|
+
const { walletConfig, publishableKey, overrides, thirdPartyAuth, chains } = useOpenfort();
|
|
30
|
+
const { getAccessToken } = useUser();
|
|
31
|
+
const chain = chains.find((c) => c.id === chainId);
|
|
32
|
+
const buildHeaders = useCallback(async () => {
|
|
33
|
+
if (thirdPartyAuth) {
|
|
34
|
+
const accessToken = await thirdPartyAuth.getAccessToken();
|
|
35
|
+
if (!accessToken) {
|
|
36
|
+
throw new OpenfortError('Failed to get access token from third party auth provider', OpenfortReactErrorType.AUTHENTICATION_ERROR);
|
|
37
|
+
}
|
|
38
|
+
const headers = {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
'x-auth-provider': thirdPartyAuth.provider,
|
|
41
|
+
'x-player-token': accessToken,
|
|
42
|
+
'x-token-type': 'idToken',
|
|
43
|
+
Authorization: `Bearer ${publishableKey}`,
|
|
44
|
+
};
|
|
45
|
+
return headers;
|
|
46
|
+
}
|
|
47
|
+
const headers = {
|
|
48
|
+
'Content-Type': 'application/json',
|
|
49
|
+
'x-project-key': publishableKey,
|
|
50
|
+
Authorization: `Bearer ${await getAccessToken()}`,
|
|
51
|
+
};
|
|
52
|
+
return headers;
|
|
53
|
+
}, [publishableKey, getAccessToken, thirdPartyAuth]);
|
|
54
|
+
const customTransport = useMemo(() => () => {
|
|
55
|
+
return custom({
|
|
56
|
+
async request({ method, params }) {
|
|
57
|
+
const res = await fetch(`${(overrides === null || overrides === void 0 ? void 0 : overrides.backendUrl) || 'https://api.openfort.io'}/rpc`, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: await buildHeaders(),
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
method,
|
|
62
|
+
params: params[0],
|
|
63
|
+
id: 1,
|
|
64
|
+
jsonrpc: '2.0',
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
const data = await res.json();
|
|
68
|
+
if (data.error) {
|
|
69
|
+
throw new Error(data.error.message);
|
|
70
|
+
}
|
|
71
|
+
return data.result;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}, [buildHeaders, overrides === null || overrides === void 0 ? void 0 : overrides.backendUrl]);
|
|
75
|
+
const customAssetsToFetch = useMemo(() => {
|
|
76
|
+
var _a;
|
|
77
|
+
if (!chainId)
|
|
78
|
+
return [];
|
|
79
|
+
const assetsFromConfig = ((_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.assets) ? walletConfig.ethereum.assets[chainId] || [] : [];
|
|
80
|
+
const assetsFromHook = hookCustomAssets ? hookCustomAssets[chainId] || [] : [];
|
|
81
|
+
const allAssets = [...assetsFromConfig, ...assetsFromHook];
|
|
82
|
+
return allAssets;
|
|
83
|
+
}, [(_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.assets, hookCustomAssets, chainId]);
|
|
84
|
+
const { data, error, isLoading, refetch } = useAsyncData({
|
|
85
|
+
queryKey: [...openfortKeys.walletAssets(chainId, customAssetsToFetch, address)],
|
|
86
|
+
queryFn: async () => {
|
|
87
|
+
var _a, _b, _c, _d;
|
|
88
|
+
if (!address || !chainId || !chain) {
|
|
89
|
+
throw new OpenfortError('Wallet not connected', OpenfortReactErrorType.UNEXPECTED_ERROR, {
|
|
90
|
+
error: new Error('Address, chainId, or chain not available'),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const customClient = createWalletClient({
|
|
94
|
+
account: address,
|
|
95
|
+
chain,
|
|
96
|
+
transport: customTransport(),
|
|
97
|
+
});
|
|
98
|
+
const extendedClient = customClient.extend(erc7811Actions());
|
|
99
|
+
const defaultAssetsPromise = extendedClient.getAssets({
|
|
100
|
+
chainIds: [chainId],
|
|
101
|
+
});
|
|
102
|
+
const hexChainId = numberToHex(chainId);
|
|
103
|
+
const customAssetsPromise = customAssetsToFetch.length > 0
|
|
104
|
+
? extendedClient.getAssets({
|
|
105
|
+
chainIds: [chainId],
|
|
106
|
+
assets: {
|
|
107
|
+
[hexChainId]: customAssetsToFetch.map((a) => ({
|
|
108
|
+
address: a,
|
|
109
|
+
type: 'erc20',
|
|
110
|
+
})),
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
: Promise.resolve({ [hexChainId]: [] });
|
|
114
|
+
const [defaultAssetsRaw, customAssets] = await Promise.all([defaultAssetsPromise, customAssetsPromise]);
|
|
115
|
+
// ERC-7811 response keys may be hex (e.g. "0x14a34") or numeric depending on the RPC
|
|
116
|
+
const rawByChain = defaultAssetsRaw;
|
|
117
|
+
const customByChain = customAssets;
|
|
118
|
+
const rawChainAssets = (_b = (_a = rawByChain[hexChainId]) !== null && _a !== void 0 ? _a : rawByChain[String(chainId)]) !== null && _b !== void 0 ? _b : [];
|
|
119
|
+
const customChainAssets = (_d = (_c = customByChain[hexChainId]) !== null && _c !== void 0 ? _c : customByChain[String(chainId)]) !== null && _d !== void 0 ? _d : [];
|
|
120
|
+
const defaultAssets = rawChainAssets.map((a) => {
|
|
121
|
+
var _a;
|
|
122
|
+
let asset;
|
|
123
|
+
if (a.type === 'erc20') {
|
|
124
|
+
const meta = a.metadata;
|
|
125
|
+
asset = {
|
|
126
|
+
type: 'erc20',
|
|
127
|
+
address: a.address,
|
|
128
|
+
balance: a.balance,
|
|
129
|
+
metadata: {
|
|
130
|
+
name: (meta === null || meta === void 0 ? void 0 : meta.name) || 'Unknown Token',
|
|
131
|
+
symbol: (meta === null || meta === void 0 ? void 0 : meta.symbol) || 'UNKNOWN',
|
|
132
|
+
decimals: meta === null || meta === void 0 ? void 0 : meta.decimals,
|
|
133
|
+
fiat: meta === null || meta === void 0 ? void 0 : meta.fiat,
|
|
134
|
+
},
|
|
135
|
+
raw: a,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
else if (a.type === 'native') {
|
|
139
|
+
const meta = a.metadata;
|
|
140
|
+
asset = {
|
|
141
|
+
type: 'native',
|
|
142
|
+
address: 'native',
|
|
143
|
+
balance: a.balance,
|
|
144
|
+
metadata: (meta === null || meta === void 0 ? void 0 : meta.fiat) ? { symbol: (_a = meta.symbol) !== null && _a !== void 0 ? _a : '', decimals: meta.decimals, fiat: meta.fiat } : undefined,
|
|
145
|
+
raw: a,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new OpenfortError('Unsupported asset type', OpenfortReactErrorType.UNEXPECTED_ERROR, { error: a });
|
|
150
|
+
}
|
|
151
|
+
return asset;
|
|
152
|
+
});
|
|
153
|
+
const mergedAssets = [...defaultAssets];
|
|
154
|
+
const customAssetsForChain = customChainAssets.flatMap((asset) => {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
// Custom assets are explicitly requested as erc20; skip if the API returns something unexpected.
|
|
157
|
+
if (asset.type !== 'erc20')
|
|
158
|
+
return [];
|
|
159
|
+
if (!((_a = walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.ethereum) === null || _a === void 0 ? void 0 : _a.assets))
|
|
160
|
+
return [{ ...asset, raw: asset }];
|
|
161
|
+
const configAsset = (_b = walletConfig.ethereum.assets[chainId]) === null || _b === void 0 ? void 0 : _b.find((a) => a.toLowerCase() === asset.address.toLowerCase());
|
|
162
|
+
if (!configAsset)
|
|
163
|
+
return [{ ...asset, raw: asset }];
|
|
164
|
+
return [
|
|
165
|
+
{
|
|
166
|
+
type: 'erc20',
|
|
167
|
+
address: asset.address,
|
|
168
|
+
balance: asset.balance,
|
|
169
|
+
metadata: asset.metadata,
|
|
170
|
+
raw: asset,
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
});
|
|
174
|
+
customAssetsForChain.forEach((asset) => {
|
|
175
|
+
if (!mergedAssets.find((a) => a.address === asset.address)) {
|
|
176
|
+
mergedAssets.push(asset);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return mergedAssets;
|
|
180
|
+
},
|
|
181
|
+
enabled: isConnected && !!chainId && !!chain && !!address,
|
|
182
|
+
staleTime,
|
|
183
|
+
});
|
|
184
|
+
const mappedError = useMemo(() => {
|
|
185
|
+
if (!error)
|
|
186
|
+
return undefined;
|
|
187
|
+
if (error instanceof OpenfortError) {
|
|
188
|
+
return error;
|
|
189
|
+
}
|
|
190
|
+
return new OpenfortError('Failed to fetch wallet assets', OpenfortReactErrorType.UNEXPECTED_ERROR, { error });
|
|
191
|
+
}, [error]);
|
|
192
|
+
return {
|
|
193
|
+
data: data !== null && data !== void 0 ? data : null,
|
|
194
|
+
isLoading,
|
|
195
|
+
isError: !!error,
|
|
196
|
+
isSuccess: !!data && !error,
|
|
197
|
+
isIdle: !isConnected || !chainId || !chain,
|
|
198
|
+
error: mappedError,
|
|
199
|
+
refetch,
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export { useEthereumWalletAssets };
|
|
204
|
+
//# sourceMappingURL=useEthereumWalletAssets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEthereumWalletAssets.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|