Created
August 16, 2020 19:21
-
-
Save rekmarks/1d249cb9d805f8b8ad89467ae961517b to your computer and use it in GitHub Desktop.
@metamask/inpage-provider draft types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type SerializableValue = string | number | null | undefined; | |
export type EthereumParameterValue = SerializableValue | Record<string, SerializableValue>; | |
export interface RequestArguments { | |
method: string; | |
params?: EthereumParameterValue[]; | |
} | |
export interface ProviderConnectInfo { | |
chainId: string; | |
} | |
export interface ProviderRpcError extends Error { | |
message: string; | |
code: number; | |
data?: any; | |
} | |
export interface ProviderMessage { | |
type: string; | |
data: any; | |
} | |
export interface EIP1193 { | |
request(args: RequestArguments): Promise<EthereumParameterValue | EthereumParameterValue[]>; | |
on<RT>(eventType: 'message', listener: (message: ProviderMessage) => void): RT; | |
on<RT>(eventType: 'accountsChanged', listener: (accounts: string[]) => void): RT; | |
on<RT>(eventType: 'chainChanged', listener: (chainId: string) => void): RT; | |
on<RT>(eventType: 'disconnect', listener: (error: ProviderRpcError) => void): RT; | |
on<RT>(eventType: 'connect', listener: (connectInfo: ProviderConnectInfo) => void): RT; | |
on<RT>(eventType: string, listener: () => void): RT; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment