@metamask/snaps-controllers 18.0.4 → 19.0.1

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 (288) hide show
  1. package/CHANGELOG.md +108 -1
  2. package/dist/cronjob/CronjobController-method-action-types.cjs +7 -0
  3. package/dist/cronjob/CronjobController-method-action-types.cjs.map +1 -0
  4. package/dist/cronjob/CronjobController-method-action-types.d.cts +51 -0
  5. package/dist/cronjob/CronjobController-method-action-types.d.cts.map +1 -0
  6. package/dist/cronjob/CronjobController-method-action-types.d.mts +51 -0
  7. package/dist/cronjob/CronjobController-method-action-types.d.mts.map +1 -0
  8. package/dist/cronjob/CronjobController-method-action-types.mjs +6 -0
  9. package/dist/cronjob/CronjobController-method-action-types.mjs.map +1 -0
  10. package/dist/cronjob/CronjobController.cjs +7 -4
  11. package/dist/cronjob/CronjobController.cjs.map +1 -1
  12. package/dist/cronjob/CronjobController.d.cts +8 -25
  13. package/dist/cronjob/CronjobController.d.cts.map +1 -1
  14. package/dist/cronjob/CronjobController.d.mts +8 -25
  15. package/dist/cronjob/CronjobController.d.mts.map +1 -1
  16. package/dist/cronjob/CronjobController.mjs +7 -4
  17. package/dist/cronjob/CronjobController.mjs.map +1 -1
  18. package/dist/cronjob/index.cjs +3 -15
  19. package/dist/cronjob/index.cjs.map +1 -1
  20. package/dist/cronjob/index.d.cts +3 -1
  21. package/dist/cronjob/index.d.cts.map +1 -1
  22. package/dist/cronjob/index.d.mts +3 -1
  23. package/dist/cronjob/index.d.mts.map +1 -1
  24. package/dist/cronjob/index.mjs +1 -1
  25. package/dist/cronjob/index.mjs.map +1 -1
  26. package/dist/insights/SnapInsightsController.cjs +1 -3
  27. package/dist/insights/SnapInsightsController.cjs.map +1 -1
  28. package/dist/insights/SnapInsightsController.d.cts +9 -9
  29. package/dist/insights/SnapInsightsController.d.cts.map +1 -1
  30. package/dist/insights/SnapInsightsController.d.mts +9 -9
  31. package/dist/insights/SnapInsightsController.d.mts.map +1 -1
  32. package/dist/insights/SnapInsightsController.mjs +1 -3
  33. package/dist/insights/SnapInsightsController.mjs.map +1 -1
  34. package/dist/insights/index.cjs +3 -15
  35. package/dist/insights/index.cjs.map +1 -1
  36. package/dist/insights/index.d.cts +2 -1
  37. package/dist/insights/index.d.cts.map +1 -1
  38. package/dist/insights/index.d.mts +2 -1
  39. package/dist/insights/index.d.mts.map +1 -1
  40. package/dist/insights/index.mjs +1 -1
  41. package/dist/insights/index.mjs.map +1 -1
  42. package/dist/interface/SnapInterfaceController-method-action-types.cjs +7 -0
  43. package/dist/interface/SnapInterfaceController-method-action-types.cjs.map +1 -0
  44. package/dist/interface/SnapInterfaceController-method-action-types.d.cts +99 -0
  45. package/dist/interface/SnapInterfaceController-method-action-types.d.cts.map +1 -0
  46. package/dist/interface/SnapInterfaceController-method-action-types.d.mts +99 -0
  47. package/dist/interface/SnapInterfaceController-method-action-types.d.mts.map +1 -0
  48. package/dist/interface/SnapInterfaceController-method-action-types.mjs +6 -0
  49. package/dist/interface/SnapInterfaceController-method-action-types.mjs.map +1 -0
  50. package/dist/interface/SnapInterfaceController.cjs +12 -16
  51. package/dist/interface/SnapInterfaceController.cjs.map +1 -1
  52. package/dist/interface/SnapInterfaceController.d.cts +10 -40
  53. package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
  54. package/dist/interface/SnapInterfaceController.d.mts +10 -40
  55. package/dist/interface/SnapInterfaceController.d.mts.map +1 -1
  56. package/dist/interface/SnapInterfaceController.mjs +12 -16
  57. package/dist/interface/SnapInterfaceController.mjs.map +1 -1
  58. package/dist/interface/index.cjs +3 -15
  59. package/dist/interface/index.cjs.map +1 -1
  60. package/dist/interface/index.d.cts +3 -1
  61. package/dist/interface/index.d.cts.map +1 -1
  62. package/dist/interface/index.d.mts +3 -1
  63. package/dist/interface/index.d.mts.map +1 -1
  64. package/dist/interface/index.mjs +1 -1
  65. package/dist/interface/index.mjs.map +1 -1
  66. package/dist/multichain/MultichainRoutingService-method-action-types.cjs +7 -0
  67. package/dist/multichain/MultichainRoutingService-method-action-types.cjs.map +1 -0
  68. package/dist/multichain/MultichainRoutingService-method-action-types.d.cts +61 -0
  69. package/dist/multichain/MultichainRoutingService-method-action-types.d.cts.map +1 -0
  70. package/dist/multichain/MultichainRoutingService-method-action-types.d.mts +61 -0
  71. package/dist/multichain/MultichainRoutingService-method-action-types.d.mts.map +1 -0
  72. package/dist/multichain/MultichainRoutingService-method-action-types.mjs +6 -0
  73. package/dist/multichain/MultichainRoutingService-method-action-types.mjs.map +1 -0
  74. package/dist/multichain/{MultichainRouter.cjs → MultichainRoutingService.cjs} +14 -13
  75. package/dist/multichain/MultichainRoutingService.cjs.map +1 -0
  76. package/dist/multichain/{MultichainRouter.d.mts → MultichainRoutingService.d.cts} +14 -29
  77. package/dist/multichain/MultichainRoutingService.d.cts.map +1 -0
  78. package/dist/multichain/{MultichainRouter.d.cts → MultichainRoutingService.d.mts} +14 -29
  79. package/dist/multichain/MultichainRoutingService.d.mts.map +1 -0
  80. package/dist/multichain/{MultichainRouter.mjs → MultichainRoutingService.mjs} +12 -11
  81. package/dist/multichain/MultichainRoutingService.mjs.map +1 -0
  82. package/dist/multichain/index.cjs +3 -15
  83. package/dist/multichain/index.cjs.map +1 -1
  84. package/dist/multichain/index.d.cts +3 -1
  85. package/dist/multichain/index.d.cts.map +1 -1
  86. package/dist/multichain/index.d.mts +3 -1
  87. package/dist/multichain/index.d.mts.map +1 -1
  88. package/dist/multichain/index.mjs +1 -1
  89. package/dist/multichain/index.mjs.map +1 -1
  90. package/dist/services/ExecutionService-method-action-types.cjs +7 -0
  91. package/dist/services/ExecutionService-method-action-types.cjs.map +1 -0
  92. package/dist/services/ExecutionService-method-action-types.d.cts +50 -0
  93. package/dist/services/ExecutionService-method-action-types.d.cts.map +1 -0
  94. package/dist/services/ExecutionService-method-action-types.d.mts +50 -0
  95. package/dist/services/ExecutionService-method-action-types.d.mts.map +1 -0
  96. package/dist/services/ExecutionService-method-action-types.mjs +6 -0
  97. package/dist/services/ExecutionService-method-action-types.mjs.map +1 -0
  98. package/dist/services/ExecutionService.cjs +287 -0
  99. package/dist/services/ExecutionService.cjs.map +1 -1
  100. package/dist/services/ExecutionService.d.cts +100 -46
  101. package/dist/services/ExecutionService.d.cts.map +1 -1
  102. package/dist/services/ExecutionService.d.mts +100 -46
  103. package/dist/services/ExecutionService.d.mts.map +1 -1
  104. package/dist/services/ExecutionService.mjs +285 -1
  105. package/dist/services/ExecutionService.mjs.map +1 -1
  106. package/dist/services/browser.cjs +5 -2
  107. package/dist/services/browser.cjs.map +1 -1
  108. package/dist/services/browser.d.cts +4 -2
  109. package/dist/services/browser.d.cts.map +1 -1
  110. package/dist/services/browser.d.mts +4 -2
  111. package/dist/services/browser.d.mts.map +1 -1
  112. package/dist/services/browser.mjs +2 -2
  113. package/dist/services/browser.mjs.map +1 -1
  114. package/dist/services/iframe/IframeExecutionService.cjs +2 -2
  115. package/dist/services/iframe/IframeExecutionService.cjs.map +1 -1
  116. package/dist/services/iframe/IframeExecutionService.d.cts +3 -3
  117. package/dist/services/iframe/IframeExecutionService.d.cts.map +1 -1
  118. package/dist/services/iframe/IframeExecutionService.d.mts +3 -3
  119. package/dist/services/iframe/IframeExecutionService.d.mts.map +1 -1
  120. package/dist/services/iframe/IframeExecutionService.mjs +2 -2
  121. package/dist/services/iframe/IframeExecutionService.mjs.map +1 -1
  122. package/dist/services/index.cjs +5 -1
  123. package/dist/services/index.cjs.map +1 -1
  124. package/dist/services/index.d.cts +4 -2
  125. package/dist/services/index.d.cts.map +1 -1
  126. package/dist/services/index.d.mts +4 -2
  127. package/dist/services/index.d.mts.map +1 -1
  128. package/dist/services/index.mjs +2 -1
  129. package/dist/services/index.mjs.map +1 -1
  130. package/dist/services/multiplex.cjs +27 -0
  131. package/dist/services/multiplex.cjs.map +1 -0
  132. package/dist/services/multiplex.d.cts +11 -0
  133. package/dist/services/multiplex.d.cts.map +1 -0
  134. package/dist/services/multiplex.d.mts +11 -0
  135. package/dist/services/multiplex.d.mts.map +1 -0
  136. package/dist/services/multiplex.mjs +27 -0
  137. package/dist/services/multiplex.mjs.map +1 -0
  138. package/dist/services/node-js/NodeProcessExecutionService.cjs +2 -2
  139. package/dist/services/node-js/NodeProcessExecutionService.cjs.map +1 -1
  140. package/dist/services/node-js/NodeProcessExecutionService.d.cts +3 -3
  141. package/dist/services/node-js/NodeProcessExecutionService.d.cts.map +1 -1
  142. package/dist/services/node-js/NodeProcessExecutionService.d.mts +3 -3
  143. package/dist/services/node-js/NodeProcessExecutionService.d.mts.map +1 -1
  144. package/dist/services/node-js/NodeProcessExecutionService.mjs +2 -2
  145. package/dist/services/node-js/NodeProcessExecutionService.mjs.map +1 -1
  146. package/dist/services/node-js/NodeThreadExecutionService.cjs +2 -5
  147. package/dist/services/node-js/NodeThreadExecutionService.cjs.map +1 -1
  148. package/dist/services/node-js/NodeThreadExecutionService.d.cts +3 -3
  149. package/dist/services/node-js/NodeThreadExecutionService.d.cts.map +1 -1
  150. package/dist/services/node-js/NodeThreadExecutionService.d.mts +3 -3
  151. package/dist/services/node-js/NodeThreadExecutionService.d.mts.map +1 -1
  152. package/dist/services/node-js/NodeThreadExecutionService.mjs +2 -5
  153. package/dist/services/node-js/NodeThreadExecutionService.mjs.map +1 -1
  154. package/dist/services/offscreen/OffscreenExecutionService.cjs.map +1 -1
  155. package/dist/services/offscreen/OffscreenExecutionService.d.cts +1 -1
  156. package/dist/services/offscreen/OffscreenExecutionService.d.cts.map +1 -1
  157. package/dist/services/offscreen/OffscreenExecutionService.d.mts +1 -1
  158. package/dist/services/offscreen/OffscreenExecutionService.d.mts.map +1 -1
  159. package/dist/services/offscreen/OffscreenExecutionService.mjs.map +1 -1
  160. package/dist/services/proxy/ProxyExecutionService.cjs +2 -5
  161. package/dist/services/proxy/ProxyExecutionService.cjs.map +1 -1
  162. package/dist/services/proxy/ProxyExecutionService.d.cts +3 -3
  163. package/dist/services/proxy/ProxyExecutionService.d.cts.map +1 -1
  164. package/dist/services/proxy/ProxyExecutionService.d.mts +3 -3
  165. package/dist/services/proxy/ProxyExecutionService.d.mts.map +1 -1
  166. package/dist/services/proxy/ProxyExecutionService.mjs +2 -5
  167. package/dist/services/proxy/ProxyExecutionService.mjs.map +1 -1
  168. package/dist/services/webview/WebViewExecutionService.cjs +2 -2
  169. package/dist/services/webview/WebViewExecutionService.cjs.map +1 -1
  170. package/dist/services/webview/WebViewExecutionService.d.cts +3 -3
  171. package/dist/services/webview/WebViewExecutionService.d.cts.map +1 -1
  172. package/dist/services/webview/WebViewExecutionService.d.mts +3 -3
  173. package/dist/services/webview/WebViewExecutionService.d.mts.map +1 -1
  174. package/dist/services/webview/WebViewExecutionService.mjs +2 -2
  175. package/dist/services/webview/WebViewExecutionService.mjs.map +1 -1
  176. package/dist/snaps/SnapController-method-action-types.cjs +7 -0
  177. package/dist/snaps/SnapController-method-action-types.cjs.map +1 -0
  178. package/dist/snaps/SnapController-method-action-types.d.cts +284 -0
  179. package/dist/snaps/SnapController-method-action-types.d.cts.map +1 -0
  180. package/dist/snaps/SnapController-method-action-types.d.mts +284 -0
  181. package/dist/snaps/SnapController-method-action-types.d.mts.map +1 -0
  182. package/dist/snaps/SnapController-method-action-types.mjs +6 -0
  183. package/dist/snaps/SnapController-method-action-types.mjs.map +1 -0
  184. package/dist/snaps/SnapController.cjs +118 -113
  185. package/dist/snaps/SnapController.cjs.map +1 -1
  186. package/dist/snaps/SnapController.d.cts +33 -190
  187. package/dist/snaps/SnapController.d.cts.map +1 -1
  188. package/dist/snaps/SnapController.d.mts +33 -190
  189. package/dist/snaps/SnapController.d.mts.map +1 -1
  190. package/dist/snaps/SnapController.mjs +119 -114
  191. package/dist/snaps/SnapController.mjs.map +1 -1
  192. package/dist/snaps/index.cjs +3 -1
  193. package/dist/snaps/index.cjs.map +1 -1
  194. package/dist/snaps/index.d.cts +3 -1
  195. package/dist/snaps/index.d.cts.map +1 -1
  196. package/dist/snaps/index.d.mts +3 -1
  197. package/dist/snaps/index.d.mts.map +1 -1
  198. package/dist/snaps/index.mjs +1 -1
  199. package/dist/snaps/index.mjs.map +1 -1
  200. package/dist/snaps/registry/SnapRegistryController-method-action-types.cjs +7 -0
  201. package/dist/snaps/registry/SnapRegistryController-method-action-types.cjs.map +1 -0
  202. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.cts +46 -0
  203. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.cts.map +1 -0
  204. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.mts +46 -0
  205. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.mts.map +1 -0
  206. package/dist/snaps/registry/SnapRegistryController-method-action-types.mjs +6 -0
  207. package/dist/snaps/registry/SnapRegistryController-method-action-types.mjs.map +1 -0
  208. package/dist/snaps/registry/{json.cjs → SnapRegistryController.cjs} +27 -24
  209. package/dist/snaps/registry/SnapRegistryController.cjs.map +1 -0
  210. package/dist/snaps/registry/SnapRegistryController.d.cts +67 -0
  211. package/dist/snaps/registry/SnapRegistryController.d.cts.map +1 -0
  212. package/dist/snaps/registry/SnapRegistryController.d.mts +67 -0
  213. package/dist/snaps/registry/SnapRegistryController.d.mts.map +1 -0
  214. package/dist/snaps/registry/{json.mjs → SnapRegistryController.mjs} +25 -22
  215. package/dist/snaps/registry/SnapRegistryController.mjs.map +1 -0
  216. package/dist/snaps/registry/index.cjs +5 -16
  217. package/dist/snaps/registry/index.cjs.map +1 -1
  218. package/dist/snaps/registry/index.d.cts +5 -2
  219. package/dist/snaps/registry/index.d.cts.map +1 -1
  220. package/dist/snaps/registry/index.d.mts +5 -2
  221. package/dist/snaps/registry/index.d.mts.map +1 -1
  222. package/dist/snaps/registry/index.mjs +2 -2
  223. package/dist/snaps/registry/index.mjs.map +1 -1
  224. package/dist/snaps/registry/types.cjs +11 -0
  225. package/dist/snaps/registry/types.cjs.map +1 -0
  226. package/dist/snaps/registry/types.d.cts +20 -0
  227. package/dist/snaps/registry/types.d.cts.map +1 -0
  228. package/dist/snaps/registry/types.d.mts +20 -0
  229. package/dist/snaps/registry/types.d.mts.map +1 -0
  230. package/dist/snaps/registry/types.mjs +8 -0
  231. package/dist/snaps/registry/types.mjs.map +1 -0
  232. package/dist/types/controllers.cjs.map +1 -1
  233. package/dist/types/controllers.d.cts +1 -1
  234. package/dist/types/controllers.d.cts.map +1 -1
  235. package/dist/types/controllers.d.mts +1 -1
  236. package/dist/types/controllers.d.mts.map +1 -1
  237. package/dist/types/controllers.mjs.map +1 -1
  238. package/dist/websocket/WebSocketService-method-action-types.cjs +7 -0
  239. package/dist/websocket/WebSocketService-method-action-types.cjs.map +1 -0
  240. package/dist/websocket/WebSocketService-method-action-types.d.cts +54 -0
  241. package/dist/websocket/WebSocketService-method-action-types.d.cts.map +1 -0
  242. package/dist/websocket/WebSocketService-method-action-types.d.mts +54 -0
  243. package/dist/websocket/WebSocketService-method-action-types.d.mts.map +1 -0
  244. package/dist/websocket/WebSocketService-method-action-types.mjs +6 -0
  245. package/dist/websocket/WebSocketService-method-action-types.mjs.map +1 -0
  246. package/dist/websocket/WebSocketService.cjs +14 -11
  247. package/dist/websocket/WebSocketService.cjs.map +1 -1
  248. package/dist/websocket/WebSocketService.d.cts +43 -22
  249. package/dist/websocket/WebSocketService.d.cts.map +1 -1
  250. package/dist/websocket/WebSocketService.d.mts +43 -22
  251. package/dist/websocket/WebSocketService.d.mts.map +1 -1
  252. package/dist/websocket/WebSocketService.mjs +14 -11
  253. package/dist/websocket/WebSocketService.mjs.map +1 -1
  254. package/dist/websocket/index.cjs +3 -15
  255. package/dist/websocket/index.cjs.map +1 -1
  256. package/dist/websocket/index.d.cts +3 -1
  257. package/dist/websocket/index.d.cts.map +1 -1
  258. package/dist/websocket/index.d.mts +3 -1
  259. package/dist/websocket/index.d.mts.map +1 -1
  260. package/dist/websocket/index.mjs +1 -1
  261. package/dist/websocket/index.mjs.map +1 -1
  262. package/package.json +12 -11
  263. package/dist/multichain/MultichainRouter.cjs.map +0 -1
  264. package/dist/multichain/MultichainRouter.d.cts.map +0 -1
  265. package/dist/multichain/MultichainRouter.d.mts.map +0 -1
  266. package/dist/multichain/MultichainRouter.mjs.map +0 -1
  267. package/dist/services/AbstractExecutionService.cjs +0 -314
  268. package/dist/services/AbstractExecutionService.cjs.map +0 -1
  269. package/dist/services/AbstractExecutionService.d.cts +0 -107
  270. package/dist/services/AbstractExecutionService.d.cts.map +0 -1
  271. package/dist/services/AbstractExecutionService.d.mts +0 -107
  272. package/dist/services/AbstractExecutionService.d.mts.map +0 -1
  273. package/dist/services/AbstractExecutionService.mjs +0 -313
  274. package/dist/services/AbstractExecutionService.mjs.map +0 -1
  275. package/dist/snaps/registry/json.cjs.map +0 -1
  276. package/dist/snaps/registry/json.d.cts +0 -58
  277. package/dist/snaps/registry/json.d.cts.map +0 -1
  278. package/dist/snaps/registry/json.d.mts +0 -58
  279. package/dist/snaps/registry/json.d.mts.map +0 -1
  280. package/dist/snaps/registry/json.mjs.map +0 -1
  281. package/dist/snaps/registry/registry.cjs +0 -11
  282. package/dist/snaps/registry/registry.cjs.map +0 -1
  283. package/dist/snaps/registry/registry.d.cts +0 -41
  284. package/dist/snaps/registry/registry.d.cts.map +0 -1
  285. package/dist/snaps/registry/registry.d.mts +0 -41
  286. package/dist/snaps/registry/registry.d.mts.map +0 -1
  287. package/dist/snaps/registry/registry.mjs +0 -8
  288. package/dist/snaps/registry/registry.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SnapInterfaceController-method-action-types.cjs","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SnapInterfaceController } from './SnapInterfaceController';\n\n/**\n * Create an interface in the controller state with the associated data.\n *\n * @param snapId - The snap id that created the interface.\n * @param content - The interface content.\n * @param context - An optional interface context object.\n * @param contentType - The type of content.\n * @returns The newly interface id.\n */\nexport type SnapInterfaceControllerCreateInterfaceAction = {\n type: `SnapInterfaceController:createInterface`;\n handler: SnapInterfaceController['createInterface'];\n};\n\n/**\n * Get the data of a given interface id.\n *\n * @param snapId - The snap id requesting the interface data.\n * @param id - The interface id.\n * @returns The interface state.\n */\nexport type SnapInterfaceControllerGetInterfaceAction = {\n type: `SnapInterfaceController:getInterface`;\n handler: SnapInterfaceController['getInterface'];\n};\n\n/**\n * Get the state of a given interface ID, if the interface has been displayed\n * at least once.\n *\n * @param snapId - The snap ID requesting the interface state.\n * @param id - The interface ID.\n * @returns The interface state.\n */\nexport type SnapInterfaceControllerGetInterfaceStateAction = {\n type: `SnapInterfaceController:getInterfaceState`;\n handler: SnapInterfaceController['getInterfaceState'];\n};\n\n/**\n * Update the interface with the given content.\n *\n * @param snapId - The snap id requesting the update.\n * @param id - The interface id.\n * @param content - The new content.\n * @param context - An optional interface context object.\n */\nexport type SnapInterfaceControllerUpdateInterfaceAction = {\n type: `SnapInterfaceController:updateInterface`;\n handler: SnapInterfaceController['updateInterface'];\n};\n\n/**\n * Delete an interface from state.\n *\n * @param id - The interface id.\n */\nexport type SnapInterfaceControllerDeleteInterfaceAction = {\n type: `SnapInterfaceController:deleteInterface`;\n handler: SnapInterfaceController['deleteInterface'];\n};\n\n/**\n * Update the interface state.\n *\n * @param id - The interface id.\n * @param state - The new state.\n */\nexport type SnapInterfaceControllerUpdateInterfaceStateAction = {\n type: `SnapInterfaceController:updateInterfaceState`;\n handler: SnapInterfaceController['updateInterfaceState'];\n};\n\n/**\n * Resolve the promise of a given interface approval request.\n * The approval needs to have the same ID as the interface.\n *\n * @param snapId - The snap id.\n * @param id - The interface id.\n * @param value - The value to resolve the promise with.\n */\nexport type SnapInterfaceControllerResolveInterfaceAction = {\n type: `SnapInterfaceController:resolveInterface`;\n handler: SnapInterfaceController['resolveInterface'];\n};\n\n/**\n * Set the interface as displayed.\n *\n * @param snapId - The snap ID requesting the update.\n * @param id - The interface ID.\n */\nexport type SnapInterfaceControllerSetInterfaceDisplayedAction = {\n type: `SnapInterfaceController:setInterfaceDisplayed`;\n handler: SnapInterfaceController['setInterfaceDisplayed'];\n};\n\n/**\n * Union of all SnapInterfaceController action types.\n */\nexport type SnapInterfaceControllerMethodActions =\n | SnapInterfaceControllerCreateInterfaceAction\n | SnapInterfaceControllerGetInterfaceAction\n | SnapInterfaceControllerGetInterfaceStateAction\n | SnapInterfaceControllerUpdateInterfaceAction\n | SnapInterfaceControllerDeleteInterfaceAction\n | SnapInterfaceControllerUpdateInterfaceStateAction\n | SnapInterfaceControllerResolveInterfaceAction\n | SnapInterfaceControllerSetInterfaceDisplayedAction;\n"]}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { SnapInterfaceController } from "./SnapInterfaceController.cjs";
