@metamask/snaps-rpc-methods 15.1.1 → 16.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 (344) hide show
  1. package/CHANGELOG.md +27 -4
  2. package/dist/index.cjs +1 -4
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1 -2
  5. package/dist/index.d.cts.map +1 -1
  6. package/dist/index.d.mts +1 -2
  7. package/dist/index.d.mts.map +1 -1
  8. package/dist/index.mjs +1 -2
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/permissions.cjs +18 -8
  11. package/dist/permissions.cjs.map +1 -1
  12. package/dist/permissions.d.cts +3 -2
  13. package/dist/permissions.d.cts.map +1 -1
  14. package/dist/permissions.d.mts +3 -2
  15. package/dist/permissions.d.mts.map +1 -1
  16. package/dist/permissions.mjs +17 -7
  17. package/dist/permissions.mjs.map +1 -1
  18. package/dist/permitted/cancelBackgroundEvent.cjs +10 -14
  19. package/dist/permitted/cancelBackgroundEvent.cjs.map +1 -1
  20. package/dist/permitted/cancelBackgroundEvent.d.cts +9 -12
  21. package/dist/permitted/cancelBackgroundEvent.d.cts.map +1 -1
  22. package/dist/permitted/cancelBackgroundEvent.d.mts +9 -12
  23. package/dist/permitted/cancelBackgroundEvent.d.mts.map +1 -1
  24. package/dist/permitted/cancelBackgroundEvent.mjs +10 -14
  25. package/dist/permitted/cancelBackgroundEvent.mjs.map +1 -1
  26. package/dist/permitted/clearState.cjs +10 -16
  27. package/dist/permitted/clearState.cjs.map +1 -1
  28. package/dist/permitted/clearState.d.cts +9 -23
  29. package/dist/permitted/clearState.d.cts.map +1 -1
  30. package/dist/permitted/clearState.d.mts +9 -23
  31. package/dist/permitted/clearState.d.mts.map +1 -1
  32. package/dist/permitted/clearState.mjs +10 -16
  33. package/dist/permitted/clearState.mjs.map +1 -1
  34. package/dist/permitted/closeWebSocket.cjs +7 -14
  35. package/dist/permitted/closeWebSocket.cjs.map +1 -1
  36. package/dist/permitted/closeWebSocket.d.cts +9 -12
  37. package/dist/permitted/closeWebSocket.d.cts.map +1 -1
  38. package/dist/permitted/closeWebSocket.d.mts +9 -12
  39. package/dist/permitted/closeWebSocket.d.mts.map +1 -1
  40. package/dist/permitted/closeWebSocket.mjs +7 -14
  41. package/dist/permitted/closeWebSocket.mjs.map +1 -1
  42. package/dist/permitted/createInterface.cjs +11 -15
  43. package/dist/permitted/createInterface.cjs.map +1 -1
  44. package/dist/permitted/createInterface.d.cts +23 -37
  45. package/dist/permitted/createInterface.d.cts.map +1 -1
  46. package/dist/permitted/createInterface.d.mts +23 -37
  47. package/dist/permitted/createInterface.d.mts.map +1 -1
  48. package/dist/permitted/createInterface.mjs +11 -15
  49. package/dist/permitted/createInterface.mjs.map +1 -1
  50. package/dist/permitted/endTrace.cjs +4 -6
  51. package/dist/permitted/endTrace.cjs.map +1 -1
  52. package/dist/permitted/endTrace.d.cts +8 -11
  53. package/dist/permitted/endTrace.d.cts.map +1 -1
  54. package/dist/permitted/endTrace.d.mts +8 -11
  55. package/dist/permitted/endTrace.d.mts.map +1 -1
  56. package/dist/permitted/endTrace.mjs +4 -6
  57. package/dist/permitted/endTrace.mjs.map +1 -1
  58. package/dist/permitted/getAllSnaps.cjs +5 -11
  59. package/dist/permitted/getAllSnaps.cjs.map +1 -1
  60. package/dist/permitted/getAllSnaps.d.cts +10 -14
  61. package/dist/permitted/getAllSnaps.d.cts.map +1 -1
  62. package/dist/permitted/getAllSnaps.d.mts +10 -14
  63. package/dist/permitted/getAllSnaps.d.mts.map +1 -1
  64. package/dist/permitted/getAllSnaps.mjs +5 -11
  65. package/dist/permitted/getAllSnaps.mjs.map +1 -1
  66. package/dist/permitted/getBackgroundEvents.cjs +8 -15
  67. package/dist/permitted/getBackgroundEvents.cjs.map +1 -1
  68. package/dist/permitted/getBackgroundEvents.d.cts +10 -13
  69. package/dist/permitted/getBackgroundEvents.d.cts.map +1 -1
  70. package/dist/permitted/getBackgroundEvents.d.mts +10 -13
  71. package/dist/permitted/getBackgroundEvents.d.mts.map +1 -1
  72. package/dist/permitted/getBackgroundEvents.mjs +8 -15
  73. package/dist/permitted/getBackgroundEvents.mjs.map +1 -1
  74. package/dist/permitted/getClientStatus.cjs +5 -6
  75. package/dist/permitted/getClientStatus.cjs.map +1 -1
  76. package/dist/permitted/getClientStatus.d.cts +17 -18
  77. package/dist/permitted/getClientStatus.d.cts.map +1 -1
  78. package/dist/permitted/getClientStatus.d.mts +17 -18
  79. package/dist/permitted/getClientStatus.d.mts.map +1 -1
  80. package/dist/permitted/getClientStatus.mjs +5 -6
  81. package/dist/permitted/getClientStatus.mjs.map +1 -1
  82. package/dist/permitted/getFile.cjs +7 -11
  83. package/dist/permitted/getFile.cjs.map +1 -1
  84. package/dist/permitted/getFile.d.cts +8 -10
  85. package/dist/permitted/getFile.d.cts.map +1 -1
  86. package/dist/permitted/getFile.d.mts +8 -10
  87. package/dist/permitted/getFile.d.mts.map +1 -1
  88. package/dist/permitted/getFile.mjs +7 -11
  89. package/dist/permitted/getFile.mjs.map +1 -1
  90. package/dist/permitted/getInterfaceContext.cjs +12 -15
  91. package/dist/permitted/getInterfaceContext.cjs.map +1 -1
  92. package/dist/permitted/getInterfaceContext.d.cts +9 -21
  93. package/dist/permitted/getInterfaceContext.d.cts.map +1 -1
  94. package/dist/permitted/getInterfaceContext.d.mts +9 -21
  95. package/dist/permitted/getInterfaceContext.d.mts.map +1 -1
  96. package/dist/permitted/getInterfaceContext.mjs +12 -15
  97. package/dist/permitted/getInterfaceContext.mjs.map +1 -1
  98. package/dist/permitted/getInterfaceState.cjs +11 -15
  99. package/dist/permitted/getInterfaceState.cjs.map +1 -1
  100. package/dist/permitted/getInterfaceState.d.cts +9 -21
  101. package/dist/permitted/getInterfaceState.d.cts.map +1 -1
  102. package/dist/permitted/getInterfaceState.d.mts +9 -21
  103. package/dist/permitted/getInterfaceState.d.mts.map +1 -1
  104. package/dist/permitted/getInterfaceState.mjs +11 -15
  105. package/dist/permitted/getInterfaceState.mjs.map +1 -1
  106. package/dist/permitted/getSnaps.cjs +6 -12
  107. package/dist/permitted/getSnaps.cjs.map +1 -1
  108. package/dist/permitted/getSnaps.d.cts +11 -14
  109. package/dist/permitted/getSnaps.d.cts.map +1 -1
  110. package/dist/permitted/getSnaps.d.mts +11 -14
  111. package/dist/permitted/getSnaps.d.mts.map +1 -1
  112. package/dist/permitted/getSnaps.mjs +6 -12
  113. package/dist/permitted/getSnaps.mjs.map +1 -1
  114. package/dist/permitted/getState.cjs +9 -11
  115. package/dist/permitted/getState.cjs.map +1 -1
  116. package/dist/permitted/getState.d.cts +17 -28
  117. package/dist/permitted/getState.d.cts.map +1 -1
  118. package/dist/permitted/getState.d.mts +17 -28
  119. package/dist/permitted/getState.d.mts.map +1 -1
  120. package/dist/permitted/getState.mjs +9 -11
  121. package/dist/permitted/getState.mjs.map +1 -1
  122. package/dist/permitted/getWebSockets.cjs +11 -14
  123. package/dist/permitted/getWebSockets.cjs.map +1 -1
  124. package/dist/permitted/getWebSockets.d.cts +10 -13
  125. package/dist/permitted/getWebSockets.d.cts.map +1 -1
  126. package/dist/permitted/getWebSockets.d.mts +10 -13
  127. package/dist/permitted/getWebSockets.d.mts.map +1 -1
  128. package/dist/permitted/getWebSockets.mjs +11 -14
  129. package/dist/permitted/getWebSockets.mjs.map +1 -1
  130. package/dist/permitted/index.cjs +0 -1
  131. package/dist/permitted/index.cjs.map +1 -1
  132. package/dist/permitted/index.d.cts +29 -25
  133. package/dist/permitted/index.d.cts.map +1 -1
  134. package/dist/permitted/index.d.mts +29 -25
  135. package/dist/permitted/index.d.mts.map +1 -1
  136. package/dist/permitted/index.mjs +0 -1
  137. package/dist/permitted/index.mjs.map +1 -1
  138. package/dist/permitted/invokeKeyring.cjs +12 -13
  139. package/dist/permitted/invokeKeyring.cjs.map +1 -1
  140. package/dist/permitted/invokeKeyring.d.cts +17 -16
  141. package/dist/permitted/invokeKeyring.d.cts.map +1 -1
  142. package/dist/permitted/invokeKeyring.d.mts +17 -16
  143. package/dist/permitted/invokeKeyring.d.mts.map +1 -1
  144. package/dist/permitted/invokeKeyring.mjs +12 -13
  145. package/dist/permitted/invokeKeyring.mjs.map +1 -1
  146. package/dist/permitted/invokeSnapSugar.cjs +6 -10
  147. package/dist/permitted/invokeSnapSugar.cjs.map +1 -1
  148. package/dist/permitted/invokeSnapSugar.d.cts +9 -12
  149. package/dist/permitted/invokeSnapSugar.d.cts.map +1 -1
  150. package/dist/permitted/invokeSnapSugar.d.mts +9 -12
  151. package/dist/permitted/invokeSnapSugar.d.mts.map +1 -1
  152. package/dist/permitted/invokeSnapSugar.mjs +6 -10
  153. package/dist/permitted/invokeSnapSugar.mjs.map +1 -1
  154. package/dist/permitted/listEntropySources.cjs +28 -12
  155. package/dist/permitted/listEntropySources.cjs.map +1 -1
  156. package/dist/permitted/listEntropySources.d.cts +12 -23
  157. package/dist/permitted/listEntropySources.d.cts.map +1 -1
  158. package/dist/permitted/listEntropySources.d.mts +12 -23
  159. package/dist/permitted/listEntropySources.d.mts.map +1 -1
  160. package/dist/permitted/listEntropySources.mjs +28 -12
  161. package/dist/permitted/listEntropySources.mjs.map +1 -1
  162. package/dist/permitted/middleware.cjs +70 -20
  163. package/dist/permitted/middleware.cjs.map +1 -1
  164. package/dist/permitted/middleware.d.cts +5 -2
  165. package/dist/permitted/middleware.d.cts.map +1 -1
  166. package/dist/permitted/middleware.d.mts +5 -2
  167. package/dist/permitted/middleware.d.mts.map +1 -1
  168. package/dist/permitted/middleware.mjs +70 -20
  169. package/dist/permitted/middleware.mjs.map +1 -1
  170. package/dist/permitted/openWebSocket.cjs +7 -14
  171. package/dist/permitted/openWebSocket.cjs.map +1 -1
  172. package/dist/permitted/openWebSocket.d.cts +9 -12
  173. package/dist/permitted/openWebSocket.d.cts.map +1 -1
  174. package/dist/permitted/openWebSocket.d.mts +9 -12
  175. package/dist/permitted/openWebSocket.d.mts.map +1 -1
  176. package/dist/permitted/openWebSocket.mjs +7 -14
  177. package/dist/permitted/openWebSocket.mjs.map +1 -1
  178. package/dist/permitted/requestSnaps.cjs +14 -19
  179. package/dist/permitted/requestSnaps.cjs.map +1 -1
  180. package/dist/permitted/requestSnaps.d.cts +9 -36
  181. package/dist/permitted/requestSnaps.d.cts.map +1 -1
  182. package/dist/permitted/requestSnaps.d.mts +9 -36
  183. package/dist/permitted/requestSnaps.d.mts.map +1 -1
  184. package/dist/permitted/requestSnaps.mjs +15 -20
  185. package/dist/permitted/requestSnaps.mjs.map +1 -1
  186. package/dist/permitted/resolveInterface.cjs +11 -15
  187. package/dist/permitted/resolveInterface.cjs.map +1 -1
  188. package/dist/permitted/resolveInterface.d.cts +12 -24
  189. package/dist/permitted/resolveInterface.d.cts.map +1 -1
  190. package/dist/permitted/resolveInterface.d.mts +12 -24
  191. package/dist/permitted/resolveInterface.d.mts.map +1 -1
  192. package/dist/permitted/resolveInterface.mjs +11 -15
  193. package/dist/permitted/resolveInterface.mjs.map +1 -1
  194. package/dist/permitted/scheduleBackgroundEvent.cjs +11 -14
  195. package/dist/permitted/scheduleBackgroundEvent.cjs.map +1 -1
  196. package/dist/permitted/scheduleBackgroundEvent.d.cts +10 -17
  197. package/dist/permitted/scheduleBackgroundEvent.d.cts.map +1 -1
  198. package/dist/permitted/scheduleBackgroundEvent.d.mts +10 -17
  199. package/dist/permitted/scheduleBackgroundEvent.d.mts.map +1 -1
  200. package/dist/permitted/scheduleBackgroundEvent.mjs +11 -14
  201. package/dist/permitted/scheduleBackgroundEvent.mjs.map +1 -1
  202. package/dist/permitted/sendWebSocketMessage.cjs +10 -14
  203. package/dist/permitted/sendWebSocketMessage.cjs.map +1 -1
  204. package/dist/permitted/sendWebSocketMessage.d.cts +9 -12
  205. package/dist/permitted/sendWebSocketMessage.d.cts.map +1 -1
  206. package/dist/permitted/sendWebSocketMessage.d.mts +9 -12
  207. package/dist/permitted/sendWebSocketMessage.d.mts.map +1 -1
  208. package/dist/permitted/sendWebSocketMessage.mjs +10 -14
  209. package/dist/permitted/sendWebSocketMessage.mjs.map +1 -1
  210. package/dist/permitted/setState.cjs +18 -21
  211. package/dist/permitted/setState.cjs.map +1 -1
  212. package/dist/permitted/setState.d.cts +18 -45
  213. package/dist/permitted/setState.d.cts.map +1 -1
  214. package/dist/permitted/setState.d.mts +18 -45
  215. package/dist/permitted/setState.d.mts.map +1 -1
  216. package/dist/permitted/setState.mjs +18 -21
  217. package/dist/permitted/setState.mjs.map +1 -1
  218. package/dist/permitted/startTrace.cjs +4 -6
  219. package/dist/permitted/startTrace.cjs.map +1 -1
  220. package/dist/permitted/startTrace.d.cts +8 -11
  221. package/dist/permitted/startTrace.d.cts.map +1 -1
  222. package/dist/permitted/startTrace.d.mts +8 -11
  223. package/dist/permitted/startTrace.d.mts.map +1 -1
  224. package/dist/permitted/startTrace.mjs +4 -6
  225. package/dist/permitted/startTrace.mjs.map +1 -1
  226. package/dist/permitted/trackError.cjs +4 -6
  227. package/dist/permitted/trackError.cjs.map +1 -1
  228. package/dist/permitted/trackError.d.cts +8 -11
  229. package/dist/permitted/trackError.d.cts.map +1 -1
  230. package/dist/permitted/trackError.d.mts +8 -11
  231. package/dist/permitted/trackError.d.mts.map +1 -1
  232. package/dist/permitted/trackError.mjs +4 -6
  233. package/dist/permitted/trackError.mjs.map +1 -1
  234. package/dist/permitted/trackEvent.cjs +4 -6
  235. package/dist/permitted/trackEvent.cjs.map +1 -1
  236. package/dist/permitted/trackEvent.d.cts +8 -11
  237. package/dist/permitted/trackEvent.d.cts.map +1 -1
  238. package/dist/permitted/trackEvent.d.mts +8 -11
  239. package/dist/permitted/trackEvent.d.mts.map +1 -1
  240. package/dist/permitted/trackEvent.mjs +4 -6
  241. package/dist/permitted/trackEvent.mjs.map +1 -1
  242. package/dist/permitted/updateInterface.cjs +11 -15
  243. package/dist/permitted/updateInterface.cjs.map +1 -1
  244. package/dist/permitted/updateInterface.d.cts +9 -22
  245. package/dist/permitted/updateInterface.d.cts.map +1 -1
  246. package/dist/permitted/updateInterface.d.mts +9 -22
  247. package/dist/permitted/updateInterface.d.mts.map +1 -1
  248. package/dist/permitted/updateInterface.mjs +11 -15
  249. package/dist/permitted/updateInterface.mjs.map +1 -1
  250. package/dist/restricted/dialog.cjs +23 -30
  251. package/dist/restricted/dialog.cjs.map +1 -1
  252. package/dist/restricted/dialog.d.cts +10 -58
  253. package/dist/restricted/dialog.d.cts.map +1 -1
  254. package/dist/restricted/dialog.d.mts +10 -58
  255. package/dist/restricted/dialog.d.mts.map +1 -1
  256. package/dist/restricted/dialog.mjs +23 -30
  257. package/dist/restricted/dialog.mjs.map +1 -1
  258. package/dist/restricted/getBip32Entropy.cjs +15 -12
  259. package/dist/restricted/getBip32Entropy.cjs.map +1 -1
  260. package/dist/restricted/getBip32Entropy.d.cts +11 -24
  261. package/dist/restricted/getBip32Entropy.d.cts.map +1 -1
  262. package/dist/restricted/getBip32Entropy.d.mts +11 -24
  263. package/dist/restricted/getBip32Entropy.d.mts.map +1 -1
  264. package/dist/restricted/getBip32Entropy.mjs +16 -13
  265. package/dist/restricted/getBip32Entropy.mjs.map +1 -1
  266. package/dist/restricted/getBip32PublicKey.cjs +15 -12
  267. package/dist/restricted/getBip32PublicKey.cjs.map +1 -1
  268. package/dist/restricted/getBip32PublicKey.d.cts +11 -24
  269. package/dist/restricted/getBip32PublicKey.d.cts.map +1 -1
  270. package/dist/restricted/getBip32PublicKey.d.mts +11 -24
  271. package/dist/restricted/getBip32PublicKey.d.mts.map +1 -1
  272. package/dist/restricted/getBip32PublicKey.mjs +16 -13
  273. package/dist/restricted/getBip32PublicKey.mjs.map +1 -1
  274. package/dist/restricted/getBip44Entropy.cjs +14 -10
  275. package/dist/restricted/getBip44Entropy.cjs.map +1 -1
  276. package/dist/restricted/getBip44Entropy.d.cts +11 -15
  277. package/dist/restricted/getBip44Entropy.d.cts.map +1 -1
  278. package/dist/restricted/getBip44Entropy.d.mts +11 -15
  279. package/dist/restricted/getBip44Entropy.d.mts.map +1 -1
  280. package/dist/restricted/getBip44Entropy.mjs +15 -11
  281. package/dist/restricted/getBip44Entropy.mjs.map +1 -1
  282. package/dist/restricted/getEntropy.cjs +10 -10
  283. package/dist/restricted/getEntropy.cjs.map +1 -1
  284. package/dist/restricted/getEntropy.d.cts +11 -15
  285. package/dist/restricted/getEntropy.d.cts.map +1 -1
  286. package/dist/restricted/getEntropy.d.mts +11 -15
  287. package/dist/restricted/getEntropy.d.mts.map +1 -1
  288. package/dist/restricted/getEntropy.mjs +11 -11
  289. package/dist/restricted/getEntropy.mjs.map +1 -1
  290. package/dist/restricted/index.cjs.map +1 -1
  291. package/dist/restricted/index.d.cts +20 -160
  292. package/dist/restricted/index.d.cts.map +1 -1
  293. package/dist/restricted/index.d.mts +20 -160
  294. package/dist/restricted/index.d.mts.map +1 -1
  295. package/dist/restricted/index.mjs.map +1 -1
  296. package/dist/restricted/invokeSnap.cjs +11 -12
  297. package/dist/restricted/invokeSnap.cjs.map +1 -1
  298. package/dist/restricted/invokeSnap.d.cts +9 -13
  299. package/dist/restricted/invokeSnap.d.cts.map +1 -1
  300. package/dist/restricted/invokeSnap.d.mts +9 -13
  301. package/dist/restricted/invokeSnap.d.mts.map +1 -1
  302. package/dist/restricted/invokeSnap.mjs +11 -12
  303. package/dist/restricted/invokeSnap.mjs.map +1 -1
  304. package/dist/restricted/manageState.cjs +21 -20
  305. package/dist/restricted/manageState.cjs.map +1 -1
  306. package/dist/restricted/manageState.d.cts +12 -34
  307. package/dist/restricted/manageState.d.cts.map +1 -1
  308. package/dist/restricted/manageState.d.mts +12 -34
  309. package/dist/restricted/manageState.d.mts.map +1 -1
  310. package/dist/restricted/manageState.mjs +21 -20
  311. package/dist/restricted/manageState.mjs.map +1 -1
  312. package/dist/restricted/notify.cjs +31 -24
  313. package/dist/restricted/notify.cjs.map +1 -1
  314. package/dist/restricted/notify.d.cts +16 -25
  315. package/dist/restricted/notify.d.cts.map +1 -1
  316. package/dist/restricted/notify.d.mts +16 -25
  317. package/dist/restricted/notify.d.mts.map +1 -1
  318. package/dist/restricted/notify.mjs +32 -25
  319. package/dist/restricted/notify.mjs.map +1 -1
  320. package/dist/types.cjs +3 -0
  321. package/dist/types.cjs.map +1 -0
  322. package/dist/types.d.cts +155 -0
  323. package/dist/types.d.cts.map +1 -0
  324. package/dist/types.d.mts +155 -0
  325. package/dist/types.d.mts.map +1 -0
  326. package/dist/types.mjs +2 -0
  327. package/dist/types.mjs.map +1 -0
  328. package/dist/utils.cjs +78 -24
  329. package/dist/utils.cjs.map +1 -1
  330. package/dist/utils.d.cts +21 -13
  331. package/dist/utils.d.cts.map +1 -1
  332. package/dist/utils.d.mts +21 -13
  333. package/dist/utils.d.mts.map +1 -1
  334. package/dist/utils.mjs +75 -22
  335. package/dist/utils.mjs.map +1 -1
  336. package/package.json +6 -6
  337. package/dist/permitted/handlers.cjs +0 -63
  338. package/dist/permitted/handlers.cjs.map +0 -1
  339. package/dist/permitted/handlers.d.cts +0 -299
  340. package/dist/permitted/handlers.d.cts.map +0 -1
  341. package/dist/permitted/handlers.d.mts +0 -299
  342. package/dist/permitted/handlers.d.mts.map +0 -1
  343. package/dist/permitted/handlers.mjs +0 -60
  344. package/dist/permitted/handlers.mjs.map +0 -1
