@@ -14,27 +14,8 @@ import type {
1414 OnUpdateHandler,
1515 OnUserInputHandler,
1616} from '@metamask/snaps-sdk';
17- import { ComponentOrElementStruct, SeverityLevel } from '@metamask/snaps-sdk';
18- import {
19- assign,
20- literal,
21- nullable,
22- object,
23- optional,
24- string,
25- array,
26- size,
27- union,
28- } from '@metamask/superstruct';
2917
30- import type { SnapHandler } from './handler-types';
31- import { HandlerType } from './handler-types';
32-
33- export type SnapRpcHookArgs = {
34- origin: string;
35- handler: HandlerType;
36- request: Record<string, unknown>;
37- };
18+ import { HandlerType } from './types';
3819
3920export const SNAP_EXPORTS = {
4021 [HandlerType.OnRpcRequest]: {
@@ -141,89 +122,4 @@ export const SNAP_EXPORTS = {
141122 },
142123} as const;
143124
144- export const OnTransactionSeverityResponseStruct = object({
145- severity: optional(literal(SeverityLevel.Critical)),
146- });
147-
148- export const OnTransactionResponseWithIdStruct = assign(
149- OnTransactionSeverityResponseStruct,
150- object({
151- id: string(),
152- }),
153- );
154-
155- export const OnTransactionResponseWithContentStruct = assign(
156- OnTransactionSeverityResponseStruct,
157- object({
158- content: ComponentOrElementStruct,
159- }),
160- );
161-
162- export const OnTransactionResponseStruct = nullable(
163- union([
164- OnTransactionResponseWithContentStruct,
165- OnTransactionResponseWithIdStruct,
166- ]),
167- );
168-
169- export const OnSignatureResponseStruct = OnTransactionResponseStruct;
170-
171- export const OnHomePageResponseWithContentStruct = object({
172- content: ComponentOrElementStruct,
173- });
174-
175- export const OnHomePageResponseWithIdStruct = object({
176- id: string(),
177- });
178-
179- export const OnHomePageResponseStruct = union([
180- OnHomePageResponseWithContentStruct,
181- OnHomePageResponseWithIdStruct,
182- ]);
183-
184- export const OnSettingsPageResponseStruct = OnHomePageResponseStruct;
185-
186- export const AddressResolutionStruct = object({
187- protocol: string(),
188- resolvedDomain: string(),
189- });
190-
191- export const DomainResolutionStruct = object({
192- protocol: string(),
193- resolvedAddress: string(),
194- domainName: string(),
195- });
196-
197- export const AddressResolutionResponseStruct = object({
198- resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity),
199- });
200-
201- export const DomainResolutionResponseStruct = object({
202- resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity),
203- });
204-
205- export const OnNameLookupResponseStruct = nullable(
206- union([AddressResolutionResponseStruct, DomainResolutionResponseStruct]),
207- );
208-
209- /**
210- * Utility type for getting the handler function type from a handler type.
211- */
212- export type HandlerFunction<Type extends SnapHandler> =
213- Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler
214- ? Handler
215- : never;
216-
217- /**
218- * All the function-based handlers that a snap can implement.
219- */
220- export type SnapFunctionExports = {
221- [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<
222- (typeof SNAP_EXPORTS)[Key]
223- >;
224- };
225-
226- /**
227- * All handlers that a snap can implement.
228- */
229- export type SnapExports = SnapFunctionExports;
125+ export const SNAP_EXPORT_NAMES = Object.values(HandlerType);
0 commit comments