UNPKG

@archway-kit/vue

Version:

Vue components to interact with the Archway network

67 lines (66 loc) 3.31 kB
import { ConnectorId, UserWallet, Wallet } from '@archway-kit/wallet'; import { SigningArchwayClient } from '@archwayhq/arch3.js'; import { ChainInfo } from '@keplr-wallet/types'; import { PromisifyFn } from '@vueuse/core'; type LifecycleHook = () => void; type ConnectedHook = (client: SigningArchwayClient, wallet: UserWallet, chainInfo: ChainInfo) => void; type DisconnectedHook = () => void; type ErrorHook<E extends unknown = unknown> = (e: E) => void; type Callbacks = { beforeConnection?: LifecycleHook; onConnected?: ConnectedHook; onConnectionError?: ErrorHook; beforeConnectionByWallet?: LifecycleHook; onConnectedByWallet?: ConnectedHook; onConnectionByWalletError?: ErrorHook; beforeConnectionFromCache?: LifecycleHook; onConnectedFromCache?: ConnectedHook; onConnectionFromCacheError?: ErrorHook; beforeAccountChange?: LifecycleHook; onAccountChanged?: ConnectedHook; onAccountChangeError?: ErrorHook; beforeDisconnect?: LifecycleHook; onDisconnected?: DisconnectedHook; onDisconnectError?: ErrorHook; onError?: ErrorHook; }; type Interceptors = { preConnect?: PromisifyFn<LifecycleHook>; postConnect?: PromisifyFn<ConnectedHook>; preConnectByWallet?: PromisifyFn<LifecycleHook>; postConnectByWallet?: PromisifyFn<ConnectedHook>; preConnectFromCache?: PromisifyFn<LifecycleHook>; postConnectFromCache?: PromisifyFn<ConnectedHook>; preAccountChange?: PromisifyFn<LifecycleHook>; postAccountChange?: PromisifyFn<ConnectedHook>; preDisconnect?: PromisifyFn<LifecycleHook>; postDisconnect?: PromisifyFn<DisconnectedHook>; }; type Hooks = Callbacks & Interceptors; export declare const useWallet: (options?: Hooks) => { address: import('vue').ComputedRef<string | undefined>; name: import('vue').ComputedRef<string | undefined>; chainInfo: import('vue').Ref<ChainInfo | undefined, ChainInfo | undefined>; signingClient: import('vue').Ref<SigningArchwayClient | undefined, SigningArchwayClient | undefined>; isAuthenticated: import('vue').ComputedRef<boolean>; connectedWallet: import('vue').Ref<UserWallet | undefined, UserWallet | undefined>; isLoading: import('vue').ComputedRef<boolean>; isConnecting: import('vue').Ref<boolean, boolean>; isConnectingFromCache: import('vue').Ref<boolean, boolean>; isChangingAccount: import('vue').Ref<boolean, boolean>; isDisconnecting: import('vue').Ref<boolean, boolean>; isConnectModalOpen: import('vue').Ref<boolean, boolean>; connectFromCache: (newChainInfo: ChainInfo, options?: import('@archwayhq/arch3-core').SigningArchwayClientOptions | undefined) => Promise<void>; connect: (id: ConnectorId, newChainInfo: ChainInfo, options?: import('@archwayhq/arch3-core').SigningArchwayClientOptions | undefined) => Promise<void>; disconnect: () => Promise<void>; openConnectModal: () => void; closeConnectModal: () => void; toggleConnectModal: () => void; subscribe: <K extends keyof Hooks>(key: K, handler: NonNullable<Hooks[K]>) => { unsubscribe: () => void; }; wallets: import('vue').ComputedRef<Wallet[] | undefined>; findWallet: (id: ConnectorId) => Wallet | undefined; connectUri: import('vue').Ref<string | undefined, string | undefined>; }; export {};