@metamask/snaps-simulation 3.1.0 → 3.3.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/constants.cjs +37 -1
  3. package/dist/constants.cjs.map +1 -1
  4. package/dist/constants.d.cts +12 -0
  5. package/dist/constants.d.cts.map +1 -1
  6. package/dist/constants.d.mts +12 -0
  7. package/dist/constants.d.mts.map +1 -1
  8. package/dist/constants.mjs +36 -0
  9. package/dist/constants.mjs.map +1 -1
  10. package/dist/controllers.cjs +4 -0
  11. package/dist/controllers.cjs.map +1 -1
  12. package/dist/controllers.d.cts.map +1 -1
  13. package/dist/controllers.d.mts.map +1 -1
  14. package/dist/controllers.mjs +4 -0
  15. package/dist/controllers.mjs.map +1 -1
  16. package/dist/helpers.cjs +13 -0
  17. package/dist/helpers.cjs.map +1 -1
  18. package/dist/helpers.d.cts.map +1 -1
  19. package/dist/helpers.d.mts.map +1 -1
  20. package/dist/helpers.mjs +13 -0
  21. package/dist/helpers.mjs.map +1 -1
  22. package/dist/interface.cjs +65 -16
  23. package/dist/interface.cjs.map +1 -1
  24. package/dist/interface.d.cts +34 -7
  25. package/dist/interface.d.cts.map +1 -1
  26. package/dist/interface.d.mts +34 -7
  27. package/dist/interface.d.mts.map +1 -1
  28. package/dist/interface.mjs +65 -17
  29. package/dist/interface.mjs.map +1 -1
  30. package/dist/options.cjs +14 -0
  31. package/dist/options.cjs.map +1 -1
  32. package/dist/options.d.cts +68 -0
  33. package/dist/options.d.cts.map +1 -1
  34. package/dist/options.d.mts +68 -0
  35. package/dist/options.d.mts.map +1 -1
  36. package/dist/options.mjs +17 -3
  37. package/dist/options.mjs.map +1 -1
  38. package/dist/request.cjs +7 -5
  39. package/dist/request.cjs.map +1 -1
  40. package/dist/request.d.cts +6 -2
  41. package/dist/request.d.cts.map +1 -1
  42. package/dist/request.d.mts +6 -2
  43. package/dist/request.d.mts.map +1 -1
  44. package/dist/request.mjs +7 -5
  45. package/dist/request.mjs.map +1 -1
  46. package/dist/simulation.cjs +38 -2
  47. package/dist/simulation.cjs.map +1 -1
  48. package/dist/simulation.d.cts +4 -2
  49. package/dist/simulation.d.cts.map +1 -1
  50. package/dist/simulation.d.mts +4 -2
  51. package/dist/simulation.d.mts.map +1 -1
  52. package/dist/simulation.mjs +38 -2
  53. package/dist/simulation.mjs.map +1 -1
  54. package/dist/structs.d.cts +14 -14
  55. package/dist/structs.d.mts +14 -14
  56. package/dist/types.cjs.map +1 -1
  57. package/dist/types.d.cts +2 -2
  58. package/dist/types.d.mts +2 -2
  59. package/dist/types.mjs.map +1 -1
  60. package/dist/utils/account.cjs +21 -0
  61. package/dist/utils/account.cjs.map +1 -0
  62. package/dist/utils/account.d.cts +26 -0
  63. package/dist/utils/account.d.cts.map +1 -0
  64. package/dist/utils/account.d.mts +26 -0
  65. package/dist/utils/account.d.mts.map +1 -0
  66. package/dist/utils/account.mjs +17 -0
  67. package/dist/utils/account.mjs.map +1 -0
  68. package/package.json +8 -8
@@ -1,9 +1,10 @@
1
1
  import type { DialogApprovalTypes } from "@metamask/snaps-rpc-methods";
2
- import type { InterfaceState, SnapId, File } from "@metamask/snaps-sdk";
2
+ import type { InterfaceState, SnapId, File, AccountSelectorState, AssetSelectorState } from "@metamask/snaps-sdk";
3
3
  import { DialogType } from "@metamask/snaps-sdk";
4
4
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
5
5
  import { type SagaIterator } from "redux-saga";
6
6
  import type { RootControllerMessenger } from "./controllers.cjs";
7
+ import type { SimulationOptions } from "./options.cjs";
7
8
  import type { Interface, RunSagaFunction } from "./store/index.cjs";
8
9
  import type { FileOptions, SnapHandlerInterface, SnapInterface, SnapInterfaceActions } from "./types.cjs";