@@ -1,29 +1,13 @@
1
1
  import type { CryptographicFunctions } from "@metamask/key-tree";
2
+ import type { Messenger } from "@metamask/messenger";
2
3
  import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from "@metamask/permission-controller";
3
4
  import { PermissionType } from "@metamask/permission-controller";
4
5
  import type { GetBip32EntropyParams, GetBip32EntropyResult } from "@metamask/snaps-sdk";
5
6
  import type { NonEmptyArray } from "@metamask/utils";
7
+ import type { KeyringControllerWithKeyringAction } from "../types.cjs";
6
8
  import type { MethodHooksObject } from "../utils.cjs";
7
9
  declare const targetName = "snap_getBip32Entropy";
8
10
  export type GetBip32EntropyMethodHooks = {
9
- /**
10
- * Get the mnemonic of the provided source. If no source is provided, the
11
- * mnemonic of the primary keyring will be returned.
12
- *
13
- * @param source - The optional ID of the source to get the mnemonic of.
14
- * @returns The mnemonic of the provided source, or the default source if no
15
- * source is provided.
16
- */
17
- getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;
18
- /**
19
- * Get the mnemonic seed of the provided source. If no source is provided, the
20
- * mnemonic seed of the primary keyring will be returned.
21
- *
22
- * @param source - The optional ID of the source to get the mnemonic of.
23
- * @returns The mnemonic seed of the provided source, or the default source if no
24
- * source is provided.
25
- */
26
- getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;
27
11
  /**
28
12
  * Waits for the extension to be unlocked.
29
13
  *
@@ -39,8 +23,10 @@ export type GetBip32EntropyMethodHooks = {
39
23
  */
40
24
  getClientCryptography: () => CryptographicFunctions | undefined;
41
25
  };
