@metamask/snaps-jest 4.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/README.md +66 -179
- package/dist/cjs/environment.js +21 -82
- package/dist/cjs/environment.js.map +1 -1
- package/dist/cjs/helpers.js +118 -43
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/internals/environment.js +1 -1
- package/dist/cjs/internals/environment.js.map +1 -1
- package/dist/cjs/internals/index.js +1 -4
- package/dist/cjs/internals/index.js.map +1 -1
- package/dist/cjs/internals/request.js +42 -94
- package/dist/cjs/internals/request.js.map +1 -1
- package/dist/cjs/internals/server.js +0 -4
- package/dist/cjs/internals/server.js.map +1 -1
- package/dist/cjs/internals/simulation/constants.js +29 -0
- package/dist/cjs/internals/simulation/constants.js.map +1 -0
- package/dist/cjs/internals/simulation/controllers.js +95 -0
- package/dist/cjs/internals/simulation/controllers.js.map +1 -0
- package/dist/cjs/internals/simulation/files.js +22 -0
- package/dist/cjs/internals/simulation/files.js.map +1 -0
- package/dist/cjs/internals/simulation/index.js +24 -0
- package/dist/cjs/internals/simulation/index.js.map +1 -0
- package/dist/cjs/internals/simulation/interface.js +98 -0
- package/dist/cjs/internals/simulation/interface.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/constants.js +84 -0
- package/dist/cjs/internals/simulation/methods/constants.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/hooks/encryption.js +33 -0
- package/dist/cjs/internals/simulation/methods/hooks/encryption.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/hooks/get-locale.js +17 -0
- package/dist/cjs/internals/simulation/methods/hooks/get-locale.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/hooks/index.js +25 -0
- package/dist/cjs/internals/simulation/methods/hooks/index.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/hooks/interface.js +26 -0
- package/dist/cjs/internals/simulation/methods/hooks/interface.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/hooks/notifications.js +66 -0
- package/dist/cjs/internals/simulation/methods/hooks/notifications.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/hooks/show-dialog.js +43 -0
- package/dist/cjs/internals/simulation/methods/hooks/show-dialog.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/hooks/state.js +80 -0
- package/dist/cjs/internals/simulation/methods/hooks/state.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/index.js +20 -0
- package/dist/cjs/internals/simulation/methods/index.js.map +1 -0
- package/dist/cjs/internals/simulation/methods/specifications.js +81 -0
- package/dist/cjs/internals/simulation/methods/specifications.js.map +1 -0
- package/dist/cjs/internals/simulation/middleware/engine.js +31 -0
- package/dist/cjs/internals/simulation/middleware/engine.js.map +1 -0
- package/dist/cjs/internals/simulation/middleware/index.js +20 -0
- package/dist/cjs/internals/simulation/middleware/index.js.map +1 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/accounts.js +30 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/accounts.js.map +1 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/index.js +20 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/index.js.map +1 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/middleware.js +37 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/middleware.js.map +1 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/provider-state.js +23 -0
- package/dist/cjs/internals/simulation/middleware/internal-methods/provider-state.js.map +1 -0
- package/dist/cjs/internals/simulation/middleware/mock.js +23 -0
- package/dist/cjs/internals/simulation/middleware/mock.js.map +1 -0
- package/dist/cjs/internals/simulation/options.js +24 -0
- package/dist/cjs/internals/simulation/options.js.map +1 -0
- package/dist/cjs/internals/simulation/simulation.js +124 -0
- package/dist/cjs/internals/simulation/simulation.js.map +1 -0
- package/dist/cjs/internals/simulation/store/index.js +23 -0
- package/dist/cjs/internals/simulation/store/index.js.map +1 -0
- package/dist/cjs/internals/simulation/store/mocks.js +52 -0
- package/dist/cjs/internals/simulation/store/mocks.js.map +1 -0
- package/dist/cjs/internals/simulation/store/notifications.js +52 -0
- package/dist/cjs/internals/simulation/store/notifications.js.map +1 -0
- package/dist/cjs/internals/simulation/store/state.js +64 -0
- package/dist/cjs/internals/simulation/store/state.js.map +1 -0
- package/dist/cjs/internals/simulation/store/store.js +57 -0
- package/dist/cjs/internals/simulation/store/store.js.map +1 -0
- package/dist/cjs/internals/simulation/store/ui.js +48 -0
- package/dist/cjs/internals/simulation/store/ui.js.map +1 -0
- package/dist/cjs/internals/structs.js +43 -0
- package/dist/cjs/internals/structs.js.map +1 -1
- package/dist/cjs/matchers.js +5 -2
- package/dist/cjs/matchers.js.map +1 -1
- package/dist/cjs/options.js +0 -6
- package/dist/cjs/options.js.map +1 -1
- package/dist/esm/environment.js +22 -83
- package/dist/esm/environment.js.map +1 -1
- package/dist/esm/helpers.js +127 -46
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/internals/environment.js +1 -1
- package/dist/esm/internals/environment.js.map +1 -1
- package/dist/esm/internals/index.js +1 -5
- package/dist/esm/internals/index.js.map +1 -1
- package/dist/esm/internals/request.js +61 -104
- package/dist/esm/internals/request.js.map +1 -1
- package/dist/esm/internals/server.js +1 -5
- package/dist/esm/internals/server.js.map +1 -1
- package/dist/esm/internals/simulation/constants.js +12 -0
- package/dist/esm/internals/simulation/constants.js.map +1 -0
- package/dist/esm/internals/simulation/controllers.js +90 -0
- package/dist/esm/internals/simulation/controllers.js.map +1 -0
- package/dist/esm/internals/simulation/files.js +19 -0
- package/dist/esm/internals/simulation/files.js.map +1 -0
- package/dist/esm/internals/simulation/index.js +7 -0
- package/dist/esm/internals/simulation/index.js.map +1 -0
- package/dist/esm/internals/simulation/interface.js +95 -0
- package/dist/esm/internals/simulation/interface.js.map +1 -0
- package/dist/esm/internals/simulation/methods/constants.js +69 -0
- package/dist/esm/internals/simulation/methods/constants.js.map +1 -0
- package/dist/esm/internals/simulation/methods/hooks/encryption.js +39 -0
- package/dist/esm/internals/simulation/methods/hooks/encryption.js.map +1 -0
- package/dist/esm/internals/simulation/methods/hooks/get-locale.js +13 -0
- package/dist/esm/internals/simulation/methods/hooks/get-locale.js.map +1 -0
- package/dist/esm/internals/simulation/methods/hooks/index.js +8 -0
- package/dist/esm/internals/simulation/methods/hooks/index.js.map +1 -0
- package/dist/esm/internals/simulation/methods/hooks/interface.js +18 -0
- package/dist/esm/internals/simulation/methods/hooks/interface.js.map +1 -0
- package/dist/esm/internals/simulation/methods/hooks/notifications.js +58 -0
- package/dist/esm/internals/simulation/methods/hooks/notifications.js.map +1 -0
- package/dist/esm/internals/simulation/methods/hooks/show-dialog.js +38 -0
- package/dist/esm/internals/simulation/methods/hooks/show-dialog.js.map +1 -0
- package/dist/esm/internals/simulation/methods/hooks/state.js +74 -0
- package/dist/esm/internals/simulation/methods/hooks/state.js.map +1 -0
- package/dist/esm/internals/simulation/methods/index.js +3 -0
- package/dist/esm/internals/simulation/methods/index.js.map +1 -0
- package/dist/esm/internals/simulation/methods/specifications.js +84 -0
- package/dist/esm/internals/simulation/methods/specifications.js.map +1 -0
- package/dist/esm/internals/simulation/middleware/engine.js +33 -0
- package/dist/esm/internals/simulation/middleware/engine.js.map +1 -0
- package/dist/esm/internals/simulation/middleware/index.js +3 -0
- package/dist/esm/internals/simulation/middleware/index.js.map +1 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/accounts.js +31 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/accounts.js.map +1 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/index.js +3 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/index.js.map +1 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/middleware.js +37 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/middleware.js.map +1 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/provider-state.js +23 -0
- package/dist/esm/internals/simulation/middleware/internal-methods/provider-state.js.map +1 -0
- package/dist/esm/internals/simulation/middleware/mock.js +18 -0
- package/dist/esm/internals/simulation/middleware/mock.js.map +1 -0
- package/dist/esm/internals/simulation/options.js +20 -0
- package/dist/esm/internals/simulation/options.js.map +1 -0
- package/dist/esm/internals/simulation/simulation.js +128 -0
- package/dist/esm/internals/simulation/simulation.js.map +1 -0
- package/dist/esm/internals/simulation/store/index.js +6 -0
- package/dist/esm/internals/simulation/store/index.js.map +1 -0
- package/dist/esm/internals/simulation/store/mocks.js +32 -0
- package/dist/esm/internals/simulation/store/mocks.js.map +1 -0
- package/dist/esm/internals/simulation/store/notifications.js +30 -0
- package/dist/esm/internals/simulation/store/notifications.js.map +1 -0
- package/dist/esm/internals/simulation/store/state.js +47 -0
- package/dist/esm/internals/simulation/store/state.js.map +1 -0
- package/dist/esm/internals/simulation/store/store.js +50 -0
- package/dist/esm/internals/simulation/store/store.js.map +1 -0
- package/dist/esm/internals/simulation/store/ui.js +21 -0
- package/dist/esm/internals/simulation/store/ui.js.map +1 -0
- package/dist/esm/internals/structs.js +38 -1
- package/dist/esm/internals/structs.js.map +1 -1
- package/dist/esm/matchers.js +5 -2
- package/dist/esm/matchers.js.map +1 -1
- package/dist/esm/options.js +1 -7
- package/dist/esm/options.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/types/environment.d.ts +14 -15
- package/dist/types/helpers.d.ts +64 -3
- package/dist/types/internals/index.d.ts +1 -4
- package/dist/types/internals/request.d.ts +38 -74
- package/dist/types/internals/simulation/constants.d.ts +13 -0
- package/dist/types/internals/simulation/controllers.d.ts +40 -0
- package/dist/types/internals/simulation/files.d.ts +11 -0
- package/dist/types/internals/simulation/index.d.ts +5 -0
- package/dist/types/internals/simulation/interface.d.ts +25 -0
- package/dist/types/internals/simulation/methods/constants.d.ts +10 -0
- package/dist/types/internals/simulation/methods/hooks/encryption.d.ts +29 -0
- package/dist/types/internals/simulation/methods/hooks/get-locale.d.ts +9 -0
- package/dist/types/internals/simulation/methods/hooks/index.d.ts +6 -0
- package/dist/types/internals/simulation/methods/hooks/interface.d.ts +16 -0
- package/dist/types/internals/simulation/methods/hooks/notifications.d.ts +16 -0
- package/dist/types/internals/simulation/methods/hooks/show-dialog.d.ts +9 -0
- package/dist/types/internals/simulation/methods/hooks/state.d.ts +22 -0
- package/dist/types/internals/simulation/methods/index.d.ts +1 -0
- package/dist/types/internals/simulation/methods/specifications.d.ts +56 -0
- package/dist/types/internals/simulation/middleware/engine.d.ts +26 -0
- package/dist/types/internals/simulation/middleware/index.d.ts +1 -0
- package/dist/types/internals/simulation/middleware/internal-methods/accounts.d.ts +18 -0
- package/dist/types/internals/simulation/middleware/internal-methods/index.d.ts +1 -0
- package/dist/types/internals/simulation/middleware/internal-methods/middleware.d.ts +22 -0
- package/dist/types/internals/simulation/middleware/internal-methods/provider-state.d.ts +14 -0
- package/dist/types/internals/simulation/middleware/mock.d.ts +10 -0
- package/dist/types/internals/simulation/options.d.ts +37 -0
- package/dist/types/internals/simulation/simulation.d.ts +98 -0
- package/dist/types/internals/simulation/store/index.d.ts +4 -0
- package/dist/types/internals/simulation/store/mocks.d.ts +35 -0
- package/dist/types/internals/simulation/store/notifications.d.ts +44 -0
- package/dist/types/internals/simulation/store/state.d.ts +55 -0
- package/dist/types/internals/simulation/store/store.d.ts +22 -0
- package/dist/types/internals/simulation/store/ui.d.ts +25 -0
- package/dist/types/internals/structs.d.ts +153 -0
- package/dist/types/options.d.ts +3 -35
- package/dist/types/types.d.ts +88 -41
- package/package.json +21 -12
- package/dist/cjs/internals/interface.js +0 -103
- package/dist/cjs/internals/interface.js.map +0 -1
- package/dist/cjs/internals/network.js +0 -148
- package/dist/cjs/internals/network.js.map +0 -1
- package/dist/cjs/internals/types.js +0 -6
- package/dist/cjs/internals/types.js.map +0 -1
- package/dist/cjs/internals/wait-for.js +0 -63
- package/dist/cjs/internals/wait-for.js.map +0 -1
- package/dist/esm/internals/interface.js +0 -100
- package/dist/esm/internals/interface.js.map +0 -1
- package/dist/esm/internals/network.js +0 -143
- package/dist/esm/internals/network.js.map +0 -1
- package/dist/esm/internals/types.js +0 -3
- package/dist/esm/internals/types.js.map +0 -1
- package/dist/esm/internals/wait-for.js +0 -63
- package/dist/esm/internals/wait-for.js.map +0 -1
- package/dist/types/internals/interface.d.ts +0 -25
- package/dist/types/internals/network.d.ts +0 -87
- package/dist/types/internals/types.d.ts +0 -18
- package/dist/types/internals/wait-for.d.ts +0 -38
|
@@ -1,120 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { getInterface, getNotifications } from './interface';
|
|
6
|
-
import { rootLogger } from './logger';
|
|
7
|
-
import { TransactionOptionsStruct } from './structs';
|
|
8
|
-
import { waitForResponse } from './wait-for';
|
|
9
|
-
const log = createModuleLogger(rootLogger, 'request');
|
|
1
|
+
import { unwrapError } from '@metamask/snaps-utils';
|
|
2
|
+
import { getSafeJson, hasProperty, isPlainObject } from '@metamask/utils';
|
|
3
|
+
import { nanoid } from '@reduxjs/toolkit';
|
|
4
|
+
import { clearNotifications, getInterface, getNotifications } from './simulation';
|
|
10
5
|
/**
|
|
11
|
-
* Send a request to the
|
|
6
|
+
* Send a JSON-RPC request to the Snap, and wrap the response in a
|
|
7
|
+
* {@link SnapResponse} object.
|
|
12
8
|
*
|
|
13
|
-
* @param page - The page to send the request from.
|
|
14
|
-
* @param args - The request arguments.
|
|
15
|
-
* @returns The request ID.
|
|
16
|
-
*/ async function sendRequest(page, args) {
|
|
17
|
-
const document = await getDocument(page);
|
|
18
|
-
const button = await queries.getByTestId(document, `navigation-${args.handler}`);
|
|
19
|
-
// Navigate to the request handler page.
|
|
20
|
-
await button.click();
|
|
21
|
-
return await page.evaluate((payload)=>{
|
|
22
|
-
window.__SIMULATOR_API__.dispatch({
|
|
23
|
-
type: 'simulation/sendRequest',
|
|
24
|
-
payload
|
|
25
|
-
});
|
|
26
|
-
return window.__SIMULATOR_API__.getRequestId();
|
|
27
|
-
}, args);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Send a request to the snap.
|
|
31
|
-
*
|
|
32
|
-
* @param page - The page to send the request from.
|
|
33
9
|
* @param options - The request options.
|
|
34
|
-
* @param options.
|
|
35
|
-
* @param
|
|
36
|
-
* @
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
log('Received response %o', response);
|
|
53
|
-
const notifications = await getNotifications(page, id);
|
|
54
|
-
return {
|
|
55
|
-
id,
|
|
56
|
-
response,
|
|
57
|
-
notifications
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
// This is a bit hacky, but it allows us to add the `getInterface` method
|
|
61
|
-
// to the response promise.
|
|
62
|
-
const response = doRequest();
|
|
63
|
-
response.getInterface = async (getInterfaceOptions)=>{
|
|
64
|
-
return await getInterface(page, getInterfaceOptions);
|
|
65
|
-
};
|
|
66
|
-
return response;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Send a transaction to the snap.
|
|
70
|
-
*
|
|
71
|
-
* @param page - The page to send the transaction from.
|
|
72
|
-
* @param options - The transaction options.
|
|
73
|
-
* @returns The response.
|
|
74
|
-
*/ export async function sendTransaction(page, options) {
|
|
75
|
-
const { origin: transactionOrigin, chainId, ...transaction } = create(options, TransactionOptionsStruct);
|
|
76
|
-
const args = {
|
|
77
|
-
origin: '',
|
|
78
|
-
handler: HandlerType.OnTransaction,
|
|
10
|
+
* @param options.snapId - The ID of the Snap to send the request to.
|
|
11
|
+
* @param options.store - The Redux store.
|
|
12
|
+
* @param options.executionService - The execution service to use to send the
|
|
13
|
+
* request.
|
|
14
|
+
* @param options.handler - The handler to use to send the request.
|
|
15
|
+
* @param options.controllerMessenger - The controller messenger used to call actions.
|
|
16
|
+
* @param options.runSaga - A function to run a saga outside the usual Redux
|
|
17
|
+
* flow.
|
|
18
|
+
* @param options.request - The request to send.
|
|
19
|
+
* @param options.request.id - The ID of the request. If not provided, a random
|
|
20
|
+
* ID will be generated.
|
|
21
|
+
* @param options.request.origin - The origin of the request. Defaults to
|
|
22
|
+
* `https://metamask.io`.
|
|
23
|
+
* @returns The response, wrapped in a {@link SnapResponse} object.
|
|
24
|
+
*/ export function handleRequest({ snapId, store, executionService, handler, controllerMessenger, runSaga, request: { id = nanoid(), origin = 'https://metamask.io', ...options } }) {
|
|
25
|
+
const promise = executionService.handleRpcRequest(snapId, {
|
|
26
|
+
origin,
|
|
27
|
+
handler,
|
|
79
28
|
request: {
|
|
80
29
|
jsonrpc: '2.0',
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
chainId,
|
|
84
|
-
transaction,
|
|
85
|
-
transactionOrigin
|
|
86
|
-
}
|
|
30
|
+
id: 1,
|
|
31
|
+
...options
|
|
87
32
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
33
|
+
}).then((result)=>{
|
|
34
|
+
const notifications = getNotifications(store.getState());
|
|
35
|
+
store.dispatch(clearNotifications());
|
|
36
|
+
const content = getContentFromResult(result, snapId, controllerMessenger);
|
|
37
|
+
return {
|
|
38
|
+
id: String(id),
|
|
39
|
+
response: {
|
|
40
|
+
result: getSafeJson(result)
|
|
41
|
+
},
|
|
42
|
+
notifications,
|
|
43
|
+
content
|
|
44
|
+
};
|
|
45
|
+
}).catch((error)=>{
|
|
46
|
+
const [unwrappedError] = unwrapError(error);
|
|
95
47
|
return {
|
|
96
|
-
id,
|
|
97
|
-
response
|
|
48
|
+
id: String(id),
|
|
49
|
+
response: {
|
|
50
|
+
error: unwrappedError.serialize()
|
|
51
|
+
},
|
|
98
52
|
notifications: []
|
|
99
53
|
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
id,
|
|
105
|
-
response,
|
|
106
|
-
notifications: [],
|
|
107
|
-
content: response.result.content
|
|
54
|
+
});
|
|
55
|
+
promise.getInterface = async ()=>{
|
|
56
|
+
return await runSaga(getInterface, runSaga, snapId, controllerMessenger).toPromise();
|
|
108
57
|
};
|
|
58
|
+
return promise;
|
|
109
59
|
}
|
|
110
60
|
/**
|
|
111
|
-
*
|
|
61
|
+
* Get the response content either from the SnapInterfaceController or the response object if there is one.
|
|
112
62
|
*
|
|
113
|
-
* @param
|
|
114
|
-
* @param
|
|
115
|
-
* @
|
|
116
|
-
|
|
117
|
-
|
|
63
|
+
* @param result - The handler result object.
|
|
64
|
+
* @param snapId - The Snap ID.
|
|
65
|
+
* @param controllerMessenger - The controller messenger.
|
|
66
|
+
* @returns The content components if any.
|
|
67
|
+
*/ export function getContentFromResult(result, snapId, controllerMessenger) {
|
|
68
|
+
if (isPlainObject(result) && hasProperty(result, 'id')) {
|
|
69
|
+
return controllerMessenger.call('SnapInterfaceController:getInterface', snapId, result.id).content;
|
|
70
|
+
}
|
|
71
|
+
if (isPlainObject(result) && hasProperty(result, 'content')) {
|
|
72
|
+
return result.content;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
118
75
|
}
|
|
119
76
|
|
|
120
77
|
//# sourceMappingURL=request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/request.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/request.ts"],"sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport type { SnapId, Component } from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { getSafeJson, hasProperty, isPlainObject } from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type { RequestOptions, SnapRequest } from '../types';\nimport {\n clearNotifications,\n getInterface,\n getNotifications,\n} from './simulation';\nimport type { RunSagaFunction, Store } from './simulation';\nimport type { RootControllerMessenger } from './simulation/controllers';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then((result) => {\n const notifications = getNotifications(store.getState());\n store.dispatch(clearNotifications());\n\n const content = getContentFromResult(result, snapId, controllerMessenger);\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n content,\n };\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n return await runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n ).toPromise();\n };\n\n return promise;\n}\n\n/**\n * Get the response content either from the SnapInterfaceController or the response object if there is one.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The content components if any.\n */\nexport function getContentFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): Component | undefined {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n result.id as string,\n ).content;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n return result.content as Component;\n }\n\n return undefined;\n}\n"],"names":["unwrapError","getSafeJson","hasProperty","isPlainObject","nanoid","clearNotifications","getInterface","getNotifications","handleRequest","snapId","store","executionService","handler","controllerMessenger","runSaga","request","id","origin","options","promise","handleRpcRequest","jsonrpc","then","result","notifications","getState","dispatch","content","getContentFromResult","String","response","catch","error","unwrappedError","serialize","toPromise","call","undefined"],"mappings":"AAGA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,SAASC,WAAW,EAAEC,WAAW,EAAEC,aAAa,QAAQ,kBAAkB;AAC1E,SAASC,MAAM,QAAQ,mBAAmB;AAG1C,SACEC,kBAAkB,EAClBC,YAAY,EACZC,gBAAgB,QACX,eAAe;AActB;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC,cAAc,EAC5BC,MAAM,EACNC,KAAK,EACLC,gBAAgB,EAChBC,OAAO,EACPC,mBAAmB,EACnBC,OAAO,EACPC,SAAS,EAAEC,KAAKZ,QAAQ,EAAEa,SAAS,qBAAqB,EAAE,GAAGC,SAAS,EACjD;IACrB,MAAMC,UAAUR,iBACbS,gBAAgB,CAACX,QAAQ;QACxBQ;QACAL;QACAG,SAAS;YACPM,SAAS;YACTL,IAAI;YACJ,GAAGE,OAAO;QACZ;IACF,GACCI,IAAI,CAAC,CAACC;QACL,MAAMC,gBAAgBjB,iBAAiBG,MAAMe,QAAQ;QACrDf,MAAMgB,QAAQ,CAACrB;QAEf,MAAMsB,UAAUC,qBAAqBL,QAAQd,QAAQI;QAErD,OAAO;YACLG,IAAIa,OAAOb;YACXc,UAAU;gBACRP,QAAQtB,YAAYsB;YACtB;YACAC;YACAG;QACF;IACF,GACCI,KAAK,CAAC,CAACC;QACN,MAAM,CAACC,eAAe,GAAGjC,YAAYgC;QAErC,OAAO;YACLhB,IAAIa,OAAOb;YACXc,UAAU;gBACRE,OAAOC,eAAeC,SAAS;YACjC;YACAV,eAAe,EAAE;QACnB;IACF;IAEFL,QAAQb,YAAY,GAAG;QACrB,OAAO,MAAMQ,QACXR,cACAQ,SACAL,QACAI,qBACAsB,SAAS;IACb;IAEA,OAAOhB;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASS,qBACdL,MAAe,EACfd,MAAc,EACdI,mBAA4C;IAE5C,IAAIV,cAAcoB,WAAWrB,YAAYqB,QAAQ,OAAO;QACtD,OAAOV,oBAAoBuB,IAAI,CAC7B,wCACA3B,QACAc,OAAOP,EAAE,EACTW,OAAO;IACX;IAEA,IAAIxB,cAAcoB,WAAWrB,YAAYqB,QAAQ,YAAY;QAC3D,OAAOA,OAAOI,OAAO;IACvB;IAEA,OAAOU;AACT"}
|
|
@@ -3,10 +3,8 @@ import { createModuleLogger } from '@metamask/utils';
|
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import { promises as fs } from 'fs';
|
|
5
5
|
import { createServer } from 'http';
|
|
6
|
-
import { resolve as pathResolve
|
|
6
|
+
import { resolve as pathResolve } from 'path';
|
|
7
7
|
import { rootLogger } from './logger';
|
|
8
|
-
const SNAPS_EXECUTION_ENVIRONMENTS_PATH = pathResolve(dirname(require.resolve('@metamask/snaps-execution-environments/package.json')), 'dist', 'browserify', 'iframe');
|
|
9
|
-
const SNAPS_SIMULATOR_PATH = pathResolve(dirname(require.resolve('@metamask/snaps-simulator/package.json')), 'dist', 'webpack', 'test');
|
|
10
8
|
/**
|
|
11
9
|
* Check that:
|
|
12
10
|
*
|
|
@@ -50,8 +48,6 @@ const SNAPS_SIMULATOR_PATH = pathResolve(dirname(require.resolve('@metamask/snap
|
|
|
50
48
|
response.header('Access-Control-Allow-Headers', 'Content-Type');
|
|
51
49
|
next();
|
|
52
50
|
});
|
|
53
|
-
app.use('/environment', express.static(SNAPS_EXECUTION_ENVIRONMENTS_PATH));
|
|
54
|
-
app.use('/simulator', express.static(SNAPS_SIMULATOR_PATH));
|
|
55
51
|
app.use(express.static(pathResolve(process.cwd(), options.root)));
|
|
56
52
|
const server = createServer(app);
|
|
57
53
|
return await new Promise((resolve, reject)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/server.ts"],"sourcesContent":["import type { SnapManifest } from '@metamask/snaps-utils';\nimport {\n assertIsSnapManifest,\n isDirectory,\n isFile,\n} from '@metamask/snaps-utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport express from 'express';\nimport { promises as fs } from 'fs';\nimport type { Server } from 'http';\nimport { createServer } from 'http';\nimport { resolve as pathResolve
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/server.ts"],"sourcesContent":["import type { SnapManifest } from '@metamask/snaps-utils';\nimport {\n assertIsSnapManifest,\n isDirectory,\n isFile,\n} from '@metamask/snaps-utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport express from 'express';\nimport { promises as fs } from 'fs';\nimport type { Server } from 'http';\nimport { createServer } from 'http';\nimport { resolve as pathResolve } from 'path';\n\nimport type { SnapsEnvironmentOptions } from '../options';\nimport { rootLogger } from './logger';\n\nexport type ServerOptions = Required<\n // We need a double `Required` for the type to be inferred correctly.\n Required<SnapsEnvironmentOptions>['server']\n>;\n\n/**\n * Check that:\n *\n * - The root directory exists.\n * - The root directory contains a `snap.manifest.json` file.\n * - The file path in the manifest exists.\n *\n * @param root - The root directory.\n * @throws If any of the checks fail.\n */\nasync function assertRoot(root: string) {\n if (!root) {\n throw new Error('You must specify a root directory.');\n }\n\n if (!(await isDirectory(root, false))) {\n throw new Error(`Root directory \"${root}\" is not a directory.`);\n }\n\n const manifestPath = pathResolve(root, 'snap.manifest.json');\n const manifest: SnapManifest = await fs\n .readFile(manifestPath, 'utf8')\n .then(JSON.parse);\n\n assertIsSnapManifest(manifest);\n const filePath = pathResolve(root, manifest.source.location.npm.filePath);\n\n if (!(await isFile(filePath))) {\n throw new Error(\n `File \"${filePath}\" does not exist, or is not a file. Did you forget to build your snap?`,\n );\n }\n}\n\n/**\n * Start an HTTP server on `localhost` with a random port. This is used to serve\n * the static files for the environment.\n *\n * @param options - The options to use.\n * @param options.port - The port to use for the server.\n * @param options.root - The root directory to serve from the server.\n * @returns The HTTP server.\n */\nexport async function startServer(options: ServerOptions) {\n await assertRoot(options.root);\n\n const log = createModuleLogger(rootLogger, 'server');\n const app = express();\n\n app.use((_request, response, next) => {\n response.header('Access-Control-Allow-Origin', '*');\n response.header('Access-Control-Allow-Credentials', 'true');\n response.header('Access-Control-Allow-Methods', 'GET, OPTIONS');\n response.header('Access-Control-Allow-Headers', 'Content-Type');\n\n next();\n });\n\n app.use(express.static(pathResolve(process.cwd(), options.root)));\n\n const server = createServer(app);\n return await new Promise<Server>((resolve, reject) => {\n server.listen(options.port, () => {\n resolve(server);\n });\n\n server.on('error', (error) => {\n log(error);\n reject(error);\n });\n });\n}\n"],"names":["assertIsSnapManifest","isDirectory","isFile","createModuleLogger","express","promises","fs","createServer","resolve","pathResolve","rootLogger","assertRoot","root","Error","manifestPath","manifest","readFile","then","JSON","parse","filePath","source","location","npm","startServer","options","log","app","use","_request","response","next","header","static","process","cwd","server","Promise","reject","listen","port","on","error"],"mappings":"AACA,SACEA,oBAAoB,EACpBC,WAAW,EACXC,MAAM,QACD,wBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,OAAOC,aAAa,UAAU;AAC9B,SAASC,YAAYC,EAAE,QAAQ,KAAK;AAEpC,SAASC,YAAY,QAAQ,OAAO;AACpC,SAASC,WAAWC,WAAW,QAAQ,OAAO;AAG9C,SAASC,UAAU,QAAQ,WAAW;AAOtC;;;;;;;;;CASC,GACD,eAAeC,WAAWC,IAAY;IACpC,IAAI,CAACA,MAAM;QACT,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,CAAE,MAAMZ,YAAYW,MAAM,QAAS;QACrC,MAAM,IAAIC,MAAM,CAAC,gBAAgB,EAAED,KAAK,qBAAqB,CAAC;IAChE;IAEA,MAAME,eAAeL,YAAYG,MAAM;IACvC,MAAMG,WAAyB,MAAMT,GAClCU,QAAQ,CAACF,cAAc,QACvBG,IAAI,CAACC,KAAKC,KAAK;IAElBnB,qBAAqBe;IACrB,MAAMK,WAAWX,YAAYG,MAAMG,SAASM,MAAM,CAACC,QAAQ,CAACC,GAAG,CAACH,QAAQ;IAExE,IAAI,CAAE,MAAMlB,OAAOkB,WAAY;QAC7B,MAAM,IAAIP,MACR,CAAC,MAAM,EAAEO,SAAS,sEAAsE,CAAC;IAE7F;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeI,YAAYC,OAAsB;IACtD,MAAMd,WAAWc,QAAQb,IAAI;IAE7B,MAAMc,MAAMvB,mBAAmBO,YAAY;IAC3C,MAAMiB,MAAMvB;IAEZuB,IAAIC,GAAG,CAAC,CAACC,UAAUC,UAAUC;QAC3BD,SAASE,MAAM,CAAC,+BAA+B;QAC/CF,SAASE,MAAM,CAAC,oCAAoC;QACpDF,SAASE,MAAM,CAAC,gCAAgC;QAChDF,SAASE,MAAM,CAAC,gCAAgC;QAEhDD;IACF;IAEAJ,IAAIC,GAAG,CAACxB,QAAQ6B,MAAM,CAACxB,YAAYyB,QAAQC,GAAG,IAAIV,QAAQb,IAAI;IAE9D,MAAMwB,SAAS7B,aAAaoB;IAC5B,OAAO,MAAM,IAAIU,QAAgB,CAAC7B,SAAS8B;QACzCF,OAAOG,MAAM,CAACd,QAAQe,IAAI,EAAE;YAC1BhC,QAAQ4B;QACV;QAEAA,OAAOK,EAAE,CAAC,SAAS,CAACC;YAClBhB,IAAIgB;YACJJ,OAAOI;QACT;IACF;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A secret recovery phrase that is used for testing purposes. Do not use this
|
|
3
|
+
* to store any real funds!
|
|
4
|
+
*/ export const DEFAULT_SRP = 'test test test test test test test test test test test ball';
|
|
5
|
+
/**
|
|
6
|
+
* The default locale.
|
|
7
|
+
*/ export const DEFAULT_LOCALE = 'en';
|
|
8
|
+
/**
|
|
9
|
+
* The default JSON-RPC endpoint for Ethereum requests.
|
|
10
|
+
*/ export const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/internals/simulation/constants.ts"],"sourcesContent":["/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n"],"names":["DEFAULT_SRP","DEFAULT_LOCALE","DEFAULT_JSON_RPC_ENDPOINT"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,cACX,8DAA8D;AAEhE;;CAEC,GACD,OAAO,MAAMC,iBAAiB,KAAK;AAEnC;;CAEC,GACD,OAAO,MAAMC,4BAA4B,8BAA8B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { PermissionController, SubjectMetadataController, SubjectType } from '@metamask/permission-controller';
|
|
2
|
+
import { SnapInterfaceController } from '@metamask/snaps-controllers';
|
|
3
|
+
import { caveatSpecifications as snapsCaveatsSpecifications, endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications, processSnapPermissions } from '@metamask/snaps-rpc-methods';
|
|
4
|
+
import { getSafeJson } from '@metamask/utils';
|
|
5
|
+
import { getPermissionSpecifications } from './methods';
|
|
6
|
+
import { UNRESTRICTED_METHODS } from './methods/constants';
|
|
7
|
+
/**
|
|
8
|
+
* Get the controllers for the Snap.
|
|
9
|
+
*
|
|
10
|
+
* @param options - The options.
|
|
11
|
+
* @returns The controllers for the Snap.
|
|
12
|
+
*/ export function getControllers(options) {
|
|
13
|
+
const { controllerMessenger } = options;
|
|
14
|
+
const subjectMetadataController = new SubjectMetadataController({
|
|
15
|
+
messenger: controllerMessenger.getRestricted({
|
|
16
|
+
name: 'SubjectMetadataController'
|
|
17
|
+
}),
|
|
18
|
+
subjectCacheLimit: 100
|
|
19
|
+
});
|
|
20
|
+
const interfaceController = new SnapInterfaceController({
|
|
21
|
+
messenger: controllerMessenger.getRestricted({
|
|
22
|
+
name: 'SnapInterfaceController',
|
|
23
|
+
allowedActions: [
|
|
24
|
+
'PhishingController:maybeUpdateState',
|
|
25
|
+
'PhishingController:testOrigin'
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
const permissionController = getPermissionController(options);
|
|
30
|
+
return {
|
|
31
|
+
permissionController,
|
|
32
|
+
subjectMetadataController,
|
|
33
|
+
interfaceController
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the permission controller for the Snap.
|
|
38
|
+
*
|
|
39
|
+
* @param options - The options.
|
|
40
|
+
* @param options.controllerMessenger - The controller messenger.
|
|
41
|
+
* @param options.options - Miscellaneous options.
|
|
42
|
+
* @returns The permission controller for the Snap.
|
|
43
|
+
*/ function getPermissionController(options) {
|
|
44
|
+
const { controllerMessenger } = options;
|
|
45
|
+
const permissionSpecifications = getPermissionSpecifications(options);
|
|
46
|
+
return new PermissionController({
|
|
47
|
+
messenger: controllerMessenger.getRestricted({
|
|
48
|
+
name: 'PermissionController',
|
|
49
|
+
allowedActions: [
|
|
50
|
+
`ApprovalController:addRequest`,
|
|
51
|
+
`ApprovalController:hasRequest`,
|
|
52
|
+
`ApprovalController:acceptRequest`,
|
|
53
|
+
`ApprovalController:rejectRequest`,
|
|
54
|
+
`SnapController:getPermitted`,
|
|
55
|
+
`SnapController:install`,
|
|
56
|
+
`SubjectMetadataController:getSubjectMetadata`
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
caveatSpecifications: {
|
|
60
|
+
...snapsCaveatsSpecifications,
|
|
61
|
+
...snapsEndowmentCaveatSpecifications
|
|
62
|
+
},
|
|
63
|
+
permissionSpecifications,
|
|
64
|
+
unrestrictedMethods: UNRESTRICTED_METHODS
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Register the Snap. This sets up the Snap's permissions and subject metadata.
|
|
69
|
+
*
|
|
70
|
+
* @param snapId - The ID of the Snap to install.
|
|
71
|
+
* @param manifest - The parsed manifest.
|
|
72
|
+
* @param controllers - The controllers for the Snap.
|
|
73
|
+
* @param controllers.permissionController - The permission controller.
|
|
74
|
+
* @param controllers.subjectMetadataController - The subject metadata controller.
|
|
75
|
+
*/ export async function registerSnap(snapId, manifest, { permissionController, subjectMetadataController }) {
|
|
76
|
+
subjectMetadataController.addSubjectMetadata({
|
|
77
|
+
origin: snapId,
|
|
78
|
+
subjectType: SubjectType.Snap
|
|
79
|
+
});
|
|
80
|
+
const approvedPermissions = processSnapPermissions(getSafeJson(manifest.initialPermissions));
|
|
81
|
+
permissionController.grantPermissions({
|
|
82
|
+
approvedPermissions,
|
|
83
|
+
subject: {
|
|
84
|
+
origin: snapId
|
|
85
|
+
},
|
|
86
|
+
preserveExistingPermissions: false
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=controllers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/internals/simulation/controllers.ts"],"sourcesContent":["import type { ControllerMessenger } from '@metamask/base-controller';\nimport type {\n CaveatSpecificationConstraint,\n PermissionSpecificationConstraint,\n PermissionControllerActions,\n SubjectMetadataControllerActions,\n} from '@metamask/permission-controller';\nimport {\n PermissionController,\n SubjectMetadataController,\n SubjectType,\n} from '@metamask/permission-controller';\nimport { SnapInterfaceController } from '@metamask/snaps-controllers';\nimport type {\n ExecutionServiceActions,\n SnapInterfaceControllerActions,\n SnapInterfaceControllerAllowedActions,\n} from '@metamask/snaps-controllers';\nimport {\n caveatSpecifications as snapsCaveatsSpecifications,\n endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications,\n processSnapPermissions,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { SnapManifest } from '@metamask/snaps-utils';\nimport { getSafeJson } from '@metamask/utils';\n\nimport { getPermissionSpecifications } from './methods';\nimport { UNRESTRICTED_METHODS } from './methods/constants';\nimport type { SimulationOptions } from './options';\nimport type { MiddlewareHooks } from './simulation';\nimport type { RunSagaFunction } from './store';\n\nexport type RootControllerAllowedActions =\n | SnapInterfaceControllerActions\n | SnapInterfaceControllerAllowedActions\n | PermissionControllerActions\n | ExecutionServiceActions\n | SubjectMetadataControllerActions;\n\nexport type RootControllerMessenger = ControllerMessenger<\n RootControllerAllowedActions,\n any\n>;\n\nexport type GetControllersOptions = {\n controllerMessenger: ControllerMessenger<any, any>;\n hooks: MiddlewareHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\nexport type Controllers = {\n permissionController: PermissionController<\n PermissionSpecificationConstraint,\n CaveatSpecificationConstraint\n >;\n subjectMetadataController: SubjectMetadataController;\n interfaceController: SnapInterfaceController;\n};\n\n/**\n * Get the controllers for the Snap.\n *\n * @param options - The options.\n * @returns The controllers for the Snap.\n */\nexport function getControllers(options: GetControllersOptions): Controllers {\n const { controllerMessenger } = options;\n const subjectMetadataController = new SubjectMetadataController({\n messenger: controllerMessenger.getRestricted({\n name: 'SubjectMetadataController',\n }),\n subjectCacheLimit: 100,\n });\n\n const interfaceController = new SnapInterfaceController({\n messenger: controllerMessenger.getRestricted({\n name: 'SnapInterfaceController',\n allowedActions: [\n 'PhishingController:maybeUpdateState',\n 'PhishingController:testOrigin',\n ],\n }),\n });\n\n const permissionController = getPermissionController(options);\n\n return {\n permissionController,\n subjectMetadataController,\n interfaceController,\n };\n}\n\n/**\n * Get the permission controller for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.options - Miscellaneous options.\n * @returns The permission controller for the Snap.\n */\nfunction getPermissionController(options: GetControllersOptions) {\n const { controllerMessenger } = options;\n const permissionSpecifications = getPermissionSpecifications(options);\n return new PermissionController({\n messenger: controllerMessenger.getRestricted({\n name: 'PermissionController',\n allowedActions: [\n `ApprovalController:addRequest`,\n `ApprovalController:hasRequest`,\n `ApprovalController:acceptRequest`,\n `ApprovalController:rejectRequest`,\n `SnapController:getPermitted`,\n `SnapController:install`,\n `SubjectMetadataController:getSubjectMetadata`,\n ],\n }),\n caveatSpecifications: {\n ...snapsCaveatsSpecifications,\n ...snapsEndowmentCaveatSpecifications,\n },\n permissionSpecifications,\n unrestrictedMethods: UNRESTRICTED_METHODS,\n });\n}\n\n/**\n * Register the Snap. This sets up the Snap's permissions and subject metadata.\n *\n * @param snapId - The ID of the Snap to install.\n * @param manifest - The parsed manifest.\n * @param controllers - The controllers for the Snap.\n * @param controllers.permissionController - The permission controller.\n * @param controllers.subjectMetadataController - The subject metadata controller.\n */\nexport async function registerSnap(\n snapId: SnapId,\n manifest: SnapManifest,\n {\n permissionController,\n subjectMetadataController,\n }: Omit<Controllers, 'interfaceController'>,\n) {\n subjectMetadataController.addSubjectMetadata({\n origin: snapId,\n subjectType: SubjectType.Snap,\n });\n\n const approvedPermissions = processSnapPermissions(\n getSafeJson(manifest.initialPermissions),\n );\n\n permissionController.grantPermissions({\n approvedPermissions,\n subject: { origin: snapId },\n preserveExistingPermissions: false,\n });\n}\n"],"names":["PermissionController","SubjectMetadataController","SubjectType","SnapInterfaceController","caveatSpecifications","snapsCaveatsSpecifications","endowmentCaveatSpecifications","snapsEndowmentCaveatSpecifications","processSnapPermissions","getSafeJson","getPermissionSpecifications","UNRESTRICTED_METHODS","getControllers","options","controllerMessenger","subjectMetadataController","messenger","getRestricted","name","subjectCacheLimit","interfaceController","allowedActions","permissionController","getPermissionController","permissionSpecifications","unrestrictedMethods","registerSnap","snapId","manifest","addSubjectMetadata","origin","subjectType","Snap","approvedPermissions","initialPermissions","grantPermissions","subject","preserveExistingPermissions"],"mappings":"AAOA,SACEA,oBAAoB,EACpBC,yBAAyB,EACzBC,WAAW,QACN,kCAAkC;AACzC,SAASC,uBAAuB,QAAQ,8BAA8B;AAMtE,SACEC,wBAAwBC,0BAA0B,EAClDC,iCAAiCC,kCAAkC,EACnEC,sBAAsB,QACjB,8BAA8B;AAGrC,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,2BAA2B,QAAQ,YAAY;AACxD,SAASC,oBAAoB,QAAQ,sBAAsB;AAiC3D;;;;;CAKC,GACD,OAAO,SAASC,eAAeC,OAA8B;IAC3D,MAAM,EAAEC,mBAAmB,EAAE,GAAGD;IAChC,MAAME,4BAA4B,IAAId,0BAA0B;QAC9De,WAAWF,oBAAoBG,aAAa,CAAC;YAC3CC,MAAM;QACR;QACAC,mBAAmB;IACrB;IAEA,MAAMC,sBAAsB,IAAIjB,wBAAwB;QACtDa,WAAWF,oBAAoBG,aAAa,CAAC;YAC3CC,MAAM;YACNG,gBAAgB;gBACd;gBACA;aACD;QACH;IACF;IAEA,MAAMC,uBAAuBC,wBAAwBV;IAErD,OAAO;QACLS;QACAP;QACAK;IACF;AACF;AAEA;;;;;;;CAOC,GACD,SAASG,wBAAwBV,OAA8B;IAC7D,MAAM,EAAEC,mBAAmB,EAAE,GAAGD;IAChC,MAAMW,2BAA2Bd,4BAA4BG;IAC7D,OAAO,IAAIb,qBAAqB;QAC9BgB,WAAWF,oBAAoBG,aAAa,CAAC;YAC3CC,MAAM;YACNG,gBAAgB;gBACd,CAAC,6BAA6B,CAAC;gBAC/B,CAAC,6BAA6B,CAAC;gBAC/B,CAAC,gCAAgC,CAAC;gBAClC,CAAC,gCAAgC,CAAC;gBAClC,CAAC,2BAA2B,CAAC;gBAC7B,CAAC,sBAAsB,CAAC;gBACxB,CAAC,4CAA4C,CAAC;aAC/C;QACH;QACAjB,sBAAsB;YACpB,GAAGC,0BAA0B;YAC7B,GAAGE,kCAAkC;QACvC;QACAiB;QACAC,qBAAqBd;IACvB;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAee,aACpBC,MAAc,EACdC,QAAsB,EACtB,EACEN,oBAAoB,EACpBP,yBAAyB,EACgB;IAE3CA,0BAA0Bc,kBAAkB,CAAC;QAC3CC,QAAQH;QACRI,aAAa7B,YAAY8B,IAAI;IAC/B;IAEA,MAAMC,sBAAsBzB,uBAC1BC,YAAYmB,SAASM,kBAAkB;IAGzCZ,qBAAqBa,gBAAgB,CAAC;QACpCF;QACAG,SAAS;YAAEN,QAAQH;QAAO;QAC1BU,6BAA6B;IAC/B;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';
|
|
2
|
+
import { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Get a statically defined Snap file from an array of files.
|
|
5
|
+
*
|
|
6
|
+
* @param files - The Snap files.
|
|
7
|
+
* @param path - The file path.
|
|
8
|
+
* @param encoding - The requested file encoding.
|
|
9
|
+
* @returns The file in the requested encoding if found, otherwise null.
|
|
10
|
+
*/ export async function getSnapFile(files, path, encoding = AuxiliaryFileEncoding.Base64) {
|
|
11
|
+
const normalizedPath = normalizeRelative(path);
|
|
12
|
+
const base64 = files.find((file)=>file.path === normalizedPath)?.toString('base64');
|
|
13
|
+
if (!base64) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return await encodeAuxiliaryFile(base64, encoding);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/internals/simulation/files.ts"],"sourcesContent":["import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport type { VirtualFile } from '@metamask/snaps-utils';\nimport { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';\n\n/**\n * Get a statically defined Snap file from an array of files.\n *\n * @param files - The Snap files.\n * @param path - The file path.\n * @param encoding - The requested file encoding.\n * @returns The file in the requested encoding if found, otherwise null.\n */\nexport async function getSnapFile(\n files: VirtualFile[],\n path: string,\n encoding: AuxiliaryFileEncoding = AuxiliaryFileEncoding.Base64,\n) {\n const normalizedPath = normalizeRelative(path);\n const base64 = files\n .find((file) => file.path === normalizedPath)\n ?.toString('base64');\n\n if (!base64) {\n return null;\n }\n\n return await encodeAuxiliaryFile(base64, encoding);\n}\n"],"names":["AuxiliaryFileEncoding","encodeAuxiliaryFile","normalizeRelative","getSnapFile","files","path","encoding","Base64","normalizedPath","base64","find","file","toString"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,sBAAsB;AAE5D,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,wBAAwB;AAE/E;;;;;;;CAOC,GACD,OAAO,eAAeC,YACpBC,KAAoB,EACpBC,IAAY,EACZC,WAAkCN,sBAAsBO,MAAM;IAE9D,MAAMC,iBAAiBN,kBAAkBG;IACzC,MAAMI,SAASL,MACZM,IAAI,CAAC,CAACC,OAASA,KAAKN,IAAI,KAAKG,iBAC5BI,SAAS;IAEb,IAAI,CAACH,QAAQ;QACX,OAAO;IACT;IAEA,OAAO,MAAMR,oBAAoBQ,QAAQH;AAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/internals/simulation/index.ts"],"sourcesContent":["export * from './constants';\nexport * from './interface';\nexport * from './simulation';\nexport * from './options';\nexport * from './store';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { DialogType } from '@metamask/snaps-sdk';
|
|
2
|
+
import { put, select, take } from 'redux-saga/effects';
|
|
3
|
+
import { getCurrentInterface, resolveInterface, setInterface } from './store';
|
|
4
|
+
/**
|
|
5
|
+
* Get a user interface object from a type and content object.
|
|
6
|
+
*
|
|
7
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
8
|
+
* @param type - The type of the interface.
|
|
9
|
+
* @param content - The content to show in the interface.
|
|
10
|
+
* @returns The user interface object.
|
|
11
|
+
*/ export function getInterfaceResponse(runSaga, type, content) {
|
|
12
|
+
switch(type){
|
|
13
|
+
case DialogType.Alert:
|
|
14
|
+
return {
|
|
15
|
+
type,
|
|
16
|
+
content,
|
|
17
|
+
ok: resolveWith(runSaga, null)
|
|
18
|
+
};
|
|
19
|
+
case DialogType.Confirmation:
|
|
20
|
+
return {
|
|
21
|
+
type,
|
|
22
|
+
content,
|
|
23
|
+
ok: resolveWith(runSaga, true),
|
|
24
|
+
cancel: resolveWith(runSaga, false)
|
|
25
|
+
};
|
|
26
|
+
case DialogType.Prompt:
|
|
27
|
+
return {
|
|
28
|
+
type,
|
|
29
|
+
content,
|
|
30
|
+
ok: resolveWithInput(runSaga),
|
|
31
|
+
cancel: resolveWith(runSaga, null)
|
|
32
|
+
};
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Unknown or unsupported dialog type: "${String(type)}".`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the current user interface with the given value. This returns a
|
|
39
|
+
* function that can be used to resolve the user interface.
|
|
40
|
+
*
|
|
41
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
42
|
+
* @param value - The value to resolve the user interface with.
|
|
43
|
+
* @returns A function that can be used to resolve the user interface.
|
|
44
|
+
*/ function resolveWith(runSaga, value) {
|
|
45
|
+
/**
|
|
46
|
+
* Resolve the current user interface with the given value.
|
|
47
|
+
*
|
|
48
|
+
* @yields Puts the resolve user interface action.
|
|
49
|
+
*/ function* resolveWithSaga() {
|
|
50
|
+
yield put(resolveInterface(value));
|
|
51
|
+
}
|
|
52
|
+
return async ()=>{
|
|
53
|
+
await runSaga(resolveWithSaga).toPromise();
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the current user interface with the provided input. This returns a
|
|
58
|
+
* function that can be used to resolve the user interface.
|
|
59
|
+
*
|
|
60
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
61
|
+
* @returns A function that can be used to resolve the user interface.
|
|
62
|
+
*/ function resolveWithInput(runSaga) {
|
|
63
|
+
/**
|
|
64
|
+
* Resolve the current user interface with the given value.
|
|
65
|
+
*
|
|
66
|
+
* @param value - The value to resolve the user interface with.
|
|
67
|
+
* @yields Puts the resolve user interface action.
|
|
68
|
+
*/ function* resolveWithSaga(value) {
|
|
69
|
+
yield put(resolveInterface(value));
|
|
70
|
+
}
|
|
71
|
+
return async (value = '')=>{
|
|
72
|
+
await runSaga(resolveWithSaga, value).toPromise();
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get a user interface object from a Snap.
|
|
77
|
+
*
|
|
78
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
79
|
+
* @param snapId - The Snap ID.
|
|
80
|
+
* @param controllerMessenger - The controller messenger used to call actions.
|
|
81
|
+
* @yields Takes the set interface action.
|
|
82
|
+
* @returns The user interface object.
|
|
83
|
+
*/ export function* getInterface(runSaga, snapId, controllerMessenger) {
|
|
84
|
+
const currentInterface = yield select(getCurrentInterface);
|
|
85
|
+
if (currentInterface) {
|
|
86
|
+
const { content } = controllerMessenger.call('SnapInterfaceController:getInterface', snapId, currentInterface.id);
|
|
87
|
+
return getInterfaceResponse(runSaga, currentInterface.type, content);
|
|
88
|
+
}
|
|
89
|
+
const { payload } = yield take(setInterface.type);
|
|
90
|
+
const { type, id } = payload;
|
|
91
|
+
const { content } = controllerMessenger.call('SnapInterfaceController:getInterface', snapId, id);
|
|
92
|
+
return getInterfaceResponse(runSaga, type, content);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/internals/simulation/interface.ts"],"sourcesContent":["import type { Component, SnapId } from '@metamask/snaps-sdk';\nimport { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport type { SagaIterator } from 'redux-saga';\nimport { put, select, take } from 'redux-saga/effects';\n\nimport type { SnapInterface } from '../../types';\nimport type { RootControllerMessenger } from './controllers';\nimport type { Interface, RunSagaFunction } from './store';\nimport { getCurrentInterface, resolveInterface, setInterface } from './store';\n\n/**\n * Get a user interface object from a type and content object.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param type - The type of the interface.\n * @param content - The content to show in the interface.\n * @returns The user interface object.\n */\nexport function getInterfaceResponse(\n runSaga: RunSagaFunction,\n type: DialogType,\n content: Component,\n): SnapInterface {\n switch (type) {\n case DialogType.Alert:\n return {\n type,\n content,\n ok: resolveWith(runSaga, null),\n };\n\n case DialogType.Confirmation:\n return {\n type,\n content,\n\n ok: resolveWith(runSaga, true),\n cancel: resolveWith(runSaga, false),\n };\n\n case DialogType.Prompt:\n return {\n type,\n content,\n\n ok: resolveWithInput(runSaga),\n cancel: resolveWith(runSaga, null),\n };\n\n default:\n throw new Error(`Unknown or unsupported dialog type: \"${String(type)}\".`);\n }\n}\n\n/**\n * Resolve the current user interface with the given value. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param value - The value to resolve the user interface with.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWith(runSaga: RunSagaFunction, value: unknown) {\n /**\n * Resolve the current user interface with the given value.\n *\n * @yields Puts the resolve user interface action.\n */\n function* resolveWithSaga(): SagaIterator {\n yield put(resolveInterface(value));\n }\n\n return async () => {\n await runSaga(resolveWithSaga).toPromise();\n };\n}\n\n/**\n * Resolve the current user interface with the provided input. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWithInput(runSaga: RunSagaFunction) {\n /**\n * Resolve the current user interface with the given value.\n *\n * @param value - The value to resolve the user interface with.\n * @yields Puts the resolve user interface action.\n */\n function* resolveWithSaga(value: string): SagaIterator {\n yield put(resolveInterface(value));\n }\n\n return async (value = '') => {\n await runSaga(resolveWithSaga, value).toPromise();\n };\n}\n\n/**\n * Get a user interface object from a Snap.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nexport function* getInterface(\n runSaga: RunSagaFunction,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): SagaIterator<SnapInterface> {\n const currentInterface: Interface | null = yield select(getCurrentInterface);\n if (currentInterface) {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n currentInterface.id,\n );\n return getInterfaceResponse(runSaga, currentInterface.type, content);\n }\n\n const { payload }: PayloadAction<Interface> = yield take(setInterface.type);\n const { type, id } = payload;\n\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n return getInterfaceResponse(runSaga, type, content);\n}\n"],"names":["DialogType","put","select","take","getCurrentInterface","resolveInterface","setInterface","getInterfaceResponse","runSaga","type","content","Alert","ok","resolveWith","Confirmation","cancel","Prompt","resolveWithInput","Error","String","value","resolveWithSaga","toPromise","getInterface","snapId","controllerMessenger","currentInterface","call","id","payload"],"mappings":"AACA,SAASA,UAAU,QAAQ,sBAAsB;AAGjD,SAASC,GAAG,EAAEC,MAAM,EAAEC,IAAI,QAAQ,qBAAqB;AAKvD,SAASC,mBAAmB,EAAEC,gBAAgB,EAAEC,YAAY,QAAQ,UAAU;AAE9E;;;;;;;CAOC,GACD,OAAO,SAASC,qBACdC,OAAwB,EACxBC,IAAgB,EAChBC,OAAkB;IAElB,OAAQD;QACN,KAAKT,WAAWW,KAAK;YACnB,OAAO;gBACLF;gBACAC;gBACAE,IAAIC,YAAYL,SAAS;YAC3B;QAEF,KAAKR,WAAWc,YAAY;YAC1B,OAAO;gBACLL;gBACAC;gBAEAE,IAAIC,YAAYL,SAAS;gBACzBO,QAAQF,YAAYL,SAAS;YAC/B;QAEF,KAAKR,WAAWgB,MAAM;YACpB,OAAO;gBACLP;gBACAC;gBAEAE,IAAIK,iBAAiBT;gBACrBO,QAAQF,YAAYL,SAAS;YAC/B;QAEF;YACE,MAAM,IAAIU,MAAM,CAAC,qCAAqC,EAAEC,OAAOV,MAAM,EAAE,CAAC;IAC5E;AACF;AAEA;;;;;;;CAOC,GACD,SAASI,YAAYL,OAAwB,EAAEY,KAAc;IAC3D;;;;GAIC,GACD,UAAUC;QACR,MAAMpB,IAAII,iBAAiBe;IAC7B;IAEA,OAAO;QACL,MAAMZ,QAAQa,iBAAiBC,SAAS;IAC1C;AACF;AAEA;;;;;;CAMC,GACD,SAASL,iBAAiBT,OAAwB;IAChD;;;;;GAKC,GACD,UAAUa,gBAAgBD,KAAa;QACrC,MAAMnB,IAAII,iBAAiBe;IAC7B;IAEA,OAAO,OAAOA,QAAQ,EAAE;QACtB,MAAMZ,QAAQa,iBAAiBD,OAAOE,SAAS;IACjD;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,UAAUC,aACff,OAAwB,EACxBgB,MAAc,EACdC,mBAA4C;IAE5C,MAAMC,mBAAqC,MAAMxB,OAAOE;IACxD,IAAIsB,kBAAkB;QACpB,MAAM,EAAEhB,OAAO,EAAE,GAAGe,oBAAoBE,IAAI,CAC1C,wCACAH,QACAE,iBAAiBE,EAAE;QAErB,OAAOrB,qBAAqBC,SAASkB,iBAAiBjB,IAAI,EAAEC;IAC9D;IAEA,MAAM,EAAEmB,OAAO,EAAE,GAA6B,MAAM1B,KAAKG,aAAaG,IAAI;IAC1E,MAAM,EAAEA,IAAI,EAAEmB,EAAE,EAAE,GAAGC;IAErB,MAAM,EAAEnB,OAAO,EAAE,GAAGe,oBAAoBE,IAAI,CAC1C,wCACAH,QACAI;IAGF,OAAOrB,qBAAqBC,SAASC,MAAMC;AAC7C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const EXCLUDED_SNAP_ENDOWMENTS = [];
|
|
2
|
+
export const EXCLUDED_SNAP_PERMISSIONS = [];
|
|
3
|
+
/**
|
|
4
|
+
* All unrestricted methods recognized by the `PermissionController`.
|
|
5
|
+
* Unrestricted methods are ignored by the permission system, but every
|
|
6
|
+
* JSON-RPC request seen by the permission system must correspond to a
|
|
7
|
+
* restricted or unrestricted method, or the request will be rejected with a
|
|
8
|
+
* "method not found" error.
|
|
9
|
+
*/ export const UNRESTRICTED_METHODS = Object.freeze([
|
|
10
|
+
'eth_blockNumber',
|
|
11
|
+
'eth_call',
|
|
12
|
+
'eth_chainId',
|
|
13
|
+
'eth_coinbase',
|
|
14
|
+
'eth_decrypt',
|
|
15
|
+
'eth_estimateGas',
|
|
16
|
+
'eth_feeHistory',
|
|
17
|
+
'eth_gasPrice',
|
|
18
|
+
'eth_getBalance',
|
|
19
|
+
'eth_getBlockByHash',
|
|
20
|
+
'eth_getBlockByNumber',
|
|
21
|
+
'eth_getBlockTransactionCountByHash',
|
|
22
|
+
'eth_getBlockTransactionCountByNumber',
|
|
23
|
+
'eth_getCode',
|
|
24
|
+
'eth_getEncryptionPublicKey',
|
|
25
|
+
'eth_getFilterChanges',
|
|
26
|
+
'eth_getFilterLogs',
|
|
27
|
+
'eth_getLogs',
|
|
28
|
+
'eth_getProof',
|
|
29
|
+
'eth_getStorageAt',
|
|
30
|
+
'eth_getTransactionByBlockHashAndIndex',
|
|
31
|
+
'eth_getTransactionByBlockNumberAndIndex',
|
|
32
|
+
'eth_getTransactionByHash',
|
|
33
|
+
'eth_getTransactionCount',
|
|
34
|
+
'eth_getTransactionReceipt',
|
|
35
|
+
'eth_getUncleByBlockHashAndIndex',
|
|
36
|
+
'eth_getUncleByBlockNumberAndIndex',
|
|
37
|
+
'eth_getUncleCountByBlockHash',
|
|
38
|
+
'eth_getUncleCountByBlockNumber',
|
|
39
|
+
'eth_getWork',
|
|
40
|
+
'eth_hashrate',
|
|
41
|
+
'eth_mining',
|
|
42
|
+
'eth_newBlockFilter',
|
|
43
|
+
'eth_newFilter',
|
|
44
|
+
'eth_newPendingTransactionFilter',
|
|
45
|
+
'eth_protocolVersion',
|
|
46
|
+
'eth_sendRawTransaction',
|
|
47
|
+
'eth_sendTransaction',
|
|
48
|
+
'eth_sign',
|
|
49
|
+
'eth_signTypedData',
|
|
50
|
+
'eth_signTypedData_v1',
|
|
51
|
+
'eth_signTypedData_v3',
|
|
52
|
+
'eth_signTypedData_v4',
|
|
53
|
+
'eth_submitHashrate',
|
|
54
|
+
'eth_submitWork',
|
|
55
|
+
'eth_syncing',
|
|
56
|
+
'eth_uninstallFilter',
|
|
57
|
+
'metamask_getProviderState',
|
|
58
|
+
'metamask_watchAsset',
|
|
59
|
+
'net_listening',
|
|
60
|
+
'net_peerCount',
|
|
61
|
+
'net_version',
|
|
62
|
+
'personal_ecRecover',
|
|
63
|
+
'personal_sign',
|
|
64
|
+
'wallet_watchAsset',
|
|
65
|
+
'web3_clientVersion',
|
|
66
|
+
'web3_sha3'
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=constants.js.map
|