UNPKG

@thirdweb-dev/wallets

Version:

<p align="center"> <br /> <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> <br /> </p> <h1 align="center">thirdweb Wallet SDK</h1> <p align="center"> <a h

84 lines 3.38 kB
import { EVMWallet } from "../interfaces"; import type { Signer } from "ethers"; import { Bytes, BigNumber } from "ethers"; import EventEmitter from "eventemitter3"; import { Ecosystem, GenericAuthWallet } from "../../core/interfaces/auth"; import { Price, TransactionResult } from "@thirdweb-dev/sdk"; export declare function chainIdToThirdwebRpc(chainId: number, clientId?: string): string; export type WalletData = { address?: string; chainId?: number; }; export interface WalletEvents { connect(data: WalletData): void; change(data: WalletData): void; message({ type, data }: { type: string; data?: unknown; }): void; disconnect(): void; error(error: Error): void; display_uri(uri: string): void; wc_session_request_sent(): void; request(): void; } /** * The base class for any wallet in the Wallet SDK, including backend wallets. It contains the functionality common to all wallets. * * This wallet is not meant to be used directly, but instead be extended to [build your own wallet](https://portal.thirdweb.com/wallet-sdk/v2/build) * * @abstractWallet */ export declare abstract class AbstractWallet extends EventEmitter<WalletEvents> implements GenericAuthWallet, EVMWallet { /** * @internal */ type: Ecosystem; /** * Returns an [ethers Signer](https://docs.ethers.org/v5/api/signer/) object of the connected wallet */ abstract getSigner(): Promise<Signer>; /** * Returns the account address of the connected wallet */ getAddress(): Promise<string>; /** * Returns the balance of the connected wallet for the specified token address. If no token address is specified, it returns the balance of the native token * * @param tokenAddress - The contract address of the token */ getBalance(tokenAddress?: string): Promise<{ symbol: string; value: BigNumber; name: string; decimals: number; displayValue: string; }>; /** * Returns the chain id of the network that the wallet is connected to */ getChainId(): Promise<number>; /** * Transfers some amount of tokens to the specified address * @param to - The address to transfer the amount to * @param amount - The amount to transfer * @param currencyAddress - The contract address of the token to transfer. If not specified, it defaults to the native token * @returns The transaction result */ transfer(to: string, amount: Price, currencyAddress?: string): Promise<TransactionResult>; /** * Sign a message with the connected wallet and return the signature * @param message - The message to sign * @returns - The signature */ signMessage(message: Bytes | string): Promise<string>; /** * Verify the signature of a message. It returns `true` if the signature is valid, `false` otherwise * @param message - The message to verify * @param signature - The signature to verify * @param address - The address to verify the signature against * @param chainId - The chain id of the network to verify the signature against, If not specified, it defaults to 1 ( Ethereum mainnet ) */ verifySignature(message: string, signature: string, address: string, _chainId?: number): Promise<boolean>; } //# sourceMappingURL=abstract.d.ts.map