9
10
  /**
@@ -71,7 +72,7 @@ export declare function clickElement(controllerMessenger: RootControllerMessenge
71
72
  * @param form - The form name if the element is in one.
72
73
  * @returns The state with the merged value.
73
74
  */
74
- export declare function mergeValue(state: InterfaceState, name: string, value: string | File | boolean | null, form?: string): InterfaceState;
75
+ export declare function mergeValue(state: InterfaceState, name: string, value: string | File | boolean | AccountSelectorState | AssetSelectorState | null, form?: string): InterfaceState;
75
76
  /**
76
77
  * Type a value in an interface element.
77
78
  *
@@ -106,26 +107,50 @@ export declare function selectInDropdown(controllerMessenger: RootControllerMess
106
107
  */
107
108
  export declare function selectFromRadioGroup(controllerMessenger: RootControllerMessenger, id: string, content: JSXElement, snapId: SnapId, name: string, value: string): Promise<void>;
108
109
  /**
109
- * Choose an option with value from Selector interface element.
110
+ * Get the value from a Selector interface element.
111
+ *
112
+ * @param element - The Selector element to get the value from.
113
+ * @param options - The simulation options.
114
+ * @param value - The value to get from the Selector.
115
+ *
116
+ * @returns The value from the Selector element.
117
+ */
118
+ export declare function getValueFromSelector(element: NamedJSXElement, options: SimulationOptions, value: string): string | {
119
+ accountId: string;
120
+ addresses: `${string}:${string}:${string}`[];
121
+ asset?: undefined;
122
+ name?: undefined;
123
+ symbol?: undefined;
124
+ } | {
125
+ asset: `${string}:${string}/${string}:${string}`;
126
+ name: string;
127
+ symbol: string;
128
+ accountId?: undefined;
129
+ addresses?: undefined;
130
+ };
131
+ /**
132
+ * Choose an option with value from a Selector interface element.
110
133
  *
111
134
  * @param controllerMessenger - The controller messenger used to call actions.
135
+ * @param options - The simulation options.
112
136
  * @param id - The interface ID.
113
137
  * @param content - The interface Components.
114
138
  * @param snapId - The Snap ID.
115
139
  * @param name - The element name.
116
140
  * @param value - The value to type in the element.
117
141
  */
118
- export declare function selectFromSelector(controllerMessenger: RootControllerMessenger, id: string, content: JSXElement, snapId: SnapId, name: string, value: string): Promise<void>;
142
+ export declare function selectFromSelector(controllerMessenger: RootControllerMessenger, options: SimulationOptions, id: string, content: JSXElement, snapId: SnapId, name: string, value: string): Promise<void>;
119
143
  /**
120
144
  * Wait for an interface to be updated.
121
145
  *
122
146
  * @param controllerMessenger - The controller messenger used to call actions.
147
+ * @param options - The simulation options.
123
148
  * @param snapId - The Snap ID.
124
149
  * @param id - The interface ID.
125
150
  * @param originalContent - The original interface content.
126
151
  * @returns A promise that resolves to the updated interface.
127
152
  */
128
- export declare function waitForUpdate(controllerMessenger: RootControllerMessenger, snapId: SnapId, id: string, originalContent: JSXElement): Promise<SnapHandlerInterface>;
153
+ export declare function waitForUpdate(controllerMessenger: RootControllerMessenger, options: SimulationOptions, snapId: SnapId, id: string, originalContent: JSXElement): Promise<SnapHandlerInterface>;
129
154
  /**
130
155
  * Upload a file to an interface element.
131
156
  *
@@ -153,12 +178,13 @@ export declare function uploadFile(controllerMessenger: RootControllerMessenger,
153
178
  *
154
179
  * @param snapId - The Snap ID.
155
180
  * @param controllerMessenger - The controller messenger used to call actions.
181
+ * @param simulationOptions - The simulation options.
156
182
  * @param interface - The interface object.
157
183
  * @param interface.content - The interface content.
158
184
  * @param interface.id - The interface ID.
159
185
  * @returns The user interface actions.
160
186
  */
