-
Notifications
You must be signed in to change notification settings - Fork 542
/
types.d.ts
52 lines (41 loc) · 1.16 KB
/
types.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
48
49
50
51
52
import { Json } from '@metamask/controllers';
import { MetaMaskInpageProvider } from '@metamask/providers';
import { JsonRpcRequest } from '@metamask/types';
/**
* Command request sent to a worker.
*/
export type WorkerCommandRequest = {
id: string;
command: string;
data?: string | Record<string, unknown>;
};
export type SnapData = {
snapId: string;
sourceCode: string;
};
export type SnapExecutionData = SnapData & {
endowments?: Json;
};
export type SnapRpcHandler = (args: {
origin: string;
request: JsonRpcRequest<unknown[] | { [key: string]: unknown }>;
}) => Promise<unknown>;
export type OnRpcRequestHandler = SnapRpcHandler;
// @todo improve type
export type GetTransactionInsightHandler = (args: {
origin: string;
transaction: { [key: string]: unknown };
}) => Promise<string>;
export type OnCronjobHandler = SnapRpcHandler;
export type SnapProvider = MetaMaskInpageProvider;
export type SnapId = string;
export type ErrorJSON = {
message: string;
code: number;
data?: Json;
};
export type SnapExports = {
onRpcRequest?: OnRpcRequestHandler;
getTransactionInsight?: GetTransactionInsightHandler;
onCronjob?: OnCronjobHandler;
};