import * as v from "valibot"; import { Params, Requests } from "./requests.advanced.js"; import { RpcResponse } from "./types.advanced.js"; // accountChange export const accountChangeEventName = "accountChange"; export const accountChangeSchema = v.object({ type: v.literal(accountChangeEventName), }); export type AccountChangeEvent = v.InferOutput; // networkChange export const networkChangeEventName = "networkChange"; export const networkChangeSchema = v.object({ type: v.literal(networkChangeEventName), }); export type NetworkChangeEvent = v.InferOutput; // disconnect export const disconnectEventName = "disconnect"; export const disconnectSchema = v.object({ type: v.literal(disconnectEventName), }); export type DisconnectEvent = v.InferOutput; export const walletEventSchema = v.variant("type", [ accountChangeSchema, networkChangeSchema, disconnectSchema, ]); export type WalletEvent = v.InferOutput; export type AddListener = ( eventName: WalletEventName, cb: (event: Extract) => void, ) => () => void; /** * Interface representing a provider for interacting with accounts and signing messages. */ export interface BtcProvider { request: ( method: Method, options: Params, providerId?: string, ) => Promise>; addListener: AddListener; } export interface Provider { id: string; name: string; icon: string; webUrl?: string; chromeWebStoreUrl?: string; mozillaAddOnsUrl?: string; googlePlayStoreUrl?: string; iOSAppStoreUrl?: string; methods?: string[]; }