161
- export declare function getInterfaceActions(snapId: SnapId, controllerMessenger: RootControllerMessenger, { content, id }: Omit<Interface, 'type'> & {
187
+ export declare function getInterfaceActions(snapId: SnapId, controllerMessenger: RootControllerMessenger, simulationOptions: SimulationOptions, { content, id }: Omit<Interface, 'type'> & {
162
188
  content: JSXElement;
163
189
  }): SnapInterfaceActions;
164
190
  /**
@@ -167,8 +193,9 @@ export declare function getInterfaceActions(snapId: SnapId, controllerMessenger:
167
193
  * @param runSaga - A function to run a saga outside the usual Redux flow.
168
194
  * @param snapId - The Snap ID.
169
195
  * @param controllerMessenger - The controller messenger used to call actions.
196
+ * @param options - The simulation options.
170
197
  * @yields Takes the set interface action.
171
198
  * @returns The user interface object.
172
199
  */
173
- export declare function getInterface(runSaga: RunSagaFunction, snapId: SnapId, controllerMessenger: RootControllerMessenger): SagaIterator;
200
+ export declare function getInterface(runSaga: RunSagaFunction, snapId: SnapId, controllerMessenger: RootControllerMessenger, options: SimulationOptions): SagaIterator;
174
201
  //# sourceMappingURL=interface.d.cts.map
@@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mB,EAAE,uBAAuB,EAC5C,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,OAAO,CAAC,EAAE,WAAW,iBAyDtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,EAC5C,iBAAiB,EAAE,iBAAiB,EACpC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,GACjE,oBAAoB,CAqEtB;AAED;;;;;;;;;GASG;AACH,wBAAiB,YAAY,CAC3B,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,iBAAiB,GACzB,YAAY,CAqBd"}
@@ -1,9 +1,10 @@
1
1
  import type { DialogApprovalTypes } from "@metamask/snaps-rpc-methods";
2
- import type { InterfaceState, SnapId, File } from "@metamask/snaps-sdk";
2
+ import type { InterfaceState, SnapId, File, AccountSelectorState, AssetSelectorState } from "@metamask/snaps-sdk";
3
3
  import { DialogType } from "@metamask/snaps-sdk";
4
4
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
5
5
  import { type SagaIterator } from "redux-saga";
6
6
  import type { RootControllerMessenger } from "./controllers.mjs";
7
+ import type { SimulationOptions } from "./options.mjs";
7
8
  import type { Interface, RunSagaFunction } from "./store/index.mjs";
8
9
  import type { FileOptions, SnapHandlerInterface, SnapInterface, SnapInterfaceActions } from "./types.mjs";
9
10
  /**
@@ -71,7 +72,7 @@ export declare function clickElement(controllerMessenger: RootControllerMessenge
71
72
  * @param form - The form name if the element is in one.
72
73
  * @returns The state with the merged value.
73
74
  */
74
- export declare function mergeValue(state: InterfaceState, name: string, value: string | File | boolean | null, form?: string): InterfaceState;
75
+ export declare function mergeValue(state: InterfaceState, name: string, value: string | File | boolean | AccountSelectorState | AssetSelectorState | null, form?: string): InterfaceState;
75
76
  /**
76
77
  * Type a value in an interface element.
77
78
  *
@@ -106,26 +107,50 @@ export declare function selectInDropdown(controllerMessenger: RootControllerMess
106
107
  */
107
108
  export declare function selectFromRadioGroup(controllerMessenger: RootControllerMessenger, id: string, content: JSXElement, snapId: SnapId, name: string, value: string): Promise<void>;
108
109
  /**
109
- * Choose an option with value from Selector interface element.
110
+ * Get the value from a Selector interface element.
111
+ *
112
+ * @param element - The Selector element to get the value from.
113
+ * @param options - The simulation options.
114
+ * @param value - The value to get from the Selector.
115
+ *
116
+ * @returns The value from the Selector element.
117
+ */
118
+ export declare function getValueFromSelector(element: NamedJSXElement, options: SimulationOptions, value: string): string | {
119
+ accountId: string;
120
+ addresses: `${string}:${string}:${string}`[];
121
+ asset?: undefined;
122
+ name?: undefined;
123
+ symbol?: undefined;
124
+ } | {
125
+ asset: `${string}:${string}/${string}:${string}`;
126
+ name: string;
127
+ symbol: string;
128
+ accountId?: undefined;
129
+ addresses?: undefined;
130
+ };
131
+ /**
132
+ * Choose an option with value from a Selector interface element.
110
133
  *
111
134
  * @param controllerMessenger - The controller messenger used to call actions.
135
+ * @param options - The simulation options.
112
136
  * @param id - The interface ID.
113
137
  * @param content - The interface Components.
114
138
  * @param snapId - The Snap ID.
115
139
  * @param name - The element name.
116
140
  * @param value - The value to type in the element.
117
141
  */
118
- export declare function selectFromSelector(controllerMessenger: RootControllerMessenger, id: string, content: JSXElement, snapId: SnapId, name: string, value: string): Promise<void>;
142
+ export declare function selectFromSelector(controllerMessenger: RootControllerMessenger, options: SimulationOptions, id: string, content: JSXElement, snapId: SnapId, name: string, value: string): Promise<void>;
119
143
  /**
120
144
  * Wait for an interface to be updated.
121
145
  *
122
146
  * @param controllerMessenger - The controller messenger used to call actions.
147
+ * @param options - The simulation options.
123
148
  * @param snapId - The Snap ID.
124
149
  * @param id - The interface ID.
125
150
  * @param originalContent - The original interface content.
126
151
  * @returns A promise that resolves to the updated interface.
127
152
  */
128
- export declare function waitForUpdate(controllerMessenger: RootControllerMessenger, snapId: SnapId, id: string, originalContent: JSXElement): Promise<SnapHandlerInterface>;
153
+ export declare function waitForUpdate(controllerMessenger: RootControllerMessenger, options: SimulationOptions, snapId: SnapId, id: string, originalContent: JSXElement): Promise<SnapHandlerInterface>;
129
154
  /**
130
155
  * Upload a file to an interface element.
131
156
  *
@@ -153,12 +178,13 @@ export declare function uploadFile(controllerMessenger: RootControllerMessenger,
153
178
  *
154
179
  * @param snapId - The Snap ID.
155
180
  * @param controllerMessenger - The controller messenger used to call actions.
181
+ * @param simulationOptions - The simulation options.
156
182
  * @param interface - The interface object.
157
183
  * @param interface.content - The interface content.
158
184
  * @param interface.id - The interface ID.
159
185
  * @returns The user interface actions.
160
186
  */
161
- export declare function getInterfaceActions(snapId: SnapId, controllerMessenger: RootControllerMessenger, { content, id }: Omit<Interface, 'type'> & {
187
+ export declare function getInterfaceActions(snapId: SnapId, controllerMessenger: RootControllerMessenger, simulationOptions: SimulationOptions, { content, id }: Omit<Interface, 'type'> & {
162
188
  content: JSXElement;
163
189
  }): SnapInterfaceActions;
164
190
  /**
@@ -167,8 +193,9 @@ export declare function getInterfaceActions(snapId: SnapId, controllerMessenger:
167
193
  * @param runSaga - A function to run a saga outside the usual Redux flow.
168
194
  * @param snapId - The Snap ID.
169
195
  * @param controllerMessenger - The controller messenger used to call actions.
196
+ * @param options - The simulation options.
170
197
  * @yields Takes the set interface action.
171
198
  * @returns The user interface object.
172
199
  */
173
- export declare function getInterface(runSaga: RunSagaFunction, snapId: SnapId, controllerMessenger: RootControllerMessenger): SagaIterator;
200
+ export declare function getInterface(runSaga: RunSagaFunction, snapId: SnapId, controllerMessenger: RootControllerMessenger, options: SimulationOptions): SagaIterator;
174
201
  //# sourceMappingURL=interface.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.mts","sourceRo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,EACV,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,OAAO,CAAC,EAAE,WAAW,iBAyDtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,EAC5C,iBAAiB,EAAE,iBAAiB,EACpC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,GACjE,oBAAoB,CAqEtB;AAED;;;;;;;;;GASG;AACH,wBAAiB,YAAY,CAC3B,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,iBAAiB,GACzB,YAAY,CAqBd"}
@@ -6,8 +6,8 @@ function $importDefault(module) {
6
6
  }
7
7
  import { DIALOG_APPROVAL_TYPES } from "@metamask/snaps-rpc-methods";
8
8
  import { DialogType, UserInputEventType, assert } from "@metamask/snaps-sdk";
9
- import { HandlerType, getJsxChildren, unwrapError, walkJsx } from "@metamask/snaps-utils";
10
- import { assertExhaustive, hasProperty } from "@metamask/utils";
9
+ import { HandlerType, createAccountList, createChainIdList, getJsxChildren, unwrapError, walkJsx } from "@metamask/snaps-utils";
10
+ import { assertExhaustive, hasProperty, parseCaipAccountId } from "@metamask/utils";
11
11
  import $deepEqual from "fast-deep-equal";
12
12
  const deepEqual = $importDefault($deepEqual);
13
13
  import { call, put, select, take } from "redux-saga/effects";
@@ -19,6 +19,10 @@ import { formatTypeErrorMessage } from "./utils/errors.mjs";
19
19
  * The maximum file size that can be uploaded.
20
20
  */
21
21
  const MAX_FILE_SIZE = 10000000; // 10 MB
22
+ /**
23
+ * The elements based on the Selector component.
24
+ */
25
+ const SELECTOR_ELEMENTS = ['Selector', 'AccountSelector', 'AssetSelector'];
22
26
  /**
23
27
  * Get a user interface object from a type and content object.
24
28
  *
@@ -457,24 +461,65 @@ export async function selectFromRadioGroup(controllerMessenger, id, content, sna
457
461
  });
458
462
  }
459
463
  /**
460
- * Choose an option with value from Selector interface element.
464
+ * Get the value from a Selector interface element.
465
+ *
466
+ * @param element - The Selector element to get the value from.
467
+ * @param options - The simulation options.
468
+ * @param value - The value to get from the Selector.
469
+ *
470
+ * @returns The value from the Selector element.
471
+ */
472
+ export function getValueFromSelector(element, options, value) {
473
+ switch (element.type) {
474
+ case 'Selector': {
475
+ const selectorOptions = getJsxChildren(element);
476
+ const selectedOption = selectorOptions.find((option) => hasProperty(option.props, 'value') && option.props.value === value);
477
+ assert(selectedOption !== undefined, `The Selector with the name "${element.props.name}" does not contain "${value}".`);
478
+ return value;
479
+ }
480
+ case 'AccountSelector': {
481
+ const { accounts } = options;
482
+ const selectedAccount = accounts.find((account) => account.id === value);
483
+ assert(selectedAccount !== undefined, `The AccountSelector with the name "${element.props.name}" does not contain an account with ID "${value}".`);
484
+ return {
485
+ accountId: selectedAccount.id,
486
+ addresses: createAccountList(selectedAccount.address, createChainIdList(selectedAccount.scopes, element.props.chainIds)),
487
+ };
488
+ }
489
+ case 'AssetSelector': {
490
+ const { assets, accounts } = options;
491
+ const selectedAsset = assets[value];
492
+ const { address } = parseCaipAccountId(element.props.addresses[0]);
493
+ const account = accounts.find((simulationAccount) => simulationAccount.address === address);
494
+ const accountHasAsset = account?.assets?.some((asset) => asset === value);
495
+ assert(selectedAsset !== undefined && accountHasAsset, `The AssetSelector with the name "${element.props.name}" does not contain an asset with ID "${value}".`);
496
+ return {
497
+ asset: value,
498
+ name: selectedAsset.name,
499
+ symbol: selectedAsset.symbol,
500
+ };
501
+ }
502
+ default:
503
+ throw new Error(`Expected an element of type ${formatTypeErrorMessage(SELECTOR_ELEMENTS)}, but found "${element.type}".`);
504
+ }
505
+ }
506
+ /**
507
+ * Choose an option with value from a Selector interface element.
461
508
  *
462
509
  * @param controllerMessenger - The controller messenger used to call actions.
510
+ * @param options - The simulation options.
463
511
  * @param id - The interface ID.
464
512
  * @param content - The interface Components.
465
513
  * @param snapId - The Snap ID.
466
514
  * @param name - The element name.
467
515
  * @param value - The value to type in the element.
468
516
  */
469
- export async function selectFromSelector(controllerMessenger, id, content, snapId, name, value) {
517
+ export async function selectFromSelector(controllerMessenger, options, id, content, snapId, name, value) {
470
518
  const result = getElement(content, name);
471
519
  assert(result !== undefined, `Could not find an element in the interface with the name "${name}".`);
472
- assert(result.element.type === 'Selector', `Expected an element of type "Selector", but found "${result.element.type}".`);
473
- const options = getJsxChildren(result.element);
474
- const selectedOption = options.find((option) => hasProperty(option.props, 'value') && option.props.value === value);
475
- assert(selectedOption !== undefined, `The Selector with the name "${name}" does not contain "${value}".`);
520
+ const selectedValue = getValueFromSelector(result.element, options, value);
476
521
  const { state, context } = controllerMessenger.call('SnapInterfaceController:getInterface', snapId, id);
477
- const newState = mergeValue(state, name, value, result.form);
522
+ const newState = mergeValue(state, name, selectedValue, result.form);
478
523
  controllerMessenger.call('SnapInterfaceController:updateInterfaceState', id, newState);
479
524
  await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {
480
525
  origin: 'metamask',
@@ -486,7 +531,7 @@ export async function selectFromSelector(controllerMessenger, id, content, snapI
486
531
  event: {
487
532
  type: UserInputEventType.InputChangeEvent,
488
533
  name: result.element.props.name,
489
- value,
534
+ value: selectedValue,
490
535
  },
491
536
  id,
492
537
  context,
@@ -498,19 +543,20 @@ export async function selectFromSelector(controllerMessenger, id, content, snapI
498
543
  * Wait for an interface to be updated.
499
544
  *
500
545
  * @param controllerMessenger - The controller messenger used to call actions.
546
+ * @param options - The simulation options.
501
547
  * @param snapId - The Snap ID.
502
548
  * @param id - The interface ID.
503
549
  * @param originalContent - The original interface content.
504
550
  * @returns A promise that resolves to the updated interface.
505
551
  */
506
- export async function waitForUpdate(controllerMessenger, snapId, id, originalContent) {
552
+ export async function waitForUpdate(controllerMessenger, options, snapId, id, originalContent) {
507
553
  return new Promise((resolve) => {
508
554
  const listener = (state) => {
509
555
  const currentInterface = state.interfaces[id];
510
556
  const newContent = currentInterface?.content;
511
557
  if (!deepEqual(originalContent, newContent)) {
512
558
  controllerMessenger.unsubscribe('SnapInterfaceController:stateChange', listener);
513
- const actions = getInterfaceActions(snapId, controllerMessenger, {
559
+ const actions = getInterfaceActions(snapId, controllerMessenger, options, {
514
560
  content: newContent,
515
561
  id,
516
562
  });
@@ -587,12 +633,13 @@ export async function uploadFile(controllerMessenger, id, content, snapId, name,
587
633
  *
588
634
  * @param snapId - The Snap ID.
589
635
  * @param controllerMessenger - The controller messenger used to call actions.
636
+ * @param simulationOptions - The simulation options.
590
637
  * @param interface - The interface object.
591
638
  * @param interface.content - The interface content.
592
639
  * @param interface.id - The interface ID.
593
640
  * @returns The user interface actions.
594
641
  */
595
- export function getInterfaceActions(snapId, controllerMessenger, { content, id }) {
642
+ export function getInterfaceActions(snapId, controllerMessenger, simulationOptions, { content, id }) {
596
643
  return {
597
644
  clickElement: async (name) => {
598
645
  await clickElement(controllerMessenger, id, content, snapId, name);
@@ -607,12 +654,12 @@ export function getInterfaceActions(snapId, controllerMessenger, { content, id }
607
654
  await selectFromRadioGroup(controllerMessenger, id, content, snapId, name, value);
608
655
  },
609
656
  selectFromSelector: async (name, value) => {
610
- await selectFromSelector(controllerMessenger, id, content, snapId, name, value);
657
+ await selectFromSelector(controllerMessenger, simulationOptions, id, content, snapId, name, value);
611
658
  },
612
659
  uploadFile: async (name, file, options) => {
613
660
  await uploadFile(controllerMessenger, id, content, snapId, name, file, options);
614
661
  },
615
- waitForUpdate: async () => waitForUpdate(controllerMessenger, snapId, id, content),
662
+ waitForUpdate: async () => waitForUpdate(controllerMessenger, simulationOptions, snapId, id, content),
616
663
  };
617
664
  }
618
665
  /**
@@ -621,12 +668,13 @@ export function getInterfaceActions(snapId, controllerMessenger, { content, id }
621
668
  * @param runSaga - A function to run a saga outside the usual Redux flow.
622
669
  * @param snapId - The Snap ID.
623
670
  * @param controllerMessenger - The controller messenger used to call actions.
671
+ * @param options - The simulation options.
624
672
  * @yields Takes the set interface action.
625
673
  * @returns The user interface object.
626
674
  */
627
- export function* getInterface(runSaga, snapId, controllerMessenger) {
675
+ export function* getInterface(runSaga, snapId, controllerMessenger, options) {
628
676
  const storedInterface = yield call(getStoredInterface, controllerMessenger, snapId);
629
- const interfaceActions = getInterfaceActions(snapId, controllerMessenger, storedInterface);
677
+ const interfaceActions = getInterfaceActions(snapId, controllerMessenger, options, storedInterface);
630
678
  return getInterfaceResponse(runSaga, storedInterface.type, storedInterface.id, storedInterface.content, interfaceActions);
631
679
  }
632
680
  //# sourceMappingURL=interface.mjs.map