Skip to main content

SnapInterfaceController Actions

9 actions registered.

NameDeprecated
createInterface
deleteInterface
getInterface
getInterfaceState
getState
resolveInterface
setInterfaceDisplayed
updateInterface
updateInterfaceState

SnapInterfaceController:createInterface​

Package: @metamask/snaps-controllers

Create an interface in the controller state with the associated data.

Parameters:

NameDescription
snapIdThe snap id that created the interface.
contentThe interface content.
contextAn optional interface context object.
contentTypeThe type of content.

Returns: The newly interface id.

Handler signature:

(snapId: SnapId, content: ComponentOrElement, context?: InterfaceContext, contentType?: ContentType) => string

SnapInterfaceController:deleteInterface​

Package: @metamask/snaps-controllers

Delete an interface from state.

Parameters:

NameDescription
idThe interface id.

Handler signature:

(id: string) => void

SnapInterfaceController:getInterface​

Package: @metamask/snaps-controllers

Get the data of a given interface id.

Parameters:

NameDescription
snapIdThe snap id requesting the interface data.
idThe interface id.

Returns: The interface state.

Handler signature:

(snapId: SnapId, id: string) => StoredInterface

SnapInterfaceController:getInterfaceState​

Package: @metamask/snaps-controllers

Get the state of a given interface ID, if the interface has been displayed at least once.

Parameters:

NameDescription
snapIdThe snap ID requesting the interface state.
idThe interface ID.

Returns: The interface state.

Handler signature:

(snapId: SnapId, id: string) => Record<string, string | boolean | {
addresses: `${string}:${string}:${string}`[];
accountId: string;
} | {
name: string;
size: number;
contentType: string;
contents: string;
} | {
symbol: string;
name: string;
asset: `${string}:${string}/${string}:${string}`;
} | Record<string, string | boolean | {
addresses: `${string}:${string}:${string}`[];
accountId: string;
} | {
name: string;
size: number;
contentType: string;
contents: string;
} | {
symbol: string;
name: string;
asset: `${string}:${string}/${string}:${string}`;
} | null> | null>

SnapInterfaceController:getState​

Package: @metamask/snaps-controllers

Handler signature:

() => SnapInterfaceControllerState

SnapInterfaceController:resolveInterface​

Package: @metamask/snaps-controllers

Resolve the promise of a given interface approval request. The approval needs to have the same ID as the interface.

Parameters:

NameDescription
snapIdThe snap id.
idThe interface id.
valueThe value to resolve the promise with.

Handler signature:

(snapId: SnapId, id: string, value: Json) => Promise<void>

SnapInterfaceController:setInterfaceDisplayed​

Package: @metamask/snaps-controllers

Set the interface as displayed.

Parameters:

NameDescription
snapIdThe snap ID requesting the update.
idThe interface ID.

Handler signature:

(snapId: SnapId, id: string) => void

SnapInterfaceController:updateInterface​

Package: @metamask/snaps-controllers

Update the interface with the given content.

Parameters:

NameDescription
snapIdThe snap id requesting the update.
idThe interface id.
contentThe new content.
contextAn optional interface context object.

Handler signature:

(snapId: SnapId, id: string, content: ComponentOrElement, context?: InterfaceContext) => void

SnapInterfaceController:updateInterfaceState​

Package: @metamask/snaps-controllers

Update the interface state.

Parameters:

NameDescription
idThe interface id.
stateThe new state.

Handler signature:

(id: string, state: InterfaceState) => void