@dioxide-js/detect-provider
Version:
A tiny utility for detecting the Dioxide-wallet provider which injected at window.dioxide.
28 lines (27 loc) • 1.34 kB
TypeScript
export interface KeyValue<T = any> {
[key: string]: T;
}
export declare type AllowedMethod = 'connected_address' | 'request_connect_address' | 'connection' | 'network' | 'is_locked' | 'balance' | 'send_transaction' | 'selected_address' | 'profile' | 'compose_nft' | 'decompose_nft' | 'gasfee';
export declare type AllowedEvent = 'connected_address_changed' | 'suspend' | 'connect' | 'disconnect' | 'network_changed' | 'lock_status_changed' | 'selected_address_changed' | 'operation_timeout';
export interface ProviderRpcError extends Error {
message: string;
code: number;
data?: unknown;
}
export interface TxRequest<T = KeyValue<any>> {
func: string;
args: T;
delegatee?: string;
}
export interface Provider {
once(eventName: AllowedEvent, listener: (...args: any[]) => void): this;
on(eventName: AllowedEvent, listener: (...args: any[]) => void): this;
off(eventName: AllowedEvent, listener: (...args: any[]) => void): this;
addListener(eventName: AllowedEvent, listener: (...args: any[]) => void): this;
removeListener(eventName: AllowedEvent, listener: (...args: any[]) => void): this;
removeAllListeners(event?: AllowedEvent): this;
request<T = TxRequest, K = any>(params: {
method: AllowedMethod;
params?: T;
}): Promise<K>;
}