26
+ export type GetBip32EntropyMessengerActions = KeyringControllerWithKeyringAction;
42
27
  type GetBip32EntropySpecificationBuilderOptions = {
43
28
  methodHooks: GetBip32EntropyMethodHooks;
29
+ messenger: Messenger<string, GetBip32EntropyMessengerActions>;
44
30
  };
45
31
  /**
46
32
  * Enables you to [manage users' non-EVM accounts](https://docs.metamask.io/snaps/features/non-evm-networks/)
@@ -107,20 +93,21 @@ export declare const getBip32EntropyBuilder: Readonly<{
107
93
  validator: PermissionValidatorConstraint;
108
94
  }>;
109
95
  readonly methodHooks: MethodHooksObject<GetBip32EntropyMethodHooks>;
96
+ readonly actionNames: readonly ["KeyringController:withKeyring"];
110
97
  }>;
111
98
  /**
112
99
  * Builds the method implementation for `snap_getBip32Entropy`.
113
100
  *
114
- * @param hooks - The RPC method hooks.
115
- * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.
116
- * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.
117
- * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
101
+ * @param options - The options.
102
+ * @param options.messenger - The messenger.
103
+ * @param options.methodHooks - The RPC method hooks.
104
+ * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
118
105
  * and prompts the user to unlock their MetaMask if it is locked.
119
- * @param hooks.getClientCryptography - A function to retrieve the cryptographic
106
+ * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic
120
107
  * functions to use for the client.
121
108
  * @returns The method implementation which returns a `JsonSLIP10Node`.
122
109
  * @throws If the params are invalid.
123
110
  */
124
- export declare function getBip32EntropyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }: GetBip32EntropyMethodHooks): (args: RestrictedMethodOptions<GetBip32EntropyParams>) => Promise<GetBip32EntropyResult>;
111
+ export declare function getBip32EntropyImplementation({ methodHooks: { getUnlockPromise, getClientCryptography }, messenger, }: GetBip32EntropySpecificationBuilderOptions): (args: RestrictedMethodOptions<GetBip32EntropyParams>) => Promise<GetBip32EntropyResult>;
125
112
  export {};
126
113
  //# sourceMappingURL=getBip32Entropy.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBip32Entropy.d.cts","sourceRoot":"","sources":["../../src/restricted/getBip32Entropy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,uBAAuB,EAExB,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAE9E,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,4BAA4B;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAOlD,QAAA,MAAM,UAAU,yBAAyB,CAAC;AAE1C,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAElE;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK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lD,QAAA,MAAM,UAAU,yBAAyB,CAAC;AAE1C,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;;;OAMG;IACH,qBAAqB,EAAE,MAAM,sBAAsB,GAAG,SAAS,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,+BAA+B,GACzC,kCAAkC,CAAC;AAErC,KAAK,0CAA0C,GAAG;IAChD,WAAW,EAAE,0BAA0B,CAAC;IACxC,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,+BAA+B,CAAC,CAAC;CAC/D,CAAC;AAuDF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,sBAAsB;;;wBA3GjB,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,oCAAoC,CAAC;wBACtD,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;mBAC3C,6BAA6B;;;;EA4G/B,CAAC;AAEZ;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,EAC5C,WAAW,EAAE,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,EACxD,SAAS,GACV,EAAE,0CAA0C,UAEnC,wBAAwB,qBAAqB,CAAC,KACnD,QAAQ,qBAAqB,CAAC,CAqClC"}
