UNPKG

@funkit/connect

Version:

Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.

111 lines (110 loc) 3.59 kB
import type { AssetBalanceInfo } from '@funkit/api-base'; import { Auth, FunWallet } from '@funkit/core'; import React, { type ReactNode } from 'react'; import type { Address } from 'viem'; import { type Config, type UseDisconnectReturnType, type UseReconnectReturnType } from 'wagmi'; import type { SwitchChainVariables } from 'wagmi/query'; import { type FunkitUserInfo } from '../consts/funkit'; /** AssetBalanceInfo with known price and totalUsdValue */ export interface KnownAssetBalanceInfo extends AssetBalanceInfo { price: number; totalUsdValue: number; } export declare enum LoginType { Web2 = "web2", Web3 = "web3", Guest = "guest" } export interface GeneralWalletContextProps { walletAddress: Address | ''; isUserLoggedIn: boolean; loginType: LoginType; userInfo: FunkitUserInfo; funWallet: FunWallet | null; funWalletAuth: Auth | null; handleLogout: () => void; logoutSymbol: symbol | undefined; } export declare function GeneralWalletProvider({ children }: { children: ReactNode; }): React.JSX.Element; export declare const useGeneralWallet: () => GeneralWalletContextProps; /** * Replacement for wagmi's `useAccount` */ export declare const useFunkitAccount: () => { account: "" | `0x${string}`; isConnected: boolean; loginType: LoginType; address: undefined; addresses: undefined; chain: undefined; chainId: undefined; connector: undefined; isReconnecting: false; isConnecting: false; isDisconnected: true; status: "disconnected"; } | { account: "" | `0x${string}`; isConnected: boolean; loginType: LoginType; address: Address; addresses: readonly [Address, ...Address[]]; chain: import("viem").Chain | undefined; chainId: number; connector: import("wagmi").Connector; isConnecting: false; isDisconnected: false; isReconnecting: false; status: "connected"; } | { account: "" | `0x${string}`; isConnected: boolean; loginType: LoginType; address: Address | undefined; addresses: readonly Address[] | undefined; chain: import("viem").Chain | undefined; chainId: number | undefined; connector: import("wagmi").Connector | undefined; isConnecting: false; isDisconnected: false; isReconnecting: true; status: "reconnecting"; } | { account: "" | `0x${string}`; isConnected: boolean; loginType: LoginType; address: Address | undefined; addresses: readonly Address[] | undefined; chain: import("viem").Chain | undefined; chainId: number | undefined; connector: import("wagmi").Connector | undefined; isReconnecting: false; isConnecting: true; isDisconnected: false; status: "connecting"; }; export declare const useFunkitUserInfo: () => FunkitUserInfo; export type FunkitDisconnectReturnType = UseDisconnectReturnType & { disconnect: () => Promise<void> | void; disconnectAsync: () => Promise<void> | void; }; /** * Replacement for wagmi's `disconnect` from `useDisconnect` */ export declare const useFunkitDisconnect: () => FunkitDisconnectReturnType; /** * Replacement for wagmi's `useReconnect` */ export declare const useFunkitReconnect: () => UseReconnectReturnType; /** * Replacement for wagmi's useSwitchChains */ export declare const useFunkitSwitchChains: ({ onSettled, }: { onSettled?: () => void; }) => { switchChain: (params: SwitchChainVariables<Config, number>) => void; switchChainAsync: (params: SwitchChainVariables<Config, number>) => Promise<void>; pendingChainId: number | null; };