@metamask/snaps-rpc-methods 3.3.0 → 4.0.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 (77) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/permitted/common/snapInstallation.js.map +1 -1
  4. package/dist/cjs/permitted/getFile.js +5 -4
  5. package/dist/cjs/permitted/getFile.js.map +1 -1
  6. package/dist/cjs/permitted/getSnaps.js.map +1 -1
  7. package/dist/cjs/permitted/invokeKeyring.js.map +1 -1
  8. package/dist/cjs/permitted/invokeSnapSugar.js.map +1 -1
  9. package/dist/cjs/permitted/requestSnaps.js.map +1 -1
  10. package/dist/cjs/restricted/caveats/permittedCoinTypes.js.map +1 -1
  11. package/dist/cjs/restricted/dialog.js +16 -25
  12. package/dist/cjs/restricted/dialog.js.map +1 -1
  13. package/dist/cjs/restricted/getBip32Entropy.js.map +1 -1
  14. package/dist/cjs/restricted/getBip32PublicKey.js.map +1 -1
  15. package/dist/cjs/restricted/getBip44Entropy.js +0 -1
  16. package/dist/cjs/restricted/getBip44Entropy.js.map +1 -1
  17. package/dist/cjs/restricted/getEntropy.js.map +1 -1
  18. package/dist/cjs/restricted/getLocale.js.map +1 -1
  19. package/dist/cjs/restricted/index.js +0 -9
  20. package/dist/cjs/restricted/index.js.map +1 -1
  21. package/dist/cjs/restricted/invokeSnap.js.map +1 -1
  22. package/dist/cjs/restricted/manageAccounts.js.map +1 -1
  23. package/dist/cjs/restricted/manageState.js +13 -22
  24. package/dist/cjs/restricted/manageState.js.map +1 -1
  25. package/dist/cjs/restricted/notify.js +6 -13
  26. package/dist/cjs/restricted/notify.js.map +1 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/permitted/common/snapInstallation.js.map +1 -1
  29. package/dist/esm/permitted/getFile.js +2 -1
  30. package/dist/esm/permitted/getFile.js.map +1 -1
  31. package/dist/esm/permitted/getSnaps.js.map +1 -1
  32. package/dist/esm/permitted/invokeKeyring.js.map +1 -1
  33. package/dist/esm/permitted/invokeSnapSugar.js.map +1 -1
  34. package/dist/esm/permitted/requestSnaps.js.map +1 -1
  35. package/dist/esm/restricted/caveats/permittedCoinTypes.js.map +1 -1
  36. package/dist/esm/restricted/dialog.js +3 -9
  37. package/dist/esm/restricted/dialog.js.map +1 -1
  38. package/dist/esm/restricted/getBip32Entropy.js.map +1 -1
  39. package/dist/esm/restricted/getBip32PublicKey.js.map +1 -1
  40. package/dist/esm/restricted/getBip44Entropy.js +0 -1
  41. package/dist/esm/restricted/getBip44Entropy.js.map +1 -1
  42. package/dist/esm/restricted/getEntropy.js.map +1 -1
  43. package/dist/esm/restricted/getLocale.js.map +1 -1
  44. package/dist/esm/restricted/index.js +0 -3
  45. package/dist/esm/restricted/index.js.map +1 -1
  46. package/dist/esm/restricted/invokeSnap.js.map +1 -1
  47. package/dist/esm/restricted/manageAccounts.js.map +1 -1
  48. package/dist/esm/restricted/manageState.js +8 -14
  49. package/dist/esm/restricted/manageState.js.map +1 -1
  50. package/dist/esm/restricted/notify.js +3 -7
  51. package/dist/esm/restricted/notify.js.map +1 -1
  52. package/dist/types/index.d.ts +0 -1
  53. package/dist/types/permitted/common/snapInstallation.d.ts +3 -5
  54. package/dist/types/permitted/getFile.d.ts +5 -4
  55. package/dist/types/permitted/getSnaps.d.ts +3 -3
  56. package/dist/types/permitted/handlers.d.ts +6 -12
  57. package/dist/types/permitted/invokeKeyring.d.ts +5 -7
  58. package/dist/types/permitted/invokeSnapSugar.d.ts +5 -8
  59. package/dist/types/permitted/requestSnaps.d.ts +3 -2
  60. package/dist/types/restricted/caveats/permittedCoinTypes.d.ts +1 -1
  61. package/dist/types/restricted/dialog.d.ts +34 -35
  62. package/dist/types/restricted/getBip32Entropy.d.ts +2 -3
  63. package/dist/types/restricted/getBip32PublicKey.d.ts +2 -6
  64. package/dist/types/restricted/getBip44Entropy.d.ts +2 -5
  65. package/dist/types/restricted/getEntropy.d.ts +3 -2
  66. package/dist/types/restricted/getLocale.d.ts +2 -1
  67. package/dist/types/restricted/index.d.ts +9 -90
  68. package/dist/types/restricted/invokeSnap.d.ts +8 -7
  69. package/dist/types/restricted/manageAccounts.d.ts +4 -3
  70. package/dist/types/restricted/manageState.d.ts +3 -13
  71. package/dist/types/restricted/notify.d.ts +4 -7
  72. package/package.json +4 -5
  73. package/dist/cjs/request.js +0 -6
  74. package/dist/cjs/request.js.map +0 -1
  75. package/dist/esm/request.js +0 -3
  76. package/dist/esm/request.js.map +0 -1
  77. package/dist/types/request.d.ts +0 -99
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/restricted/notify.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { assertLinksAreSafe } from '@metamask/snaps-ui';\nimport type { EnumToUnion } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { isObject } from '@metamask/utils';\n\nimport { type MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_notify';\n\n// TODO: Move all the types to a shared place when implementing more\n// notifications.\nexport enum NotificationType {\n InApp = 'inApp',\n Native = 'native',\n}\n\nexport type NotificationArgs = {\n /**\n * Enum type to determine notification type.\n */\n type: EnumToUnion<NotificationType>;\n\n /**\n * A message to show on the notification.\n */\n message: string;\n};\n\nexport type NotifyMethodHooks = {\n /**\n * @param snapId - The ID of the Snap that created the notification.\n * @param args - The notification arguments.\n */\n showNativeNotification: (\n snapId: string,\n args: NotificationArgs,\n ) => Promise<null>;\n\n /**\n * @param snapId - The ID of the Snap that created the notification.\n * @param args - The notification arguments.\n */\n showInAppNotification: (\n snapId: string,\n args: NotificationArgs,\n ) => Promise<null>;\n\n isOnPhishingList: (url: string) => boolean;\n\n maybeUpdatePhishingList: () => Promise<void>;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: NotifyMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_notify` permission.\n * `snap_notify` allows snaps to send multiple types of notifications to its users.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_notify` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<NotifyMethodHooks> = {\n showNativeNotification: true,\n showInAppNotification: true,\n isOnPhishingList: true,\n maybeUpdatePhishingList: true,\n};\n\nexport const notifyBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_notify`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.showNativeNotification - A function that shows a native browser notification.\n * @param hooks.showInAppNotification - A function that shows a notification in the MetaMask UI.\n * @param hooks.isOnPhishingList - A function that checks for links against the phishing list.\n * @param hooks.maybeUpdatePhishingList - A function that updates the phishing list if needed.\n * @returns The method implementation which returns `null` on success.\n * @throws If the params are invalid.\n */\nexport function getImplementation({\n showNativeNotification,\n showInAppNotification,\n isOnPhishingList,\n maybeUpdatePhishingList,\n}: NotifyMethodHooks) {\n return async function implementation(\n args: RestrictedMethodOptions<NotificationArgs>,\n ): Promise<null> {\n const {\n params,\n context: { origin },\n } = args;\n\n const validatedParams = getValidatedParams(params);\n\n await maybeUpdatePhishingList();\n\n assertLinksAreSafe(validatedParams.message, isOnPhishingList);\n\n switch (validatedParams.type) {\n case NotificationType.Native:\n return await showNativeNotification(origin, validatedParams);\n case NotificationType.InApp:\n return await showInAppNotification(origin, validatedParams);\n default:\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid notification \"type\".',\n });\n }\n };\n}\n\n/**\n * Validates the notify method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated method parameter object.\n */\nexport function getValidatedParams(params: unknown): NotificationArgs {\n if (!isObject(params)) {\n throw rpcErrors.invalidParams({\n message: 'Expected params to be a single object.',\n });\n }\n\n const { type, message } = params;\n\n if (\n !type ||\n typeof type !== 'string' ||\n !Object.values(NotificationType).includes(type as NotificationType)\n ) {\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid notification \"type\".',\n });\n }\n\n // Set to the max message length on a Mac notification for now.\n if (!message || typeof message !== 'string' || message.length >= 50) {\n throw rpcErrors.invalidParams({\n message:\n 'Must specify a non-empty string \"message\" less than 50 characters long.',\n });\n }\n\n return params as NotificationArgs;\n}\n"],"names":["PermissionType","SubjectType","rpcErrors","assertLinksAreSafe","isObject","methodName","NotificationType","InApp","Native","specificationBuilder","allowedCaveats","methodHooks","permissionType","RestrictedMethod","targetName","methodImplementation","getImplementation","subjectTypes","Snap","showNativeNotification","showInAppNotification","isOnPhishingList","maybeUpdatePhishingList","notifyBuilder","Object","freeze","implementation","args","params","context","origin","validatedParams","getValidatedParams","message","type","invalidParams","values","includes","length"],"mappings":"AAKA,SAASA,cAAc,EAAEC,WAAW,QAAQ,kCAAkC;AAC9E,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,kBAAkB,QAAQ,qBAAqB;AAGxD,SAASC,QAAQ,QAAQ,kBAAkB;AAI3C,MAAMC,aAAa;WAIZ;UAAKC,gBAAgB;IAAhBA,iBACVC,WAAQ;IADED,iBAEVE,YAAS;GAFCF,qBAAAA;AAqDZ;;;;;;;;CAQC,GACD,OAAO,MAAMG,uBAIT,CAAC,EAAEC,iBAAiB,IAAI,EAAEC,WAAW,EAA+B;IACtE,OAAO;QACLC,gBAAgBZ,eAAea,gBAAgB;QAC/CC,YAAYT;QACZK;QACAK,sBAAsBC,kBAAkBL;QACxCM,cAAc;YAAChB,YAAYiB,IAAI;SAAC;IAClC;AACF,EAAE;AAEF,MAAMP,cAAoD;IACxDQ,wBAAwB;IACxBC,uBAAuB;IACvBC,kBAAkB;IAClBC,yBAAyB;AAC3B;AAEA,OAAO,MAAMC,gBAAgBC,OAAOC,MAAM,CAAC;IACzCX,YAAYT;IACZI;IACAE;AACF,GAAY;AAEZ;;;;;;;;;;CAUC,GACD,OAAO,SAASK,kBAAkB,EAChCG,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,uBAAuB,EACL;IAClB,OAAO,eAAeI,eACpBC,IAA+C;QAE/C,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGH;QAEJ,MAAMI,kBAAkBC,mBAAmBJ;QAE3C,MAAMN;QAENnB,mBAAmB4B,gBAAgBE,OAAO,EAAEZ;QAE5C,OAAQU,gBAAgBG,IAAI;YAC1B,KAAK5B,iBAAiBE,MAAM;gBAC1B,OAAO,MAAMW,uBAAuBW,QAAQC;YAC9C,KAAKzB,iBAAiBC,KAAK;gBACzB,OAAO,MAAMa,sBAAsBU,QAAQC;YAC7C;gBACE,MAAM7B,UAAUiC,aAAa,CAAC;oBAC5BF,SAAS;gBACX;QACJ;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASD,mBAAmBJ,MAAe;IAChD,IAAI,CAACxB,SAASwB,SAAS;QACrB,MAAM1B,UAAUiC,aAAa,CAAC;YAC5BF,SAAS;QACX;IACF;IAEA,MAAM,EAAEC,IAAI,EAAED,OAAO,EAAE,GAAGL;IAE1B,IACE,CAACM,QACD,OAAOA,SAAS,YAChB,CAACV,OAAOY,MAAM,CAAC9B,kBAAkB+B,QAAQ,CAACH,OAC1C;QACA,MAAMhC,UAAUiC,aAAa,CAAC;YAC5BF,SAAS;QACX;IACF;IAEA,+DAA+D;IAC/D,IAAI,CAACA,WAAW,OAAOA,YAAY,YAAYA,QAAQK,MAAM,IAAI,IAAI;QACnE,MAAMpC,UAAUiC,aAAa,CAAC;YAC5BF,SACE;QACJ;IACF;IAEA,OAAOL;AACT"}
1
+ {"version":3,"sources":["../../../src/restricted/notify.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { NotificationType } from '@metamask/snaps-sdk';\nimport type {\n NotifyParams,\n NotifyResult,\n EnumToUnion,\n} from '@metamask/snaps-sdk';\nimport { validateTextLinks } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { isObject } from '@metamask/utils';\n\nimport { type MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_notify';\n\nexport type NotificationArgs = {\n /**\n * Enum type to determine notification type.\n */\n type: EnumToUnion<NotificationType>;\n\n /**\n * A message to show on the notification.\n */\n message: string;\n};\n\nexport type NotifyMethodHooks = {\n /**\n * @param snapId - The ID of the Snap that created the notification.\n * @param args - The notification arguments.\n */\n showNativeNotification: (\n snapId: string,\n args: NotificationArgs,\n ) => Promise<null>;\n\n /**\n * @param snapId - The ID of the Snap that created the notification.\n * @param args - The notification arguments.\n */\n showInAppNotification: (\n snapId: string,\n args: NotificationArgs,\n ) => Promise<null>;\n\n isOnPhishingList: (url: string) => boolean;\n\n maybeUpdatePhishingList: () => Promise<void>;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: NotifyMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_notify` permission.\n * `snap_notify` allows snaps to send multiple types of notifications to its users.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_notify` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<NotifyMethodHooks> = {\n showNativeNotification: true,\n showInAppNotification: true,\n isOnPhishingList: true,\n maybeUpdatePhishingList: true,\n};\n\nexport const notifyBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_notify`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.showNativeNotification - A function that shows a native browser notification.\n * @param hooks.showInAppNotification - A function that shows a notification in the MetaMask UI.\n * @param hooks.isOnPhishingList - A function that checks for links against the phishing list.\n * @param hooks.maybeUpdatePhishingList - A function that updates the phishing list if needed.\n * @returns The method implementation which returns `null` on success.\n * @throws If the params are invalid.\n */\nexport function getImplementation({\n showNativeNotification,\n showInAppNotification,\n isOnPhishingList,\n maybeUpdatePhishingList,\n}: NotifyMethodHooks) {\n return async function implementation(\n args: RestrictedMethodOptions<NotifyParams>,\n ): Promise<NotifyResult> {\n const {\n params,\n context: { origin },\n } = args;\n\n const validatedParams = getValidatedParams(params);\n\n await maybeUpdatePhishingList();\n\n validateTextLinks(validatedParams.message, isOnPhishingList);\n\n switch (validatedParams.type) {\n case NotificationType.Native:\n return await showNativeNotification(origin, validatedParams);\n case NotificationType.InApp:\n return await showInAppNotification(origin, validatedParams);\n default:\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid notification \"type\".',\n });\n }\n };\n}\n\n/**\n * Validates the notify method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated method parameter object.\n */\nexport function getValidatedParams(params: unknown): NotifyParams {\n if (!isObject(params)) {\n throw rpcErrors.invalidParams({\n message: 'Expected params to be a single object.',\n });\n }\n\n const { type, message } = params;\n\n if (\n !type ||\n typeof type !== 'string' ||\n !Object.values(NotificationType).includes(type as NotificationType)\n ) {\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid notification \"type\".',\n });\n }\n\n // Set to the max message length on a Mac notification for now.\n if (!message || typeof message !== 'string' || message.length >= 50) {\n throw rpcErrors.invalidParams({\n message:\n 'Must specify a non-empty string \"message\" less than 50 characters long.',\n });\n }\n\n return params as NotificationArgs;\n}\n"],"names":["PermissionType","SubjectType","rpcErrors","NotificationType","validateTextLinks","isObject","methodName","specificationBuilder","allowedCaveats","methodHooks","permissionType","RestrictedMethod","targetName","methodImplementation","getImplementation","subjectTypes","Snap","showNativeNotification","showInAppNotification","isOnPhishingList","maybeUpdatePhishingList","notifyBuilder","Object","freeze","implementation","args","params","context","origin","validatedParams","getValidatedParams","message","type","Native","InApp","invalidParams","values","includes","length"],"mappings":"AAKA,SAASA,cAAc,EAAEC,WAAW,QAAQ,kCAAkC;AAC9E,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,gBAAgB,QAAQ,sBAAsB;AAMvD,SAASC,iBAAiB,QAAQ,wBAAwB;AAE1D,SAASC,QAAQ,QAAQ,kBAAkB;AAI3C,MAAMC,aAAa;AAkDnB;;;;;;;;CAQC,GACD,OAAO,MAAMC,uBAIT,CAAC,EAAEC,iBAAiB,IAAI,EAAEC,WAAW,EAA+B;IACtE,OAAO;QACLC,gBAAgBV,eAAeW,gBAAgB;QAC/CC,YAAYN;QACZE;QACAK,sBAAsBC,kBAAkBL;QACxCM,cAAc;YAACd,YAAYe,IAAI;SAAC;IAClC;AACF,EAAE;AAEF,MAAMP,cAAoD;IACxDQ,wBAAwB;IACxBC,uBAAuB;IACvBC,kBAAkB;IAClBC,yBAAyB;AAC3B;AAEA,OAAO,MAAMC,gBAAgBC,OAAOC,MAAM,CAAC;IACzCX,YAAYN;IACZC;IACAE;AACF,GAAY;AAEZ;;;;;;;;;;CAUC,GACD,OAAO,SAASK,kBAAkB,EAChCG,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,uBAAuB,EACL;IAClB,OAAO,eAAeI,eACpBC,IAA2C;QAE3C,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGH;QAEJ,MAAMI,kBAAkBC,mBAAmBJ;QAE3C,MAAMN;QAENhB,kBAAkByB,gBAAgBE,OAAO,EAAEZ;QAE3C,OAAQU,gBAAgBG,IAAI;YAC1B,KAAK7B,iBAAiB8B,MAAM;gBAC1B,OAAO,MAAMhB,uBAAuBW,QAAQC;YAC9C,KAAK1B,iBAAiB+B,KAAK;gBACzB,OAAO,MAAMhB,sBAAsBU,QAAQC;YAC7C;gBACE,MAAM3B,UAAUiC,aAAa,CAAC;oBAC5BJ,SAAS;gBACX;QACJ;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASD,mBAAmBJ,MAAe;IAChD,IAAI,CAACrB,SAASqB,SAAS;QACrB,MAAMxB,UAAUiC,aAAa,CAAC;YAC5BJ,SAAS;QACX;IACF;IAEA,MAAM,EAAEC,IAAI,EAAED,OAAO,EAAE,GAAGL;IAE1B,IACE,CAACM,QACD,OAAOA,SAAS,YAChB,CAACV,OAAOc,MAAM,CAACjC,kBAAkBkC,QAAQ,CAACL,OAC1C;QACA,MAAM9B,UAAUiC,aAAa,CAAC;YAC5BJ,SAAS;QACX;IACF;IAEA,+DAA+D;IAC/D,IAAI,CAACA,WAAW,OAAOA,YAAY,YAAYA,QAAQO,MAAM,IAAI,IAAI;QACnE,MAAMpC,UAAUiC,aAAa,CAAC;YAC5BJ,SACE;QACJ;IACF;IAEA,OAAOL;AACT"}
@@ -3,4 +3,3 @@ export { handlers as permittedMethods, createSnapsMethodMiddleware, } from './pe
3
3
  export * from './restricted';
