import { ccc } from "@ckb-ccc/core"; /** * Interface representing a provider for interacting with accounts and signing messages. */ export interface Provider { /** * Signs a PSBT using UniSat wallet. * * @param psbtHex - The hex string of PSBT to sign * @param options - Options for signing the PSBT * @returns A promise that resolves to the signed PSBT hex string */ signPsbt(psbtHex: string, options?: ccc.SignPsbtOptionsLike): Promise; /** * Broadcasts a signed PSBT to the Bitcoin network. * * @param psbtHex - The hex string of the signed PSBT to broadcast. * @returns A promise that resolves to the transaction ID. */ pushPsbt(psbtHex: string): Promise; /** * Requests user accounts. * @returns A promise that resolves to an array of account addresses. */ requestAccounts(): Promise; /** * Gets the current network. * @returns current network. */ getNetwork(): Promise<"livenet" | "testnet">; /** * Switch the current network. */ switchNetwork(chain: "livenet" | "testnet"): Promise; /** * Gets the current chain. * @returns current chain. */ getChain?(): Promise<{ enum: string; name: string; network: string }>; /** * Switch the current chain. */ switchChain?( chain: string, ): Promise<{ enum: string; name: string; network: string }>; /** * Gets the current accounts. * @returns A promise that resolves to an array of account addresses. */ getAccounts(): Promise; /** * Gets the public key of the account. * @returns A promise that resolves to the public key. */ getPublicKey(): Promise; /** * Signs a message with the specified type. * @param msg - The message to sign. * @param type - The type of signature. * @returns A promise that resolves to the signed message. */ signMessage(msg: string, type: "ecdsa" | "bip322-simple"): Promise; /** * Adds an event listener to the provider. */ on: OnMethod; /** * Removes an event listener from the provider. * @param eventName - The name of the event to remove the listener from. * @param listener - The listener function to remove. * @returns The provider instance. */ removeListener( eventName: string, listener: (...args: unknown[]) => unknown, ): Provider; } /** * Interface representing a method to add event listeners to the provider. */ export interface OnMethod { /** * Adds an event listener to the provider. * @param eventName - The name of the event. * @param listener - The listener function. * @returns The provider instance. */ (eventName: string, listener: (...args: unknown[]) => unknown): Provider; }