Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,14 @@ export class SnapInterfaceController extends BaseController<
* @param contentType - The type of content.
* @returns The newly interface id.
*/
async createInterface(
createInterface(
snapId: SnapId,
content: ComponentOrElement,
context?: InterfaceContext,
contentType?: ContentType,
) {
const element = getJsxInterface(content);
await this.#validateContent(element);
this.#validateContent(element);
validateInterfaceContext(context);

const id = nanoid();
Expand Down Expand Up @@ -333,15 +333,15 @@ export class SnapInterfaceController extends BaseController<
* @param content - The new content.
* @param context - An optional interface context object.
*/
async updateInterface(
updateInterface(
snapId: SnapId,
id: string,
content: ComponentOrElement,
context?: InterfaceContext,
) {
this.#validateArgs(snapId, id);
const element = getJsxInterface(content);
await this.#validateContent(element);
this.#validateContent(element);
validateInterfaceContext(context);

const oldState = this.state.interfaces[id].state;
Expand Down Expand Up @@ -543,7 +543,7 @@ export class SnapInterfaceController extends BaseController<
*
* @param element - The JSX element to verify.
*/
async #validateContent(element: JSXElement) {
#validateContent(element: JSXElement) {
// We assume the validity of this JSON to be validated by the caller.
// E.g., in the RPC method implementation.
const size = getJsonSizeUnsafe(element);
Expand Down
8 changes: 4 additions & 4 deletions packages/snaps-rpc-methods/src/permitted/createInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type CreateInterfaceMethodHooks = {
ui: ComponentOrElement,
context?: InterfaceContext,
contentType?: ContentType,
) => Promise<string>;
) => string;
};

export const createInterfaceHandler: PermittedHandlerExport<
Expand Down Expand Up @@ -67,21 +67,21 @@ export type CreateInterfaceParameters = InferMatching<
* @param hooks.createInterface - The function to create the interface.
* @returns Nothing.
*/
async function getCreateInterfaceImplementation(
function getCreateInterfaceImplementation(
req: JsonRpcRequest<CreateInterfaceParameters>,
res: PendingJsonRpcResponse<CreateInterfaceResult>,
_next: unknown,
end: JsonRpcEngineEndCallback,
{ createInterface }: CreateInterfaceMethodHooks,
): Promise<void> {
): void {
const { params } = req;

try {
const validatedParams = getValidatedParams(params);

const { ui, context } = validatedParams;

res.result = await createInterface(ui, context);
res.result = createInterface(ui, context);
} catch (error) {
return end(error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/snaps-rpc-methods/src/permitted/updateInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type UpdateInterfaceMethodHooks = {
id: string,
ui: ComponentOrElement,
context?: InterfaceContext,
) => Promise<void>;
) => void;
};

export const updateInterfaceHandler: PermittedHandlerExport<
Expand Down Expand Up @@ -74,21 +74,21 @@ export type UpdateInterfaceParameters = InferMatching<
* @param hooks.updateInterface - The function to update the interface.
* @returns Nothing.
*/
async function getUpdateInterfaceImplementation(
function getUpdateInterfaceImplementation(
req: JsonRpcRequest<UpdateInterfaceParameters>,
res: PendingJsonRpcResponse<UpdateInterfaceResult>,
_next: unknown,
end: JsonRpcEngineEndCallback,
{ updateInterface }: UpdateInterfaceMethodHooks,
): Promise<void> {
): void {
const { params } = req;

try {
const validatedParams = getValidatedParams(params);

const { id, ui, context } = validatedParams;

await updateInterface(id, ui, context);
updateInterface(id, ui, context);
res.result = null;
} catch (error) {
return end(error);
Expand Down
Loading
Loading