-
Notifications
You must be signed in to change notification settings - Fork 10
/
additional.d.ts
49 lines (40 loc) · 1.45 KB
/
additional.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { ProviderMessage, ProviderRpcError, ProviderConnectInfo, RequestArguments } from 'hardhat/types';
export type ExternalProvider = {
isMetaMask?: boolean;
isStatus?: boolean;
host?: string;
path?: string;
sendAsync?: (request: { method: string, params?: Array<any> }, callback: (error: any, response: any) => void) => void
send?: (request: { method: string, params?: Array<any> }, callback: (error: any, response: any) => void) => void
request?: (request: { method: string, params?: Array<any> }) => Promise<any>
}
export interface EthereumEvent {
connect: ProviderConnectInfo;
disconnect: ProviderRpcError;
accountsChanged: Array<string>;
chainChanged: string;
message: ProviderMessage
}
type EventKeys = keyof EthereumEvent;
type EventHandler<K extends EventKeys> = (event: EthereumEvent[K]) => void;
export interface Ethereumish {
autoRefreshOnNetworkChange: boolean;
chainId: string;
isMetaMask?: boolean;
isStatus?: boolean;
networkVersion: string;
selectedAddress: any;
on<K extends EventKeys>(event: K, eventHandler: EventHandler<K>): void;
enable(): Promise<any>;
request: (request: { method: string, params?: Array<any> }) => Promise<any>
/**
* @deprecated
*/
send?: (request: { method: string, params?: Array<any> }, callback: (error: any, response: any) => void) => void
sendAsync: (request: RequestArguments) => Promise<unknown>
}
declare global {
interface Window {
ethereum: Ethereumish;
}
}