6
+ /**
7
+ * Create an interface in the controller state with the associated data.
8
+ *
9
+ * @param snapId - The snap id that created the interface.
10
+ * @param content - The interface content.
11
+ * @param context - An optional interface context object.
12
+ * @param contentType - The type of content.
13
+ * @returns The newly interface id.
14
+ */
15
+ export type SnapInterfaceControllerCreateInterfaceAction = {
16
+ type: `SnapInterfaceController:createInterface`;
17
+ handler: SnapInterfaceController['createInterface'];
18
+ };
19
+ /**
20
+ * Get the data of a given interface id.
21
+ *
22
+ * @param snapId - The snap id requesting the interface data.
23
+ * @param id - The interface id.
24
+ * @returns The interface state.
25
+ */
26
+ export type SnapInterfaceControllerGetInterfaceAction = {
27
+ type: `SnapInterfaceController:getInterface`;
28
+ handler: SnapInterfaceController['getInterface'];
29
+ };
30
+ /**
31
+ * Get the state of a given interface ID, if the interface has been displayed
32
+ * at least once.
33
+ *
34
+ * @param snapId - The snap ID requesting the interface state.
35
+ * @param id - The interface ID.
36
+ * @returns The interface state.
37
+ */
38
+ export type SnapInterfaceControllerGetInterfaceStateAction = {
39
+ type: `SnapInterfaceController:getInterfaceState`;
40
+ handler: SnapInterfaceController['getInterfaceState'];
41
+ };
42
+ /**
43
+ * Update the interface with the given content.
44
+ *
45
+ * @param snapId - The snap id requesting the update.
46
+ * @param id - The interface id.
47
+ * @param content - The new content.
48
+ * @param context - An optional interface context object.
49
+ */
50
+ export type SnapInterfaceControllerUpdateInterfaceAction = {
51
+ type: `SnapInterfaceController:updateInterface`;
52
+ handler: SnapInterfaceController['updateInterface'];
53
+ };
54
+ /**
55
+ * Delete an interface from state.
56
+ *
57
+ * @param id - The interface id.
58
+ */
59
+ export type SnapInterfaceControllerDeleteInterfaceAction = {
60
+ type: `SnapInterfaceController:deleteInterface`;
61
+ handler: SnapInterfaceController['deleteInterface'];
62
+ };
63
+ /**
64
+ * Update the interface state.
65
+ *
66
+ * @param id - The interface id.
67
+ * @param state - The new state.
68
+ */
69
+ export type SnapInterfaceControllerUpdateInterfaceStateAction = {
70
+ type: `SnapInterfaceController:updateInterfaceState`;
71
+ handler: SnapInterfaceController['updateInterfaceState'];
72
+ };
73
+ /**
74
+ * Resolve the promise of a given interface approval request.
75
+ * The approval needs to have the same ID as the interface.
76
+ *
77
+ * @param snapId - The snap id.
78
+ * @param id - The interface id.
79
+ * @param value - The value to resolve the promise with.
80
+ */
81
+ export type SnapInterfaceControllerResolveInterfaceAction = {
82
+ type: `SnapInterfaceController:resolveInterface`;
83
+ handler: SnapInterfaceController['resolveInterface'];
84
+ };
85
+ /**
86
+ * Set the interface as displayed.
87
+ *
88
+ * @param snapId - The snap ID requesting the update.
89
+ * @param id - The interface ID.
90
+ */
91
+ export type SnapInterfaceControllerSetInterfaceDisplayedAction = {
92
+ type: `SnapInterfaceController:setInterfaceDisplayed`;
93
+ handler: SnapInterfaceController['setInterfaceDisplayed'];
94
+ };
95
+ /**
96
+ * Union of all SnapInterfaceController action types.
97
+ */
98
+ export type SnapInterfaceControllerMethodActions = SnapInterfaceControllerCreateInterfaceAction | SnapInterfaceControllerGetInterfaceAction | SnapInterfaceControllerGetInterfaceStateAction | SnapInterfaceControllerUpdateInterfaceAction | SnapInterfaceControllerDeleteInterfaceAction | SnapInterfaceControllerUpdateInterfaceStateAction | SnapInterfaceControllerResolveInterfaceAction | SnapInterfaceControllerSetInterfaceDisplayedAction;
99
+ //# sourceMappingURL=SnapInterfaceController-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SnapInterfaceController-method-action-types.d.cts","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAkC;AAEzE;;;;;;;;GAQG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;CACvD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAC5C,4CAA4C,GAC5C,yCAAyC,GACzC,8CAA8C,GAC9C,4CAA4C,GAC5C,4CAA4C,GAC5C,iDAAiD,GACjD,6CAA6C,GAC7C,kDAAkD,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { SnapInterfaceController } from "./SnapInterfaceController.mjs";
6
+ /**
7
+ * Create an interface in the controller state with the associated data.
8
+ *
9
+ * @param snapId - The snap id that created the interface.
10
+ * @param content - The interface content.
11
+ * @param context - An optional interface context object.
12
+ * @param contentType - The type of content.
13
+ * @returns The newly interface id.
14
+ */
15
+ export type SnapInterfaceControllerCreateInterfaceAction = {
16
+ type: `SnapInterfaceController:createInterface`;
17
+ handler: SnapInterfaceController['createInterface'];
18
+ };
19
+ /**
20
+ * Get the data of a given interface id.
21
+ *
22
+ * @param snapId - The snap id requesting the interface data.
23
+ * @param id - The interface id.
24
+ * @returns The interface state.
25
+ */
26
+ export type SnapInterfaceControllerGetInterfaceAction = {
27
+ type: `SnapInterfaceController:getInterface`;
28
+ handler: SnapInterfaceController['getInterface'];
29
+ };
30
+ /**
31
+ * Get the state of a given interface ID, if the interface has been displayed
32
+ * at least once.
33
+ *
34
+ * @param snapId - The snap ID requesting the interface state.
35
+ * @param id - The interface ID.
36
+ * @returns The interface state.
37
+ */
38
+ export type SnapInterfaceControllerGetInterfaceStateAction = {
39
+ type: `SnapInterfaceController:getInterfaceState`;
40
+ handler: SnapInterfaceController['getInterfaceState'];
41
+ };
42
+ /**
43
+ * Update the interface with the given content.
44
+ *
45
+ * @param snapId - The snap id requesting the update.
46
+ * @param id - The interface id.
47
+ * @param content - The new content.
48
+ * @param context - An optional interface context object.
49
+ */
50
+ export type SnapInterfaceControllerUpdateInterfaceAction = {
51
+ type: `SnapInterfaceController:updateInterface`;
52
+ handler: SnapInterfaceController['updateInterface'];
53
+ };
54
+ /**
55
+ * Delete an interface from state.
56
+ *
57
+ * @param id - The interface id.
58
+ */
59
+ export type SnapInterfaceControllerDeleteInterfaceAction = {
60
+ type: `SnapInterfaceController:deleteInterface`;
61
+ handler: SnapInterfaceController['deleteInterface'];
62
+ };
63
+ /**
64
+ * Update the interface state.
65
+ *
66
+ * @param id - The interface id.
67
+ * @param state - The new state.
68
+ */
69
+ export type SnapInterfaceControllerUpdateInterfaceStateAction = {
70
+ type: `SnapInterfaceController:updateInterfaceState`;
71
+ handler: SnapInterfaceController['updateInterfaceState'];
72
+ };
73
+ /**
74
+ * Resolve the promise of a given interface approval request.
75
+ * The approval needs to have the same ID as the interface.
76
+ *
77
+ * @param snapId - The snap id.
78
+ * @param id - The interface id.
79
+ * @param value - The value to resolve the promise with.
80
+ */
81
+ export type SnapInterfaceControllerResolveInterfaceAction = {
82
+ type: `SnapInterfaceController:resolveInterface`;
83
+ handler: SnapInterfaceController['resolveInterface'];
84
+ };
85
+ /**
86
+ * Set the interface as displayed.
87
+ *
88
+ * @param snapId - The snap ID requesting the update.
89
+ * @param id - The interface ID.
90
+ */
91
+ export type SnapInterfaceControllerSetInterfaceDisplayedAction = {
92
+ type: `SnapInterfaceController:setInterfaceDisplayed`;
93
+ handler: SnapInterfaceController['setInterfaceDisplayed'];
94
+ };
95
+ /**
96
+ * Union of all SnapInterfaceController action types.
97
+ */
98
+ export type SnapInterfaceControllerMethodActions = SnapInterfaceControllerCreateInterfaceAction | SnapInterfaceControllerGetInterfaceAction | SnapInterfaceControllerGetInterfaceStateAction | SnapInterfaceControllerUpdateInterfaceAction | SnapInterfaceControllerDeleteInterfaceAction | SnapInterfaceControllerUpdateInterfaceStateAction | SnapInterfaceControllerResolveInterfaceAction | SnapInterfaceControllerSetInterfaceDisplayedAction;
99
+ //# sourceMappingURL=SnapInterfaceController-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SnapInterfaceController-method-action-types.d.mts","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAkC;AAEzE;;;;;;;;GAQG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;CACvD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAC5C,4CAA4C,GAC5C,yCAAyC,GACzC,8CAA8C,GAC9C,4CAA4C,GAC5C,4CAA4C,GAC5C,iDAAiD,GACjD,6CAA6C,GAC7C,kDAAkD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=SnapInterfaceController-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SnapInterfaceController-method-action-types.mjs","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SnapInterfaceController } from './SnapInterfaceController';\n\n/**\n * Create an interface in the controller state with the associated data.\n *\n * @param snapId - The snap id that created the interface.\n * @param content - The interface content.\n * @param context - An optional interface context object.\n * @param contentType - The type of content.\n * @returns The newly interface id.\n */\nexport type SnapInterfaceControllerCreateInterfaceAction = {\n type: `SnapInterfaceController:createInterface`;\n handler: SnapInterfaceController['createInterface'];\n};\n\n/**\n * Get the data of a given interface id.\n *\n * @param snapId - The snap id requesting the interface data.\n * @param id - The interface id.\n * @returns The interface state.\n */\nexport type SnapInterfaceControllerGetInterfaceAction = {\n type: `SnapInterfaceController:getInterface`;\n handler: SnapInterfaceController['getInterface'];\n};\n\n/**\n * Get the state of a given interface ID, if the interface has been displayed\n * at least once.\n *\n * @param snapId - The snap ID requesting the interface state.\n * @param id - The interface ID.\n * @returns The interface state.\n */\nexport type SnapInterfaceControllerGetInterfaceStateAction = {\n type: `SnapInterfaceController:getInterfaceState`;\n handler: SnapInterfaceController['getInterfaceState'];\n};\n\n/**\n * Update the interface with the given content.\n *\n * @param snapId - The snap id requesting the update.\n * @param id - The interface id.\n * @param content - The new content.\n * @param context - An optional interface context object.\n */\nexport type SnapInterfaceControllerUpdateInterfaceAction = {\n type: `SnapInterfaceController:updateInterface`;\n handler: SnapInterfaceController['updateInterface'];\n};\n\n/**\n * Delete an interface from state.\n *\n * @param id - The interface id.\n */\nexport type SnapInterfaceControllerDeleteInterfaceAction = {\n type: `SnapInterfaceController:deleteInterface`;\n handler: SnapInterfaceController['deleteInterface'];\n};\n\n/**\n * Update the interface state.\n *\n * @param id - The interface id.\n * @param state - The new state.\n */\nexport type SnapInterfaceControllerUpdateInterfaceStateAction = {\n type: `SnapInterfaceController:updateInterfaceState`;\n handler: SnapInterfaceController['updateInterfaceState'];\n};\n\n/**\n * Resolve the promise of a given interface approval request.\n * The approval needs to have the same ID as the interface.\n *\n * @param snapId - The snap id.\n * @param id - The interface id.\n * @param value - The value to resolve the promise with.\n */\nexport type SnapInterfaceControllerResolveInterfaceAction = {\n type: `SnapInterfaceController:resolveInterface`;\n handler: SnapInterfaceController['resolveInterface'];\n};\n\n/**\n * Set the interface as displayed.\n *\n * @param snapId - The snap ID requesting the update.\n * @param id - The interface ID.\n */\nexport type SnapInterfaceControllerSetInterfaceDisplayedAction = {\n type: `SnapInterfaceController:setInterfaceDisplayed`;\n handler: SnapInterfaceController['setInterfaceDisplayed'];\n};\n\n/**\n * Union of all SnapInterfaceController action types.\n */\nexport type SnapInterfaceControllerMethodActions =\n | SnapInterfaceControllerCreateInterfaceAction\n | SnapInterfaceControllerGetInterfaceAction\n | SnapInterfaceControllerGetInterfaceStateAction\n | SnapInterfaceControllerUpdateInterfaceAction\n | SnapInterfaceControllerDeleteInterfaceAction\n | SnapInterfaceControllerUpdateInterfaceStateAction\n | SnapInterfaceControllerResolveInterfaceAction\n | SnapInterfaceControllerSetInterfaceDisplayedAction;\n"]}
@@ -10,6 +10,16 @@ const nanoid_1 = require("nanoid");
10
10
  const utils_2 = require("./utils.cjs");