4
4
  export { SnapCaveatType } from '@metamask/snaps-utils';
5
5
  export { selectHooks } from './utils';
6
- export type { RequestFunction, SnapsGlobalObject } from './request';
@@ -1,7 +1,5 @@
1
- import type { RequestedPermissions } from '@metamask/permission-controller';
2
- import type { InstallSnapsResult } from '@metamask/snaps-utils';
3
- export type { InstallSnapsResult } from '@metamask/snaps-utils';
4
- export declare type InstallSnapsHook = (requestedSnaps: RequestedPermissions) => Promise<InstallSnapsResult>;
1
+ import type { RequestSnapsParams, RequestSnapsResult } from '@metamask/snaps-sdk';
2
+ export declare type InstallSnapsHook = (requestedSnaps: RequestSnapsParams) => Promise<RequestSnapsResult>;
5
3
  /**
6
4
  * Typechecks the requested snaps and passes them to the permissions
7
5
  * controller for installation.
@@ -13,4 +11,4 @@ export declare type InstallSnapsHook = (requestedSnaps: RequestedPermissions) =>
13
11
  * @returns An object containing the installed snaps.
14
12
  * @throws If the params are invalid or the snap installation fails.
15
13
  */
16
- export declare function handleInstallSnaps(requestedSnaps: RequestedPermissions, installSnaps: InstallSnapsHook): Promise<InstallSnapsResult>;
14
+ export declare function handleInstallSnaps(requestedSnaps: RequestSnapsParams, installSnaps: InstallSnapsHook): Promise<RequestSnapsResult>;
@@ -1,5 +1,6 @@
1
1
  import type { PermittedHandlerExport } from '@metamask/permission-controller';