@@ -1,29 +1,13 @@
1
1
  import type { CryptographicFunctions } from "@metamask/key-tree";
2
+ import type { Messenger } from "@metamask/messenger";
2
3
  import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from "@metamask/permission-controller";
3
4
  import { PermissionType } from "@metamask/permission-controller";
4
5
  import type { GetBip32EntropyParams, GetBip32EntropyResult } from "@metamask/snaps-sdk";
5
6
  import type { NonEmptyArray } from "@metamask/utils";
7
+ import type { KeyringControllerWithKeyringAction } from "../types.mjs";
6
8
  import type { MethodHooksObject } from "../utils.mjs";
7
9
  declare const targetName = "snap_getBip32Entropy";
8
10
  export type GetBip32EntropyMethodHooks = {
9
- /**
10
- * Get the mnemonic of the provided source. If no source is provided, the
11
- * mnemonic of the primary keyring will be returned.
12
- *
13
- * @param source - The optional ID of the source to get the mnemonic of.
14
- * @returns The mnemonic of the provided source, or the default source if no
15
- * source is provided.
16
- */
17
- getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;
18
- /**
19
- * Get the mnemonic seed of the provided source. If no source is provided, the
20
- * mnemonic seed of the primary keyring will be returned.
21
- *
22
- * @param source - The optional ID of the source to get the mnemonic of.
23
- * @returns The mnemonic seed of the provided source, or the default source if no
24
- * source is provided.
25
- */
26
- getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;
27
11
  /**
28
12
  * Waits for the extension to be unlocked.
29
13
  *
@@ -39,8 +23,10 @@ export type GetBip32EntropyMethodHooks = {
39
23
  */
40
24
  getClientCryptography: () => CryptographicFunctions | undefined;
41
25
  };
26
+ export type GetBip32EntropyMessengerActions = KeyringControllerWithKeyringAction;
42
27
  type GetBip32EntropySpecificationBuilderOptions = {
43
28
  methodHooks: GetBip32EntropyMethodHooks;
29
+ messenger: Messenger<string, GetBip32EntropyMessengerActions>;
44
30
  };
45
31
  /**
46
32
  * Enables you to [manage users' non-EVM accounts](https://docs.metamask.io/snaps/features/non-evm-networks/)
@@ -107,20 +93,21 @@ export declare const getBip32EntropyBuilder: Readonly<{
107
93
  validator: PermissionValidatorConstraint;
108
94
  }>;
109
95
  readonly methodHooks: MethodHooksObject<GetBip32EntropyMethodHooks>;
96
+ readonly actionNames: readonly ["KeyringController:withKeyring"];
110
97
  }>;
111
98
  /**
112
99
  * Builds the method implementation for `snap_getBip32Entropy`.
113
100
  *
114
- * @param hooks - The RPC method hooks.
115
- * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.
116
- * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.
117
- * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
101
+ * @param options - The options.
102
+ * @param options.messenger - The messenger.
103
+ * @param options.methodHooks - The RPC method hooks.
104
+ * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
118
105
  * and prompts the user to unlock their MetaMask if it is locked.
119
- * @param hooks.getClientCryptography - A function to retrieve the cryptographic
106
+ * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic
120
107
  * functions to use for the client.
121
108
  * @returns The method implementation which returns a `JsonSLIP10Node`.
122
109
  * @throws If the params are invalid.
123
110
  */
124
- export declare function getBip32EntropyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }: GetBip32EntropyMethodHooks): (args: RestrictedMethodOptions<GetBip32EntropyParams>) => Promise<GetBip32EntropyResult>;
111
+ export declare function getBip32EntropyImplementation({ methodHooks: { getUnlockPromise, getClientCryptography }, messenger, }: GetBip32EntropySpecificationBuilderOptions): (args: RestrictedMethodOptions<GetBip32EntropyParams>) => Promise<GetBip32EntropyResult>;
125
112
  export {};
126
113
  //# sourceMappingURL=getBip32Entropy.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBip32Entropy.d.mts","sourceRoot":"","sources":["../../src/restricted/getBip32Entropy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,uBAAuB,EAExB,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAE9E,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,4BAA4B;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAOlD,QAAA,MAAM,UAAU,yBAAyB,CAAC;AAE1C,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC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ACtB,4BAA4B;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,kCAAkC,EAAE,qBAAiB;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AASlD,QAAA,MAAM,UAAU,yBAAyB,CAAC;AAE1C,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;;;OAMG;IACH,qBAAqB,EAAE,MAAM,sBAAsB,GAAG,SAAS,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,+BAA+B,GACzC,kCAAkC,CAAC;AAErC,KAAK,0CAA0C,GAAG;IAChD,WAAW,EAAE,0BAA0B,CAAC;IACxC,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,+BAA+B,CAAC,CAAC;CAC/D,CAAC;AAuDF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,sBAAsB;;;wBA3GjB,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,oCAAoC,CAAC;wBACtD,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;mBAC3C,6BAA6B;;;;EA4G/B,CAAC;AAEZ;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,EAC5C,WAAW,EAAE,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,EACxD,SAAS,GACV,EAAE,0CAA0C,UAEnC,wBAAwB,qBAAqB,CAAC,KACnD,QAAQ,qBAAqB,CAAC,CAqClC"}
@@ -2,7 +2,7 @@ import { PermissionType, SubjectType } from "@metamask/permission-controller";
2
2
  import { rpcErrors } from "@metamask/rpc-errors";
3
3
  import { SnapCaveatType } from "@metamask/snaps-utils";
4
4
  import { assert } from "@metamask/utils";
5
- import { getNodeFromMnemonic, getNodeFromSeed, getValueFromEntropySource } from "../utils.mjs";
5
+ import { getMnemonic, getMnemonicSeed, getNodeFromMnemonic, getNodeFromSeed, getValueFromEntropySource } from "../utils.mjs";
6
6
  const targetName = 'snap_getBip32Entropy';
7
7
  /**
8
8
  * The specification builder for the `snap_getBip32Entropy` permission.
@@ -10,15 +10,19 @@ const targetName = 'snap_getBip32Entropy';
10
10
  * BIP-32 node.
11
11
  *
12
12
  * @param options - The specification builder options.
13
+ * @param options.messenger - The messenger.
13
14
  * @param options.methodHooks - The RPC method hooks needed by the method implementation.
14
15
  * @returns The specification for the `snap_getBip32Entropy` permission.
15
16
  */
