@web3auth/no-modal 10.0.0-beta.1 → 10.0.0-beta.10
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/dist/lib.cjs/base/connector/baseConnector.js +2 -1
- package/dist/lib.cjs/base/connector/constants.js +3 -1
- package/dist/lib.cjs/base/constants.js +7 -0
- package/dist/lib.cjs/base/cookie.js +38 -0
- package/dist/lib.cjs/base/deserialize.js +13 -0
- package/dist/lib.cjs/base/errors/index.js +3 -22
- package/dist/lib.cjs/base/utils.js +24 -6
- package/dist/lib.cjs/base/wallet/index.js +2 -4
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +63 -20
- package/dist/lib.cjs/connectors/coinbase-connector/coinbaseConnector.js +13 -5
- package/dist/lib.cjs/connectors/coinbase-connector/index.js +7 -0
- package/dist/lib.cjs/connectors/injected-evm-connector/injectedEvmConnector.js +7 -3
- package/dist/lib.cjs/connectors/injected-solana-connector/walletStandardConnector.js +7 -4
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +43 -15
- package/dist/lib.cjs/connectors/utils.js +10 -0
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/config.js +6 -1
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +6 -2
- package/dist/lib.cjs/index.js +13 -9
- package/dist/lib.cjs/noModal.js +190 -69
- package/dist/lib.cjs/plugins/nft-checkout-plugin/plugin.js +2 -2
- package/dist/lib.cjs/plugins/wallet-services-plugin/plugin.js +1 -1
- package/dist/lib.cjs/providers/account-abstraction-provider/index.js +5 -0
- package/dist/lib.cjs/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +29 -2
- package/dist/lib.cjs/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +25 -3
- package/dist/lib.cjs/providers/base-provider/baseProvider.js +2 -0
- package/dist/lib.cjs/providers/ethereum-mpc-provider/index.js +7 -0
- package/dist/lib.cjs/providers/xrpl-provider/index.js +9 -0
- package/dist/lib.cjs/react/Web3AuthProvider.js +19 -0
- package/dist/lib.cjs/react/{wallet-services-plugin/WalletServicesContext.js → context/WalletServicesInnerContext.js} +18 -33
- package/dist/lib.cjs/react/{no-modal → context}/Web3AuthInnerContext.js +37 -95
- package/dist/lib.cjs/react/hooks/useCheckout.js +45 -0
- package/dist/lib.cjs/react/hooks/useEnableMFA.js +30 -0
- package/dist/lib.cjs/react/hooks/useIdentityToken.js +42 -0
- package/dist/lib.cjs/react/hooks/useManageMFA.js +30 -0
- package/dist/lib.cjs/react/hooks/useSwap.js +45 -0
- package/dist/lib.cjs/react/hooks/useSwitchChain.js +32 -0
- package/dist/lib.cjs/react/hooks/useWalletConnectScanner.js +45 -0
- package/dist/lib.cjs/react/hooks/useWalletServicesPlugin.js +19 -0
- package/dist/lib.cjs/react/hooks/useWalletUI.js +45 -0
- package/dist/lib.cjs/react/hooks/useWeb3Auth.js +28 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthConnect.js +48 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.cjs/react/{no-modal/hooks/useWeb3Auth.js → hooks/useWeb3AuthInner.js} +9 -9
- package/dist/lib.cjs/react/hooks/useWeb3AuthUser.js +50 -0
- package/dist/lib.cjs/react/index.js +26 -9
- package/dist/lib.cjs/react/solana/hooks/useSignAndSendTransaction.js +35 -0
- package/dist/lib.cjs/react/solana/hooks/useSignMessage.js +36 -0
- package/dist/lib.cjs/react/solana/hooks/useSignTransaction.js +34 -0
- package/dist/lib.cjs/react/solana/hooks/useSolanaWallet.js +62 -0
- package/dist/lib.cjs/react/solana/index.js +13 -0
- package/dist/lib.cjs/react/wagmi/constants.js +16 -0
- package/dist/lib.cjs/react/wagmi/index.js +7 -0
- package/dist/lib.cjs/react/wagmi/provider.js +189 -0
- package/dist/lib.cjs/types/base/connector/baseConnector.d.ts +4 -5
- package/dist/lib.cjs/types/base/connector/constants.d.ts +2 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +18 -16
- package/dist/lib.cjs/types/base/constants.d.ts +5 -0
- package/dist/lib.cjs/types/base/cookie.d.ts +10 -0
- package/dist/lib.cjs/types/base/core/IWeb3Auth.d.ts +40 -12
- package/dist/lib.cjs/types/base/deserialize.d.ts +3 -0
- package/dist/lib.cjs/types/base/errors/index.d.ts +1 -2
- package/dist/lib.cjs/types/base/hooks/index.d.ts +3 -23
- package/dist/lib.cjs/types/base/index.d.ts +1 -0
- package/dist/lib.cjs/types/base/interfaces.d.ts +9 -4
- package/dist/lib.cjs/types/base/plugin/IPlugin.d.ts +1 -1
- package/dist/lib.cjs/types/base/utils.d.ts +3 -1
- package/dist/lib.cjs/types/base/wallet/index.d.ts +18 -17
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +5 -6
- package/dist/lib.cjs/types/connectors/auth-connector/interface.d.ts +3 -2
- package/dist/lib.cjs/types/connectors/coinbase-connector/coinbaseConnector.d.ts +1 -1
- package/dist/lib.cjs/types/connectors/index.d.ts +1 -1
- package/dist/lib.cjs/types/connectors/metamask-connector/index.d.ts +1 -1
- package/dist/lib.cjs/types/connectors/metamask-connector/metamaskConnector.d.ts +2 -2
- package/dist/lib.cjs/types/connectors/utils.d.ts +8 -0
- package/dist/lib.cjs/types/noModal.d.ts +20 -9
- package/dist/lib.cjs/types/plugins/nft-checkout-plugin/plugin.d.ts +2 -2
- package/dist/lib.cjs/types/plugins/wallet-services-plugin/plugin.d.ts +2 -2
- package/dist/lib.cjs/types/providers/account-abstraction-provider/providers/AccountAbstractionProvider.d.ts +3 -2
- package/dist/lib.cjs/types/providers/account-abstraction-provider/providers/smartAccounts/index.d.ts +1 -1
- package/dist/lib.cjs/types/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.d.ts +4 -1
- package/dist/lib.cjs/types/providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.d.ts +1 -1
- package/dist/lib.cjs/types/providers/index.d.ts +0 -2
- package/dist/lib.cjs/types/providers/solana-provider/providers/injectedProviders/base/baseInjectedProvider.d.ts +1 -1
- package/dist/lib.cjs/types/providers/xrpl-provider/providers/privateKeyProviders/xrplPrivateKeyProvider.d.ts +1 -1
- package/dist/lib.cjs/types/react/context/WalletServicesInnerContext.d.ts +6 -0
- package/dist/lib.cjs/types/react/{no-modal → context}/Web3AuthInnerContext.d.ts +1 -1
- package/dist/lib.cjs/types/react/hooks/index.d.ts +13 -0
- package/dist/lib.cjs/types/react/hooks/useCheckout.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useEnableMFA.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useIdentityToken.d.ts +13 -0
- package/dist/lib.cjs/types/react/hooks/useManageMFA.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useSwap.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useSwitchChain.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useWalletConnectScanner.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useWalletUI.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3Auth.d.ts +3 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthConnect.d.ts +9 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthDisconnect.d.ts +9 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthInner.d.ts +2 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthUser.d.ts +9 -0
- package/dist/lib.cjs/types/react/index.d.ts +3 -2
- package/dist/lib.cjs/types/react/interfaces.d.ts +21 -0
- package/dist/lib.cjs/types/react/solana/hooks/index.d.ts +4 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignAndSendTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignMessage.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignTransaction.d.ts +14 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSolanaWallet.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/react/wagmi/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/interface.d.ts +4 -0
- package/dist/lib.cjs/types/react/wagmi/provider.d.ts +3 -0
- package/dist/lib.cjs/types/vue/WalletServicesInnerProvider.d.ts +1 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +13 -0
- package/dist/lib.cjs/types/vue/composables/useCheckout.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useEnableMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useIdentityToken.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useManageMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useSwap.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useSwitchChain.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWalletConnectScanner.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWalletServicesPlugin.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWalletUI.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3Auth.d.ts +3 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthDisconnect.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthInner.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthUser.d.ts +10 -0
- package/dist/lib.cjs/types/vue/{wallet-services-plugin/context.d.ts → context/WalletServicesContext.d.ts} +2 -2
- package/dist/lib.cjs/types/vue/context/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/index.d.ts +4 -2
- package/dist/lib.cjs/types/vue/interfaces.d.ts +30 -0
- package/dist/lib.cjs/types/vue/solana/composables/index.d.ts +4 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignAndSendTransaction.d.ts +10 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignMessage.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignTransaction.d.ts +10 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSolanaWallet.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/vue/wagmi/index.d.ts +2 -0
- package/dist/lib.cjs/types/vue/wagmi/interface.d.ts +4 -0
- package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +17 -0
- package/dist/lib.cjs/vue/{wallet-services-plugin/WalletServicesProvider.js → WalletServicesInnerProvider.js} +26 -43
- package/dist/lib.cjs/vue/{no-modal/Web3AuthProvider.js → Web3AuthProvider.js} +45 -86
- package/dist/lib.cjs/vue/composables/useCheckout.js +45 -0
- package/dist/lib.cjs/vue/composables/useEnableMFA.js +43 -0
- package/dist/lib.cjs/vue/composables/useIdentityToken.js +55 -0
- package/dist/lib.cjs/vue/composables/useManageMFA.js +43 -0
- package/dist/lib.cjs/vue/composables/useSwap.js +45 -0
- package/dist/lib.cjs/vue/composables/useSwitchChain.js +43 -0
- package/dist/lib.cjs/vue/composables/useWalletConnectScanner.js +45 -0
- package/dist/lib.cjs/vue/composables/useWalletServicesPlugin.js +12 -0
- package/dist/lib.cjs/vue/composables/useWalletUI.js +45 -0
- package/dist/lib.cjs/vue/composables/useWeb3Auth.js +28 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthConnect.js +61 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthDisconnect.js +43 -0
- package/dist/lib.cjs/vue/{no-modal/composables/useWeb3Auth.js → composables/useWeb3AuthInner.js} +9 -9
- package/dist/lib.cjs/vue/composables/useWeb3AuthUser.js +64 -0
- package/dist/lib.cjs/vue/index.js +28 -8
- package/dist/lib.cjs/vue/solana/composables/useSignAndSendTransaction.js +36 -0
- package/dist/lib.cjs/vue/solana/composables/useSignMessage.js +38 -0
- package/dist/lib.cjs/vue/solana/composables/useSignTransaction.js +36 -0
- package/dist/lib.cjs/vue/solana/composables/useSolanaWallet.js +64 -0
- package/dist/lib.cjs/vue/solana/index.js +13 -0
- package/dist/lib.cjs/vue/wagmi/constants.js +16 -0
- package/dist/lib.cjs/vue/wagmi/index.js +7 -0
- package/dist/lib.cjs/vue/wagmi/provider.js +244 -0
- package/dist/lib.esm/base/connector/baseConnector.js +6 -1
- package/dist/lib.esm/base/connector/constants.js +3 -1
- package/dist/lib.esm/base/constants.js +6 -1
- package/dist/lib.esm/base/cookie.js +34 -0
- package/dist/lib.esm/base/deserialize.js +11 -0
- package/dist/lib.esm/base/errors/index.js +14 -22
- package/dist/lib.esm/base/plugin/errors.js +2 -0
- package/dist/lib.esm/base/utils.js +28 -12
- package/dist/lib.esm/base/wallet/index.js +2 -4
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +83 -30
- package/dist/lib.esm/connectors/base-evm-connector/baseEvmConnector.js +1 -8
- package/dist/lib.esm/connectors/base-solana-connector/baseSolanaConnector.js +1 -8
- package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +16 -15
- package/dist/lib.esm/connectors/coinbase-connector/index.js +1 -0
- package/dist/lib.esm/connectors/injected-evm-connector/injectedEvmConnector.js +11 -12
- package/dist/lib.esm/connectors/injected-solana-connector/walletStandardConnector.js +13 -17
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +52 -27
- package/dist/lib.esm/connectors/utils.js +14 -1
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +8 -25
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/config.js +20 -25
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +15 -15
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Utils.js +1 -11
- package/dist/lib.esm/index.js +12 -14
- package/dist/lib.esm/noModal.js +217 -80
- package/dist/lib.esm/plugins/nft-checkout-plugin/embed.js +4 -1
- package/dist/lib.esm/plugins/nft-checkout-plugin/plugin.js +4 -10
- package/dist/lib.esm/plugins/wallet-services-plugin/plugin.js +7 -9
- package/dist/lib.esm/providers/account-abstraction-provider/index.js +2 -2
- package/dist/lib.esm/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +37 -20
- package/dist/lib.esm/providers/account-abstraction-provider/providers/utils.js +0 -10
- package/dist/lib.esm/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +26 -3
- package/dist/lib.esm/providers/base-provider/baseProvider.js +7 -9
- package/dist/lib.esm/providers/base-provider/utils.js +3 -3
- package/dist/lib.esm/providers/ethereum-mpc-provider/index.js +1 -0
- package/dist/lib.esm/providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.js +4 -17
- package/dist/lib.esm/providers/ethereum-mpc-provider/providers/signingProviders/signingUtils.js +3 -13
- package/dist/lib.esm/providers/ethereum-mpc-provider/rpc/ethRpcMiddlewares.js +1 -0
- package/dist/lib.esm/providers/ethereum-provider/providers/converter.js +1 -0
- package/dist/lib.esm/providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/formatter.js +10 -11
- package/dist/lib.esm/providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/interfaces.js +3 -3
- package/dist/lib.esm/providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/utils.js +1 -0
- package/dist/lib.esm/providers/ethereum-provider/rpc/walletMidddleware.js +8 -0
- package/dist/lib.esm/providers/solana-provider/providers/injectedProviders/base/baseInjectedProvider.js +2 -15
- package/dist/lib.esm/providers/solana-provider/providers/injectedProviders/walletStandardProvider.js +5 -12
- package/dist/lib.esm/providers/solana-provider/rpc/solanaRpcMiddlewares.js +1 -1
- package/dist/lib.esm/providers/solana-provider/solanaWallet.js +3 -0
- package/dist/lib.esm/providers/xrpl-provider/index.js +2 -0
- package/dist/lib.esm/providers/xrpl-provider/providers/privateKeyProviders/xrplPrivateKeyProvider.js +3 -14
- package/dist/lib.esm/providers/xrpl-provider/rpc/xrplRpcMiddlewares.js +1 -0
- package/dist/lib.esm/react/Web3AuthProvider.js +17 -0
- package/dist/lib.esm/react/context/WalletServicesInnerContext.js +70 -0
- package/dist/lib.esm/react/context/Web3AuthInnerContext.js +129 -0
- package/dist/lib.esm/react/hooks/useCheckout.js +32 -0
- package/dist/lib.esm/react/hooks/useEnableMFA.js +28 -0
- package/dist/lib.esm/react/hooks/useIdentityToken.js +40 -0
- package/dist/lib.esm/react/hooks/useManageMFA.js +28 -0
- package/dist/lib.esm/react/hooks/useSwap.js +32 -0
- package/dist/lib.esm/react/hooks/useSwitchChain.js +30 -0
- package/dist/lib.esm/react/hooks/useWalletConnectScanner.js +32 -0
- package/dist/lib.esm/react/hooks/useWalletServicesPlugin.js +17 -0
- package/dist/lib.esm/react/hooks/useWalletUI.js +32 -0
- package/dist/lib.esm/react/hooks/useWeb3Auth.js +26 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthConnect.js +46 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthDisconnect.js +28 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthInner.js +13 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthUser.js +48 -0
- package/dist/lib.esm/react/index.js +14 -5
- package/dist/lib.esm/react/solana/hooks/useSignAndSendTransaction.js +33 -0
- package/dist/lib.esm/react/solana/hooks/useSignMessage.js +34 -0
- package/dist/lib.esm/react/solana/hooks/useSignTransaction.js +32 -0
- package/dist/lib.esm/react/solana/hooks/useSolanaWallet.js +42 -0
- package/dist/lib.esm/react/solana/index.js +4 -0
- package/dist/lib.esm/react/wagmi/constants.js +14 -0
- package/dist/lib.esm/react/wagmi/index.js +1 -0
- package/dist/lib.esm/react/wagmi/provider.js +179 -0
- package/dist/lib.esm/vue/WalletServicesInnerProvider.js +71 -0
- package/dist/lib.esm/vue/Web3AuthProvider.js +154 -0
- package/dist/lib.esm/vue/composables/useCheckout.js +32 -0
- package/dist/lib.esm/vue/composables/useEnableMFA.js +30 -0
- package/dist/lib.esm/vue/composables/useIdentityToken.js +42 -0
- package/dist/lib.esm/vue/composables/useManageMFA.js +30 -0
- package/dist/lib.esm/vue/composables/useSwap.js +32 -0
- package/dist/lib.esm/vue/composables/useSwitchChain.js +30 -0
- package/dist/lib.esm/vue/composables/useWalletConnectScanner.js +32 -0
- package/dist/lib.esm/vue/composables/useWalletServicesPlugin.js +10 -0
- package/dist/lib.esm/vue/composables/useWalletUI.js +32 -0
- package/dist/lib.esm/vue/composables/useWeb3Auth.js +26 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthConnect.js +48 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthInner.js +11 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthUser.js +51 -0
- package/dist/lib.esm/vue/index.js +15 -5
- package/dist/lib.esm/vue/solana/composables/useSignAndSendTransaction.js +34 -0
- package/dist/lib.esm/vue/solana/composables/useSignMessage.js +36 -0
- package/dist/lib.esm/vue/solana/composables/useSignTransaction.js +34 -0
- package/dist/lib.esm/vue/solana/composables/useSolanaWallet.js +51 -0
- package/dist/lib.esm/vue/solana/index.js +4 -0
- package/dist/lib.esm/vue/wagmi/constants.js +14 -0
- package/dist/lib.esm/vue/wagmi/index.js +1 -0
- package/dist/lib.esm/vue/wagmi/provider.js +237 -0
- package/dist/noModal.umd.min.js +1 -1
- package/dist/noModal.umd.min.js.LICENSE.txt +0 -26
- package/package.json +79 -20
- package/dist/lib.cjs/react/no-modal/Web3AuthProvider.js +0 -15
- package/dist/lib.cjs/react/wallet-services-plugin/WalletServicesProvider.js +0 -16
- package/dist/lib.cjs/react/wallet-services-plugin/hooks/useWalletServicesPlugin.js +0 -26
- package/dist/lib.cjs/types/react/no-modal/hooks/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/no-modal/hooks/useWeb3Auth.d.ts +0 -2
- package/dist/lib.cjs/types/react/no-modal/index.d.ts +0 -3
- package/dist/lib.cjs/types/react/no-modal/interfaces.d.ts +0 -15
- package/dist/lib.cjs/types/react/wallet-services-plugin/WalletServicesContext.d.ts +0 -7
- package/dist/lib.cjs/types/react/wallet-services-plugin/WalletServicesProvider.d.ts +0 -7
- package/dist/lib.cjs/types/react/wallet-services-plugin/hooks/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/wallet-services-plugin/index.d.ts +0 -4
- package/dist/lib.cjs/types/react/wallet-services-plugin/interfaces.d.ts +0 -5
- package/dist/lib.cjs/types/vue/no-modal/composables/index.d.ts +0 -1
- package/dist/lib.cjs/types/vue/no-modal/composables/useWeb3Auth.d.ts +0 -2
- package/dist/lib.cjs/types/vue/no-modal/index.d.ts +0 -3
- package/dist/lib.cjs/types/vue/no-modal/interfaces.d.ts +0 -39
- package/dist/lib.cjs/types/vue/wallet-services-plugin/WalletServicesProvider.d.ts +0 -1
- package/dist/lib.cjs/types/vue/wallet-services-plugin/composables/index.d.ts +0 -1
- package/dist/lib.cjs/types/vue/wallet-services-plugin/composables/useWalletServicesPlugin.d.ts +0 -2
- package/dist/lib.cjs/types/vue/wallet-services-plugin/index.d.ts +0 -4
- package/dist/lib.cjs/types/vue/wallet-services-plugin/interfaces.d.ts +0 -13
- package/dist/lib.cjs/vue/wallet-services-plugin/composables/useWalletServicesPlugin.js +0 -24
- package/dist/lib.esm/react/no-modal/Web3AuthInnerContext.js +0 -197
- package/dist/lib.esm/react/no-modal/Web3AuthProvider.js +0 -13
- package/dist/lib.esm/react/no-modal/hooks/useWeb3Auth.js +0 -24
- package/dist/lib.esm/react/wallet-services-plugin/WalletServicesContext.js +0 -95
- package/dist/lib.esm/react/wallet-services-plugin/WalletServicesProvider.js +0 -14
- package/dist/lib.esm/react/wallet-services-plugin/hooks/useWalletServicesPlugin.js +0 -24
- package/dist/lib.esm/vue/no-modal/Web3AuthProvider.js +0 -203
- package/dist/lib.esm/vue/no-modal/composables/useWeb3Auth.js +0 -22
- package/dist/lib.esm/vue/wallet-services-plugin/WalletServicesProvider.js +0 -96
- package/dist/lib.esm/vue/wallet-services-plugin/composables/useWalletServicesPlugin.js +0 -22
- /package/dist/lib.cjs/types/react/{no-modal/Web3AuthProvider.d.ts → Web3AuthProvider.d.ts} +0 -0
- /package/dist/lib.cjs/types/react/{wallet-services-plugin/hooks → hooks}/useWalletServicesPlugin.d.ts +0 -0
- /package/dist/lib.cjs/types/vue/{no-modal/Web3AuthProvider.d.ts → Web3AuthProvider.d.ts} +0 -0
- /package/dist/lib.cjs/vue/{wallet-services-plugin/context.js → context/WalletServicesContext.js} +0 -0
- /package/dist/lib.esm/vue/{wallet-services-plugin/context.js → context/WalletServicesContext.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
|
|
5
|
+
const useManageMFA = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const manageMFA = async () => {
|
|
12
|
+
try {
|
|
13
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
|
+
error.value = null;
|
|
15
|
+
loading.value = true;
|
|
16
|
+
await web3Auth.value.enableMFA();
|
|
17
|
+
} catch (err) {
|
|
18
|
+
error.value = err;
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
manageMFA
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useManageMFA };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
|
+
|
|
5
|
+
const useSwap = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showSwap = async showSwapParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showSwap(showSwapParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showSwap
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useSwap };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
|
|
5
|
+
const useSwitchChain = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const switchChain = async chainParams => {
|
|
12
|
+
try {
|
|
13
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
|
+
error.value = null;
|
|
15
|
+
loading.value = true;
|
|
16
|
+
await web3Auth.value.switchChain(chainParams);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
error.value = err;
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
switchChain
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useSwitchChain };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
|
+
|
|
5
|
+
const useWalletConnectScanner = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showWalletConnectScanner = async showWalletConnectScannerParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showWalletConnectScanner(showWalletConnectScannerParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showWalletConnectScanner
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useWalletConnectScanner };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { inject } from 'vue';
|
|
2
|
+
import { WalletServicesContextKey } from '../context/WalletServicesContext.js';
|
|
3
|
+
|
|
4
|
+
const useWalletServicesPlugin = () => {
|
|
5
|
+
const context = inject(WalletServicesContextKey);
|
|
6
|
+
if (!context) throw new Error("WalletServicesContext not found");
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { useWalletServicesPlugin };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
|
+
|
|
5
|
+
const useWalletUI = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showWalletUI = async showWalletUiParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showWalletUi(showWalletUiParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showWalletUI
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useWalletUI };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
2
|
+
|
|
3
|
+
const useWeb3Auth = () => {
|
|
4
|
+
const {
|
|
5
|
+
initError,
|
|
6
|
+
isConnected,
|
|
7
|
+
isInitialized,
|
|
8
|
+
isInitializing,
|
|
9
|
+
provider,
|
|
10
|
+
status,
|
|
11
|
+
web3Auth,
|
|
12
|
+
getPlugin
|
|
13
|
+
} = useWeb3AuthInner();
|
|
14
|
+
return {
|
|
15
|
+
initError,
|
|
16
|
+
isConnected,
|
|
17
|
+
isInitialized,
|
|
18
|
+
isInitializing,
|
|
19
|
+
provider,
|
|
20
|
+
status,
|
|
21
|
+
web3Auth,
|
|
22
|
+
getPlugin
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { useWeb3Auth };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
|
|
5
|
+
const useWeb3AuthConnect = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth,
|
|
8
|
+
isConnected
|
|
9
|
+
} = useWeb3AuthInner();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const connectorName = ref(null);
|
|
13
|
+
watch(isConnected, newVal => {
|
|
14
|
+
if (!newVal && connectorName.value) {
|
|
15
|
+
connectorName.value = null;
|
|
16
|
+
}
|
|
17
|
+
if (newVal && !connectorName.value) {
|
|
18
|
+
var _web3Auth$value;
|
|
19
|
+
connectorName.value = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.connectedConnectorName;
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
immediate: true
|
|
23
|
+
});
|
|
24
|
+
const connect = async (connectorType, loginParams) => {
|
|
25
|
+
try {
|
|
26
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
27
|
+
error.value = null;
|
|
28
|
+
loading.value = true;
|
|
29
|
+
const localProvider = await web3Auth.value.connectTo(connectorType, loginParams);
|
|
30
|
+
connectorName.value = web3Auth.value.connectedConnectorName;
|
|
31
|
+
return localProvider;
|
|
32
|
+
} catch (err) {
|
|
33
|
+
error.value = err;
|
|
34
|
+
return null;
|
|
35
|
+
} finally {
|
|
36
|
+
loading.value = false;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
isConnected,
|
|
41
|
+
loading,
|
|
42
|
+
error,
|
|
43
|
+
connectorName,
|
|
44
|
+
connect
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { useWeb3AuthConnect };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
|
|
5
|
+
const useWeb3AuthDisconnect = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const disconnect = async options => {
|
|
12
|
+
try {
|
|
13
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
|
+
error.value = null;
|
|
15
|
+
loading.value = true;
|
|
16
|
+
await web3Auth.value.logout(options);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
error.value = err;
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
disconnect
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useWeb3AuthDisconnect };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { inject } from 'vue';
|
|
2
|
+
import { Web3AuthContextKey } from '../../base/composables/index.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
|
|
5
|
+
const useWeb3AuthInner = () => {
|
|
6
|
+
const context = inject(Web3AuthContextKey);
|
|
7
|
+
if (!context) throw WalletInitializationError.fromCode(1000, "usage of `useWeb3Auth` not wrapped in `Web3AuthProvider`.");
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useWeb3AuthInner };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
|
|
5
|
+
const useWeb3AuthUser = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth,
|
|
8
|
+
isConnected,
|
|
9
|
+
isMFAEnabled,
|
|
10
|
+
setIsMFAEnabled
|
|
11
|
+
} = useWeb3AuthInner();
|
|
12
|
+
const loading = ref(false);
|
|
13
|
+
const error = ref(null);
|
|
14
|
+
const userInfo = ref(null);
|
|
15
|
+
const getUserInfo = async () => {
|
|
16
|
+
try {
|
|
17
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
18
|
+
error.value = null;
|
|
19
|
+
loading.value = true;
|
|
20
|
+
const result = await web3Auth.value.getUserInfo();
|
|
21
|
+
userInfo.value = result;
|
|
22
|
+
return result;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
error.value = err;
|
|
25
|
+
} finally {
|
|
26
|
+
loading.value = false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
watch(isConnected, async newIsConnected => {
|
|
30
|
+
if (newIsConnected && !userInfo.value) {
|
|
31
|
+
const result = await getUserInfo();
|
|
32
|
+
userInfo.value = result;
|
|
33
|
+
setIsMFAEnabled((result === null || result === void 0 ? void 0 : result.isMfaEnabled) || false);
|
|
34
|
+
}
|
|
35
|
+
if (!newIsConnected && userInfo.value) {
|
|
36
|
+
userInfo.value = null;
|
|
37
|
+
setIsMFAEnabled(false);
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
immediate: true
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
loading,
|
|
44
|
+
error,
|
|
45
|
+
userInfo,
|
|
46
|
+
isMFAEnabled,
|
|
47
|
+
getUserInfo
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { useWeb3AuthUser };
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { Web3AuthProvider } from './Web3AuthProvider.js';
|
|
2
|
+
export { useCheckout } from './composables/useCheckout.js';
|
|
3
|
+
export { useEnableMFA } from './composables/useEnableMFA.js';
|
|
4
|
+
export { useIdentityToken } from './composables/useIdentityToken.js';
|
|
5
|
+
export { useManageMFA } from './composables/useManageMFA.js';
|
|
6
|
+
export { useSwap } from './composables/useSwap.js';
|
|
7
|
+
export { useSwitchChain } from './composables/useSwitchChain.js';
|
|
8
|
+
export { useWalletConnectScanner } from './composables/useWalletConnectScanner.js';
|
|
9
|
+
export { useWalletServicesPlugin } from './composables/useWalletServicesPlugin.js';
|
|
10
|
+
export { useWalletUI } from './composables/useWalletUI.js';
|
|
11
|
+
export { useWeb3Auth } from './composables/useWeb3Auth.js';
|
|
12
|
+
export { useWeb3AuthConnect } from './composables/useWeb3AuthConnect.js';
|
|
13
|
+
export { useWeb3AuthDisconnect } from './composables/useWeb3AuthDisconnect.js';
|
|
14
|
+
export { useWeb3AuthUser } from './composables/useWeb3AuthUser.js';
|
|
15
|
+
export { WalletServicesContextKey } from './context/WalletServicesContext.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { WalletInitializationError } from '../../../base/errors/index.js';
|
|
3
|
+
import { useSolanaWallet } from './useSolanaWallet.js';
|
|
4
|
+
|
|
5
|
+
const useSignAndSendTransaction = () => {
|
|
6
|
+
const {
|
|
7
|
+
solanaWallet
|
|
8
|
+
} = useSolanaWallet();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const data = ref(null);
|
|
12
|
+
const signAndSendTransaction = async transaction => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!solanaWallet.value) throw WalletInitializationError.notReady();
|
|
17
|
+
const signature = await solanaWallet.value.signAndSendTransaction(transaction);
|
|
18
|
+
data.value = signature;
|
|
19
|
+
return signature;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
error.value = err;
|
|
22
|
+
} finally {
|
|
23
|
+
loading.value = false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
loading,
|
|
28
|
+
error,
|
|
29
|
+
data,
|
|
30
|
+
signAndSendTransaction
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { useSignAndSendTransaction };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { WalletInitializationError } from '../../../base/errors/index.js';
|
|
3
|
+
import { useSolanaWallet } from './useSolanaWallet.js';
|
|
4
|
+
|
|
5
|
+
const useSignMessage = () => {
|
|
6
|
+
const {
|
|
7
|
+
solanaWallet,
|
|
8
|
+
accounts
|
|
9
|
+
} = useSolanaWallet();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const data = ref(null);
|
|
13
|
+
const signMessage = async (message, from) => {
|
|
14
|
+
loading.value = true;
|
|
15
|
+
error.value = null;
|
|
16
|
+
try {
|
|
17
|
+
var _accounts$value;
|
|
18
|
+
if (!solanaWallet.value) throw WalletInitializationError.notReady();
|
|
19
|
+
const signature = await solanaWallet.value.signMessage(message, from !== null && from !== void 0 ? from : (_accounts$value = accounts.value) === null || _accounts$value === void 0 ? void 0 : _accounts$value[0]);
|
|
20
|
+
data.value = signature;
|
|
21
|
+
return signature;
|
|
22
|
+
} catch (err) {
|
|
23
|
+
error.value = err;
|
|
24
|
+
} finally {
|
|
25
|
+
loading.value = false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
loading,
|
|
30
|
+
error,
|
|
31
|
+
data,
|
|
32
|
+
signMessage
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { useSignMessage };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { WalletInitializationError } from '../../../base/errors/index.js';
|
|
3
|
+
import { useSolanaWallet } from './useSolanaWallet.js';
|
|
4
|
+
|
|
5
|
+
const useSignTransaction = () => {
|
|
6
|
+
const {
|
|
7
|
+
solanaWallet
|
|
8
|
+
} = useSolanaWallet();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const data = ref(null);
|
|
12
|
+
const signTransaction = async transaction => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!solanaWallet.value) throw WalletInitializationError.notReady();
|
|
17
|
+
const signedTransaction = await solanaWallet.value.signTransaction(transaction);
|
|
18
|
+
data.value = signedTransaction;
|
|
19
|
+
return signedTransaction;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
error.value = err;
|
|
22
|
+
} finally {
|
|
23
|
+
loading.value = false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
loading,
|
|
28
|
+
error,
|
|
29
|
+
data,
|
|
30
|
+
signTransaction
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { useSignTransaction };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import { ref, shallowRef, watch } from 'vue';
|
|
3
|
+
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
4
|
+
import { SolanaWallet } from '../../../providers/solana-provider/solanaWallet.js';
|
|
5
|
+
import { useWeb3Auth } from '../../composables/useWeb3Auth.js';
|
|
6
|
+
|
|
7
|
+
const useSolanaWallet = () => {
|
|
8
|
+
const {
|
|
9
|
+
provider,
|
|
10
|
+
web3Auth
|
|
11
|
+
} = useWeb3Auth();
|
|
12
|
+
const accounts = ref([]);
|
|
13
|
+
const solanaWallet = shallowRef(null);
|
|
14
|
+
const connection = shallowRef(null);
|
|
15
|
+
const setupWallet = async () => {
|
|
16
|
+
var _web3Auth$value;
|
|
17
|
+
solanaWallet.value = new SolanaWallet(provider.value);
|
|
18
|
+
const result = await solanaWallet.value.requestAccounts();
|
|
19
|
+
if ((result === null || result === void 0 ? void 0 : result.length) > 0) {
|
|
20
|
+
accounts.value = result;
|
|
21
|
+
}
|
|
22
|
+
connection.value = new Connection((_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.rpcTarget);
|
|
23
|
+
};
|
|
24
|
+
if (provider.value && !solanaWallet.value) {
|
|
25
|
+
setupWallet();
|
|
26
|
+
}
|
|
27
|
+
watch(provider, async newVal => {
|
|
28
|
+
var _web3Auth$value2;
|
|
29
|
+
if (!((_web3Auth$value2 = web3Auth.value) !== null && _web3Auth$value2 !== void 0 && (_web3Auth$value2 = _web3Auth$value2.currentChain) !== null && _web3Auth$value2 !== void 0 && _web3Auth$value2.chainNamespace) || web3Auth.value.currentChain.chainNamespace !== CHAIN_NAMESPACES.SOLANA) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!newVal && solanaWallet.value) {
|
|
33
|
+
solanaWallet.value = null;
|
|
34
|
+
accounts.value = null;
|
|
35
|
+
connection.value = null;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (newVal && !solanaWallet.value) {
|
|
39
|
+
setupWallet();
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
immediate: true
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
solanaWallet,
|
|
46
|
+
accounts,
|
|
47
|
+
connection
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { useSolanaWallet };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useSignAndSendTransaction } from './composables/useSignAndSendTransaction.js';
|
|
2
|
+
export { useSignMessage } from './composables/useSignMessage.js';
|
|
3
|
+
export { useSignTransaction } from './composables/useSignTransaction.js';
|
|
4
|
+
export { useSolanaWallet } from './composables/useSolanaWallet.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createConfig, http } from '@wagmi/vue';
|
|
2
|
+
import { mainnet } from '@wagmi/vue/chains';
|
|
3
|
+
|
|
4
|
+
const defaultWagmiConfig = createConfig({
|
|
5
|
+
chains: [mainnet],
|
|
6
|
+
connectors: [],
|
|
7
|
+
// or your basic wallets
|
|
8
|
+
ssr: true,
|
|
9
|
+
transports: {
|
|
10
|
+
[mainnet.id]: http(mainnet.rpcUrls.default.http[0])
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { defaultWagmiConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WagmiProvider } from './provider.js';
|