Skip to content

Commit

Permalink
Add support for context
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding committed Jun 24, 2024
1 parent 5096785 commit 085e506
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/snaps-sdk/src/provider-wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ describe('createInterface', () => {
(snap.request as jest.MockedFn<typeof snap.request>).mockResolvedValue(
'foo',
);
expect(await createInterface(panel([text('Hello world!')]))).toBe('foo');
expect(
await createInterface(panel([text('Hello world!')]), { foo: 'bar' }),
).toBe('foo');
expect(snap.request).toHaveBeenCalledWith({
method: 'snap_createInterface',
params: {
Expand All @@ -345,6 +347,7 @@ describe('createInterface', () => {
],
type: 'panel',
},
context: { foo: 'bar' },
},
});
});
Expand Down
11 changes: 9 additions & 2 deletions packages/snaps-sdk/src/provider-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,17 @@ export async function notify(
* Create a new interface with the specified UI.
*
* @param ui - The UI of the interface.
* @param context - An optional context blob for the interface.
* @returns A promise that resolves to the interface ID.
*/
export async function createInterface(ui: CreateInterfaceParams['ui']) {
return snap.request({ method: 'snap_createInterface', params: { ui } });
export async function createInterface(
ui: CreateInterfaceParams['ui'],
context?: CreateInterfaceParams['context'],
) {
return snap.request({
method: 'snap_createInterface',
params: { ui, context },
});
}

/**
Expand Down

0 comments on commit 085e506

Please sign in to comment.