16
- const specificationBuilder = ({ methodHooks }) => {
17
+ const specificationBuilder = ({ methodHooks, messenger, }) => {
17
18
  return {
18
19
  permissionType: PermissionType.RestrictedMethod,
19
20
  targetName,
20
21
  allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],
21
- methodImplementation: getBip32EntropyImplementation(methodHooks),
22
+ methodImplementation: getBip32EntropyImplementation({
23
+ methodHooks,
24
+ messenger,
25
+ }),
22
26
  validator: ({ caveats }) => {
23
27
  if (caveats?.length !== 1 ||
24
28
  caveats[0].type !== SnapCaveatType.PermittedDerivationPaths) {
@@ -31,8 +35,6 @@ const specificationBuilder = ({ methodHooks }) => {
31
35
  };
32
36
  };
33
37
  const methodHooks = {
34
- getMnemonic: true,
35
- getMnemonicSeed: true,
36
38
  getUnlockPromise: true,
37
39
  getClientCryptography: true,
38
40
  };
@@ -95,28 +97,29 @@ export const getBip32EntropyBuilder = Object.freeze({
95
97
  targetName,
96
98
  specificationBuilder,
97
99
  methodHooks,
100
+ actionNames: ['KeyringController:withKeyring'],
98
101
  });
99
102
  /**
100
103
  * Builds the method implementation for `snap_getBip32Entropy`.
101
104
  *
102
- * @param hooks - The RPC method hooks.
103
- * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.
104
- * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.
105
- * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
105
+ * @param options - The options.
106
+ * @param options.messenger - The messenger.
107
+ * @param options.methodHooks - The RPC method hooks.
108
+ * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
106
109
  * and prompts the user to unlock their MetaMask if it is locked.
107
- * @param hooks.getClientCryptography - A function to retrieve the cryptographic
110
+ * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic
108
111
  * functions to use for the client.
109
112
  * @returns The method implementation which returns a `JsonSLIP10Node`.
110
113
  * @throws If the params are invalid.
111
114
  */
112
- export function getBip32EntropyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }) {
115
+ export function getBip32EntropyImplementation({ methodHooks: { getUnlockPromise, getClientCryptography }, messenger, }) {
113
116
  return async function getBip32Entropy(args) {
114
117
  await getUnlockPromise(true);
115
118
  const { params } = args;
116
119
  assert(params);
117
120
  // Using the seed is much faster, but we can only do it for these specific curves.
118
121
  if (params.curve === 'secp256k1' || params.curve === 'ed25519') {
119
- const seed = await getValueFromEntropySource(getMnemonicSeed, params.source);
122
+ const seed = await getValueFromEntropySource(getMnemonicSeed.bind(null, messenger), params.source);
120
123
  const node = await getNodeFromSeed({
121
124
  curve: params.curve,
122
125
  path: params.path,
@@ -125,7 +128,7 @@ export function getBip32EntropyImplementation({ getMnemonic, getMnemonicSeed, ge
125
128
  });
126
129
  return node.toJSON();
127
130
  }
128
- const secretRecoveryPhrase = await getValueFromEntropySource(getMnemonic, params.source);
131
+ const secretRecoveryPhrase = await getValueFromEntropySource(getMnemonic.bind(null, messenger), params.source);
129
132
  const node = await getNodeFromMnemonic({
130
133
  curve: params.curve,
131
134
  path: params.path,
@@ -1 +1 @@
1
- {"version":3,"file":"getBip32Entropy.mjs","sourceRoot":"","sources":["../../src/restricted/getBip32Entropy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAC9E,OAAO,EAAE,SAAS,EAAE,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,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACM;IAC3B,OAAO,KAAK,UAAU,eAAe,CACnC,IAAoD;QAEpD,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAE7B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,MAAM,CAAC,CAAC;QAEf,kFAAkF;QAClF,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/D,MAAM,IAAI,GAAG,MAAM,yBAAyB,CAC1C,eAAe,EACf,MAAM,CAAC,MAAM,CACd,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC;gBACjC,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI;gBACJ,sBAAsB,EAAE,qBAAqB,EAAE;aAChD,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QAED,MAAM,oBAAoB,GAAG,MAAM,yBAAyB,CAC1D,WAAW,EACX,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC;YACrC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,oBAAoB;YACpB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from '@metamask/snaps-sdk';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assert } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport {\n getNodeFromMnemonic,\n getNodeFromSeed,\n getValueFromEntropySource,\n} from '../utils';\n\nconst targetName = 'snap_getBip32Entropy';\n\nexport type GetBip32EntropyMethodHooks = {\n /**\n * Get the mnemonic of the provided source. If no source is provided, the\n * mnemonic of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\n};\n\ntype GetBip32EntropySpecificationBuilderOptions = {\n methodHooks: GetBip32EntropyMethodHooks;\n};\n\ntype GetBip32EntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32EntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * The specification builder for the `snap_getBip32Entropy` permission.\n * `snap_getBip32Entropy` lets the Snap control private keys for a particular\n * BIP-32 node.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getBip32Entropy` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32EntropySpecificationBuilderOptions,\n GetBip32EntropySpecification\n> = ({ methodHooks }: GetBip32EntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32EntropyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32EntropyMethodHooks> = {\n getMnemonic: true,\n getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\n/**\n * Enables you to [manage users' non-EVM accounts](https://docs.metamask.io/snaps/features/non-evm-networks/)\n * by deriving the [SLIP-10](https://github.com/satoshilabs/slips/blob/master/slip-0010.md)\n * keys specified by the `path` and `curve` parameters. The keys are derived\n * using the entropy from the user's Secret Recovery Phrase.\n *\n * If the keys you want to derive conform to the [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)\n * structure, use [snap_getBip44Entropy](https://docs.metamask.io/snaps/reference/snaps-api/snap_getbip44entropy)\n * instead. Otherwise, use this method.\n *\n * This method is designed to be used with the [`@metamask/key-tree`](https://npmjs.com/package/@metamask/key-tree)\n * module. `@metamask/key-tree` can help you get the [extended private keys](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys)\n * for user addresses, but it's your responsibility to know how to use those\n * keys to, for example, derive an address for the relevant protocol or sign a\n * transaction for the user.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getBip32Entropy\": [\n * {\n * \"path\": [\"m\", \"44'\", \"3'\"],\n * \"curve\": \"secp256k1\" // Or \"ed25519\", \"ed25519Bip32\"\n * }\n * ]\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * import { SLIP10Node } from '@metamask/key-tree'\n *\n * // This example uses Dogecoin, which has a derivation path starting with\n * // m/44'/3'.\n * const dogecoinNode = await snap.request({\n * method: 'snap_getBip32Entropy',\n * params: {\n * // The path and curve must be specified in the initial permissions.\n * path: ['m', \"44'\", \"3'\"],\n * curve: 'secp256k1',\n * },\n * })\n *\n * // Next, create an instance of a SLIP-10 node for the Dogecoin node.\n * const dogecoinSlip10Node = await SLIP10Node.fromJSON(dogecoinNode)\n *\n * // m/44'/3'/0'\n * const accountKey0 = await dogecoinSlip10Node.derive([\"bip32:0'\"])\n *\n * // m/44'/3'/1'\n * const accountKey1 = await dogecoinSlip10Node.derive([\"bip32:1'\"])\n *\n * // Now, you can ask the user to sign transactions, etc.\n * ```\n */\nexport const getBip32EntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32Entropy`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.\n * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation which returns a `JsonSLIP10Node`.\n * @throws If the params are invalid.\n */\nexport function getBip32EntropyImplementation({\n getMnemonic,\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\n}: GetBip32EntropyMethodHooks) {\n return async function getBip32Entropy(\n args: RestrictedMethodOptions<GetBip32EntropyParams>,\n ): Promise<GetBip32EntropyResult> {\n await getUnlockPromise(true);\n\n const { params } = args;\n assert(params);\n\n // Using the seed is much faster, but we can only do it for these specific curves.\n if (params.curve === 'secp256k1' || params.curve === 'ed25519') {\n const seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n const node = await getNodeFromSeed({\n curve: params.curve,\n path: params.path,\n seed,\n cryptographicFunctions: getClientCryptography(),\n });\n\n return node.toJSON();\n }\n\n const secretRecoveryPhrase = await getValueFromEntropySource(\n getMnemonic,\n params.source,\n );\n\n const node = await getNodeFromMnemonic({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase,\n cryptographicFunctions: getClientCryptography(),\n });\n\n return node.toJSON();\n };\n}\n"]}
1
+ {"version":3,"file":"getBip32Entropy.mjs","sourceRoot":"","sources":["../../src/restricted/getBip32Entropy.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAC9E,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAKjD,OAAO,EAAE,cAAc,EAAE,8BAA8B;AAEvD,OAAO,EAAE,MAAM,EAAE,wBAAwB;AAIzC,OAAO,EACL,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EAC1B,qBAAiB;AAElB,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAoC1C;;;;;;;;;GASG;AACH,MAAM,oBAAoB,GAItB,CAAC,EACH,WAAW,EACX,SAAS,GACkC,EAAE,EAAE;IAC/C,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,gBAAgB;QAC/C,UAAU;QACV,cAAc,EAAE,CAAC,cAAc,CAAC,wBAAwB,CAAC;QACzD,oBAAoB,EAAE,6BAA6B,CAAC;YAClD,WAAW;YACX,SAAS;SACV,CAAC;QACF,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;YACzB,IACE,OAAO,EAAE,MAAM,KAAK,CAAC;gBACrB,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,wBAAwB,EAC3D,CAAC;gBACD,MAAM,S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AAC,CAAC;YAEH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QAED,MAAM,oBAAoB,GAAG,MAAM,yBAAyB,CAC1D,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EACjC,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC;YACrC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,oBAAoB;YACpB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from '@metamask/snaps-sdk';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assert } from '@metamask/utils';\n\nimport type { KeyringControllerWithKeyringAction } from '../types';\nimport type { MethodHooksObject } from '../utils';\nimport {\n getMnemonic,\n getMnemonicSeed,\n getNodeFromMnemonic,\n getNodeFromSeed,\n getValueFromEntropySource,\n} from '../utils';\n\nconst targetName = 'snap_getBip32Entropy';\n\nexport type GetBip32EntropyMethodHooks = {\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\n};\n\nexport type GetBip32EntropyMessengerActions =\n KeyringControllerWithKeyringAction;\n\ntype GetBip32EntropySpecificationBuilderOptions = {\n methodHooks: GetBip32EntropyMethodHooks;\n messenger: Messenger<string, GetBip32EntropyMessengerActions>;\n};\n\ntype GetBip32EntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32EntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * The specification builder for the `snap_getBip32Entropy` permission.\n * `snap_getBip32Entropy` lets the Snap control private keys for a particular\n * BIP-32 node.\n *\n * @param options - The specification builder options.\n * @param options.messenger - The messenger.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getBip32Entropy` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32EntropySpecificationBuilderOptions,\n GetBip32EntropySpecification\n> = ({\n methodHooks,\n messenger,\n}: GetBip32EntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32EntropyImplementation({\n methodHooks,\n messenger,\n }),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32EntropyMethodHooks> = {\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\n/**\n * Enables you to [manage users' non-EVM accounts](https://docs.metamask.io/snaps/features/non-evm-networks/)\n * by deriving the [SLIP-10](https://github.com/satoshilabs/slips/blob/master/slip-0010.md)\n * keys specified by the `path` and `curve` parameters. The keys are derived\n * using the entropy from the user's Secret Recovery Phrase.\n *\n * If the keys you want to derive conform to the [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)\n * structure, use [snap_getBip44Entropy](https://docs.metamask.io/snaps/reference/snaps-api/snap_getbip44entropy)\n * instead. Otherwise, use this method.\n *\n * This method is designed to be used with the [`@metamask/key-tree`](https://npmjs.com/package/@metamask/key-tree)\n * module. `@metamask/key-tree` can help you get the [extended private keys](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys)\n * for user addresses, but it's your responsibility to know how to use those\n * keys to, for example, derive an address for the relevant protocol or sign a\n * transaction for the user.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getBip32Entropy\": [\n * {\n * \"path\": [\"m\", \"44'\", \"3'\"],\n * \"curve\": \"secp256k1\" // Or \"ed25519\", \"ed25519Bip32\"\n * }\n * ]\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * import { SLIP10Node } from '@metamask/key-tree'\n *\n * // This example uses Dogecoin, which has a derivation path starting with\n * // m/44'/3'.\n * const dogecoinNode = await snap.request({\n * method: 'snap_getBip32Entropy',\n * params: {\n * // The path and curve must be specified in the initial permissions.\n * path: ['m', \"44'\", \"3'\"],\n * curve: 'secp256k1',\n * },\n * })\n *\n * // Next, create an instance of a SLIP-10 node for the Dogecoin node.\n * const dogecoinSlip10Node = await SLIP10Node.fromJSON(dogecoinNode)\n *\n * // m/44'/3'/0'\n * const accountKey0 = await dogecoinSlip10Node.derive([\"bip32:0'\"])\n *\n * // m/44'/3'/1'\n * const accountKey1 = await dogecoinSlip10Node.derive([\"bip32:1'\"])\n *\n * // Now, you can ask the user to sign transactions, etc.\n * ```\n */\nexport const getBip32EntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n actionNames: ['KeyringController:withKeyring'],\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32Entropy`.\n *\n * @param options - The options.\n * @param options.messenger - The messenger.\n * @param options.methodHooks - The RPC method hooks.\n * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation which returns a `JsonSLIP10Node`.\n * @throws If the params are invalid.\n */\nexport function getBip32EntropyImplementation({\n methodHooks: { getUnlockPromise, getClientCryptography },\n messenger,\n}: GetBip32EntropySpecificationBuilderOptions) {\n return async function getBip32Entropy(\n args: RestrictedMethodOptions<GetBip32EntropyParams>,\n ): Promise<GetBip32EntropyResult> {\n await getUnlockPromise(true);\n\n const { params } = args;\n assert(params);\n\n // Using the seed is much faster, but we can only do it for these specific curves.\n if (params.curve === 'secp256k1' || params.curve === 'ed25519') {\n const seed = await getValueFromEntropySource(\n getMnemonicSeed.bind(null, messenger),\n params.source,\n );\n\n const node = await getNodeFromSeed({\n curve: params.curve,\n path: params.path,\n seed,\n cryptographicFunctions: getClientCryptography(),\n });\n\n return node.toJSON();\n }\n\n const secretRecoveryPhrase = await getValueFromEntropySource(\n getMnemonic.bind(null, messenger),\n params.source,\n );\n\n const node = await getNodeFromMnemonic({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase,\n cryptographicFunctions: getClientCryptography(),\n });\n\n return node.toJSON();\n };\n}\n"]}
@@ -20,15 +20,19 @@ exports.Bip32PublicKeyArgsStruct = (0, snaps_utils_1.bip32entropy)((0, superstru
20
20
  * BIP-32 node.
21
21
  *
22
22
  * @param options - The specification builder options.
23
+ * @param options.messenger - The messenger.
23
24
  * @param options.methodHooks - The RPC method hooks needed by the method implementation.
24
25
  * @returns The specification for the `snap_getBip32PublicKey` permission.
25
26
  */
26
- const specificationBuilder = ({ methodHooks }) => {
27
+ const specificationBuilder = ({ methodHooks, messenger, }) => {
27
28
  return {
28
29
  permissionType: permission_controller_1.PermissionType.RestrictedMethod,
29
30
  targetName,
30
31
  allowedCaveats: [snaps_utils_1.SnapCaveatType.PermittedDerivationPaths],
31
- methodImplementation: getBip32PublicKeyImplementation(methodHooks),
32
+ methodImplementation: getBip32PublicKeyImplementation({
33
+ methodHooks,
34
+ messenger,
35
+ }),
32
36
  validator: ({ caveats }) => {
33
37
  if (caveats?.length !== 1 ||
34
38
  caveats[0].type !== snaps_utils_1.SnapCaveatType.PermittedDerivationPaths) {
@@ -41,8 +45,6 @@ const specificationBuilder = ({ methodHooks }) => {
41
45
  };
42
46
  };
43
47
  const methodHooks = {
44
- getMnemonic: true,
45
- getMnemonicSeed: true,
46
48
  getUnlockPromise: true,
47
49
  getClientCryptography: true,
48
50
  };
@@ -86,28 +88,29 @@ exports.getBip32PublicKeyBuilder = Object.freeze({
86
88
  targetName,
87
89
  specificationBuilder,
88
90
  methodHooks,
91
+ actionNames: ['KeyringController:withKeyring'],
89
92
  });
90
93
  /**
91
94
  * Builds the method implementation for `snap_getBip32PublicKey`.
92
95
  *
93
- * @param hooks - The RPC method hooks.
94
- * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.
95
- * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.
96
- * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
96
+ * @param options - The options.
97
+ * @param options.messenger - The messenger.
98
+ * @param options.methodHooks - The RPC method hooks.
99
+ * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
97
100
  * and prompts the user to unlock their MetaMask if it is locked.
98
- * @param hooks.getClientCryptography - A function to retrieve the cryptographic
101
+ * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic
99
102
  * functions to use for the client.
100
103
  * @returns The method implementation which returns a public key.
101
104
  * @throws If the params are invalid.
102
105
  */
103
- function getBip32PublicKeyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }) {
106
+ function getBip32PublicKeyImplementation({ methodHooks: { getUnlockPromise, getClientCryptography }, messenger, }) {
104
107
  return async function getBip32PublicKey(args) {
105
108
  await getUnlockPromise(true);
106
109
  (0, utils_1.assertStruct)(args.params, exports.Bip32PublicKeyArgsStruct, 'Invalid BIP-32 public key params', rpc_errors_1.rpcErrors.invalidParams);
107
110
  const { params } = args;
108
111
  // Using the seed is much faster, but we can only do it for these specific curves.
109
112
  if (params.curve === 'secp256k1' || params.curve === 'ed25519') {
110
- const seed = await (0, utils_2.getValueFromEntropySource)(getMnemonicSeed, params.source);
113
+ const seed = await (0, utils_2.getValueFromEntropySource)(utils_2.getMnemonicSeed.bind(null, messenger), params.source);
111
114
  const node = await (0, utils_2.getNodeFromSeed)({
112
115
  curve: params.curve,
113
116
  path: params.path,
@@ -119,7 +122,7 @@ function getBip32PublicKeyImplementation({ getMnemonic, getMnemonicSeed, getUnlo
119
122
  }
120
123
  return node.publicKey;
121
124
  }
122
- const secretRecoveryPhrase = await (0, utils_2.getValueFromEntropySource)(getMnemonic, params.source);
125
+ const secretRecoveryPhrase = await (0, utils_2.getValueFromEntropySource)(utils_2.getMnemonic.bind(null, messenger), params.source);
123
126
  const node = await (0, utils_2.getNodeFromMnemonic)({
124
127
  curve: params.curve,
125
128
  path: params.path,
@@ -1 +1 @@
1
- {"version":3,"file":"getBip32PublicKey.cjs","sourceRoot":"","sources":["../../src/restricted/getBip32PublicKey.ts"],"names":[],"mappings":";;;AAOA,2EAA8E;AAC9E,qDAAiD;AAKjD,uDAK+B;AAC/B,uDAA0E;AAE1E,2CAA+C;AAG/C,wCAIkB;AAElB,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAoD/B,QAAA,wBAAwB,GAAG,IAAA,0BAAY,EAClD,IAAA,oBAAM,EAAC;IACL,IAAI,EAAE,6BAAe;IACrB,KAAK,EAAE,yBAAW;IAClB,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IAC/B,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,G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B,kCAAkC,EAClC,sBAAS,CAAC,aAAa,CACxB,CAAC;QAEF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,kFAAkF;QAClF,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/D,MAAM,IAAI,GAAG,MAAM,IAAA,iCAAyB,EAC1C,eAAe,EACf,MAAM,CAAC,MAAM,CACd,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,IAAA,uBAAe,EAAC;gBACjC,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI;gBACJ,sBAAsB,EAAE,qBAAqB,EAAE;aAChD,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC,mBAAmB,CAAC;YAClC,CAAC;YAED,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;QAED,MAAM,oBAAoB,GAAG,MAAM,IAAA,iCAAyB,EAC1D,WAAW,EACX,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,IAAA,2BAAmB,EAAC;YACrC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,oBAAoB;YACpB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,mBAAmB,CAAC;QAClC,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AA3DD,0EA2DC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from '@metamask/snaps-sdk';\nimport {\n bip32entropy,\n Bip32PathStruct,\n CurveStruct,\n SnapCaveatType,\n} from '@metamask/snaps-utils';\nimport { boolean, object, optional, string } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport {\n getValueFromEntropySource,\n getNodeFromMnemonic,\n getNodeFromSeed,\n} from '../utils';\n\nconst targetName = 'snap_getBip32PublicKey';\n\nexport type GetBip32PublicKeyMethodHooks = {\n /**\n * Get the mnemonic of the provided source. If no source is provided, the\n * mnemonic of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * Get the mnemonic seed of the provided source. If no source is provided, the\n * mnemonic seed of the primary keyring will be returned.\n *\n * @param source - The optional ID of the source to get the mnemonic of.\n * @returns The mnemonic seed of the provided source, or the default source if no\n * source is provided.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\n};\n\ntype GetBip32PublicKeySpecificationBuilderOptions = {\n methodHooks: GetBip32PublicKeyMethodHooks;\n};\n\ntype GetBip32PublicKeySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32PublicKeyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\nexport const Bip32PublicKeyArgsStruct = bip32entropy(\n object({\n path: Bip32PathStruct,\n curve: CurveStruct,\n compressed: optional(boolean()),\n source: optional(string()),\n }),\n);\n\n/**\n * The specification builder for the `snap_getBip32PublicKey` permission.\n * `snap_getBip32PublicKey` lets the Snap retrieve public keys for a particular\n * BIP-32 node.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getBip32PublicKey` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32PublicKeySpecificationBuilderOptions,\n GetBip32PublicKeySpecification\n> = ({ methodHooks }: GetBip32PublicKeySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32PublicKeyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks> = {\n getMnemonic: true,\n getMnemonicSeed: true,\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\n/**\n * Gets the [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)\n * public key for the derivation path specified by the `path` parameter. Note\n * that this returns the public key, not the extended public key (`xpub`), or\n * Ethereum address.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getBip32PublicKey\": [\n * {\n * \"path\": [\"m\", \"44'\", \"3'\", \"0'\", \"0\", \"0\"],\n * \"curve\": \"secp256k1\"\n * }\n * ]\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * // This example uses Dogecoin, which has a derivation path starting with\n * // \"m / 44' / 3'\".\n * const dogecoinPublicKey = await snap.request({\n * method: 'snap_getBip32PublicKey',\n * params: {\n * // The path and curve must be specified in the initial permissions.\n * path: ['m', \"44'\", \"3'\", \"0'\", \"0\", \"0\"],\n * curve: 'secp256k1',\n * compressed: false,\n * },\n * })\n *\n * // '0x...'\n * console.log(dogecoinPublicKey)\n * ```\n */\nexport const getBip32PublicKeyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32PublicKey`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.\n * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @param hooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation which returns a public key.\n * @throws If the params are invalid.\n */\nexport function getBip32PublicKeyImplementation({\n getMnemonic,\n getMnemonicSeed,\n getUnlockPromise,\n getClientCryptography,\n}: GetBip32PublicKeyMethodHooks) {\n return async function getBip32PublicKey(\n args: RestrictedMethodOptions<GetBip32PublicKeyParams>,\n ): Promise<GetBip32PublicKeyResult> {\n await getUnlockPromise(true);\n\n assertStruct(\n args.params,\n Bip32PublicKeyArgsStruct,\n 'Invalid BIP-32 public key params',\n rpcErrors.invalidParams,\n );\n\n const { params } = args;\n\n // Using the seed is much faster, but we can only do it for these specific curves.\n if (params.curve === 'secp256k1' || params.curve === 'ed25519') {\n const seed = await getValueFromEntropySource(\n getMnemonicSeed,\n params.source,\n );\n\n const node = await getNodeFromSeed({\n curve: params.curve,\n path: params.path,\n seed,\n cryptographicFunctions: getClientCryptography(),\n });\n\n if (params.compressed) {\n return node.compressedPublicKey;\n }\n\n return node.publicKey;\n }\n\n const secretRecoveryPhrase = await getValueFromEntropySource(\n getMnemonic,\n params.source,\n );\n\n const node = await getNodeFromMnemonic({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase,\n cryptographicFunctions: getClientCryptography(),\n });\n\n if (params.compressed) {\n return node.compressedPublicKey;\n }\n\n return node.publicKey;\n };\n}\n"]}
1
+ {"version":3,"file":"getBip32PublicKey.cjs","sourceRoot":"","sources":["../../src/restricted/getBip32PublicKey.ts"],"names":[],"mappings":";;;AAQA,2EAA8E;AAC9E,qDAAiD;AAKjD,uDAK+B;AAC/B,uDAA0E;AAE1E,2CAA+C;AAI/C,wCAMkB;AAElB,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAoC/B,QAAA,wBAAwB,GAAG,IAAA,0BAAY,EAClD,IAAA,oBAAM,EAAC;IACL,IAAI,EAAE,6BAAe;IACrB,KAAK,EAAE,yBAAW;IAClB,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;IAC/B,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC3B,CAAC,CACH,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,oBAAoB,GAItB,CAAC,EACH,WAAW,EACX,SAAS,GACoC,EAAE,EAAE;IACjD,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU;QACV,cAAc,EAAE,CAAC,4BAAc,CAAC,wBAAwB,CAAC;QACzD,oBAAoB,EAAE,+BAA+B,CAAC;YACpD,WAAW;YACX,SAAS;SACV,CAAC;QACF,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;YACzB,IACE,OAAO,EAAE,MAAM,KAAK,CAAC;gBACrB,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,4BAAc,CAAC,wBAAwB,EAC3D,CAAC;gBACD,MAAM,sBAAS,CAAC,aAAa,CAAC;oBAC5B,OAAO,EAAE,sB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ChD,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC,mBAAmB,CAAC;YAClC,CAAC;YAED,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;QAED,MAAM,oBAAoB,GAAG,MAAM,IAAA,iCAAyB,EAC1D,mBAAW,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EACjC,MAAM,CAAC,MAAM,CACd,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,IAAA,2BAAmB,EAAC;YACrC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,oBAAoB;YACpB,sBAAsB,EAAE,qBAAqB,EAAE;SAChD,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,mBAAmB,CAAC;QAClC,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAzDD,0EAyDC","sourcesContent":["import type { CryptographicFunctions } from '@metamask/key-tree';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from '@metamask/snaps-sdk';\nimport {\n bip32entropy,\n Bip32PathStruct,\n CurveStruct,\n SnapCaveatType,\n} from '@metamask/snaps-utils';\nimport { boolean, object, optional, string } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { KeyringControllerWithKeyringAction } from '../types';\nimport type { MethodHooksObject } from '../utils';\nimport {\n getMnemonic,\n getMnemonicSeed,\n getNodeFromMnemonic,\n getNodeFromSeed,\n getValueFromEntropySource,\n} from '../utils';\n\nconst targetName = 'snap_getBip32PublicKey';\n\nexport type GetBip32PublicKeyMethodHooks = {\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object or `undefined` to fall back to the default cryptographic\n * functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions | undefined;\n};\n\nexport type GetBip32PublicKeyMessengerActions =\n KeyringControllerWithKeyringAction;\n\ntype GetBip32PublicKeySpecificationBuilderOptions = {\n methodHooks: GetBip32PublicKeyMethodHooks;\n messenger: Messenger<string, GetBip32PublicKeyMessengerActions>;\n};\n\ntype GetBip32PublicKeySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32PublicKeyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\nexport const Bip32PublicKeyArgsStruct = bip32entropy(\n object({\n path: Bip32PathStruct,\n curve: CurveStruct,\n compressed: optional(boolean()),\n source: optional(string()),\n }),\n);\n\n/**\n * The specification builder for the `snap_getBip32PublicKey` permission.\n * `snap_getBip32PublicKey` lets the Snap retrieve public keys for a particular\n * BIP-32 node.\n *\n * @param options - The specification builder options.\n * @param options.messenger - The messenger.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getBip32PublicKey` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32PublicKeySpecificationBuilderOptions,\n GetBip32PublicKeySpecification\n> = ({\n methodHooks,\n messenger,\n}: GetBip32PublicKeySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32PublicKeyImplementation({\n methodHooks,\n messenger,\n }),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks> = {\n getUnlockPromise: true,\n getClientCryptography: true,\n};\n\n/**\n * Gets the [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)\n * public key for the derivation path specified by the `path` parameter. Note\n * that this returns the public key, not the extended public key (`xpub`), or\n * Ethereum address.\n *\n * @example\n * ```json name=\"Manifest\"\n * {\n * \"initialPermissions\": {\n * \"snap_getBip32PublicKey\": [\n * {\n * \"path\": [\"m\", \"44'\", \"3'\", \"0'\", \"0\", \"0\"],\n * \"curve\": \"secp256k1\"\n * }\n * ]\n * }\n * }\n * ```\n * ```ts name=\"Usage\"\n * // This example uses Dogecoin, which has a derivation path starting with\n * // \"m / 44' / 3'\".\n * const dogecoinPublicKey = await snap.request({\n * method: 'snap_getBip32PublicKey',\n * params: {\n * // The path and curve must be specified in the initial permissions.\n * path: ['m', \"44'\", \"3'\", \"0'\", \"0\", \"0\"],\n * curve: 'secp256k1',\n * compressed: false,\n * },\n * })\n *\n * // '0x...'\n * console.log(dogecoinPublicKey)\n * ```\n */\nexport const getBip32PublicKeyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n actionNames: ['KeyringController:withKeyring'],\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32PublicKey`.\n *\n * @param options - The options.\n * @param options.messenger - The messenger.\n * @param options.methodHooks - The RPC method hooks.\n * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic\n * functions to use for the client.\n * @returns The method implementation which returns a public key.\n * @throws If the params are invalid.\n */\nexport function getBip32PublicKeyImplementation({\n methodHooks: { getUnlockPromise, getClientCryptography },\n messenger,\n}: GetBip32PublicKeySpecificationBuilderOptions) {\n return async function getBip32PublicKey(\n args: RestrictedMethodOptions<GetBip32PublicKeyParams>,\n ): Promise<GetBip32PublicKeyResult> {\n await getUnlockPromise(true);\n\n assertStruct(\n args.params,\n Bip32PublicKeyArgsStruct,\n 'Invalid BIP-32 public key params',\n rpcErrors.invalidParams,\n );\n\n const { params } = args;\n\n // Using the seed is much faster, but we can only do it for these specific curves.\n if (params.curve === 'secp256k1' || params.curve === 'ed25519') {\n const seed = await getValueFromEntropySource(\n getMnemonicSeed.bind(null, messenger),\n params.source,\n );\n\n const node = await getNodeFromSeed({\n curve: params.curve,\n path: params.path,\n seed,\n cryptographicFunctions: getClientCryptography(),\n });\n\n if (params.compressed) {\n return node.compressedPublicKey;\n }\n\n return node.publicKey;\n }\n\n const secretRecoveryPhrase = await getValueFromEntropySource(\n getMnemonic.bind(null, messenger),\n params.source,\n );\n\n const node = await getNodeFromMnemonic({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase,\n cryptographicFunctions: getClientCryptography(),\n });\n\n if (params.compressed) {\n return node.compressedPublicKey;\n }\n\n return node.publicKey;\n };\n}\n"]}
@@ -1,29 +1,13 @@
1
1
  import type { CryptographicFunctions } from "@metamask/key-tree";
2
+ import type { Messenger } from "@metamask/messenger";
2
3
  import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from "@metamask/permission-controller";
3
4
  import { PermissionType } from "@metamask/permission-controller";
4
5
  import type { GetBip32PublicKeyParams, GetBip32PublicKeyResult } from "@metamask/snaps-sdk";
5
6
  import type { NonEmptyArray } from "@metamask/utils";
7
+ import type { KeyringControllerWithKeyringAction } from "../types.cjs";
6
8
  import type { MethodHooksObject } from "../utils.cjs";
7
9
  declare const targetName = "snap_getBip32PublicKey";
8
10
  export type GetBip32PublicKeyMethodHooks = {
9
- /**
10
- * Get the mnemonic of the provided source. If no source is provided, the
11
- * mnemonic of the primary keyring will be returned.
12
- *
13
- * @param source - The optional ID of the source to get the mnemonic of.
14
- * @returns The mnemonic of the provided source, or the default source if no
15
- * source is provided.
16
- */
17
- getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;
18
- /**
19
- * Get the mnemonic seed of the provided source. If no source is provided, the
20
- * mnemonic seed of the primary keyring will be returned.
21
- *
22
- * @param source - The optional ID of the source to get the mnemonic of.
23
- * @returns The mnemonic seed of the provided source, or the default source if no
24
- * source is provided.
25
- */
26
- getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;
27
11
  /**
28
12
  * Waits for the extension to be unlocked.
29
13
  *
@@ -39,8 +23,10 @@ export type GetBip32PublicKeyMethodHooks = {
39
23
  */
40
24
  getClientCryptography: () => CryptographicFunctions | undefined;
41
25
  };
26
+ export type GetBip32PublicKeyMessengerActions = KeyringControllerWithKeyringAction;
42
27
  type GetBip32PublicKeySpecificationBuilderOptions = {
43
28
  methodHooks: GetBip32PublicKeyMethodHooks;
29
+ messenger: Messenger<string, GetBip32PublicKeyMessengerActions>;
44
30
  };
45
31
  export declare const Bip32PublicKeyArgsStruct: import("@metamask/superstruct").Struct<{
46
32
  curve: "secp256k1" | "ed25519" | "ed25519Bip32";
@@ -99,20 +85,21 @@ export declare const getBip32PublicKeyBuilder: Readonly<{
99
85
  validator: PermissionValidatorConstraint;
100
86
  }>;
101
87
  readonly methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks>;
88
+ readonly actionNames: readonly ["KeyringController:withKeyring"];
102
89
  }>;
103
90
  /**
104
91
  * Builds the method implementation for `snap_getBip32PublicKey`.
105
92
  *
106
- * @param hooks - The RPC method hooks.
107
- * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.
108
- * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.
109
- * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
93
+ * @param options - The options.
94
+ * @param options.messenger - The messenger.
95
+ * @param options.methodHooks - The RPC method hooks.
96
+ * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
110
97
  * and prompts the user to unlock their MetaMask if it is locked.
111
- * @param hooks.getClientCryptography - A function to retrieve the cryptographic
98
+ * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic
112
99
  * functions to use for the client.
113
100
  * @returns The method implementation which returns a public key.
114
101
  * @throws If the params are invalid.
115
102
  */
116
- export declare function getBip32PublicKeyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }: GetBip32PublicKeyMethodHooks): (args: RestrictedMethodOptions<GetBip32PublicKeyParams>) => Promise<GetBip32PublicKeyResult>;
103
+ export declare function getBip32PublicKeyImplementation({ methodHooks: { getUnlockPromise, getClientCryptography }, messenger, }: GetBip32PublicKeySpecificationBuilderOptions): (args: RestrictedMethodOptions<GetBip32PublicKeyParams>) => Promise<GetBip32PublicKeyResult>;
117
104
  export {};
118
105
  //# sourceMappingURL=getBip32PublicKey.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBip32PublicKey.d.cts","sourceRoot":"","sources":["../../src/restricted/getBip32PublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,uBAAuB,EAExB,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAE9E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,4BAA4B;AAQ7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAOlD,QAAA,MAAM,UAAU,2BAA2B,CAAC;AAE5C,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;;;;;OAOG;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AwC;AAE9E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,4BAA4B;AAQ7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,kCAAkC,EAAE,qBAAiB;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AASlD,QAAA,MAAM,UAAU,2BAA2B,CAAC;AAE5C,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;;;OAMG;IACH,qBAAqB,EAAE,MAAM,sBAAsB,GAAG,SAAS,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAC3C,kCAAkC,CAAC;AAErC,KAAK,4CAA4C,GAAG;IAClD,WAAW,EAAE,4BAA4B,CAAC;IAC1C,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,iCAAiC,CAAC,CAAC;CACjE,CAAC;AAUF,eAAO,MAAM,wBAAwB;;;;;;;;;;EAOpC,CAAC;AA+CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,wBAAwB;;;wBAjGnB,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,sCAAsC,CAAC;wBACxD,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;mBAC3C,6BAA6B;;;;EAkG/B,CAAC;AAEZ;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAAC,EAC9C,WAAW,EAAE,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,EACxD,SAAS,GACV,EAAE,4CAA4C,UAErC,wBAAwB,uBAAuB,CAAC,KACrD,QAAQ,uBAAuB,CAAC,CAmDpC"}
@@ -1,29 +1,13 @@
1
1
  import type { CryptographicFunctions } from "@metamask/key-tree";
2
+ import type { Messenger } from "@metamask/messenger";
2
3
  import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from "@metamask/permission-controller";
3
4
  import { PermissionType } from "@metamask/permission-controller";
4
5
  import type { GetBip32PublicKeyParams, GetBip32PublicKeyResult } from "@metamask/snaps-sdk";
5
6
  import type { NonEmptyArray } from "@metamask/utils";
7
+ import type { KeyringControllerWithKeyringAction } from "../types.mjs";
6
8
  import type { MethodHooksObject } from "../utils.mjs";
7
9
  declare const targetName = "snap_getBip32PublicKey";
8
10
  export type GetBip32PublicKeyMethodHooks = {
9
- /**
10
- * Get the mnemonic of the provided source. If no source is provided, the
11
- * mnemonic of the primary keyring will be returned.
12
- *
13
- * @param source - The optional ID of the source to get the mnemonic of.
14
- * @returns The mnemonic of the provided source, or the default source if no
15
- * source is provided.
16
- */
17
- getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;
18
- /**
19
- * Get the mnemonic seed of the provided source. If no source is provided, the
20
- * mnemonic seed of the primary keyring will be returned.
21
- *
22
- * @param source - The optional ID of the source to get the mnemonic of.
23
- * @returns The mnemonic seed of the provided source, or the default source if no
24
- * source is provided.
25
- */
26
- getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;
27
11
  /**
28
12
  * Waits for the extension to be unlocked.
29
13
  *
@@ -39,8 +23,10 @@ export type GetBip32PublicKeyMethodHooks = {
39
23
  */
40
24
  getClientCryptography: () => CryptographicFunctions | undefined;
41
25
  };
26
+ export type GetBip32PublicKeyMessengerActions = KeyringControllerWithKeyringAction;
42
27
  type GetBip32PublicKeySpecificationBuilderOptions = {
43
28
  methodHooks: GetBip32PublicKeyMethodHooks;
29
+ messenger: Messenger<string, GetBip32PublicKeyMessengerActions>;
44
30
  };
45
31
  export declare const Bip32PublicKeyArgsStruct: import("@metamask/superstruct").Struct<{
46
32
  curve: "secp256k1" | "ed25519" | "ed25519Bip32";
@@ -99,20 +85,21 @@ export declare const getBip32PublicKeyBuilder: Readonly<{
99
85
  validator: PermissionValidatorConstraint;
100
86
  }>;
101
87
  readonly methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks>;
88
+ readonly actionNames: readonly ["KeyringController:withKeyring"];
102
89
  }>;
103
90
  /**
104
91
  * Builds the method implementation for `snap_getBip32PublicKey`.
105
92
  *
106
- * @param hooks - The RPC method hooks.
107
- * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.
108
- * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user.
109
- * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
93
+ * @param options - The options.
94
+ * @param options.messenger - The messenger.
95
+ * @param options.methodHooks - The RPC method hooks.
96
+ * @param options.methodHooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked
110
97
  * and prompts the user to unlock their MetaMask if it is locked.
111
- * @param hooks.getClientCryptography - A function to retrieve the cryptographic
98
+ * @param options.methodHooks.getClientCryptography - A function to retrieve the cryptographic
112
99
  * functions to use for the client.
113
100
  * @returns The method implementation which returns a public key.
114
101
  * @throws If the params are invalid.
115
102
  */
116
- export declare function getBip32PublicKeyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }: GetBip32PublicKeyMethodHooks): (args: RestrictedMethodOptions<GetBip32PublicKeyParams>) => Promise<GetBip32PublicKeyResult>;
103
+ export declare function getBip32PublicKeyImplementation({ methodHooks: { getUnlockPromise, getClientCryptography }, messenger, }: GetBip32PublicKeySpecificationBuilderOptions): (args: RestrictedMethodOptions<GetBip32PublicKeyParams>) => Promise<GetBip32PublicKeyResult>;
117
104
  export {};
118
105
  //# sourceMappingURL=getBip32PublicKey.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBip32PublicKey.d.mts","sourceRoot":"","sources":["../../src/restricted/getBip32PublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,uBAAuB,EAExB,wCAAwC;AACzC,OAA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