UNPKG

based-auth

Version:

A Next.js/Node.js authentication and wallet API kit for Ethereum and Solana, with utilities for serialization and contract interaction, designed for serverless and API route usage.

85 lines (84 loc) 3.87 kB
import { JsonRpcProvider, FallbackProvider } from 'ethers'; import { PublicKey as SolanaPublicKey, Transaction as SolanaTransaction, VersionedTransaction, Connection } from '@solana/web3.js'; import { WalletName } from '@solana/wallet-adapter-base'; import { IChain } from '../chains'; import { UseMutationResult, UseQueryResult } from '@tanstack/react-query'; import { Wallet } from '@solana/wallet-adapter-react'; export declare function useAccount(): { chainId: number; network: string; address: string; social: string; name: string; image: string; role: string; provider: string; users: any[]; chain: IChain; switchChain: (chainId: number) => Promise<void>; switchAccount: (network: string, address: string) => Promise<void>; }; export declare function useChainInfo(): { chainLogo: any; networkLogo: any; nativeSymbol: any; nativeDecimals: any; txExplorer: any; addressExplorer: any; }; export declare function useSocialProviders(): UseQueryResult<any, unknown>; export declare function useEthWallets(): UseQueryResult<any, unknown>; export declare function useSolanaWallet(): { wallet: Wallet; publicKey: SolanaPublicKey | null; solConnect: () => Promise<void>; solDisconnect: () => Promise<void>; solSelect: (walletName: WalletName | null) => void; solSignMessage: ((message: Uint8Array) => Promise<Uint8Array>) | undefined; solSignTransaction: (<T extends SolanaTransaction | VersionedTransaction>(transaction: T) => Promise<T>) | undefined; solSignAllTransactions: (<T_1 extends SolanaTransaction | VersionedTransaction>(transactions: T_1[]) => Promise<T_1[]>) | undefined; solWallets: import('@solana/wallet-adapter-base').Adapter[]; }; export declare function getProvider(chainId: number, chains: IChain[], wagmiConfig?: any, isSignedIn?: boolean): JsonRpcProvider | FallbackProvider | Connection | undefined; export declare function useBalance({ address: queryAddress, chainId: queryChainId, }?: { address?: string; chainId?: number; }): UseQueryResult<bigint, unknown>; export declare function useTokenBalance({ address: queryAddress, tokenAddress, chainId: queryChainId, }: { address?: string; tokenAddress: string; chainId?: number; }): UseQueryResult<bigint, unknown>; export declare function useConnectAccount(): UseMutationResult<void, any, void, unknown>; export declare function useSwitchChain(): UseMutationResult<void, unknown, number>; export declare function useSignAccount(): UseMutationResult<void, unknown, void>; export declare function useSwitchAccount(): UseMutationResult<void, unknown, { network: string; address: string; }>; export declare function useDisconnectAccount(): UseMutationResult<void, unknown, void>; export declare function useBalanceAsync({ address: queryAddress, chainId: queryChainId, }?: { address?: string; chainId?: number; }): UseMutationResult<bigint, unknown, void>; export declare function useTokenBalanceAsync({ address: queryAddress, chainId: queryChainId, }?: { address?: string; chainId?: number; }): UseMutationResult<bigint, unknown, string>; export declare function useTransferAsync(): UseMutationResult<any, unknown, { address: string; value: bigint; }>; export declare function useSignMessageAsync({ chainId: queryChainId, }?: { chainId?: number; }): UseMutationResult<any, unknown, string>; export declare function useSignTypedDataAsync({ chainId: queryChainId, }?: { chainId?: number; }): UseMutationResult<any, unknown, any>; export declare function useReadContractAsync({ chainId: queryChainId, }?: { chainId?: number; }): UseMutationResult<any, unknown, any>; export declare function useWriteContractAsync({ key, chainId: queryChainId, }?: { key?: string; chainId?: number; }): UseMutationResult<any, unknown, any>;