@metamask/snaps-jest 8.1.3 → 8.2.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 +9 -1
- package/dist/{chunk-AFA4KKWW.mjs → chunk-43HRTFLS.mjs} +148 -33
- package/dist/chunk-43HRTFLS.mjs.map +1 -0
- package/dist/{chunk-2OHD2VKS.js → chunk-4MAA7WGJ.js} +8 -34
- package/dist/chunk-4MAA7WGJ.js.map +1 -0
- package/dist/{chunk-UPR3PTSA.mjs → chunk-5SGLRSWR.mjs} +8 -34
- package/dist/chunk-5SGLRSWR.mjs.map +1 -0
- package/dist/{chunk-KQBJQLZG.js → chunk-7Y27L2EV.js} +1 -1
- package/dist/chunk-7Y27L2EV.js.map +1 -0
- package/dist/{chunk-U3DVRTS2.mjs → chunk-CYPP66I7.mjs} +2 -2
- package/dist/{chunk-EDFQDZNY.js → chunk-DVDAOXO7.js} +3 -3
- package/dist/{chunk-R55KAAM4.js → chunk-GVTDUKXK.js} +148 -33
- package/dist/chunk-GVTDUKXK.js.map +1 -0
- package/dist/{chunk-3FDEYMQU.js → chunk-IVFVB4VR.js} +7 -7
- package/dist/chunk-IWJ4HKDR.mjs +50 -0
- package/dist/chunk-IWJ4HKDR.mjs.map +1 -0
- package/dist/{chunk-6V5GEUDO.mjs → chunk-MAT5SBM7.mjs} +1 -1
- package/dist/chunk-MAT5SBM7.mjs.map +1 -0
- package/dist/{chunk-K55LIE3W.mjs → chunk-NSMTFK33.mjs} +2 -2
- package/dist/{chunk-E2BYTLOT.mjs → chunk-O24GTINW.mjs} +2 -2
- package/dist/chunk-SW65QYFV.js +50 -0
- package/dist/chunk-SW65QYFV.js.map +1 -0
- package/dist/{chunk-JXAJWUVZ.js → chunk-WRKY2DLV.js} +3 -3
- package/dist/environment.js +6 -6
- package/dist/environment.mjs +5 -5
- package/dist/helpers.js +6 -6
- package/dist/helpers.mjs +5 -5
- package/dist/index.js +7 -7
- package/dist/index.mjs +6 -6
- package/dist/internals/index.js +9 -5
- package/dist/internals/index.mjs +10 -6
- package/dist/internals/request.js +5 -5
- package/dist/internals/request.mjs +4 -4
- package/dist/internals/simulation/files.js +8 -2
- package/dist/internals/simulation/files.mjs +7 -1
- package/dist/internals/simulation/index.js +8 -4
- package/dist/internals/simulation/index.mjs +9 -5
- package/dist/internals/simulation/interface.js +7 -2
- package/dist/internals/simulation/interface.mjs +8 -3
- package/dist/internals/simulation/simulation.js +3 -3
- package/dist/internals/simulation/simulation.mjs +2 -2
- package/dist/matchers.js +6 -6
- package/dist/matchers.mjs +5 -5
- package/dist/setup.js +5 -5
- package/dist/setup.mjs +5 -5
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/internals/request.d.ts +2 -1
- package/dist/types/internals/simulation/files.d.ts +36 -0
- package/dist/types/internals/simulation/interface.d.ts +39 -4
- package/dist/types/types.d.ts +32 -0
- package/package.json +8 -6
- package/dist/chunk-2OHD2VKS.js.map +0 -1
- package/dist/chunk-6V5GEUDO.mjs.map +0 -1
- package/dist/chunk-AFA4KKWW.mjs.map +0 -1
- package/dist/chunk-KQBJQLZG.js.map +0 -1
- package/dist/chunk-R55KAAM4.js.map +0 -1
- package/dist/chunk-TBDYQSRT.mjs +0 -16
- package/dist/chunk-TBDYQSRT.mjs.map +0 -1
- package/dist/chunk-TVD4SWH7.js +0 -16
- package/dist/chunk-TVD4SWH7.js.map +0 -1
- package/dist/chunk-UPR3PTSA.mjs.map +0 -1
- /package/dist/{chunk-U3DVRTS2.mjs.map → chunk-CYPP66I7.mjs.map} +0 -0
- /package/dist/{chunk-EDFQDZNY.js.map → chunk-DVDAOXO7.js.map} +0 -0
- /package/dist/{chunk-3FDEYMQU.js.map → chunk-IVFVB4VR.js.map} +0 -0
- /package/dist/{chunk-K55LIE3W.mjs.map → chunk-NSMTFK33.mjs.map} +0 -0
- /package/dist/{chunk-E2BYTLOT.mjs.map → chunk-O24GTINW.mjs.map} +0 -0
- /package/dist/{chunk-JXAJWUVZ.js.map → chunk-WRKY2DLV.js.map} +0 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
var _chunkSW65QYFVjs = require('./chunk-SW65QYFV.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
4
8
|
|
|
5
9
|
var _chunkPZDTZGSIjs = require('./chunk-PZDTZGSI.js');
|
|
6
10
|
|
|
@@ -14,6 +18,7 @@ var _snapssdk = require('@metamask/snaps-sdk');
|
|
|
14
18
|
var _snapsutils = require('@metamask/snaps-utils');
|
|
15
19
|
var _utils = require('@metamask/utils');
|
|
16
20
|
var _effects = require('redux-saga/effects');
|
|
21
|
+
var MAX_FILE_SIZE = 1e7;
|
|
17
22
|
function getInterfaceResponse(runSaga, type, content, interfaceActions) {
|
|
18
23
|
switch (type) {
|
|
19
24
|
case _snapssdk.DialogType.Alert:
|
|
@@ -137,36 +142,68 @@ async function clickElement(controllerMessenger, id, content, snapId, name) {
|
|
|
137
142
|
`Could not find an element in the interface with the name "${name}".`
|
|
138
143
|
);
|
|
139
144
|
_snapssdk.assert.call(void 0,
|
|
140
|
-
result.element.type === "Button",
|
|
141
|
-
`Expected an element of type "Button", but found "${result.element.type}".`
|
|
145
|
+
result.element.type === "Button" || result.element.type === "Checkbox",
|
|
146
|
+
`Expected an element of type "Button" or "Checkbox", but found "${result.element.type}".`
|
|
142
147
|
);
|
|
143
148
|
const { state, context } = controllerMessenger.call(
|
|
144
149
|
"SnapInterfaceController:getInterface",
|
|
145
150
|
snapId,
|
|
146
151
|
id
|
|
147
152
|
);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
153
|
+
const { type } = result.element;
|
|
154
|
+
const elementName = result.element.props.name;
|
|
155
|
+
const formState = result.form ? state[result.form] : state;
|
|
156
|
+
const currentValue = formState[elementName];
|
|
157
|
+
switch (type) {
|
|
158
|
+
case "Button": {
|
|
159
|
+
await handleEvent(
|
|
160
|
+
controllerMessenger,
|
|
161
|
+
snapId,
|
|
162
|
+
id,
|
|
163
|
+
{
|
|
164
|
+
type: _snapssdk.UserInputEventType.ButtonClickEvent,
|
|
165
|
+
name: elementName
|
|
166
|
+
},
|
|
167
|
+
context
|
|
168
|
+
);
|
|
169
|
+
if (result.form && result.element.props.type === "submit") {
|
|
170
|
+
await handleEvent(
|
|
171
|
+
controllerMessenger,
|
|
172
|
+
snapId,
|
|
173
|
+
id,
|
|
174
|
+
{
|
|
175
|
+
type: _snapssdk.UserInputEventType.FormSubmitEvent,
|
|
176
|
+
name: result.form,
|
|
177
|
+
value: state[result.form]
|
|
178
|
+
},
|
|
179
|
+
context
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case "Checkbox": {
|
|
185
|
+
const newValue = !currentValue;
|
|
186
|
+
const newState = mergeValue(state, name, newValue, result.form);
|
|
187
|
+
controllerMessenger.call(
|
|
188
|
+
"SnapInterfaceController:updateInterfaceState",
|
|
189
|
+
id,
|
|
190
|
+
newState
|
|
191
|
+
);
|
|
192
|
+
await handleEvent(
|
|
193
|
+
controllerMessenger,
|
|
194
|
+
snapId,
|
|
195
|
+
id,
|
|
196
|
+
{
|
|
197
|
+
type: _snapssdk.UserInputEventType.InputChangeEvent,
|
|
198
|
+
name: elementName,
|
|
199
|
+
value: newValue
|
|
200
|
+
},
|
|
201
|
+
context
|
|
202
|
+
);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
default:
|
|
206
|
+
_utils.assertExhaustive.call(void 0, type);
|
|
170
207
|
}
|
|
171
208
|
}
|
|
172
209
|
function mergeValue(state, name, value, form) {
|
|
@@ -267,13 +304,61 @@ async function selectInDropdown(controllerMessenger, id, content, snapId, name,
|
|
|
267
304
|
}
|
|
268
305
|
});
|
|
269
306
|
}
|
|
270
|
-
function
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
307
|
+
function getFormattedFileSize(size) {
|
|
308
|
+
return `${(size / 1e6).toFixed(2)} MB`;
|
|
309
|
+
}
|
|
310
|
+
async function uploadFile(controllerMessenger, id, content, snapId, name, file, options) {
|
|
311
|
+
const result = getElement(content, name);
|
|
312
|
+
_snapssdk.assert.call(void 0,
|
|
313
|
+
result !== void 0,
|
|
314
|
+
`Could not find an element in the interface with the name "${name}".`
|
|
275
315
|
);
|
|
276
|
-
|
|
316
|
+
_snapssdk.assert.call(void 0,
|
|
317
|
+
result.element.type === "FileInput",
|
|
318
|
+
`Expected an element of type "FileInput", but found "${result.element.type}".`
|
|
319
|
+
);
|
|
320
|
+
const { state, context } = controllerMessenger.call(
|
|
321
|
+
"SnapInterfaceController:getInterface",
|
|
322
|
+
snapId,
|
|
323
|
+
id
|
|
324
|
+
);
|
|
325
|
+
const fileSize = await _chunkSW65QYFVjs.getFileSize.call(void 0, file);
|
|
326
|
+
if (fileSize > MAX_FILE_SIZE) {
|
|
327
|
+
throw new Error(
|
|
328
|
+
`The file size (${getFormattedFileSize(
|
|
329
|
+
fileSize
|
|
330
|
+
)}) exceeds the maximum allowed size of ${getFormattedFileSize(
|
|
331
|
+
MAX_FILE_SIZE
|
|
332
|
+
)}.`
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
const fileObject = await _chunkSW65QYFVjs.getFileToUpload.call(void 0, file, options);
|
|
336
|
+
const newState = mergeValue(state, name, fileObject, result.form);
|
|
337
|
+
controllerMessenger.call(
|
|
338
|
+
"SnapInterfaceController:updateInterfaceState",
|
|
339
|
+
id,
|
|
340
|
+
newState
|
|
341
|
+
);
|
|
342
|
+
await controllerMessenger.call("ExecutionService:handleRpcRequest", snapId, {
|
|
343
|
+
origin: "",
|
|
344
|
+
handler: _snapsutils.HandlerType.OnUserInput,
|
|
345
|
+
request: {
|
|
346
|
+
jsonrpc: "2.0",
|
|
347
|
+
method: " ",
|
|
348
|
+
params: {
|
|
349
|
+
event: {
|
|
350
|
+
type: _snapssdk.UserInputEventType.FileUploadEvent,
|
|
351
|
+
name: result.element.props.name,
|
|
352
|
+
file: fileObject
|
|
353
|
+
},
|
|
354
|
+
id,
|
|
355
|
+
context
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function getInterfaceActions(snapId, controllerMessenger, { content, id }) {
|
|
361
|
+
return {
|
|
277
362
|
clickElement: async (name) => {
|
|
278
363
|
await clickElement(controllerMessenger, id, content, snapId, name);
|
|
279
364
|
},
|
|
@@ -289,10 +374,40 @@ function* getInterface(runSaga, snapId, controllerMessenger) {
|
|
|
289
374
|
name,
|
|
290
375
|
value
|
|
291
376
|
);
|
|
377
|
+
},
|
|
378
|
+
uploadFile: async (name, file, options) => {
|
|
379
|
+
await uploadFile(
|
|
380
|
+
controllerMessenger,
|
|
381
|
+
id,
|
|
382
|
+
content,
|
|
383
|
+
snapId,
|
|
384
|
+
name,
|
|
385
|
+
file,
|
|
386
|
+
options
|
|
387
|
+
);
|
|
292
388
|
}
|
|
293
389
|
};
|
|
294
|
-
return getInterfaceResponse(runSaga, type, content, interfaceActions);
|
|
295
390
|
}
|
|
391
|
+
function* getInterface(runSaga, snapId, controllerMessenger) {
|
|
392
|
+
const storedInterface = yield _effects.call.call(void 0,
|
|
393
|
+
getStoredInterface,
|
|
394
|
+
controllerMessenger,
|
|
395
|
+
snapId
|
|
396
|
+
);
|
|
397
|
+
const interfaceActions = getInterfaceActions(
|
|
398
|
+
snapId,
|
|
399
|
+
controllerMessenger,
|
|
400
|
+
storedInterface
|
|
401
|
+
);
|
|
402
|
+
return getInterfaceResponse(
|
|
403
|
+
runSaga,
|
|
404
|
+
storedInterface.type,
|
|
405
|
+
storedInterface.content,
|
|
406
|
+
interfaceActions
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
|
|
296
411
|
|
|
297
412
|
|
|
298
413
|
|
|
@@ -302,5 +417,5 @@ function* getInterface(runSaga, snapId, controllerMessenger) {
|
|
|
302
417
|
|
|
303
418
|
|
|
304
419
|
|
|
305
|
-
exports.getInterfaceResponse = getInterfaceResponse; exports.getElement = getElement; exports.clickElement = clickElement; exports.mergeValue = mergeValue; exports.typeInField = typeInField; exports.selectInDropdown = selectInDropdown; exports.getInterface = getInterface;
|
|
306
|
-
//# sourceMappingURL=chunk-
|
|
420
|
+
exports.getInterfaceResponse = getInterfaceResponse; exports.getElement = getElement; exports.clickElement = clickElement; exports.mergeValue = mergeValue; exports.typeInField = typeInField; exports.selectInDropdown = selectInDropdown; exports.uploadFile = uploadFile; exports.getInterfaceActions = getInterfaceActions; exports.getInterface = getInterface;
|
|
421
|
+
//# sourceMappingURL=chunk-GVTDUKXK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/interface.ts"],"names":["content"],"mappings":";;;;;;;;;;;AAQA,SAAS,YAAY,oBAAoB,cAAc;AAEvD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB,mBAAmB;AAG9C,SAAS,MAAM,KAAK,QAAQ,YAAY;AAexC,IAAM,gBAAgB;AAWf,SAAS,qBACd,SACA,MACA,SACA,kBACe;AACf,UAAQ,MAAM;AAAA,IACZ,KAAK,WAAW;AACd,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,IAAI,YAAY,SAAS,IAAI;AAAA,MAC/B;AAAA,IAEF,KAAK,WAAW;AACd,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QAEA,IAA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AEA,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB;AAAA,EACF;AACF","sourcesContent":["import type {\n FormState,\n InterfaceContext,\n InterfaceState,\n SnapId,\n UserInputEvent,\n File,\n} from '@metamask/snaps-sdk';\nimport { DialogType, UserInputEventType, assert } from '@metamask/snaps-sdk';\nimport type { FormElement, JSXElement } from '@metamask/snaps-sdk/jsx';\nimport {\n HandlerType,\n getJsxChildren,\n unwrapError,\n walkJsx,\n} from '@metamask/snaps-utils';\nimport { assertExhaustive, hasProperty } from '@metamask/utils';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { type SagaIterator } from 'redux-saga';\nimport { call, put, select, take } from 'redux-saga/effects';\n\nimport type {\n FileOptions,\n SnapInterface,\n SnapInterfaceActions,\n} from '../../types';\nimport type { RootControllerMessenger } from './controllers';\nimport { getFileSize, getFileToUpload } from './files';\nimport type { Interface, RunSagaFunction } from './store';\nimport { getCurrentInterface, resolveInterface, setInterface } from './store';\n\n/**\n * The maximum file size that can be uploaded.\n */\nconst MAX_FILE_SIZE = 10_000_000; // 10 MB\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 * @param interfaceActions - The actions to interact with the interface.\n * @returns The user interface object.\n */\nexport function getInterfaceResponse(\n runSaga: RunSagaFunction,\n type: DialogType,\n content: JSXElement,\n interfaceActions: SnapInterfaceActions,\n): SnapInterface {\n switch (type) {\n case DialogType.Alert:\n return {\n ...interfaceActions,\n type,\n content,\n ok: resolveWith(runSaga, null),\n };\n\n case DialogType.Confirmation:\n return {\n ...interfaceActions,\n type,\n content,\n\n ok: resolveWith(runSaga, true),\n cancel: resolveWith(runSaga, false),\n };\n\n case DialogType.Prompt:\n return {\n ...interfaceActions,\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 the stored user interface from the store.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param snapId - The Snap ID.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nfunction* getStoredInterface(\n controllerMessenger: RootControllerMessenger,\n snapId: SnapId,\n): SagaIterator<Interface & { content: JSXElement }> {\n const currentInterface: Interface | null = yield select(getCurrentInterface);\n\n if (currentInterface) {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n currentInterface.id,\n );\n\n return { ...currentInterface, content };\n }\n\n const { payload }: PayloadAction<Interface> = yield take(setInterface.type);\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n payload.id,\n );\n\n return { ...payload, content };\n}\n\n/**\n * A JSX element with a name.\n */\nexport type NamedJSXElement = JSXElement & { props: { name: string } };\n\n/**\n * Check if a JSX element is a JSX element with a given name.\n *\n * @param element - The JSX element.\n * @param name - The element name.\n * @returns True if the element is a JSX element with the given name, otherwise\n * false.\n */\nfunction isJSXElementWithName<Element extends JSXElement, Name extends string>(\n element: Element,\n name: Name,\n): element is Element & { props: { name: Name } } {\n return hasProperty(element.props, 'name') && element.props.name === name;\n}\n\n/**\n * Find an element inside a form element in a JSX tree.\n *\n * @param form - The form element.\n * @param name - The element name.\n * @returns An object containing the element and the form name if it's contained\n * in a form, otherwise undefined.\n */\nfunction getFormElement(form: FormElement, name: string) {\n const element = walkJsx<NamedJSXElement>(form, (childElement) => {\n if (isJSXElementWithName(childElement, name)) {\n return childElement;\n }\n\n return undefined;\n });\n\n if (element === undefined) {\n return undefined;\n }\n\n return { element, form: form.props.name };\n}\n\n/**\n * Get an element from a JSX tree with the given name.\n *\n * @param content - The interface content.\n * @param name - The element name.\n * @returns An object containing the element and the form name if it's contained\n * in a form, otherwise undefined.\n */\nexport function getElement(\n content: JSXElement,\n name: string,\n):\n | {\n element: NamedJSXElement;\n form?: string;\n }\n | undefined {\n if (isJSXElementWithName(content, name)) {\n return { element: content };\n }\n\n return walkJsx(content, (element) => {\n if (element.type === 'Form') {\n return getFormElement(element, name);\n }\n\n if (isJSXElementWithName(element, name)) {\n return { element };\n }\n\n return undefined;\n });\n}\n/**\n * Handle submitting event requests to OnUserInput including unwrapping potential errors.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param snapId - The Snap ID.\n * @param id - The interface ID.\n * @param event - The event to submit.\n * @param context - The interface context.\n */\nasync function handleEvent(\n controllerMessenger: RootControllerMessenger,\n snapId: SnapId,\n id: string,\n event: UserInputEvent,\n context: InterfaceContext | null,\n) {\n try {\n await controllerMessenger.call(\n 'ExecutionService:handleRpcRequest',\n snapId,\n {\n origin: '',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event,\n id,\n context,\n },\n },\n },\n );\n } catch (error) {\n const [unwrapped] = unwrapError(error);\n throw unwrapped;\n }\n}\n\n/**\n * Click on an element of the Snap interface.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface content.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n */\nexport async function clickElement(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n): Promise<void> {\n const result = getElement(content, name);\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'Button' || result.element.type === 'Checkbox',\n `Expected an element of type \"Button\" or \"Checkbox\", but found \"${result.element.type}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const { type } = result.element;\n const elementName = result.element.props.name;\n\n const formState = (result.form ? state[result.form] : state) as FormState;\n const currentValue = formState[elementName];\n\n switch (type) {\n case 'Button': {\n // Button click events are always triggered.\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.ButtonClickEvent,\n name: elementName,\n },\n context,\n );\n\n if (result.form && result.element.props.type === 'submit') {\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.FormSubmitEvent,\n name: result.form,\n value: state[result.form] as FormState,\n },\n context,\n );\n }\n break;\n }\n\n case 'Checkbox': {\n const newValue = !currentValue;\n const newState = mergeValue(state, name, newValue, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.InputChangeEvent,\n name: elementName,\n value: newValue,\n },\n context,\n );\n break;\n }\n\n /* istanbul ignore next */\n default:\n assertExhaustive(type);\n }\n}\n\n/**\n * Merge a value in the interface state.\n *\n * @param state - The actual interface state.\n * @param name - The component name that changed value.\n * @param value - The new value.\n * @param form - The form name if the element is in one.\n * @returns The state with the merged value.\n */\nexport function mergeValue(\n state: InterfaceState,\n name: string,\n value: string | File | boolean | null,\n form?: string,\n): InterfaceState {\n if (form) {\n return {\n ...state,\n [form]: {\n ...(state[form] as FormState),\n [name]: value,\n },\n };\n }\n\n return { ...state, [name]: value };\n}\n\n/**\n * Type a value in an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function typeInField(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'Input',\n `Expected an element of type \"Input\", but found \"${result.element.type}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, value, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: '',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Type a value in an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function selectInDropdown(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'Dropdown',\n `Expected an element of type \"Dropdown\", but found \"${result.element.type}\".`,\n );\n\n const options = getJsxChildren(result.element) as JSXElement[];\n const selectedOption = options.find(\n (option) =>\n hasProperty(option.props, 'value') && option.props.value === value,\n );\n\n assert(\n selectedOption !== undefined,\n `The dropdown with the name \"${name}\" does not contain \"${value}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, value, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: '',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Get a formatted file size.\n *\n * @param size - The file size in bytes.\n * @returns The formatted file size in MB, with two decimal places.\n * @example\n * getFormattedFileSize(1_000_000); // '1.00 MB'\n */\nfunction getFormattedFileSize(size: number) {\n return `${(size / 1_000_000).toFixed(2)} MB`;\n}\n\n/**\n * Upload a file to an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\nexport async function uploadFile(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'FileInput',\n `Expected an element of type \"FileInput\", but found \"${result.element.type}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const fileSize = await getFileSize(file);\n if (fileSize > MAX_FILE_SIZE) {\n throw new Error(\n `The file size (${getFormattedFileSize(\n fileSize,\n )}) exceeds the maximum allowed size of ${getFormattedFileSize(\n MAX_FILE_SIZE,\n )}.`,\n );\n }\n\n const fileObject = await getFileToUpload(file, options);\n const newState = mergeValue(state, name, fileObject, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: '',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.FileUploadEvent,\n name: result.element.props.name,\n file: fileObject,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Get the user interface actions for a Snap interface. These actions can be\n * used to interact with the interface.\n *\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param interface - The interface object.\n * @param interface.content - The interface content.\n * @param interface.id - The interface ID.\n * @returns The user interface actions.\n */\nexport function getInterfaceActions(\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n { content, id }: Omit<Interface, 'type'> & { content: JSXElement },\n): SnapInterfaceActions {\n return {\n clickElement: async (name: string) => {\n await clickElement(controllerMessenger, id, content, snapId, name);\n },\n\n typeInField: async (name: string, value: string) => {\n await typeInField(controllerMessenger, id, content, snapId, name, value);\n },\n\n selectInDropdown: async (name: string, value: string) => {\n await selectInDropdown(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n value,\n );\n },\n\n uploadFile: async (\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ) => {\n await uploadFile(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n file,\n options,\n );\n },\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 storedInterface = yield call(\n getStoredInterface,\n controllerMessenger,\n snapId,\n );\n\n const interfaceActions = getInterfaceActions(\n snapId,\n controllerMessenger,\n storedInterface,\n );\n\n return getInterfaceResponse(\n runSaga,\n storedInterface.type,\n storedInterface.content,\n interfaceActions,\n );\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunk2JTGBHPRjs = require('./chunk-2JTGBHPR.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk4MAA7WGJjs = require('./chunk-4MAA7WGJ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkTZB4LBT7js = require('./chunk-TZB4LBT7.js');
|
|
@@ -48,7 +48,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
48
48
|
chainId,
|
|
49
49
|
...transaction
|
|
50
50
|
} = _superstruct.create.call(void 0, request, _chunkYNUVT3HCjs.TransactionOptionsStruct);
|
|
51
|
-
const response = await
|
|
51
|
+
const response = await _chunk4MAA7WGJjs.handleRequest.call(void 0, {
|
|
52
52
|
snapId: installedSnapId,
|
|
53
53
|
store,
|
|
54
54
|
executionService,
|
|
@@ -69,7 +69,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
69
69
|
};
|
|
70
70
|
const onCronjob = (request) => {
|
|
71
71
|
log("Running cronjob %o.", options);
|
|
72
|
-
return
|
|
72
|
+
return _chunk4MAA7WGJjs.handleRequest.call(void 0, {
|
|
73
73
|
snapId: installedSnapId,
|
|
74
74
|
store,
|
|
75
75
|
executionService,
|
|
@@ -82,7 +82,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
82
82
|
return {
|
|
83
83
|
request: (request) => {
|
|
84
84
|
log("Sending request %o.", request);
|
|
85
|
-
return
|
|
85
|
+
return _chunk4MAA7WGJjs.handleRequest.call(void 0, {
|
|
86
86
|
snapId: installedSnapId,
|
|
87
87
|
store,
|
|
88
88
|
executionService,
|
|
@@ -100,7 +100,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
100
100
|
request,
|
|
101
101
|
_chunkYNUVT3HCjs.SignatureOptionsStruct
|
|
102
102
|
);
|
|
103
|
-
const response = await
|
|
103
|
+
const response = await _chunk4MAA7WGJjs.handleRequest.call(void 0, {
|
|
104
104
|
snapId: installedSnapId,
|
|
105
105
|
store,
|
|
106
106
|
executionService,
|
|
@@ -122,7 +122,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
122
122
|
runCronjob: onCronjob,
|
|
123
123
|
onHomePage: async () => {
|
|
124
124
|
log("Rendering home page.");
|
|
125
|
-
const response = await
|
|
125
|
+
const response = await _chunk4MAA7WGJjs.handleRequest.call(void 0, {
|
|
126
126
|
snapId: installedSnapId,
|
|
127
127
|
store,
|
|
128
128
|
executionService,
|
|
@@ -160,4 +160,4 @@ async function installSnap(snapId, options = {}) {
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
exports.installSnap = installSnap;
|
|
163
|
-
//# sourceMappingURL=chunk-
|
|
163
|
+
//# sourceMappingURL=chunk-IVFVB4VR.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/internals/simulation/files.ts
|
|
2
|
+
import { AuxiliaryFileEncoding } from "@metamask/snaps-sdk";
|
|
3
|
+
import { encodeAuxiliaryFile, normalizeRelative } from "@metamask/snaps-utils";
|
|
4
|
+
import { bytesToBase64 } from "@metamask/utils";
|
|
5
|
+
import { readFile, stat } from "fs/promises";
|
|
6
|
+
import mime from "mime";
|
|
7
|
+
import { basename, extname, resolve } from "path";
|
|
8
|
+
async function getSnapFile(files, path, encoding = AuxiliaryFileEncoding.Base64) {
|
|
9
|
+
const normalizedPath = normalizeRelative(path);
|
|
10
|
+
const base64 = files.find((file) => file.path === normalizedPath)?.toString("base64");
|
|
11
|
+
if (!base64) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return await encodeAuxiliaryFile(base64, encoding);
|
|
15
|
+
}
|
|
16
|
+
function getContentType(extension) {
|
|
17
|
+
return mime.getType(extension) ?? "application/octet-stream";
|
|
18
|
+
}
|
|
19
|
+
async function getFileSize(file) {
|
|
20
|
+
if (typeof file === "string") {
|
|
21
|
+
const { size } = await stat(resolve(process.cwd(), file));
|
|
22
|
+
return size;
|
|
23
|
+
}
|
|
24
|
+
return file.length;
|
|
25
|
+
}
|
|
26
|
+
async function getFileToUpload(file, { fileName, contentType } = {}) {
|
|
27
|
+
if (typeof file === "string") {
|
|
28
|
+
const buffer = await readFile(resolve(process.cwd(), file));
|
|
29
|
+
return {
|
|
30
|
+
name: fileName ?? basename(file),
|
|
31
|
+
size: buffer.byteLength,
|
|
32
|
+
contentType: contentType ?? getContentType(extname(file)),
|
|
33
|
+
contents: bytesToBase64(buffer)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
name: fileName ?? "",
|
|
38
|
+
size: file.length,
|
|
39
|
+
contentType: contentType ?? "application/octet-stream",
|
|
40
|
+
contents: bytesToBase64(file)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
getSnapFile,
|
|
46
|
+
getContentType,
|
|
47
|
+
getFileSize,
|
|
48
|
+
getFileToUpload
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-IWJ4HKDR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/files.ts"],"sourcesContent":["import type { File } from '@metamask/snaps-sdk';\nimport { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport type { VirtualFile } from '@metamask/snaps-utils';\nimport { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';\nimport { bytesToBase64 } from '@metamask/utils';\nimport { readFile, stat } from 'fs/promises';\nimport mime from 'mime';\nimport { basename, extname, resolve } from 'path';\n\nimport type { FileOptions } from '../../types';\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\n/**\n * Get the content type of a file based on its extension.\n *\n * @param extension - The file extension.\n * @returns The content type of the file. If the content type cannot be inferred\n * from the extension, `application/octet-stream` is returned.\n */\nexport function getContentType(extension: string) {\n return mime.getType(extension) ?? 'application/octet-stream';\n}\n\n/**\n * Get the size of a file, from a file path or a `Uint8Array`.\n *\n * @param file - The file to get the size of. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @returns The size of the file in bytes.\n */\nexport async function getFileSize(file: string | Uint8Array) {\n if (typeof file === 'string') {\n const { size } = await stat(resolve(process.cwd(), file));\n return size;\n }\n\n return file.length;\n}\n\n/**\n * Get a file object to upload, from a file path or a `Uint8Array`, with an\n * optional file name and content type.\n *\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\nexport async function getFileToUpload(\n file: string | Uint8Array,\n { fileName, contentType }: FileOptions = {},\n): Promise<File> {\n if (typeof file === 'string') {\n const buffer = await readFile(resolve(process.cwd(), file));\n\n return {\n name: fileName ?? basename(file),\n size: buffer.byteLength,\n contentType: contentType ?? getContentType(extname(file)),\n contents: bytesToBase64(buffer),\n };\n }\n\n return {\n name: fileName ?? '',\n size: file.length,\n contentType: contentType ?? 'application/octet-stream',\n contents: bytesToBase64(file),\n };\n}\n"],"mappings":";AACA,SAAS,6BAA6B;AAEtC,SAAS,qBAAqB,yBAAyB;AACvD,SAAS,qBAAqB;AAC9B,SAAS,UAAU,YAAY;AAC/B,OAAO,UAAU;AACjB,SAAS,UAAU,SAAS,eAAe;AAY3C,eAAsB,YACpB,OACA,MACA,WAAkC,sBAAsB,QACxD;AACA,QAAM,iBAAiB,kBAAkB,IAAI;AAC7C,QAAM,SAAS,MACZ,KAAK,CAAC,SAAS,KAAK,SAAS,cAAc,GAC1C,SAAS,QAAQ;AAErB,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,oBAAoB,QAAQ,QAAQ;AACnD;AASO,SAAS,eAAe,WAAmB;AAChD,SAAO,KAAK,QAAQ,SAAS,KAAK;AACpC;AAUA,eAAsB,YAAY,MAA2B;AAC3D,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,QAAQ,QAAQ,IAAI,GAAG,IAAI,CAAC;AACxD,WAAO;AAAA,EACT;AAEA,SAAO,KAAK;AACd;AAkBA,eAAsB,gBACpB,MACA,EAAE,UAAU,YAAY,IAAiB,CAAC,GAC3B;AACf,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,SAAS,MAAM,SAAS,QAAQ,QAAQ,IAAI,GAAG,IAAI,CAAC;AAE1D,WAAO;AAAA,MACL,MAAM,YAAY,SAAS,IAAI;AAAA,MAC/B,MAAM,OAAO;AAAA,MACb,aAAa,eAAe,eAAe,QAAQ,IAAI,CAAC;AAAA,MACxD,UAAU,cAAc,MAAM;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,MAAM,KAAK;AAAA,IACX,aAAa,eAAe;AAAA,IAC5B,UAAU,cAAc,IAAI;AAAA,EAC9B;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/matchers.ts"],"sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport type { MatcherFunction } from '@jest/expect';\nimport { expect } from '@jest/globals';\nimport type {\n NotificationType,\n EnumToUnion,\n ComponentOrElement,\n Component,\n} from '@metamask/snaps-sdk';\nimport type {\n GenericSnapElement,\n JSXElement,\n SnapNode,\n} from '@metamask/snaps-sdk/jsx';\nimport { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx';\nimport { getJsxElementFromComponent } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n EXPECTED_COLOR,\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: JSXElement } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\n/**\n * Serialise a JSX prop to a string.\n *\n * @param prop - The JSX prop.\n * @returns The serialised JSX prop.\n */\nfunction serialiseProp(prop: unknown): string {\n if (typeof prop === 'string') {\n return `\"${prop}\"`;\n }\n\n return `{${JSON.stringify(prop)}}`;\n}\n\n/**\n * Serialise JSX props to a string.\n *\n * @param props - The JSX props.\n * @returns The serialised JSX props.\n */\nfunction serialiseProps(props: Record<string, unknown>): string {\n return Object.entries(props)\n .filter(([key]) => key !== 'children')\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([key, value]) => ` ${key}=${serialiseProp(value)}`)\n .join('');\n}\n\n/**\n * Serialise a JSX node to a string.\n *\n * @param node - The JSX node.\n * @param indentation - The indentation level. Defaults to `0`. This should not\n * be set by the caller, as it is used for recursion.\n * @returns The serialised JSX node.\n */\nexport function serialiseJsx(node: SnapNode, indentation = 0): string {\n if (Array.isArray(node)) {\n return node.map((child) => serialiseJsx(child, indentation)).join('');\n }\n\n const indent = ' '.repeat(indentation);\n if (typeof node === 'string') {\n return `${indent}${node}\\n`;\n }\n\n if (!node) {\n return '';\n }\n\n const { type, props } = node as GenericSnapElement;\n const trailingNewline = indentation > 0 ? '\\n' : '';\n\n if (hasProperty(props, 'children')) {\n const children = serialiseJsx(props.children as SnapNode, indentation + 1);\n return `${indent}<${type}${serialiseProps(\n props,\n )}>\\n${children}${indent}</${type}>${trailingNewline}`;\n }\n\n return `${indent}<${type}${serialiseProps(props)} />${trailingNewline}`;\n}\n\nconst toRenderLegacy: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const expectedElement = getJsxElementFromComponent(expected);\n const pass = this.equals(content, expectedElement);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expectedElement, content) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: ComponentOrElement]> =\n function (actual, expected) {\n assertHasInterface(actual, 'toRender');\n\n if (!isJSXElementUnsafe(expected)) {\n return toRenderLegacy.call(this, actual, expected);\n }\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(\n serialiseJsx(expected),\n serialiseJsx(content),\n ) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n };\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"],"mappings":";;;;;;AAMA,SAAS,cAAc;AAYvB,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAE3C,SAAS,mBAAmB;AAE5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AAYnB,SAAS,2BACP,QACA,aACA,SACgC;AAChC,MAAI,CAAC,GAAG,QAAQ,kBAAkB,GAAG;AACnC,UAAM,IAAI;AAAA,MACR;AAAA,QACE,YAAY,aAAa,QAAW,QAAW,OAAO;AAAA,QACtD,GAAG;AAAA,UACD;AAAA,QACF,CAAC;AAAA,QACD,cAAc,YAAY,QAAQ,aAAa;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF;AAUA,SAAS,mBACP,QACA,aACA,SAC2C;AAC3C,MAAI,CAAC,GAAG,QAAQ,eAAe,KAA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O,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":["message"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-B73P64TE.mjs";
|
|
4
4
|
import {
|
|
5
5
|
handleInstallSnap
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-O24GTINW.mjs";
|
|
7
7
|
import {
|
|
8
8
|
startServer
|
|
9
9
|
} from "./chunk-SLU4FNKX.mjs";
|
|
@@ -101,4 +101,4 @@ export {
|
|
|
101
101
|
SnapsEnvironment,
|
|
102
102
|
environment_default
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
104
|
+
//# sourceMappingURL=chunk-NSMTFK33.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KNJNL723.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getSnapFile
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IWJ4HKDR.mjs";
|
|
7
7
|
import {
|
|
8
8
|
getOptions
|
|
9
9
|
} from "./chunk-IH7UNS5A.mjs";
|
|
@@ -131,4 +131,4 @@ export {
|
|
|
131
131
|
getHooks,
|
|
132
132
|
registerActions
|
|
133
133
|
};
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
//# sourceMappingURL=chunk-O24GTINW.mjs.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/internals/simulation/files.ts
|
|
2
|
+
var _snapssdk = require('@metamask/snaps-sdk');
|
|
3
|
+
var _snapsutils = require('@metamask/snaps-utils');
|
|
4
|
+
var _utils = require('@metamask/utils');
|
|
5
|
+
var _promises = require('fs/promises');
|
|
6
|
+
var _mime = require('mime'); var _mime2 = _interopRequireDefault(_mime);
|
|
7
|
+
var _path = require('path');
|
|
8
|
+
async function getSnapFile(files, path, encoding = _snapssdk.AuxiliaryFileEncoding.Base64) {
|
|
9
|
+
const normalizedPath = _snapsutils.normalizeRelative.call(void 0, path);
|
|
10
|
+
const base64 = files.find((file) => file.path === normalizedPath)?.toString("base64");
|
|
11
|
+
if (!base64) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return await _snapsutils.encodeAuxiliaryFile.call(void 0, base64, encoding);
|
|
15
|
+
}
|
|
16
|
+
function getContentType(extension) {
|
|
17
|
+
return _mime2.default.getType(extension) ?? "application/octet-stream";
|
|
18
|
+
}
|
|
19
|
+
async function getFileSize(file) {
|
|
20
|
+
if (typeof file === "string") {
|
|
21
|
+
const { size } = await _promises.stat.call(void 0, _path.resolve.call(void 0, process.cwd(), file));
|
|
22
|
+
return size;
|
|
23
|
+
}
|
|
24
|
+
return file.length;
|
|
25
|
+
}
|
|
26
|
+
async function getFileToUpload(file, { fileName, contentType } = {}) {
|
|
27
|
+
if (typeof file === "string") {
|
|
28
|
+
const buffer = await _promises.readFile.call(void 0, _path.resolve.call(void 0, process.cwd(), file));
|
|
29
|
+
return {
|
|
30
|
+
name: fileName ?? _path.basename.call(void 0, file),
|
|
31
|
+
size: buffer.byteLength,
|
|
32
|
+
contentType: contentType ?? getContentType(_path.extname.call(void 0, file)),
|
|
33
|
+
contents: _utils.bytesToBase64.call(void 0, buffer)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
name: fileName ?? "",
|
|
38
|
+
size: file.length,
|
|
39
|
+
contentType: contentType ?? "application/octet-stream",
|
|
40
|
+
contents: _utils.bytesToBase64.call(void 0, file)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
exports.getSnapFile = getSnapFile; exports.getContentType = getContentType; exports.getFileSize = getFileSize; exports.getFileToUpload = getFileToUpload;
|
|
50
|
+
//# source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ACF","sourcesContent":["import type { File } from '@metamask/snaps-sdk';\nimport { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport type { VirtualFile } from '@metamask/snaps-utils';\nimport { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';\nimport { bytesToBase64 } from '@metamask/utils';\nimport { readFile, stat } from 'fs/promises';\nimport mime from 'mime';\nimport { basename, extname, resolve } from 'path';\n\nimport type { FileOptions } from '../../types';\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\n/**\n * Get the content type of a file based on its extension.\n *\n * @param extension - The file extension.\n * @returns The content type of the file. If the content type cannot be inferred\n * from the extension, `application/octet-stream` is returned.\n */\nexport function getContentType(extension: string) {\n return mime.getType(extension) ?? 'application/octet-stream';\n}\n\n/**\n * Get the size of a file, from a file path or a `Uint8Array`.\n *\n * @param file - The file to get the size of. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @returns The size of the file in bytes.\n */\nexport async function getFileSize(file: string | Uint8Array) {\n if (typeof file === 'string') {\n const { size } = await stat(resolve(process.cwd(), file));\n return size;\n }\n\n return file.length;\n}\n\n/**\n * Get a file object to upload, from a file path or a `Uint8Array`, with an\n * optional file name and content type.\n *\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\nexport async function getFileToUpload(\n file: string | Uint8Array,\n { fileName, contentType }: FileOptions = {},\n): Promise<File> {\n if (typeof file === 'string') {\n const buffer = await readFile(resolve(process.cwd(), file));\n\n return {\n name: fileName ?? basename(file),\n size: buffer.byteLength,\n contentType: contentType ?? getContentType(extname(file)),\n contents: bytesToBase64(buffer),\n };\n }\n\n return {\n name: fileName ?? '',\n size: file.length,\n contentType: contentType ?? 'application/octet-stream',\n contents: bytesToBase64(file),\n };\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkT2PHS5FYjs = require('./chunk-T2PHS5FY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkDVDAOXO7js = require('./chunk-DVDAOXO7.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkN6MAO223js = require('./chunk-N6MAO223.js');
|
|
@@ -72,7 +72,7 @@ var SnapsEnvironment = class extends _jestenvironmentnode2.default {
|
|
|
72
72
|
*/
|
|
73
73
|
async installSnap(snapId = this.snapId, options = {}) {
|
|
74
74
|
await _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance)?.executionService.terminateAllSnaps();
|
|
75
|
-
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _instance, await
|
|
75
|
+
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _instance, await _chunkDVDAOXO7js.handleInstallSnap.call(void 0, snapId, options));
|
|
76
76
|
return _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance);
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -101,4 +101,4 @@ var environment_default = SnapsEnvironment;
|
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
exports.SnapsEnvironment = SnapsEnvironment; exports.environment_default = environment_default;
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
104
|
+
//# sourceMappingURL=chunk-WRKY2DLV.js.map
|
package/dist/environment.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkWRKY2DLVjs = require('./chunk-WRKY2DLV.js');
|
|
5
5
|
require('./chunk-T2PHS5FY.js');
|
|
6
6
|
require('./chunk-HROOL3VI.js');
|
|
7
7
|
require('./chunk-2JTGBHPR.js');
|
|
8
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-4MAA7WGJ.js');
|
|
9
9
|
require('./chunk-GECE47HW.js');
|
|
10
|
-
require('./chunk-
|
|
11
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-GVTDUKXK.js');
|
|
11
|
+
require('./chunk-DVDAOXO7.js');
|
|
12
12
|
require('./chunk-ZTX624YO.js');
|
|
13
13
|
require('./chunk-XWGECIXI.js');
|
|
14
14
|
require('./chunk-WHGYMK5B.js');
|
|
@@ -16,7 +16,7 @@ require('./chunk-Y3JC4WGW.js');
|
|
|
16
16
|
require('./chunk-WDYPMEZB.js');
|
|
17
17
|
require('./chunk-3FNLFVV2.js');
|
|
18
18
|
require('./chunk-EMTW3H54.js');
|
|
19
|
-
require('./chunk-
|
|
19
|
+
require('./chunk-SW65QYFV.js');
|
|
20
20
|
require('./chunk-VXPCUDBI.js');
|
|
21
21
|
require('./chunk-N6MAO223.js');
|
|
22
22
|
require('./chunk-TZB4LBT7.js');
|
|
@@ -42,5 +42,5 @@ require('./chunk-PHUTP7NB.js');
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
exports.SnapsEnvironment =
|
|
45
|
+
exports.SnapsEnvironment = _chunkWRKY2DLVjs.SnapsEnvironment; exports.default = _chunkWRKY2DLVjs.environment_default;
|
|
46
46
|
//# sourceMappingURL=environment.js.map
|
package/dist/environment.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SnapsEnvironment,
|
|
3
3
|
environment_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NSMTFK33.mjs";
|
|
5
5
|
import "./chunk-B73P64TE.mjs";
|
|
6
6
|
import "./chunk-MF43OG3Z.mjs";
|
|
7
7
|
import "./chunk-XK5HPZZC.mjs";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-5SGLRSWR.mjs";
|
|
9
9
|
import "./chunk-5ZFHFICZ.mjs";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-43HRTFLS.mjs";
|
|
11
|
+
import "./chunk-O24GTINW.mjs";
|
|
12
12
|
import "./chunk-ZG33OGC3.mjs";
|
|
13
13
|
import "./chunk-KNJNL723.mjs";
|
|
14
14
|
import "./chunk-6HHV6YFQ.mjs";
|
|
@@ -16,7 +16,7 @@ import "./chunk-Q2OQXAUM.mjs";
|
|
|
16
16
|
import "./chunk-VOYBI6T4.mjs";
|
|
17
17
|
import "./chunk-IXKO6X55.mjs";
|
|
18
18
|
import "./chunk-FP4H3ADT.mjs";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-IWJ4HKDR.mjs";
|
|
20
20
|
import "./chunk-IH7UNS5A.mjs";
|
|
21
21
|
import "./chunk-SLU4FNKX.mjs";
|
|
22
22
|
import "./chunk-J4ZPUCLX.mjs";
|