2
- import type { Infer } from 'superstruct';
2
+ import type { GetFileParams } from '@metamask/snaps-sdk';
3
+ import type { InferMatching } from '@metamask/snaps-utils';
3
4
  export declare const GetFileArgsStruct: import("superstruct").Struct<{
4
5
  path: string;
5
6
  encoding?: "base64" | "utf8" | "hex" | undefined;
@@ -7,8 +8,8 @@ export declare const GetFileArgsStruct: import("superstruct").Struct<{
7
8
  path: import("superstruct").Struct<string, null>;
8
9
  encoding: import("superstruct").Struct<"base64" | "utf8" | "hex" | undefined, null>;
9
10
  }>;
10
- export declare type GetFileArgs = Infer<typeof GetFileArgsStruct>;
11
- export declare const getFileHandler: PermittedHandlerExport<GetFileHooks, GetFileArgs, string>;
11
+ export declare type InferredGetFileParams = InferMatching<typeof GetFileArgsStruct, GetFileParams>;
12
+ export declare const getFileHandler: PermittedHandlerExport<GetFileHooks, InferredGetFileParams, string>;
12
13
  export declare type GetFileHooks = {
13
- getSnapFile: (path: GetFileArgs['path'], encoding: GetFileArgs['encoding']) => Promise<string>;
14
+ getSnapFile: (path: InferredGetFileParams['path'], encoding: InferredGetFileParams['encoding']) => Promise<string>;
14
15
  };
@@ -1,13 +1,13 @@
1
1
  import type { PermittedHandlerExport } from '@metamask/permission-controller';
2
- import type { InstallSnapsResult } from '@metamask/snaps-utils';
2
+ import type { GetSnapsResult } from '@metamask/snaps-sdk';
3
3
  import type { JsonRpcParams } from '@metamask/utils';
4
4
  /**
5
5
  * `wallet_getSnaps` gets the requester's permitted and installed Snaps.
6
6
  */
7
- export declare const getSnapsHandler: PermittedHandlerExport<GetSnapsHooks, JsonRpcParams, InstallSnapsResult>;
7
+ export declare const getSnapsHandler: PermittedHandlerExport<GetSnapsHooks, JsonRpcParams, GetSnapsResult>;
8
8
  export declare type GetSnapsHooks = {
9
9
  /**
10
10
  * @returns The permitted and installed snaps for the requesting origin.
11
11
  */
12
- getSnaps: () => Promise<InstallSnapsResult>;
12
+ getSnaps: () => Promise<GetSnapsResult>;
13
13
  };
@@ -1,14 +1,8 @@
1
1
  export declare const methodHandlers: {
2
- wallet_getSnaps: import("@metamask/permission-controller").PermittedHandlerExport<import("./getSnaps").GetSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-utils").InstallSnapsResult>;
3
- wallet_requestSnaps: import("@metamask/permission-controller").PermittedHandlerExport<import("./requestSnaps").RequestSnapsHooks, import("@metamask/permission-controller").RequestedPermissions, import("@metamask/snaps-utils").InstallSnapsResult>;
4
- wallet_invokeSnap: import("@metamask/permission-controller").PermittedHandlerExport<void, import("./invokeSnapSugar").InvokeSnapSugarArgs, import("@metamask/utils").Json>;
5
- wallet_invokeKeyring: import("@metamask/permission-controller").PermittedHandlerExport<import("./invokeKeyring").InvokeKeyringHooks, import("@metamask/utils").JsonRpcRequest<import("@metamask/utils").JsonRpcParams>, import("@metamask/utils").Json>;
6
- snap_getFile: import("@metamask/permission-controller").PermittedHandlerExport<import("./getFile").GetFileHooks, {
7
- path: string;
8
- encoding?: "base64" | "utf8" | "hex" | undefined;
9
- }, string>;
2
+ wallet_getSnaps: import("@metamask/permission-controller").PermittedHandlerExport<import("./getSnaps").GetSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetSnapsResult>;
3
+ wallet_requestSnaps: import("@metamask/permission-controller").PermittedHandlerExport<import("./requestSnaps").RequestSnapsHooks, import("@metamask/snaps-sdk").RequestSnapsParams, import("@metamask/snaps-sdk").RequestSnapsResult>;
4
+ wallet_invokeSnap: import("@metamask/permission-controller").PermittedHandlerExport<void, import("@metamask/snaps-sdk").InvokeSnapParams, import("@metamask/utils").Json>;
5
+ wallet_invokeKeyring: import("@metamask/permission-controller").PermittedHandlerExport<import("./invokeKeyring").InvokeKeyringHooks, import("@metamask/snaps-sdk").InvokeSnapParams, import("@metamask/utils").Json>;
6
+ snap_getFile: import("@metamask/permission-controller").PermittedHandlerExport<import("./getFile").GetFileHooks, import("@metamask/snaps-sdk").GetFileParams, string>;
10
7
  };
11
- export declare const handlers: (import("@metamask/permission-controller").PermittedHandlerExport<import("./getSnaps").GetSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-utils").InstallSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./requestSnaps").RequestSnapsHooks, import("@metamask/permission-controller").RequestedPermissions, import("@metamask/snaps-utils").InstallSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getFile").GetFileHooks, {
12
- path: string;
13
- encoding?: "base64" | "utf8" | "hex" | undefined;
14
- }, string> | import("@metamask/permission-controller").PermittedHandlerExport<void, import("./invokeSnapSugar").InvokeSnapSugarArgs, import("@metamask/utils").Json> | import("@metamask/permission-controller").PermittedHandlerExport<import("./invokeKeyring").InvokeKeyringHooks, import("@metamask/utils").JsonRpcRequest<import("@metamask/utils").JsonRpcParams>, import("@metamask/utils").Json>)[];
8
+ export declare const handlers: (import("@metamask/permission-controller").PermittedHandlerExport<import("./getSnaps").GetSnapsHooks, import("@metamask/utils").JsonRpcParams, import("@metamask/snaps-sdk").GetSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./requestSnaps").RequestSnapsHooks, import("@metamask/snaps-sdk").RequestSnapsParams, import("@metamask/snaps-sdk").RequestSnapsResult> | import("@metamask/permission-controller").PermittedHandlerExport<import("./getFile").GetFileHooks, import("@metamask/snaps-sdk").GetFileParams, string> | import("@metamask/permission-controller").PermittedHandlerExport<void, import("@metamask/snaps-sdk").InvokeSnapParams, import("@metamask/utils").Json> | import("@metamask/permission-controller").PermittedHandlerExport<import("./invokeKeyring").InvokeKeyringHooks, import("@metamask/snaps-sdk").InvokeSnapParams, import("@metamask/utils").Json>)[];
@@ -1,17 +1,15 @@
1
1
  import type { PermittedHandlerExport } from '@metamask/permission-controller';
2
- import type { Snap } from '@metamask/snaps-utils';
3
- import { type SnapId, type SnapRpcHookArgs } from '@metamask/snaps-utils';
4
- import type { JsonRpcRequest } from '@metamask/utils';
5
- import { type Json } from '@metamask/utils';
2
+ import type { InvokeKeyringResult, InvokeSnapParams } from '@metamask/snaps-sdk';
3
+ import type { Snap, SnapRpcHookArgs } from '@metamask/snaps-utils';
6
4
  /**
7
5
  * `wallet_invokeKeyring` gets the requester's permitted and installed Snaps.
8
6
  */
9
- export declare const invokeKeyringHandler: PermittedHandlerExport<InvokeKeyringHooks, JsonRpcRequest, Json>;
7
+ export declare const invokeKeyringHandler: PermittedHandlerExport<InvokeKeyringHooks, InvokeSnapParams, InvokeKeyringResult>;
10
8
  export declare type InvokeKeyringHooks = {
11
9
  hasPermission: (origin: string, permissionName: string) => boolean;
12
10
  handleSnapRpcRequest: ({ snapId, origin, handler, request, }: SnapRpcHookArgs & {
13
- snapId: SnapId;
11
+ snapId: string;
14
12
  }) => Promise<unknown>;
15
- getSnap: (snapId: SnapId) => Snap | undefined;
13
+ getSnap: (snapId: string) => Snap | undefined;
16
14
  getAllowedKeyringMethods: (origin: string) => string[];
17
15
  };
@@ -1,14 +1,11 @@
1
1
  import type { JsonRpcEngineEndCallback, JsonRpcEngineNextCallback } from '@metamask/json-rpc-engine';
2
2
  import type { PermittedHandlerExport } from '@metamask/permission-controller';
3
- import type { Json, JsonRpcRequest } from '@metamask/utils';
4
- export declare type InvokeSnapSugarArgs = {
5
- snapId: string;
6
- request: Record<string, Json>;
7
- };
3
+ import type { InvokeSnapParams, InvokeSnapResult } from '@metamask/snaps-sdk';
4
+ import type { JsonRpcRequest } from '@metamask/utils';
8
5
  /**
9
6
  * `wallet_invokeSnap` attempts to invoke an RPC method of the specified Snap.
10
7
  */
11
- export declare const invokeSnapSugarHandler: PermittedHandlerExport<void, InvokeSnapSugarArgs, Json>;
8
+ export declare const invokeSnapSugarHandler: PermittedHandlerExport<void, InvokeSnapParams, InvokeSnapResult>;
12
9
  /**
13
10
  * The `wallet_invokeSnap` method implementation.
14
11
  * Reroutes incoming JSON-RPC requests that are targeting snaps, by modifying the method and params.
@@ -21,7 +18,7 @@ export declare const invokeSnapSugarHandler: PermittedHandlerExport<void, Invoke
21
18
  * @returns Nothing.
22
19
  * @throws If the params are invalid.
23
20
  */
24
- export declare function invokeSnapSugar(req: JsonRpcRequest<InvokeSnapSugarArgs>, _res: unknown, next: JsonRpcEngineNextCallback, end: JsonRpcEngineEndCallback): void;
21
+ export declare function invokeSnapSugar(req: JsonRpcRequest<InvokeSnapParams>, _res: unknown, next: JsonRpcEngineNextCallback, end: JsonRpcEngineEndCallback): void;
25
22
  /**
26
23
  * Validates the wallet_invokeSnap method `params` and returns them cast to the correct
27
24
  * type. Throws if validation fails.
@@ -29,4 +26,4 @@ export declare function invokeSnapSugar(req: JsonRpcRequest<InvokeSnapSugarArgs>
29
26
  * @param params - The unvalidated params object from the method request.
30
27
  * @returns The validated method parameter object.
31
28
  */
32
- export declare function getValidatedParams(params: unknown): InvokeSnapSugarArgs;
29
+ export declare function getValidatedParams(params: unknown): InvokeSnapParams;
@@ -1,10 +1,11 @@
1
1
  import type { PermissionConstraint, RequestedPermissions, PermittedHandlerExport } from '@metamask/permission-controller';
2
+ import type { RequestSnapsParams, RequestSnapsResult } from '@metamask/snaps-sdk';
2
3
  import type { SnapsPermissionRequest } from '@metamask/snaps-utils';
3
- import type { InstallSnapsHook, InstallSnapsResult } from './common/snapInstallation';
4
+ import type { InstallSnapsHook } from './common/snapInstallation';
4
5
  /**
5
6
  * `wallet_requestSnaps` installs the requested Snaps and requests permission to use them if necessary.
6
7
  */
7
- export declare const requestSnapsHandler: PermittedHandlerExport<RequestSnapsHooks, RequestedPermissions, InstallSnapsResult>;
8
+ export declare const requestSnapsHandler: PermittedHandlerExport<RequestSnapsHooks, RequestSnapsParams, RequestSnapsResult>;
8
9
  export declare type RequestSnapsHooks = {
9
10
  /**
10
11
  * Installs the requested snaps if they are permitted.
@@ -1,7 +1,7 @@
1
1
  import type { PermissionConstraint, RestrictedMethodCaveatSpecificationConstraint, Caveat } from '@metamask/permission-controller';
2
+ import type { GetBip44EntropyParams } from '@metamask/snaps-sdk';
2
3
  import { SnapCaveatType } from '@metamask/snaps-utils';
3
4
  import type { Json } from '@metamask/utils';
4
- import type { GetBip44EntropyParams } from '../getBip44Entropy';
5
5
  /**
6
6
  * Map a raw value from the `initialPermissions` to a caveat specification.
7
7
  * Note that this function does not do any validation, that's handled by the
@@ -1,16 +1,12 @@
1
1
  import type { PermissionSpecificationBuilder, RestrictedMethodOptions } from '@metamask/permission-controller';
2
2
  import { PermissionType } from '@metamask/permission-controller';
3
- import type { Component } from '@metamask/snaps-ui';
4
- import type { EnumToUnion } from '@metamask/snaps-utils';
3
+ import { DialogType } from '@metamask/snaps-sdk';
4
+ import type { DialogParams, EnumToUnion, Component } from '@metamask/snaps-sdk';
5
+ import type { InferMatching } from '@metamask/snaps-utils';
5
6
  import type { NonEmptyArray } from '@metamask/utils';
6
7
  import type { Infer, Struct } from 'superstruct';
7
8
  import { type MethodHooksObject } from '../utils';
8
9
  declare const methodName = "snap_dialog";
9
- export declare enum DialogType {
10
- Alert = "alert",
11
- Confirmation = "confirmation",
12
- Prompt = "prompt"
13
- }
14
10
  declare const PlaceholderStruct: Struct<string | undefined, null>;
15
11
  export declare type Placeholder = Infer<typeof PlaceholderStruct>;
16
12
  declare type ShowDialog = (snapId: string, type: EnumToUnion<DialogType>, content: Component, placeholder?: Placeholder) => Promise<null | boolean | string>;
@@ -46,67 +42,70 @@ export declare const dialogBuilder: Readonly<{
46
42
  }>;
47
43
  declare const DialogParametersStruct: Struct<{
48
44
  type: "alert";
49
- content: import("@metamask/snaps-ui").Panel | {
45
+ content: import("@metamask/snaps-sdk").Panel | {
50
46
  value: string;
51
- type: import("@metamask/snaps-ui").NodeType.Copyable;
47
+ type: import("@metamask/snaps-sdk").NodeType.Copyable;
48
+ sensitive?: boolean | undefined;
52
49
  } | {
53
- type: import("@metamask/snaps-ui").NodeType.Divider;
50
+ type: import("@metamask/snaps-sdk").NodeType.Divider;
54
51
  } | {
55
52
  value: string;
56
- type: import("@metamask/snaps-ui").NodeType.Heading;
57
- } | {
58
- type: import("@metamask/snaps-ui").NodeType.Spinner;
53
+ type: import("@metamask/snaps-sdk").NodeType.Heading;
59
54
  } | {
60
55
  value: string;
61
- type: import("@metamask/snaps-ui").NodeType.Text;
62
- markdown?: boolean | undefined;
56
+ type: import("@metamask/snaps-sdk").NodeType.Image;
57
+ } | {
58
+ type: import("@metamask/snaps-sdk").NodeType.Spinner;
63
59
  } | {
64
60
  value: string;
65
- type: import("@metamask/snaps-ui").NodeType.Image;
61
+ type: import("@metamask/snaps-sdk").NodeType.Text;
62
+ markdown?: boolean | undefined;
66
63
  };
67
64
  } | {
68
65
  type: "confirmation";
69
- content: import("@metamask/snaps-ui").Panel | {
66
+ content: import("@metamask/snaps-sdk").Panel | {
70
67
  value: string;
71
- type: import("@metamask/snaps-ui").NodeType.Copyable;
68
+ type: import("@metamask/snaps-sdk").NodeType.Copyable;
69
+ sensitive?: boolean | undefined;
72
70
  } | {
73
- type: import("@metamask/snaps-ui").NodeType.Divider;
71
+ type: import("@metamask/snaps-sdk").NodeType.Divider;
74
72
  } | {
75
73
  value: string;
76
- type: import("@metamask/snaps-ui").NodeType.Heading;
77
- } | {
78
- type: import("@metamask/snaps-ui").NodeType.Spinner;
74
+ type: import("@metamask/snaps-sdk").NodeType.Heading;
79
75
  } | {
80
76
  value: string;
81
- type: import("@metamask/snaps-ui").NodeType.Text;
82
- markdown?: boolean | undefined;
77
+ type: import("@metamask/snaps-sdk").NodeType.Image;
78
+ } | {
79
+ type: import("@metamask/snaps-sdk").NodeType.Spinner;
83
80
  } | {
84
81
  value: string;
85
- type: import("@metamask/snaps-ui").NodeType.Image;
82
+ type: import("@metamask/snaps-sdk").NodeType.Text;
83
+ markdown?: boolean | undefined;
86
84
  };
87
85
  } | {
88
86
  type: "prompt";
89
- content: import("@metamask/snaps-ui").Panel | {
87
+ content: import("@metamask/snaps-sdk").Panel | {
90
88
  value: string;
91
- type: import("@metamask/snaps-ui").NodeType.Copyable;
89
+ type: import("@metamask/snaps-sdk").NodeType.Copyable;
90
+ sensitive?: boolean | undefined;
92
91
  } | {
93
- type: import("@metamask/snaps-ui").NodeType.Divider;
92
+ type: import("@metamask/snaps-sdk").NodeType.Divider;
94
93
  } | {
95
94
  value: string;
96
- type: import("@metamask/snaps-ui").NodeType.Heading;
97
- } | {
98
- type: import("@metamask/snaps-ui").NodeType.Spinner;
95
+ type: import("@metamask/snaps-sdk").NodeType.Heading;
99
96
  } | {
100
97
  value: string;
101
- type: import("@metamask/snaps-ui").NodeType.Text;
102
- markdown?: boolean | undefined;
98
+ type: import("@metamask/snaps-sdk").NodeType.Image;
99
+ } | {
100
+ type: import("@metamask/snaps-sdk").NodeType.Spinner;
103
101
  } | {
104
102
  value: string;
105
- type: import("@metamask/snaps-ui").NodeType.Image;
103
+ type: import("@metamask/snaps-sdk").NodeType.Text;
104
+ markdown?: boolean | undefined;
106
105
  };
107
106
  placeholder?: string | undefined;
108
107
  }, null>;
109
- export declare type DialogParameters = Infer<typeof DialogParametersStruct>;
108
+ export declare type DialogParameters = InferMatching<typeof DialogParametersStruct, DialogParams>;
110
109
  /**
111
110
  * Builds the method implementation for `snap_dialog`.
112
111
  *
@@ -1,7 +1,6 @@
1
- import type { JsonSLIP10Node } from '@metamask/key-tree';
2
1
  import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from '@metamask/permission-controller';
3
2
  import { PermissionType } from '@metamask/permission-controller';
4
- import type { Bip32Entropy } from '@metamask/snaps-utils';
3
+ import type { GetBip32EntropyParams, GetBip32EntropyResult } from '@metamask/snaps-sdk';
5
4
  import type { NonEmptyArray } from '@metamask/utils';
6
5
  import type { MethodHooksObject } from '../utils';
7
6
  declare const targetName = "snap_getBip32Entropy";
@@ -41,5 +40,5 @@ export declare const getBip32EntropyBuilder: Readonly<{
41
40
  * @returns The method implementation which returns a `JsonSLIP10Node`.
42
41
  * @throws If the params are invalid.
43
42
  */
44
- export declare function getBip32EntropyImplementation({ getMnemonic, getUnlockPromise, }: GetBip32EntropyMethodHooks): (args: RestrictedMethodOptions<Bip32Entropy>) => Promise<JsonSLIP10Node>;
43
+ export declare function getBip32EntropyImplementation({ getMnemonic, getUnlockPromise, }: GetBip32EntropyMethodHooks): (args: RestrictedMethodOptions<GetBip32EntropyParams>) => Promise<GetBip32EntropyResult>;
45
44
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from '@metamask/permission-controller';
2
2
  import { PermissionType } from '@metamask/permission-controller';
3
+ import type { GetBip32PublicKeyParams, GetBip32PublicKeyResult } from '@metamask/snaps-sdk';
3
4
  import type { NonEmptyArray } from '@metamask/utils';
4
5
  import type { MethodHooksObject } from '../utils';
5
6
  declare const targetName = "snap_getBip32PublicKey";
@@ -18,11 +19,6 @@ export declare type GetBip32PublicKeyMethodHooks = {
18
19
  declare type GetBip32PublicKeySpecificationBuilderOptions = {
19
20
  methodHooks: GetBip32PublicKeyMethodHooks;
20
21
  };
21
- declare type GetBip32PublicKeyParameters = {
22
- path: ['m', ...(`${number}` | `${number}'`)[]];
23
- curve: 'secp256k1' | 'ed25519';
24
- compressed?: boolean;
25
- };
26
22
  export declare const Bip32PublicKeyArgsStruct: import("superstruct").Struct<{
27
23
  path: string[];
28
24
  curve: "ed25519" | "secp256k1";
@@ -56,5 +52,5 @@ export declare const getBip32PublicKeyBuilder: Readonly<{
56
52
  * @returns The method implementation which returns a public key.
57
53
  * @throws If the params are invalid.
58
54
  */
59
- export declare function getBip32PublicKeyImplementation({ getMnemonic, getUnlockPromise, }: GetBip32PublicKeyMethodHooks): (args: RestrictedMethodOptions<GetBip32PublicKeyParameters>) => Promise<string>;
55
+ export declare function getBip32PublicKeyImplementation({ getMnemonic, getUnlockPromise, }: GetBip32PublicKeyMethodHooks): (args: RestrictedMethodOptions<GetBip32PublicKeyParams>) => Promise<GetBip32PublicKeyResult>;
60
56
  export {};
@@ -1,6 +1,6 @@
1
- import type { JsonBIP44CoinTypeNode } from '@metamask/key-tree';
2
1
  import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from '@metamask/permission-controller';
3
2
  import { PermissionType } from '@metamask/permission-controller';
3
+ import type { GetBip44EntropyParams, GetBip44EntropyResult } from '@metamask/snaps-sdk';
4
4
  import type { NonEmptyArray } from '@metamask/utils';
5
5
  import type { MethodHooksObject } from '../utils';
6
6
  declare const targetName = "snap_getBip44Entropy";
@@ -19,9 +19,6 @@ export declare type GetBip44EntropyMethodHooks = {
19
19
  declare type GetBip44EntropySpecificationBuilderOptions = {
20
20
  methodHooks: GetBip44EntropyMethodHooks;
21
21
  };
22
- export declare type GetBip44EntropyParams = {
23
- coinType: number;
24
- };
25
22
  export declare const getBip44EntropyBuilder: Readonly<{
26
23
  readonly targetName: "snap_getBip44Entropy";
27
24
  readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, GetBip44EntropySpecificationBuilderOptions, {
@@ -45,5 +42,5 @@ export declare const getBip44EntropyBuilder: Readonly<{
45
42
  * @returns The method implementation which returns a `BIP44CoinTypeNode`.
46
43
  * @throws If the params are invalid.
47
44
  */
48
- export declare function getBip44EntropyImplementation({ getMnemonic, getUnlockPromise, }: GetBip44EntropyMethodHooks): (args: RestrictedMethodOptions<GetBip44EntropyParams>) => Promise<JsonBIP44CoinTypeNode>;
45
+ export declare function getBip44EntropyImplementation({ getMnemonic, getUnlockPromise, }: GetBip44EntropyMethodHooks): (args: RestrictedMethodOptions<GetBip44EntropyParams>) => Promise<GetBip44EntropyResult>;
49
46
  export {};
@@ -1,6 +1,7 @@
1
1
  import type { PermissionSpecificationBuilder, RestrictedMethodOptions } from '@metamask/permission-controller';
2
2
  import { PermissionType } from '@metamask/permission-controller';
3
- import type { Hex, NonEmptyArray } from '@metamask/utils';
3
+ import type { GetEntropyParams, GetEntropyResult } from '@metamask/snaps-sdk';
4
+ import type { NonEmptyArray } from '@metamask/utils';
4
5
  import type { Infer } from 'superstruct';
5
6
  import type { MethodHooksObject } from '../utils';
6
7
  declare const targetName = "snap_getEntropy";
@@ -56,5 +57,5 @@ export declare type GetEntropyHooks = {
56
57
  * once the extension is unlocked.
57
58
  * @returns The method implementation.
58
59
  */
59
- declare function getEntropyImplementation({ getMnemonic, getUnlockPromise, }: GetEntropyHooks): (options: RestrictedMethodOptions<GetEntropyArgs>) => Promise<Hex>;
60
+ declare function getEntropyImplementation({ getMnemonic, getUnlockPromise, }: GetEntropyHooks): (options: RestrictedMethodOptions<GetEntropyParams>) => Promise<GetEntropyResult>;
60
61
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from '@metamask/permission-controller';
2
2
  import { PermissionType } from '@metamask/permission-controller';
3
+ import type { GetLocaleResult } from '@metamask/snaps-sdk';
3
4
  import type { NonEmptyArray } from '@metamask/utils';
4
5
  import type { MethodHooksObject } from '../utils';
5
6
  declare const methodName = "snap_getLocale";
@@ -43,5 +44,5 @@ export declare const getLocaleBuilder: Readonly<{
43
44
  * @param hooks.getLocale - A function that returns the user selected locale.
44
45
  * @returns The user selected locale.
45
46
  */
46
- export declare function getImplementation({ getLocale }: GetLocaleMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<string>;
47
+ export declare function getImplementation({ getLocale }: GetLocaleMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<GetLocaleResult>;
47
48
  export {};
@@ -8,12 +8,7 @@ import type { InvokeSnapMethodHooks } from './invokeSnap';
8
8
  import type { ManageAccountsMethodHooks } from './manageAccounts';
9
9
  import type { ManageStateMethodHooks } from './manageState';
10
10
  import type { NotifyMethodHooks } from './notify';
11
- export type { DialogParameters } from './dialog';
12
- export { DialogType } from './dialog';
13
- export { ManageStateOperation } from './manageState';
14
11
  export { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';
15
- export type { NotificationArgs } from './notify';
16
- export { NotificationType } from './notify';
17
12
  export declare type RestrictedMethodHooks = DialogMethodHooks & GetBip32EntropyMethodHooks & GetBip32PublicKeyMethodHooks & GetBip44EntropyMethodHooks & GetEntropyHooks & InvokeSnapMethodHooks & ManageStateMethodHooks & NotifyMethodHooks & ManageAccountsMethodHooks & GetLocaleMethodHooks;
18
13
  export declare const restrictedMethodPermissionBuilders: {
19
14
  readonly snap_dialog: Readonly<{
@@ -24,68 +19,7 @@ export declare const restrictedMethodPermissionBuilders: {
24
19
  }, {
25
20
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
26
21
  targetName: "snap_dialog";
27
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<{
28
- type: "alert";
29
- content: import("@metamask/snaps-ui").Panel | {
30
- value: string;
31
- type: import("@metamask/snaps-ui").NodeType.Copyable;
32
- } | {
33
- type: import("@metamask/snaps-ui").NodeType.Divider;
34
- } | {
35
- value: string;
36
- type: import("@metamask/snaps-ui").NodeType.Heading;
37
- } | {
38
- type: import("@metamask/snaps-ui").NodeType.Spinner;
39
- } | {
40
- value: string;
41
- type: import("@metamask/snaps-ui").NodeType.Text;
42
- markdown?: boolean | undefined;
43
- } | {
44
- value: string;
45
- type: import("@metamask/snaps-ui").NodeType.Image;
46
- };
47
- } | {
48
- type: "confirmation";
49
- content: import("@metamask/snaps-ui").Panel | {
50
- value: string;
51
- type: import("@metamask/snaps-ui").NodeType.Copyable;
52
- } | {
53
- type: import("@metamask/snaps-ui").NodeType.Divider;
54
- } | {
55
- value: string;
56
- type: import("@metamask/snaps-ui").NodeType.Heading;
57
- } | {
58
- type: import("@metamask/snaps-ui").NodeType.Spinner;
59
- } | {
60
- value: string;
61
- type: import("@metamask/snaps-ui").NodeType.Text;
62
- markdown?: boolean | undefined;
63
- } | {
64
- value: string;
65
- type: import("@metamask/snaps-ui").NodeType.Image;
66
- };
67
- } | {
68
- type: "prompt";
69
- content: import("@metamask/snaps-ui").Panel | {
70
- value: string;
71
- type: import("@metamask/snaps-ui").NodeType.Copyable;
72
- } | {
73
- type: import("@metamask/snaps-ui").NodeType.Divider;
74
- } | {
75
- value: string;
76
- type: import("@metamask/snaps-ui").NodeType.Heading;
77
- } | {
78
- type: import("@metamask/snaps-ui").NodeType.Spinner;
79
- } | {
80
- value: string;
81
- type: import("@metamask/snaps-ui").NodeType.Text;
82
- markdown?: boolean | undefined;
83
- } | {
84
- value: string;
85
- type: import("@metamask/snaps-ui").NodeType.Image;
86
- };
87
- placeholder?: string | undefined;
88
- }>) => Promise<string | boolean | null>;
22
+ methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").DialogParams>) => Promise<string | boolean | null>;
89
23
  allowedCaveats: readonly [string, ...string[]] | null;
90
24
  }>;
91
25
  readonly methodHooks: import("../utils").MethodHooksObject<DialogMethodHooks>;
@@ -97,10 +31,7 @@ export declare const restrictedMethodPermissionBuilders: {
97
31
  }, {
98
32
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
99
33
  targetName: "snap_getBip32Entropy";
100
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<{
101
- path: string[];
102
- curve: "ed25519" | "secp256k1";
103
- }>) => Promise<import("@metamask/key-tree").JsonSLIP10Node>;
34
+ methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").Bip32Entropy>) => Promise<import("@metamask/key-tree").JsonSLIP10Node>;
104
35
  allowedCaveats: readonly [string, ...string[]] | null;
105
36
  validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
106
37
  }>;
@@ -113,11 +44,7 @@ export declare const restrictedMethodPermissionBuilders: {
113
44
  }, {
114
45
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
115
46
  targetName: "snap_getBip32PublicKey";
116
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<{
117
- path: ["m", ...(`${number}` | `${number}'`)[]];
118
- curve: "ed25519" | "secp256k1";
119
- compressed?: boolean | undefined;
120
- }>) => Promise<string>;
47
+ methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetBip32PublicKeyParams>) => Promise<string>;
121
48
  allowedCaveats: readonly [string, ...string[]] | null;
122
49
  validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
123
50
  }>;
@@ -130,7 +57,7 @@ export declare const restrictedMethodPermissionBuilders: {
130
57
  }, {
131
58
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
132
59
  targetName: "snap_getBip44Entropy";
133
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("./getBip44Entropy").GetBip44EntropyParams>) => Promise<import("@metamask/key-tree").JsonBIP44CoinTypeNode>;
60
+ methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").Bip44Entropy>) => Promise<import("@metamask/key-tree").JsonBIP44CoinTypeNode>;
134
61
  allowedCaveats: readonly [string, ...string[]] | null;
135
62
  validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
136
63
  }>;
@@ -144,10 +71,7 @@ export declare const restrictedMethodPermissionBuilders: {
144
71
  }, {
145
72
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
146
73
  targetName: "snap_getEntropy";
147
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<{
148
- version: 1;
149
- salt?: string | undefined;
150
- }>) => Promise<`0x${string}`>;
74
+ methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").GetEntropyParams>) => Promise<`0x${string}`>;
151
75
  allowedCaveats: readonly [string, ...string[]] | null;
152
76
  }>;
153
77
  readonly methodHooks: import("../utils").MethodHooksObject<GetEntropyHooks>;
@@ -160,7 +84,7 @@ export declare const restrictedMethodPermissionBuilders: {
160
84
  }, {
161
85
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
162
86
  targetName: "wallet_snap";
163
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<Record<string, import("@metamask/utils").Json>>) => Promise<import("@metamask/utils").Json>;
87
+ methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("./invokeSnap").InvokeSnapParams>) => Promise<import("@metamask/utils").Json>;
164
88
  allowedCaveats: readonly [string, ...string[]] | null;
165
89
  validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
166
90
  sideEffect: {
@@ -177,7 +101,7 @@ export declare const restrictedMethodPermissionBuilders: {
177
101
  }, {
178
102
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
179
103
  targetName: "snap_manageState";
180
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("./manageState").ManageStateArgs>) => Promise<Record<string, import("@metamask/utils").Json> | null>;
104
+ methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").ManageStateParams>) => Promise<import("@metamask/snaps-sdk").ManageStateResult>;
181
105
  allowedCaveats: readonly [string, ...string[]] | null;
182
106
  }>;
183
107
  readonly methodHooks: import("../utils").MethodHooksObject<ManageStateMethodHooks>;
@@ -190,7 +114,7 @@ export declare const restrictedMethodPermissionBuilders: {
190
114
  }, {
191
115
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
192
116
  targetName: "snap_notify";
193
- methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("./notify").NotificationArgs>) => Promise<null>;
117
+ methodImplementation: (args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").NotifyParams>) => Promise<null>;
194
118
  allowedCaveats: readonly [string, ...string[]] | null;
195
119
  }>;
196
120
  readonly methodHooks: import("../utils").MethodHooksObject<NotifyMethodHooks>;
@@ -203,12 +127,7 @@ export declare const restrictedMethodPermissionBuilders: {
203
127
  }, {
204
128
  permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
205
129
  targetName: "snap_manageAccounts";
206
- methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<{
207
- method: string;
208
- } | {
209
- params: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[];
210
- method: string;
211
- }>) => Promise<import("@metamask/utils").Json>;
130
+ methodImplementation: (options: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/snaps-sdk").ManageAccountsParams>) => Promise<import("@metamask/utils").Json>;
212
131
  allowedCaveats: readonly [string, ...string[]] | null;
213
132
  }>;
214
133
  readonly methodHooks: {