11
11
  const MAX_UI_CONTENT_SIZE = 10000000; // 10 mb
12
12
  const controllerName = 'SnapInterfaceController';
13
+ const MESSENGER_EXPOSED_METHODS = [
14
+ 'createInterface',
15
+ 'getInterface',
16
+ 'getInterfaceState',
17
+ 'updateInterface',
18
+ 'deleteInterface',
19
+ 'updateInterfaceState',
20
+ 'resolveInterface',
21
+ 'setInterfaceDisplayed',
22
+ ];
13
23
  /**
14
24
  * Use this controller to manage snaps UI interfaces using RPC method hooks.
15
25
  */
@@ -39,21 +49,7 @@ class SnapInterfaceController extends base_controller_1.BaseController {
39
49
  state: { interfaces: {}, ...state },
40
50
  });
41
51
  this.messenger.subscribe('NotificationServicesController:notificationsListUpdated', this.#onNotificationsListUpdated.bind(this));
42
- this.#registerMessageHandlers();
43
- }
44
- /**
45
- * Constructor helper for registering this controller's messaging system
46
- * actions.
47
- */
48
- #registerMessageHandlers() {
49
- this.messenger.registerActionHandler(`${controllerName}:createInterface`, this.createInterface.bind(this));
50
- this.messenger.registerActionHandler(`${controllerName}:getInterface`, this.getInterface.bind(this));
51
- this.messenger.registerActionHandler(`${controllerName}:getInterfaceState`, this.getInterfaceState.bind(this));
52
- this.messenger.registerActionHandler(`${controllerName}:updateInterface`, this.updateInterface.bind(this));
53
- this.messenger.registerActionHandler(`${controllerName}:deleteInterface`, this.deleteInterface.bind(this));
54
- this.messenger.registerActionHandler(`${controllerName}:updateInterfaceState`, this.updateInterfaceState.bind(this));
55
- this.messenger.registerActionHandler(`${controllerName}:resolveInterface`, this.resolveInterface.bind(this));
56
- this.messenger.registerActionHandler(`${controllerName}:setInterfaceDisplayed`, this.setInterfaceDisplayed.bind(this));
52
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
57
53
  }
58
54
  /**
59
55
  * Create an interface in the controller state with the associated data.
@@ -290,7 +286,7 @@ class SnapInterfaceController extends base_controller_1.BaseController {
290
286
  * @returns The snap.
291
287
  */
292
288
  #getSnap(id) {
293
- return this.messenger.call('SnapController:get', id);
289
+ return this.messenger.call('SnapController:getSnap', id);
294
290
  }
295
291
  #hasPermission(snapId, permission) {
296
292
  return this.messenger.call('PermissionController:hasPermission', snapId, permission);
@@ -1 +1 @@
1
- {"version":3,"file":"SnapInterfaceController.cjs","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController.ts"],"names":[],"mappings":";;;AAQA,+DAA2D;AAU3D,mDAAkD;AAGlD,uDAI+B;AAO/B,2CAA0E;AAC1E,iCAAkC;AAClC,mCAAgC;AAEhC,uCAKiB;AAGjB,MAAM,mBAAmB,GAAG,QAAU,CAAC,CAAC,QAAQ;AAEhD,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAsKjD;;GAEG;AACH,MAAa,uBAAwB,SAAQ,gCAI5C;IACC,YAAY,EAAE,SAAS,EAAE,KAAK,EAA+B;QAC3D,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE;gBACR,UAAU,EAAE;oBACV,kBAAkB,EAAE,IAAI;oBACxB,OAAO,EAAE,CAAC,UAA2C,EAAE,EAAE;wBACvD,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAEtC,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,EAAE,EAAE;4BAC7C,QAAQ,aAAa,CAAC,WAAW,EAAE,CAAC;gCAClC,KAAK,uBAAW,CAAC,YAAY;oCAC3B,mBAAmB,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC;oCACxC,OAAO,mBAAmB,CAAC;gCAC7B;oCACE,OAAO,mBAAmB,CAAC;4BAC/B,CAAC;wBACH,CAAC,EAAE,EAAE,CAAC,CAAC;oBACT,CAAC;oBACD,sBAAsB,EAAE,KAAK;oBAC7B,QAAQ,EAAE,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,CAAC,EAAE,EAAE,aAAa,CAAC,EAAE,EAAE;gBAC/D,IACE,aAAa,CAAC,WAAW,KAAK,uBAAW,CAAC,YAAY;oBACtD,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,EACvB,CAAC;oBACD,OAAO,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAncD,0DAmcC","sourcesContent":["import type {\n AcceptRequest,\n HasApprovalRequest,\n} from '@metamask/approval-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { HasPermission } from '@metamask/permission-controller';\nimport type {\n InterfaceState,\n SnapId,\n ComponentOrElement,\n InterfaceContext,\n FungibleAssetMetadata,\n} from '@metamask/snaps-sdk';\nimport { ContentType } from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type { InternalAccount } from '@metamask/snaps-utils';\nimport {\n getJsonSizeUnsafe,\n snapOwnsAccount,\n validateJsxElements,\n} from '@metamask/snaps-utils';\nimport type {\n CaipAccountId,\n CaipAssetType,\n CaipChainId,\n Json,\n} from '@metamask/utils';\nimport { assert, hasProperty, parseCaipAccountId } from '@metamask/utils';\nimport { castDraft } from 'immer';\nimport { nanoid } from 'nanoid';\n\nimport {\n constructState,\n getJsxInterface,\n isMatchingChainId,\n validateInterfaceContext,\n} from './utils';\nimport type { GetSnap } from '../snaps';\n\nconst MAX_UI_CONTENT_SIZE = 10_000_000; // 10 mb\n\nconst controllerName = 'SnapInterfaceController';\n\nexport type CreateInterface = {\n type: `${typeof controllerName}:createInterface`;\n handler: SnapInterfaceController['createInterface'];\n};\n\nexport type GetInterface = {\n type: `${typeof controllerName}:getInterface`;\n handler: SnapInterfaceController['getInterface'];\n};\n\nexport type UpdateInterface = {\n type: `${typeof controllerName}:updateInterface`;\n handler: SnapInterfaceController['updateInterface'];\n};\n\nexport type DeleteInterface = {\n type: `${typeof controllerName}:deleteInterface`;\n handler: SnapInterfaceController['deleteInterface'];\n};\n\nexport type UpdateInterfaceState = {\n type: `${typeof controllerName}:updateInterfaceState`;\n handler: SnapInterfaceController['updateInterfaceState'];\n};\n\nexport type ResolveInterface = {\n type: `${typeof controllerName}:resolveInterface`;\n handler: SnapInterfaceController['resolveInterface'];\n};\n\nexport type SnapInterfaceControllerGetInterfaceStateAction = {\n type: `${typeof controllerName}:getInterfaceState`;\n handler: SnapInterfaceController['getInterfaceState'];\n};\n\nexport type SnapInterfaceControllerSetInterfaceDisplayedAction = {\n type: `${typeof controllerName}:setInterfaceDisplayed`;\n handler: SnapInterfaceController['setInterfaceDisplayed'];\n};\n\ntype AccountsControllerGetAccountByAddressAction = {\n type: `AccountsController:getAccountByAddress`;\n handler: (address: string) => InternalAccount | undefined;\n};\n\ntype AccountsControllerGetSelectedMultichainAccountAction = {\n type: `AccountsController:getSelectedMultichainAccount`;\n handler: () => InternalAccount;\n};\n\ntype AccountsControllerListMultichainAccountsAction = {\n type: `AccountsController:listMultichainAccounts`;\n handler: (chainId?: CaipChainId) => InternalAccount[];\n};\n\nexport type SnapInterfaceControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n SnapInterfaceControllerState\n>;\n\ntype MultichainAssetsControllerGetStateAction = ControllerGetStateAction<\n 'MultichainAssetsController',\n {\n assetsMetadata: {\n [asset: CaipAssetType]: FungibleAssetMetadata;\n };\n accountsAssets: { [account: string]: CaipAssetType[] };\n }\n>;\n\ntype PhishingControllerTestOrigin = {\n type: 'PhishingController:testOrigin';\n handler: (origin: string) => { result: boolean; type: string };\n};\n\nexport type SnapInterfaceControllerAllowedActions =\n | PhishingControllerTestOrigin\n | HasApprovalRequest\n | AcceptRequest\n | GetSnap\n | MultichainAssetsControllerGetStateAction\n | AccountsControllerGetSelectedMultichainAccountAction\n | AccountsControllerGetAccountByAddressAction\n | AccountsControllerListMultichainAccountsAction\n | HasPermission;\n\nexport type SnapInterfaceControllerActions =\n | CreateInterface\n | GetInterface\n | UpdateInterface\n | DeleteInterface\n | UpdateInterfaceState\n | ResolveInterface\n | SnapInterfaceControllerGetInterfaceStateAction\n | SnapInterfaceControllerSetInterfaceDisplayedAction\n | SnapInterfaceControllerGetStateAction;\n\nexport type SnapInterfaceControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n SnapInterfaceControllerState\n >;\n\ntype OtherNotification = { type: string; [key: string]: unknown };\n\nexport type ExpandedView = {\n title: string;\n interfaceId: string;\n footerLink?: { href: string; text: string };\n};\n\ntype NormalSnapNotificationData = { message: string; origin: string };\n\ntype ExpandedSnapNotificationData = {\n message: string;\n origin: string;\n detailedView: ExpandedView;\n};\n\ntype SnapNotification = {\n type: 'snap';\n data: NormalSnapNotificationData | ExpandedSnapNotificationData;\n readDate: string | null;\n};\n\ntype Notification = OtherNotification | SnapNotification;\n\ntype NotificationListUpdatedEvent = {\n type: 'NotificationServicesController:notificationsListUpdated';\n payload: [Notification[]];\n};\n\nexport type SnapInterfaceControllerEvents =\n | SnapInterfaceControllerStateChangeEvent\n | NotificationListUpdatedEvent;\n\nexport type SnapInterfaceControllerMessenger = Messenger<\n typeof controllerName,\n SnapInterfaceControllerActions | SnapInterfaceControllerAllowedActions,\n SnapInterfaceControllerEvents\n>;\n\nexport type StoredInterface = {\n snapId: SnapId;\n content: JSXElement;\n state: InterfaceState;\n context: InterfaceContext | null;\n contentType: ContentType | null;\n\n /**\n * Whether the interface has been displayed in the UI at least once.\n */\n displayed: boolean;\n};\n\nexport type SnapInterfaceControllerState = {\n interfaces: Record<string, StoredInterface>;\n};\n\nexport type SnapInterfaceControllerArgs = {\n messenger: SnapInterfaceControllerMessenger;\n state?: SnapInterfaceControllerState;\n};\n\n/**\n * Use this controller to manage snaps UI interfaces using RPC method hooks.\n */\nexport class SnapInterfaceController extends BaseController<\n typeof controllerName,\n SnapInterfaceControllerState,\n SnapInterfaceControllerMessenger\n> {\n constructor({ messenger, state }: SnapInterfaceControllerArgs) {\n super({\n messenger,\n metadata: {\n interfaces: {\n includeInStateLogs: true,\n persist: (interfaces: Record<string, StoredInterface>) => {\n return Object.entries(interfaces).reduce<\n Record<string, StoredInterface>\n >((persistedInterfaces, [id, snapInterface]) => {\n switch (snapInterface.contentType) {\n case ContentType.Notification:\n persistedInterfaces[id] = snapInterface;\n return persistedInterfaces;\n default:\n return persistedInterfaces;\n }\n }, {});\n },\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n },\n name: controllerName,\n state: { interfaces: {}, ...state },\n });\n\n this.messenger.subscribe(\n 'NotificationServicesController:notificationsListUpdated',\n this.#onNotificationsListUpdated.bind(this),\n );\n\n this.#registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers() {\n this.messenger.registerActionHandler(\n `${controllerName}:createInterface`,\n this.createInterface.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:getInterface`,\n this.getInterface.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:getInterfaceState`,\n this.getInterfaceState.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:updateInterface`,\n this.updateInterface.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:deleteInterface`,\n this.deleteInterface.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:updateInterfaceState`,\n this.updateInterfaceState.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:resolveInterface`,\n this.resolveInterface.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:setInterfaceDisplayed`,\n this.setInterfaceDisplayed.bind(this),\n );\n }\n\n /**\n * Create an interface in the controller state with the associated data.\n *\n * @param snapId - The snap id that created the interface.\n * @param content - The interface content.\n * @param context - An optional interface context object.\n * @param contentType - The type of content.\n * @returns The newly interface id.\n */\n createInterface(\n snapId: SnapId,\n content: ComponentOrElement,\n context?: InterfaceContext,\n contentType?: ContentType,\n ) {\n const element = getJsxInterface(content);\n this.#validateContent(snapId, element);\n validateInterfaceContext(context);\n\n const id = nanoid();\n const componentState = constructState({}, element, {\n getAssetsState: this.#getAssetsState.bind(this),\n getAccountByAddress: this.#getAccountByAddress.bind(this),\n getSelectedAccount: this.#getSelectedAccount.bind(this),\n listAccounts: this.#listAccounts.bind(this),\n snapOwnsAccount: (account: InternalAccount) =>\n snapOwnsAccount(snapId, account),\n });\n\n this.update((draftState) => {\n // @ts-expect-error - TS2589: Type instantiation is excessively deep and\n // possibly infinite.\n draftState.interfaces[id] = {\n snapId,\n content: castDraft(element),\n state: componentState,\n context: context ?? null,\n contentType: contentType ?? null,\n displayed: false,\n };\n });\n\n return id;\n }\n\n /**\n * Get the data of a given interface id.\n *\n * @param snapId - The snap id requesting the interface data.\n * @param id - The interface id.\n * @returns The interface state.\n */\n getInterface(snapId: SnapId, id: string) {\n this.#validateArgs(snapId, id);\n\n return this.state.interfaces[id];\n }\n\n /**\n * Get the state of a given interface ID, if the interface has been displayed\n * at least once.\n *\n * @param snapId - The snap ID requesting the interface state.\n * @param id - The interface ID.\n * @returns The interface state.\n */\n getInterfaceState(snapId: SnapId, id: string) {\n const storedInterface = this.getInterface(snapId, id);\n if (!storedInterface.displayed) {\n throw new Error(\n `Interface with ID '${id}' has not been displayed yet. Interface state is not available until the interface has been displayed at least once.`,\n );\n }\n\n return storedInterface.state;\n }\n\n /**\n * Update the interface with the given content.\n *\n * @param snapId - The snap id requesting the update.\n * @param id - The interface id.\n * @param content - The new content.\n * @param context - An optional interface context object.\n */\n updateInterface(\n snapId: SnapId,\n id: string,\n content: ComponentOrElement,\n context?: InterfaceContext,\n ) {\n this.#validateArgs(snapId, id);\n const element = getJsxInterface(content);\n this.#validateContent(snapId, element);\n validateInterfaceContext(context);\n\n const oldState = this.state.interfaces[id].state;\n const newState = constructState(oldState, element, {\n getAssetsState: this.#getAssetsState.bind(this),\n getAccountByAddress: this.#getAccountByAddress.bind(this),\n getSelectedAccount: this.#getSelectedAccount.bind(this),\n listAccounts: this.#listAccounts.bind(this),\n snapOwnsAccount: (account: InternalAccount) =>\n snapOwnsAccount(snapId, account),\n });\n\n this.update((draftState) => {\n draftState.interfaces[id].state = newState;\n draftState.interfaces[id].content = castDraft(element);\n if (context) {\n draftState.interfaces[id].context = context;\n }\n });\n }\n\n /**\n * Delete an interface from state.\n *\n * @param id - The interface id.\n */\n deleteInterface(id: string) {\n this.update((draftState) => {\n delete draftState.interfaces[id];\n });\n }\n\n /**\n * Update the interface state.\n *\n * @param id - The interface id.\n * @param state - The new state.\n */\n updateInterfaceState(id: string, state: InterfaceState) {\n this.update((draftState) => {\n draftState.interfaces[id].state = state;\n });\n }\n\n /**\n * Resolve the promise of a given interface approval request.\n * The approval needs to have the same ID as the interface.\n *\n * @param snapId - The snap id.\n * @param id - The interface id.\n * @param value - The value to resolve the promise with.\n */\n async resolveInterface(snapId: SnapId, id: string, value: Json) {\n this.#validateArgs(snapId, id);\n this.#validateApproval(id);\n\n await this.#acceptApprovalRequest(id, value);\n\n this.deleteInterface(id);\n }\n\n /**\n * Set the interface as displayed.\n *\n * @param snapId - The snap ID requesting the update.\n * @param id - The interface ID.\n */\n setInterfaceDisplayed(snapId: SnapId, id: string) {\n this.#validateArgs(snapId, id);\n\n if (this.state.interfaces[id].displayed) {\n return;\n }\n\n this.update((draftState) => {\n draftState.interfaces[id].displayed = true;\n });\n }\n\n /**\n * Utility function to validate the args passed to the other methods.\n *\n * @param snapId - The snap id.\n * @param id - The interface id.\n */\n #validateArgs(snapId: SnapId, id: string) {\n const existingInterface = this.state.interfaces[id];\n\n assert(\n existingInterface !== undefined,\n `Interface with id '${id}' not found.`,\n );\n assert(\n existingInterface.snapId === snapId,\n `Interface not created by ${snapId}.`,\n );\n }\n\n /**\n * Utility function to validate that the approval request exists.\n *\n * @param id - The interface id.\n */\n #validateApproval(id: string) {\n assert(\n this.#hasApprovalRequest(id),\n `Approval request with id '${id}' not found.`,\n );\n }\n\n /**\n * Check an origin against the phishing list.\n *\n * @param origin - The origin to check.\n * @returns True if the origin is on the phishing list, otherwise false.\n */\n #checkPhishingList(origin: string) {\n return this.messenger.call('PhishingController:testOrigin', origin).result;\n }\n\n /**\n * Check if an approval request exists for a given interface by looking up\n * if the ApprovalController has a request with the given interface ID.\n *\n * @param id - The interface id.\n * @returns True if an approval request exists, otherwise false.\n */\n #hasApprovalRequest(id: string) {\n return this.messenger.call('ApprovalController:hasRequest', {\n id,\n });\n }\n\n /**\n * Accept an approval request for a given interface.\n *\n * @param id - The interface id.\n * @param value - The value to resolve the promise with.\n */\n async #acceptApprovalRequest(id: string, value: Json) {\n await this.messenger.call('ApprovalController:acceptRequest', id, value);\n }\n\n /**\n * Get the selected account in the client.\n *\n * @returns The selected account.\n */\n #getSelectedAccount() {\n return this.messenger.call(\n 'AccountsController:getSelectedMultichainAccount',\n );\n }\n\n /**\n * Get a list of accounts for the given chain IDs.\n *\n * @param chainIds - The chain IDs to get the accounts for.\n * @returns The list of accounts.\n */\n #listAccounts(chainIds?: CaipChainId[]) {\n const accounts = this.messenger.call(\n 'AccountsController:listMultichainAccounts',\n );\n\n if (!chainIds || chainIds.length === 0) {\n return accounts;\n }\n\n return accounts.filter((account) =>\n account.scopes.some((scope) => isMatchingChainId(scope, chainIds)),\n );\n }\n\n /**\n * Get an account by its address.\n *\n * @param address - The account address.\n * @returns The account or undefined if not found.\n */\n #getAccountByAddress(address: CaipAccountId) {\n const { address: parsedAddress } = parseCaipAccountId(address);\n\n return this.messenger.call(\n 'AccountsController:getAccountByAddress',\n parsedAddress,\n );\n }\n\n /**\n * Get the MultichainAssetsController state.\n *\n * @returns The MultichainAssetsController state.\n */\n #getAssetsState() {\n return this.messenger.call('MultichainAssetsController:getState');\n }\n\n /**\n * Get a snap by its id.\n *\n * @param id - The snap id.\n * @returns The snap.\n */\n #getSnap(id: string) {\n return this.messenger.call('SnapController:get', id);\n }\n\n #hasPermission(snapId: SnapId, permission: string) {\n return this.messenger.call(\n 'PermissionController:hasPermission',\n snapId,\n permission,\n );\n }\n\n /**\n * Utility function to validate the components of an interface.\n * Throws if something is invalid.\n *\n * @param snapId - The Snap ID.\n * @param element - The JSX element to verify.\n */\n #validateContent(snapId: SnapId, element: JSXElement) {\n // We assume the validity of this JSON to be validated by the caller.\n // E.g., in the RPC method implementation.\n const size = getJsonSizeUnsafe(element);\n assert(\n size <= MAX_UI_CONTENT_SIZE,\n `A Snap UI may not be larger than ${MAX_UI_CONTENT_SIZE / 1000000} MB.`,\n );\n\n validateJsxElements(element, {\n isOnPhishingList: this.#checkPhishingList.bind(this),\n getSnap: this.#getSnap.bind(this),\n getAccountByAddress: this.#getAccountByAddress.bind(this),\n hasPermission: this.#hasPermission.bind(this, snapId),\n });\n }\n\n #onNotificationsListUpdated(notificationsList: Notification[]) {\n const snapNotificationsWithInterface = notificationsList.filter(\n (notification) => {\n return (\n notification.type === 'snap' &&\n hasProperty((notification as SnapNotification).data, 'detailedView')\n );\n },\n );\n\n const interfaceIdSet = new Set(\n snapNotificationsWithInterface.map(\n (notification) =>\n (\n (notification as SnapNotification)\n .data as ExpandedSnapNotificationData\n ).detailedView.interfaceId,\n ),\n );\n\n this.update((state) => {\n Object.entries(state.interfaces).forEach(([id, snapInterface]) => {\n if (\n snapInterface.contentType === ContentType.Notification &&\n !interfaceIdSet.has(id)\n ) {\n delete state.interfaces[id];\n }\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"SnapInterfaceController.cjs","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController.ts"],"names":[],"mappings":";;;AAQA,+DAA2D;AAU3D,mDAAkD;AAGlD,uDAI+B;AAO/B,2CAA0E;AAC1E,iCAAkC;AAClC,mCAAgC;AAGhC,uCAKiB;AAGjB,MAAM,mBAAmB,GAAG,QAAU,CAAC,CAAC,QAAQ;AAEhD,MAAM,cAAc,GAAG,yBAAyB,CAAC;AA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AAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxZD,0DAwZC","sourcesContent":["import type {\n ApprovalControllerAcceptRequestAction,\n ApprovalControllerHasRequestAction,\n} from '@metamask/approval-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { PermissionControllerHasPermissionAction } from '@metamask/permission-controller';\nimport type {\n InterfaceState,\n SnapId,\n ComponentOrElement,\n InterfaceContext,\n FungibleAssetMetadata,\n} from '@metamask/snaps-sdk';\nimport { ContentType } from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type { InternalAccount } from '@metamask/snaps-utils';\nimport {\n getJsonSizeUnsafe,\n snapOwnsAccount,\n validateJsxElements,\n} from '@metamask/snaps-utils';\nimport type {\n CaipAccountId,\n CaipAssetType,\n CaipChainId,\n Json,\n} from '@metamask/utils';\nimport { assert, hasProperty, parseCaipAccountId } from '@metamask/utils';\nimport { castDraft } from 'immer';\nimport { nanoid } from 'nanoid';\n\nimport type { SnapInterfaceControllerMethodActions } from './SnapInterfaceController-method-action-types';\nimport {\n constructState,\n getJsxInterface,\n isMatchingChainId,\n validateInterfaceContext,\n} from './utils';\nimport type { SnapControllerGetSnapAction } from '../snaps';\n\nconst MAX_UI_CONTENT_SIZE = 10_000_000; // 10 mb\n\nconst controllerName = 'SnapInterfaceController';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'createInterface',\n 'getInterface',\n 'getInterfaceState',\n 'updateInterface',\n 'deleteInterface',\n 'updateInterfaceState',\n 'resolveInterface',\n 'setInterfaceDisplayed',\n] as const;\n\ntype AccountsControllerGetAccountByAddressAction = {\n type: `AccountsController:getAccountByAddress`;\n handler: (address: string) => InternalAccount | undefined;\n};\n\ntype AccountsControllerGetSelectedMultichainAccountAction = {\n type: `AccountsController:getSelectedMultichainAccount`;\n handler: () => InternalAccount;\n};\n\ntype AccountsControllerListMultichainAccountsAction = {\n type: `AccountsController:listMultichainAccounts`;\n handler: (chainId?: CaipChainId) => InternalAccount[];\n};\n\nexport type SnapInterfaceControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n SnapInterfaceControllerState\n>;\n\ntype MultichainAssetsControllerGetStateAction = ControllerGetStateAction<\n 'MultichainAssetsController',\n {\n assetsMetadata: {\n [asset: CaipAssetType]: FungibleAssetMetadata;\n };\n accountsAssets: { [account: string]: CaipAssetType[] };\n }\n>;\n\ntype PhishingControllerTestOrigin = {\n type: 'PhishingController:testOrigin';\n handler: (origin: string) => { result: boolean; type: string };\n};\n\ntype AllowedActions =\n | PhishingControllerTestOrigin\n | ApprovalControllerHasRequestAction\n | ApprovalControllerAcceptRequestAction\n | SnapControllerGetSnapAction\n | MultichainAssetsControllerGetStateAction\n | AccountsControllerGetSelectedMultichainAccountAction\n | AccountsControllerGetAccountByAddressAction\n | AccountsControllerListMultichainAccountsAction\n | PermissionControllerHasPermissionAction;\n\nexport type SnapInterfaceControllerActions =\n | SnapInterfaceControllerGetStateAction\n | SnapInterfaceControllerMethodActions;\n\nexport type SnapInterfaceControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n SnapInterfaceControllerState\n >;\n\ntype OtherNotification = { type: string; [key: string]: unknown };\n\ntype ExpandedView = {\n title: string;\n interfaceId: string;\n footerLink?: { href: string; text: string };\n};\n\ntype NormalSnapNotificationData = { message: string; origin: string };\n\ntype ExpandedSnapNotificationData = {\n message: string;\n origin: string;\n detailedView: ExpandedView;\n};\n\ntype SnapNotification = {\n type: 'snap';\n data: NormalSnapNotificationData | ExpandedSnapNotificationData;\n readDate: string | null;\n};\n\ntype Notification = OtherNotification | SnapNotification;\n\ntype NotificationListUpdatedEvent = {\n type: 'NotificationServicesController:notificationsListUpdated';\n payload: [Notification[]];\n};\n\ntype AllowedEvents = NotificationListUpdatedEvent;\n\nexport type SnapInterfaceControllerEvents =\n SnapInterfaceControllerStateChangeEvent;\n\nexport type SnapInterfaceControllerMessenger = Messenger<\n typeof controllerName,\n SnapInterfaceControllerActions | AllowedActions,\n SnapInterfaceControllerEvents | AllowedEvents\n>;\n\nexport type StoredInterface = {\n snapId: SnapId;\n content: JSXElement;\n state: InterfaceState;\n context: InterfaceContext | null;\n contentType: ContentType | null;\n\n /**\n * Whether the interface has been displayed in the UI at least once.\n */\n displayed: boolean;\n};\n\nexport type SnapInterfaceControllerState = {\n interfaces: Record<string, StoredInterface>;\n};\n\nexport type SnapInterfaceControllerArgs = {\n messenger: SnapInterfaceControllerMessenger;\n state?: SnapInterfaceControllerState;\n};\n\n/**\n * Use this controller to manage snaps UI interfaces using RPC method hooks.\n */\nexport class SnapInterfaceController extends BaseController<\n typeof controllerName,\n SnapInterfaceControllerState,\n SnapInterfaceControllerMessenger\n> {\n constructor({ messenger, state }: SnapInterfaceControllerArgs) {\n super({\n messenger,\n metadata: {\n interfaces: {\n includeInStateLogs: true,\n persist: (interfaces: Record<string, StoredInterface>) => {\n return Object.entries(interfaces).reduce<\n Record<string, StoredInterface>\n >((persistedInterfaces, [id, snapInterface]) => {\n switch (snapInterface.contentType) {\n case ContentType.Notification:\n persistedInterfaces[id] = snapInterface;\n return persistedInterfaces;\n default:\n return persistedInterfaces;\n }\n }, {});\n },\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n },\n name: controllerName,\n state: { interfaces: {}, ...state },\n });\n\n this.messenger.subscribe(\n 'NotificationServicesController:notificationsListUpdated',\n this.#onNotificationsListUpdated.bind(this),\n );\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Create an interface in the controller state with the associated data.\n *\n * @param snapId - The snap id that created the interface.\n * @param content - The interface content.\n * @param context - An optional interface context object.\n * @param contentType - The type of content.\n * @returns The newly interface id.\n */\n createInterface(\n snapId: SnapId,\n content: ComponentOrElement,\n context?: InterfaceContext,\n contentType?: ContentType,\n ) {\n const element = getJsxInterface(content);\n this.#validateContent(snapId, element);\n validateInterfaceContext(context);\n\n const id = nanoid();\n const componentState = constructState({}, element, {\n getAssetsState: this.#getAssetsState.bind(this),\n getAccountByAddress: this.#getAccountByAddress.bind(this),\n getSelectedAccount: this.#getSelectedAccount.bind(this),\n listAccounts: this.#listAccounts.bind(this),\n snapOwnsAccount: (account: InternalAccount) =>\n snapOwnsAccount(snapId, account),\n });\n\n this.update((draftState) => {\n // @ts-expect-error - TS2589: Type instantiation is excessively deep and\n // possibly infinite.\n draftState.interfaces[id] = {\n snapId,\n content: castDraft(element),\n state: componentState,\n context: context ?? null,\n contentType: contentType ?? null,\n displayed: false,\n };\n });\n\n return id;\n }\n\n /**\n * Get the data of a given interface id.\n *\n * @param snapId - The snap id requesting the interface data.\n * @param id - The interface id.\n * @returns The interface state.\n */\n getInterface(snapId: SnapId, id: string) {\n this.#validateArgs(snapId, id);\n\n return this.state.interfaces[id];\n }\n\n /**\n * Get the state of a given interface ID, if the interface has been displayed\n * at least once.\n *\n * @param snapId - The snap ID requesting the interface state.\n * @param id - The interface ID.\n * @returns The interface state.\n */\n getInterfaceState(snapId: SnapId, id: string) {\n const storedInterface = this.getInterface(snapId, id);\n if (!storedInterface.displayed) {\n throw new Error(\n `Interface with ID '${id}' has not been displayed yet. Interface state is not available until the interface has been displayed at least once.`,\n );\n }\n\n return storedInterface.state;\n }\n\n /**\n * Update the interface with the given content.\n *\n * @param snapId - The snap id requesting the update.\n * @param id - The interface id.\n * @param content - The new content.\n * @param context - An optional interface context object.\n */\n updateInterface(\n snapId: SnapId,\n id: string,\n content: ComponentOrElement,\n context?: InterfaceContext,\n ) {\n this.#validateArgs(snapId, id);\n const element = getJsxInterface(content);\n this.#validateContent(snapId, element);\n validateInterfaceContext(context);\n\n const oldState = this.state.interfaces[id].state;\n const newState = constructState(oldState, element, {\n getAssetsState: this.#getAssetsState.bind(this),\n getAccountByAddress: this.#getAccountByAddress.bind(this),\n getSelectedAccount: this.#getSelectedAccount.bind(this),\n listAccounts: this.#listAccounts.bind(this),\n snapOwnsAccount: (account: InternalAccount) =>\n snapOwnsAccount(snapId, account),\n });\n\n this.update((draftState) => {\n draftState.interfaces[id].state = newState;\n draftState.interfaces[id].content = castDraft(element);\n if (context) {\n draftState.interfaces[id].context = context;\n }\n });\n }\n\n /**\n * Delete an interface from state.\n *\n * @param id - The interface id.\n */\n deleteInterface(id: string) {\n this.update((draftState) => {\n delete draftState.interfaces[id];\n });\n }\n\n /**\n * Update the interface state.\n *\n * @param id - The interface id.\n * @param state - The new state.\n */\n updateInterfaceState(id: string, state: InterfaceState) {\n this.update((draftState) => {\n draftState.interfaces[id].state = state;\n });\n }\n\n /**\n * Resolve the promise of a given interface approval request.\n * The approval needs to have the same ID as the interface.\n *\n * @param snapId - The snap id.\n * @param id - The interface id.\n * @param value - The value to resolve the promise with.\n */\n async resolveInterface(snapId: SnapId, id: string, value: Json) {\n this.#validateArgs(snapId, id);\n this.#validateApproval(id);\n\n await this.#acceptApprovalRequest(id, value);\n\n this.deleteInterface(id);\n }\n\n /**\n * Set the interface as displayed.\n *\n * @param snapId - The snap ID requesting the update.\n * @param id - The interface ID.\n */\n setInterfaceDisplayed(snapId: SnapId, id: string) {\n this.#validateArgs(snapId, id);\n\n if (this.state.interfaces[id].displayed) {\n return;\n }\n\n this.update((draftState) => {\n draftState.interfaces[id].displayed = true;\n });\n }\n\n /**\n * Utility function to validate the args passed to the other methods.\n *\n * @param snapId - The snap id.\n * @param id - The interface id.\n */\n #validateArgs(snapId: SnapId, id: string) {\n const existingInterface = this.state.interfaces[id];\n\n assert(\n existingInterface !== undefined,\n `Interface with id '${id}' not found.`,\n );\n assert(\n existingInterface.snapId === snapId,\n `Interface not created by ${snapId}.`,\n );\n }\n\n /**\n * Utility function to validate that the approval request exists.\n *\n * @param id - The interface id.\n */\n #validateApproval(id: string) {\n assert(\n this.#hasApprovalRequest(id),\n `Approval request with id '${id}' not found.`,\n );\n }\n\n /**\n * Check an origin against the phishing list.\n *\n * @param origin - The origin to check.\n * @returns True if the origin is on the phishing list, otherwise false.\n */\n #checkPhishingList(origin: string) {\n return this.messenger.call('PhishingController:testOrigin', origin).result;\n }\n\n /**\n * Check if an approval request exists for a given interface by looking up\n * if the ApprovalController has a request with the given interface ID.\n *\n * @param id - The interface id.\n * @returns True if an approval request exists, otherwise false.\n */\n #hasApprovalRequest(id: string) {\n return this.messenger.call('ApprovalController:hasRequest', {\n id,\n });\n }\n\n /**\n * Accept an approval request for a given interface.\n *\n * @param id - The interface id.\n * @param value - The value to resolve the promise with.\n */\n async #acceptApprovalRequest(id: string, value: Json) {\n await this.messenger.call('ApprovalController:acceptRequest', id, value);\n }\n\n /**\n * Get the selected account in the client.\n *\n * @returns The selected account.\n */\n #getSelectedAccount() {\n return this.messenger.call(\n 'AccountsController:getSelectedMultichainAccount',\n );\n }\n\n /**\n * Get a list of accounts for the given chain IDs.\n *\n * @param chainIds - The chain IDs to get the accounts for.\n * @returns The list of accounts.\n */\n #listAccounts(chainIds?: CaipChainId[]) {\n const accounts = this.messenger.call(\n 'AccountsController:listMultichainAccounts',\n );\n\n if (!chainIds || chainIds.length === 0) {\n return accounts;\n }\n\n return accounts.filter((account) =>\n account.scopes.some((scope) => isMatchingChainId(scope, chainIds)),\n );\n }\n\n /**\n * Get an account by its address.\n *\n * @param address - The account address.\n * @returns The account or undefined if not found.\n */\n #getAccountByAddress(address: CaipAccountId) {\n const { address: parsedAddress } = parseCaipAccountId(address);\n\n return this.messenger.call(\n 'AccountsController:getAccountByAddress',\n parsedAddress,\n );\n }\n\n /**\n * Get the MultichainAssetsController state.\n *\n * @returns The MultichainAssetsController state.\n */\n #getAssetsState() {\n return this.messenger.call('MultichainAssetsController:getState');\n }\n\n /**\n * Get a snap by its id.\n *\n * @param id - The snap id.\n * @returns The snap.\n */\n #getSnap(id: string) {\n return this.messenger.call('SnapController:getSnap', id);\n }\n\n #hasPermission(snapId: SnapId, permission: string) {\n return this.messenger.call(\n 'PermissionController:hasPermission',\n snapId,\n permission,\n );\n }\n\n /**\n * Utility function to validate the components of an interface.\n * Throws if something is invalid.\n *\n * @param snapId - The Snap ID.\n * @param element - The JSX element to verify.\n */\n #validateContent(snapId: SnapId, element: JSXElement) {\n // We assume the validity of this JSON to be validated by the caller.\n // E.g., in the RPC method implementation.\n const size = getJsonSizeUnsafe(element);\n assert(\n size <= MAX_UI_CONTENT_SIZE,\n `A Snap UI may not be larger than ${MAX_UI_CONTENT_SIZE / 1000000} MB.`,\n );\n\n validateJsxElements(element, {\n isOnPhishingList: this.#checkPhishingList.bind(this),\n getSnap: this.#getSnap.bind(this),\n getAccountByAddress: this.#getAccountByAddress.bind(this),\n hasPermission: this.#hasPermission.bind(this, snapId),\n });\n }\n\n #onNotificationsListUpdated(notificationsList: Notification[]) {\n const snapNotificationsWithInterface = notificationsList.filter(\n (notification) => {\n return (\n notification.type === 'snap' &&\n hasProperty((notification as SnapNotification).data, 'detailedView')\n );\n },\n );\n\n const interfaceIdSet = new Set(\n snapNotificationsWithInterface.map(\n (notification) =>\n (\n (notification as SnapNotification)\n .data as ExpandedSnapNotificationData\n ).detailedView.interfaceId,\n ),\n );\n\n this.update((state) => {\n Object.entries(state.interfaces).forEach(([id, snapInterface]) => {\n if (\n snapInterface.contentType === ContentType.Notification &&\n !interfaceIdSet.has(id)\n ) {\n delete state.interfaces[id];\n }\n });\n });\n }\n}\n"]}
@@ -1,47 +1,16 @@
1
- import type { AcceptRequest, HasApprovalRequest } from "@metamask/approval-controller";
1
+ import type { ApprovalControllerAcceptRequestAction, ApprovalControllerHasRequestAction } from "@metamask/approval-controller";
2
2
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
3
3
  import { BaseController } from "@metamask/base-controller";
4
4
  import type { Messenger } from "@metamask/messenger";
5
- import type { HasPermission } from "@metamask/permission-controller";
5
+ import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller";
6
6
  import type { InterfaceState, SnapId, ComponentOrElement, InterfaceContext, FungibleAssetMetadata } from "@metamask/snaps-sdk";
7
7
  import { ContentType } from "@metamask/snaps-sdk";
8
8
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
9
9
  import type { InternalAccount } from "@metamask/snaps-utils";
10
10
  import type { CaipAssetType, CaipChainId, Json } from "@metamask/utils";
11
- import type { GetSnap } from "../snaps/index.cjs";
11
+ import type { SnapInterfaceControllerMethodActions } from "./SnapInterfaceController-method-action-types.cjs";
12
+ import type { SnapControllerGetSnapAction } from "../snaps/index.cjs";
12
13
  declare const controllerName = "SnapInterfaceController";
13
- export type CreateInterface = {
14
- type: `${typeof controllerName}:createInterface`;
15
- handler: SnapInterfaceController['createInterface'];
16
- };
17
- export type GetInterface = {
18
- type: `${typeof controllerName}:getInterface`;
19
- handler: SnapInterfaceController['getInterface'];
20
- };
21
- export type UpdateInterface = {
22
- type: `${typeof controllerName}:updateInterface`;
23
- handler: SnapInterfaceController['updateInterface'];
24
- };
25
- export type DeleteInterface = {
26
- type: `${typeof controllerName}:deleteInterface`;
27
- handler: SnapInterfaceController['deleteInterface'];
28
- };
29
- export type UpdateInterfaceState = {
30
- type: `${typeof controllerName}:updateInterfaceState`;
31
- handler: SnapInterfaceController['updateInterfaceState'];
32
- };
33
- export type ResolveInterface = {
34
- type: `${typeof controllerName}:resolveInterface`;
35
- handler: SnapInterfaceController['resolveInterface'];
36
- };
37
- export type SnapInterfaceControllerGetInterfaceStateAction = {
38
- type: `${typeof controllerName}:getInterfaceState`;
39
- handler: SnapInterfaceController['getInterfaceState'];
40
- };
41
- export type SnapInterfaceControllerSetInterfaceDisplayedAction = {
42
- type: `${typeof controllerName}:setInterfaceDisplayed`;
43
- handler: SnapInterfaceController['setInterfaceDisplayed'];
44
- };
45
14
  type AccountsControllerGetAccountByAddressAction = {
46
15
  type: `AccountsController:getAccountByAddress`;
47
16
  handler: (address: string) => InternalAccount | undefined;
@@ -70,14 +39,14 @@ type PhishingControllerTestOrigin = {
70
39
  type: string;
71
40
  };
72
41
  };
73
- export type SnapInterfaceControllerAllowedActions = PhishingControllerTestOrigin | HasApprovalRequest | AcceptRequest | GetSnap | MultichainAssetsControllerGetStateAction | AccountsControllerGetSelectedMultichainAccountAction | AccountsControllerGetAccountByAddressAction | AccountsControllerListMultichainAccountsAction | HasPermission;
74
- export type SnapInterfaceControllerActions = CreateInterface | GetInterface | UpdateInterface | DeleteInterface | UpdateInterfaceState | ResolveInterface | SnapInterfaceControllerGetInterfaceStateAction | SnapInterfaceControllerSetInterfaceDisplayedAction | SnapInterfaceControllerGetStateAction;
42
+ type AllowedActions = PhishingControllerTestOrigin | ApprovalControllerHasRequestAction | ApprovalControllerAcceptRequestAction | SnapControllerGetSnapAction | MultichainAssetsControllerGetStateAction | AccountsControllerGetSelectedMultichainAccountAction | AccountsControllerGetAccountByAddressAction | AccountsControllerListMultichainAccountsAction | PermissionControllerHasPermissionAction;
43
+ export type SnapInterfaceControllerActions = SnapInterfaceControllerGetStateAction | SnapInterfaceControllerMethodActions;
75
44
  export type SnapInterfaceControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SnapInterfaceControllerState>;
76
45
  type OtherNotification = {
77
46
  type: string;
78
47
  [key: string]: unknown;
79
48
  };
80
- export type ExpandedView = {
49
+ type ExpandedView = {
81
50
  title: string;
82
51
  interfaceId: string;
83
52
  footerLink?: {
@@ -104,8 +73,9 @@ type NotificationListUpdatedEvent = {
104
73
  type: 'NotificationServicesController:notificationsListUpdated';
105
74
  payload: [Notification[]];
106
75
  };
107
- export type SnapInterfaceControllerEvents = SnapInterfaceControllerStateChangeEvent | NotificationListUpdatedEvent;
108
- export type SnapInterfaceControllerMessenger = Messenger<typeof controllerName, SnapInterfaceControllerActions | SnapInterfaceControllerAllowedActions, SnapInterfaceControllerEvents>;
76
+ type AllowedEvents = NotificationListUpdatedEvent;
77
+ export type SnapInterfaceControllerEvents = SnapInterfaceControllerStateChangeEvent;
78
+ export type SnapInterfaceControllerMessenger = Messenger<typeof controllerName, SnapInterfaceControllerActions | AllowedActions, SnapInterfaceControllerEvents | AllowedEvents>;
109
79
  export type StoredInterface = {
110
80
  snapId: SnapId;
111
81
  content: JSXElement;
@@ -1 +1 @@
1
- {"version":3,"file":"SnapInterfaceController.d.cts","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EACnB,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,wCAAwC;AACrE,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACtB,4BAA4B;AAC7B,OAAO,EAAE,WAAW,EAAE,4BAA4B;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,gCAAgC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAM7D,OAAO,KAAK,EAEV,aAAa,EACb,WAAW,EACX,IAAI,EACL,wBAAwB;AAWzB,OAAO,KAAK,EAAE,OAAO,EAAE,2BAAiB;AAIxC,QAAA,MAAM,cAAc,4BAA4B,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,GAAG,OAAO,cAAc,kBAAkB,CAAC;IACjD,OAAO,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,GAAG,OAAO,cAAc,eAAe,CAAC;IAC9C,OAAO,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,GAAG,OAAO,cAAc,kBAAkB,CAAC;IACjD,OAAO,EAAE,uBAAuB,CAAC,iBAAi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EAC5B,gCAAgC,CACjC;;gBACa,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,2BAA2B;IAiF7D;;;;;;;;OAQG;IACH,eAAe,CACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,kBAAkB,EAC3B,OAAO,CAAC,EAAE,gBAAgB,EAC1B,WAAW,CAAC,EAAE,WAAW;IAgC3B;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAMvC;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;IAW5C;;;;;;;OAOG;IACH,eAAe,CACb,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,kBAAkB,EAC3B,OAAO,CAAC,EAAE,gBAAgB;IA0B5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM;IAM1B;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc;IAMtD;;;;;;;OAOG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI;IAS9D;;;;;OAKG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CA4MjD"}
1
+ {"version":3,"file":"SnapInterfaceController.d.cts","sourceRoot":"","sources":["../../src/interface/SnapInterfaceController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qCAAqC,EACrC,kCAAkC,EACnC,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,uCAAuC,EAAE,wCAAwC;AAC/F,OAAO,KA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;;;;;;;OAOG;IACH,eAAe,CACb,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,kBAAkB,EAC3B,OAAO,CAAC,EAAE,gBAAgB;IA0B5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM;IAM1B;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc;IAMtD;;;;;;;OAOG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI;IAS9D;;;;;OAKG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CA4MjD"}
@@ -1,47 +1,16 @@
1
- import type { AcceptRequest, HasApprovalRequest } from "@metamask/approval-controller";
1
+ import type { ApprovalControllerAcceptRequestAction, ApprovalControllerHasRequestAction } from "@metamask/approval-controller";
2
2
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
3
3
  import { BaseController } from "@metamask/base-controller";
4
4
  import type { Messenger } from "@metamask/messenger";
5
- import type { HasPermission } from "@metamask/permission-controller";
5
+ import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller";
6
6
  import type { InterfaceState, SnapId, ComponentOrElement, InterfaceContext, FungibleAssetMetadata } from "@metamask/snaps-sdk";
7
7
  import { ContentType } from "@metamask/snaps-sdk";
8
8
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
9
9
  import type { InternalAccount } from "@metamask/snaps-utils";
10
10
  import type { CaipAssetType, CaipChainId, Json } from "@metamask/utils";
11
- import type { GetSnap } from "../snaps/index.mjs";
11
+ import type { SnapInterfaceControllerMethodActions } from "./SnapInterfaceController-method-action-types.mjs";
12
+ import type { SnapControllerGetSnapAction } from "../snaps/index.mjs";
12
13
  declare const controllerName = "SnapInterfaceController";
13
- export type CreateInterface = {
14
- type: `${typeof controllerName}:createInterface`;
15
- handler: SnapInterfaceController['createInterface'];
16
- };
17
- export type GetInterface = {
18
- type: `${typeof controllerName}:getInterface`;
19
- handler: SnapInterfaceController['getInterface'];
20
- };
21
- export type UpdateInterface = {
22
- type: `${typeof controllerName}:updateInterface`;
23
- handler: SnapInterfaceController['updateInterface'];
24
- };
25
- export type DeleteInterface = {
26
- type: `${typeof controllerName}:deleteInterface`;
27
- handler: SnapInterfaceController['deleteInterface'];
28
- };
29
- export type UpdateInterfaceState = {
30
- type: `${typeof controllerName}:updateInterfaceState`;
31
- handler: SnapInterfaceController['updateInterfaceState'];
32
- };
33
- export type ResolveInterface = {
34
- type: `${typeof controllerName}:resolveInterface`;
35
- handler: SnapInterfaceController['resolveInterface'];
36
- };
37
- export type SnapInterfaceControllerGetInterfaceStateAction = {
38
- type: `${typeof controllerName}:getInterfaceState`;
39
- handler: SnapInterfaceController['getInterfaceState'];
40
- };
41
- export type SnapInterfaceControllerSetInterfaceDisplayedAction = {
42
- type: `${typeof controllerName}:setInterfaceDisplayed`;
43
- handler: SnapInterfaceController['setInterfaceDisplayed'];
44
- };
45
14
  type AccountsControllerGetAccountByAddressAction = {
46
15
  type: `AccountsController:getAccountByAddress`;
47
16
  handler: (address: string) => InternalAccount | undefined;
@@ -70,14 +39,14 @@ type PhishingControllerTestOrigin = {
70
39
  type: string;
71
40
  };
72
41
  };
73
- export type SnapInterfaceControllerAllowedActions = PhishingControllerTestOrigin | HasApprovalRequest | AcceptRequest | GetSnap | MultichainAssetsControllerGetStateAction | AccountsControllerGetSelectedMultichainAccountAction | AccountsControllerGetAccountByAddressAction | AccountsControllerListMultichainAccountsAction | HasPermission;
74
- export type SnapInterfaceControllerActions = CreateInterface | GetInterface | UpdateInterface | DeleteInterface | UpdateInterfaceState | ResolveInterface | SnapInterfaceControllerGetInterfaceStateAction | SnapInterfaceControllerSetInterfaceDisplayedAction | SnapInterfaceControllerGetStateAction;
42
+ type AllowedActions = PhishingControllerTestOrigin | ApprovalControllerHasRequestAction | ApprovalControllerAcceptRequestAction | SnapControllerGetSnapAction | MultichainAssetsControllerGetStateAction | AccountsControllerGetSelectedMultichainAccountAction | AccountsControllerGetAccountByAddressAction | AccountsControllerListMultichainAccountsAction | PermissionControllerHasPermissionAction;
43
+ export type SnapInterfaceControllerActions = SnapInterfaceControllerGetStateAction | SnapInterfaceControllerMethodActions;
75
44
  export type SnapInterfaceControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SnapInterfaceControllerState>;
76
45
  type OtherNotification = {
77
46
  type: string;
78
47
  [key: string]: unknown;
79
48
  };
80
- export type ExpandedView = {
49
+ type ExpandedView = {
81
50
  title: string;
82
51
  interfaceId: string;
83
52
  footerLink?: {
@@ -104,8 +73,9 @@ type NotificationListUpdatedEvent = {
104
73
  type: 'NotificationServicesController:notificationsListUpdated';
105
74
  payload: [Notification[]];
106
75
  };
107
- export type SnapInterfaceControllerEvents = SnapInterfaceControllerStateChangeEvent | NotificationListUpdatedEvent;
108
- export type SnapInterfaceControllerMessenger = Messenger<typeof controllerName, SnapInterfaceControllerActions | SnapInterfaceControllerAllowedActions, SnapInterfaceControllerEvents>;
76
+ type AllowedEvents = NotificationListUpdatedEvent;
77
+ export type SnapInterfaceControllerEvents = SnapInterfaceControllerStateChangeEvent;
78
+ export type SnapInterfaceControllerMessenger = Messenger<typeof controllerName, SnapInterfaceControllerActions | AllowedActions, SnapInterfaceControllerEvents | AllowedEvents>;
109
79
  export type StoredInterface = {
110
80
  snapId: SnapId;
111
81
  content: JSXElement;