@hashgraphonline/standards-sdk 0.0.48 → 0.0.50

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 (337) hide show
  1. package/dist/es/hcs-10/agent-builder.d.ts +2 -1
  2. package/dist/es/hcs-10/agent-builder.d.ts.map +1 -0
  3. package/dist/es/hcs-10/base-client.d.ts +1 -0
  4. package/dist/es/hcs-10/base-client.d.ts.map +1 -0
  5. package/dist/es/hcs-10/browser.d.ts +2 -1
  6. package/dist/es/hcs-10/browser.d.ts.map +1 -0
  7. package/dist/es/hcs-10/errors.d.ts +1 -0
  8. package/dist/es/hcs-10/errors.d.ts.map +1 -0
  9. package/dist/es/hcs-10/fee-config-builder.d.ts +2 -1
  10. package/dist/es/hcs-10/fee-config-builder.d.ts.map +1 -0
  11. package/dist/es/hcs-10/index.d.ts +1 -0
  12. package/dist/es/hcs-10/index.d.ts.map +1 -0
  13. package/dist/es/hcs-10/registrations.d.ts +1 -0
  14. package/dist/es/hcs-10/registrations.d.ts.map +1 -0
  15. package/dist/es/hcs-10/sdk.d.ts +3 -2
  16. package/dist/es/hcs-10/sdk.d.ts.map +1 -0
  17. package/dist/es/hcs-10/types.d.ts +176 -0
  18. package/dist/es/hcs-10/types.d.ts.map +1 -0
  19. package/dist/es/hcs-11/index.d.ts +1 -0
  20. package/dist/es/hcs-11/index.d.ts.map +1 -0
  21. package/dist/es/hcs-3/index.d.ts +1 -0
  22. package/dist/es/hcs-3/index.d.ts.map +1 -0
  23. package/dist/es/hcs-3/src/index.d.ts +1 -0
  24. package/dist/es/hcs-3/src/index.d.ts.map +1 -0
  25. package/dist/es/hcs-7/evm-bridge.d.ts +1 -0
  26. package/dist/es/hcs-7/evm-bridge.d.ts.map +1 -0
  27. package/dist/es/hcs-7/index.d.ts +1 -0
  28. package/dist/es/hcs-7/index.d.ts.map +1 -0
  29. package/dist/es/hcs-7/redis-cache.d.ts +1 -0
  30. package/dist/es/hcs-7/redis-cache.d.ts.map +1 -0
  31. package/dist/es/hcs-7/wasm-bridge.d.ts +1 -0
  32. package/dist/es/hcs-7/wasm-bridge.d.ts.map +1 -0
  33. package/dist/es/index.d.ts +1 -0
  34. package/dist/es/index.d.ts.map +1 -0
  35. package/dist/es/inscribe/index.d.ts +1 -0
  36. package/dist/es/inscribe/index.d.ts.map +1 -0
  37. package/dist/es/inscribe/inscriber.d.ts +1 -0
  38. package/dist/es/inscribe/inscriber.d.ts.map +1 -0
  39. package/dist/es/inscribe/types.d.ts +1 -0
  40. package/dist/es/inscribe/types.d.ts.map +1 -0
  41. package/dist/es/services/index.d.ts +1 -0
  42. package/dist/es/services/index.d.ts.map +1 -0
  43. package/dist/es/services/mirror-node.d.ts +1 -0
  44. package/dist/es/services/mirror-node.d.ts.map +1 -0
  45. package/dist/es/services/types.d.ts +1 -0
  46. package/dist/es/services/types.d.ts.map +1 -0
  47. package/dist/es/standards-sdk.es.js +19 -26467
  48. package/dist/es/standards-sdk.es.js.map +1 -1
  49. package/dist/es/standards-sdk.es10.js +1058 -0
  50. package/dist/es/standards-sdk.es10.js.map +1 -0
  51. package/dist/es/standards-sdk.es100.js +8 -0
  52. package/dist/es/standards-sdk.es100.js.map +1 -0
  53. package/dist/es/standards-sdk.es101.js +42 -0
  54. package/dist/es/standards-sdk.es101.js.map +1 -0
  55. package/dist/es/standards-sdk.es102.js +43 -0
  56. package/dist/es/standards-sdk.es102.js.map +1 -0
  57. package/dist/es/standards-sdk.es103.js +40 -0
  58. package/dist/es/standards-sdk.es103.js.map +1 -0
  59. package/dist/es/standards-sdk.es104.js +81 -0
  60. package/dist/es/standards-sdk.es104.js.map +1 -0
  61. package/dist/es/standards-sdk.es105.js +6 -0
  62. package/dist/es/standards-sdk.es105.js.map +1 -0
  63. package/dist/es/standards-sdk.es106.js +5 -0
  64. package/dist/es/standards-sdk.es106.js.map +1 -0
  65. package/dist/es/standards-sdk.es107.js +5 -0
  66. package/dist/es/standards-sdk.es107.js.map +1 -0
  67. package/dist/es/standards-sdk.es108.js +37 -0
  68. package/dist/es/standards-sdk.es108.js.map +1 -0
  69. package/dist/es/standards-sdk.es109.js +36 -0
  70. package/dist/es/standards-sdk.es109.js.map +1 -0
  71. package/dist/es/standards-sdk.es11.js +98 -0
  72. package/dist/es/standards-sdk.es11.js.map +1 -0
  73. package/dist/es/standards-sdk.es110.js +12 -0
  74. package/dist/es/standards-sdk.es110.js.map +1 -0
  75. package/dist/es/standards-sdk.es111.js +37 -0
  76. package/dist/es/standards-sdk.es111.js.map +1 -0
  77. package/dist/es/standards-sdk.es12.js +741 -0
  78. package/dist/es/standards-sdk.es12.js.map +1 -0
  79. package/dist/es/standards-sdk.es13.js +72 -0
  80. package/dist/es/standards-sdk.es13.js.map +1 -0
  81. package/dist/es/standards-sdk.es14.js +25 -0
  82. package/dist/es/standards-sdk.es14.js.map +1 -0
  83. package/dist/es/standards-sdk.es15.js +163 -0
  84. package/dist/es/standards-sdk.es15.js.map +1 -0
  85. package/dist/es/standards-sdk.es16.js +409 -0
  86. package/dist/es/standards-sdk.es16.js.map +1 -0
  87. package/dist/es/standards-sdk.es17.js +235 -0
  88. package/dist/es/standards-sdk.es17.js.map +1 -0
  89. package/dist/es/standards-sdk.es18.js +10 -0
  90. package/dist/es/standards-sdk.es18.js.map +1 -0
  91. package/dist/es/standards-sdk.es19.js +6 -0
  92. package/dist/es/standards-sdk.es19.js.map +1 -0
  93. package/dist/es/standards-sdk.es2.js +697 -0
  94. package/dist/es/standards-sdk.es2.js.map +1 -0
  95. package/dist/es/standards-sdk.es20.js +4170 -0
  96. package/dist/es/standards-sdk.es20.js.map +1 -0
  97. package/dist/es/standards-sdk.es21.js +1044 -0
  98. package/dist/es/standards-sdk.es21.js.map +1 -0
  99. package/dist/es/standards-sdk.es22.js +6627 -0
  100. package/dist/es/standards-sdk.es22.js.map +1 -0
  101. package/dist/es/standards-sdk.es23.js +39 -0
  102. package/dist/es/standards-sdk.es23.js.map +1 -0
  103. package/dist/es/standards-sdk.es24.js +51 -0
  104. package/dist/es/standards-sdk.es24.js.map +1 -0
  105. package/dist/es/standards-sdk.es25.js +5 -0
  106. package/dist/es/standards-sdk.es25.js.map +1 -0
  107. package/dist/es/standards-sdk.es26.js +8 -0
  108. package/dist/es/standards-sdk.es26.js.map +1 -0
  109. package/dist/es/standards-sdk.es27.js +104 -0
  110. package/dist/es/standards-sdk.es27.js.map +1 -0
  111. package/dist/es/standards-sdk.es28.js +5 -0
  112. package/dist/es/standards-sdk.es28.js.map +1 -0
  113. package/dist/es/standards-sdk.es29.js +19 -0
  114. package/dist/es/standards-sdk.es29.js.map +1 -0
  115. package/dist/es/standards-sdk.es3.js +196 -0
  116. package/dist/es/standards-sdk.es3.js.map +1 -0
  117. package/dist/es/standards-sdk.es30.js +7 -0
  118. package/dist/es/standards-sdk.es30.js.map +1 -0
  119. package/dist/es/standards-sdk.es31.js +2285 -0
  120. package/dist/es/standards-sdk.es31.js.map +1 -0
  121. package/dist/es/standards-sdk.es32.js +5 -0
  122. package/dist/es/standards-sdk.es32.js.map +1 -0
  123. package/dist/es/standards-sdk.es33.js +5 -0
  124. package/dist/es/standards-sdk.es33.js.map +1 -0
  125. package/dist/es/standards-sdk.es34.js +198 -0
  126. package/dist/es/standards-sdk.es34.js.map +1 -0
  127. package/dist/es/standards-sdk.es35.js +441 -0
  128. package/dist/es/standards-sdk.es35.js.map +1 -0
  129. package/dist/es/standards-sdk.es36.js +28 -0
  130. package/dist/es/standards-sdk.es36.js.map +1 -0
  131. package/dist/es/standards-sdk.es37.js +142 -0
  132. package/dist/es/standards-sdk.es37.js.map +1 -0
  133. package/dist/es/standards-sdk.es38.js +21 -0
  134. package/dist/es/standards-sdk.es38.js.map +1 -0
  135. package/dist/es/standards-sdk.es39.js +32 -0
  136. package/dist/es/standards-sdk.es39.js.map +1 -0
  137. package/dist/es/standards-sdk.es4.js +174 -0
  138. package/dist/es/standards-sdk.es4.js.map +1 -0
  139. package/dist/es/standards-sdk.es40.js +32 -0
  140. package/dist/es/standards-sdk.es40.js.map +1 -0
  141. package/dist/es/standards-sdk.es41.js +24 -0
  142. package/dist/es/standards-sdk.es41.js.map +1 -0
  143. package/dist/es/standards-sdk.es42.js +47 -0
  144. package/dist/es/standards-sdk.es42.js.map +1 -0
  145. package/dist/es/standards-sdk.es43.js +21 -0
  146. package/dist/es/standards-sdk.es43.js.map +1 -0
  147. package/dist/es/standards-sdk.es44.js +64 -0
  148. package/dist/es/standards-sdk.es44.js.map +1 -0
  149. package/dist/es/standards-sdk.es45.js +1292 -0
  150. package/dist/es/standards-sdk.es45.js.map +1 -0
  151. package/dist/es/standards-sdk.es46.js +151 -0
  152. package/dist/es/standards-sdk.es46.js.map +1 -0
  153. package/dist/es/standards-sdk.es47.js +94 -0
  154. package/dist/es/standards-sdk.es47.js.map +1 -0
  155. package/dist/es/standards-sdk.es48.js +87 -0
  156. package/dist/es/standards-sdk.es48.js.map +1 -0
  157. package/dist/es/standards-sdk.es49.js +35 -0
  158. package/dist/es/standards-sdk.es49.js.map +1 -0
  159. package/dist/es/standards-sdk.es5.js +1042 -0
  160. package/dist/es/standards-sdk.es5.js.map +1 -0
  161. package/dist/es/standards-sdk.es50.js +9 -0
  162. package/dist/es/standards-sdk.es50.js.map +1 -0
  163. package/dist/es/standards-sdk.es51.js +162 -0
  164. package/dist/es/standards-sdk.es51.js.map +1 -0
  165. package/dist/es/standards-sdk.es52.js +26 -0
  166. package/dist/es/standards-sdk.es52.js.map +1 -0
  167. package/dist/es/standards-sdk.es53.js +796 -0
  168. package/dist/es/standards-sdk.es53.js.map +1 -0
  169. package/dist/es/standards-sdk.es54.js +146 -0
  170. package/dist/es/standards-sdk.es54.js.map +1 -0
  171. package/dist/es/standards-sdk.es55.js +177 -0
  172. package/dist/es/standards-sdk.es55.js.map +1 -0
  173. package/dist/es/standards-sdk.es56.js +422 -0
  174. package/dist/es/standards-sdk.es56.js.map +1 -0
  175. package/dist/es/standards-sdk.es57.js +5 -0
  176. package/dist/es/standards-sdk.es57.js.map +1 -0
  177. package/dist/es/standards-sdk.es58.js +123 -0
  178. package/dist/es/standards-sdk.es58.js.map +1 -0
  179. package/dist/es/standards-sdk.es59.js +24 -0
  180. package/dist/es/standards-sdk.es59.js.map +1 -0
  181. package/dist/es/standards-sdk.es6.js +32 -0
  182. package/dist/es/standards-sdk.es6.js.map +1 -0
  183. package/dist/es/standards-sdk.es60.js +30 -0
  184. package/dist/es/standards-sdk.es60.js.map +1 -0
  185. package/dist/es/standards-sdk.es61.js +29 -0
  186. package/dist/es/standards-sdk.es61.js.map +1 -0
  187. package/dist/es/standards-sdk.es62.js +41 -0
  188. package/dist/es/standards-sdk.es62.js.map +1 -0
  189. package/dist/es/standards-sdk.es63.js +32 -0
  190. package/dist/es/standards-sdk.es63.js.map +1 -0
  191. package/dist/es/standards-sdk.es64.js +365 -0
  192. package/dist/es/standards-sdk.es64.js.map +1 -0
  193. package/dist/es/standards-sdk.es65.js +9 -0
  194. package/dist/es/standards-sdk.es65.js.map +1 -0
  195. package/dist/es/standards-sdk.es66.js +182 -0
  196. package/dist/es/standards-sdk.es66.js.map +1 -0
  197. package/dist/es/standards-sdk.es67.js +84 -0
  198. package/dist/es/standards-sdk.es67.js.map +1 -0
  199. package/dist/es/standards-sdk.es68.js +117 -0
  200. package/dist/es/standards-sdk.es68.js.map +1 -0
  201. package/dist/es/standards-sdk.es69.js +55 -0
  202. package/dist/es/standards-sdk.es69.js.map +1 -0
  203. package/dist/es/standards-sdk.es7.js +124 -0
  204. package/dist/es/standards-sdk.es7.js.map +1 -0
  205. package/dist/es/standards-sdk.es70.js +13 -0
  206. package/dist/es/standards-sdk.es70.js.map +1 -0
  207. package/dist/es/standards-sdk.es71.js +100 -0
  208. package/dist/es/standards-sdk.es71.js.map +1 -0
  209. package/dist/es/standards-sdk.es72.js +7 -0
  210. package/dist/es/standards-sdk.es72.js.map +1 -0
  211. package/dist/es/standards-sdk.es73.js +5 -0
  212. package/dist/es/standards-sdk.es73.js.map +1 -0
  213. package/dist/es/standards-sdk.es74.js +115 -0
  214. package/dist/es/standards-sdk.es74.js.map +1 -0
  215. package/dist/es/standards-sdk.es75.js +77 -0
  216. package/dist/es/standards-sdk.es75.js.map +1 -0
  217. package/dist/es/standards-sdk.es76.js +9 -0
  218. package/dist/es/standards-sdk.es76.js.map +1 -0
  219. package/dist/es/standards-sdk.es77.js +8 -0
  220. package/dist/es/standards-sdk.es77.js.map +1 -0
  221. package/dist/es/standards-sdk.es78.js +224 -0
  222. package/dist/es/standards-sdk.es78.js.map +1 -0
  223. package/dist/es/standards-sdk.es79.js +61 -0
  224. package/dist/es/standards-sdk.es79.js.map +1 -0
  225. package/dist/es/standards-sdk.es8.js +343 -0
  226. package/dist/es/standards-sdk.es8.js.map +1 -0
  227. package/dist/es/standards-sdk.es80.js +72 -0
  228. package/dist/es/standards-sdk.es80.js.map +1 -0
  229. package/dist/es/standards-sdk.es81.js +35 -0
  230. package/dist/es/standards-sdk.es81.js.map +1 -0
  231. package/dist/es/standards-sdk.es82.js +66 -0
  232. package/dist/es/standards-sdk.es82.js.map +1 -0
  233. package/dist/es/standards-sdk.es83.js +53 -0
  234. package/dist/es/standards-sdk.es83.js.map +1 -0
  235. package/dist/es/standards-sdk.es84.js +13 -0
  236. package/dist/es/standards-sdk.es84.js.map +1 -0
  237. package/dist/es/standards-sdk.es85.js +68 -0
  238. package/dist/es/standards-sdk.es85.js.map +1 -0
  239. package/dist/es/standards-sdk.es86.js +9 -0
  240. package/dist/es/standards-sdk.es86.js.map +1 -0
  241. package/dist/es/standards-sdk.es87.js +18 -0
  242. package/dist/es/standards-sdk.es87.js.map +1 -0
  243. package/dist/es/standards-sdk.es88.js +10 -0
  244. package/dist/es/standards-sdk.es88.js.map +1 -0
  245. package/dist/es/standards-sdk.es89.js +48 -0
  246. package/dist/es/standards-sdk.es89.js.map +1 -0
  247. package/dist/es/standards-sdk.es9.js +270 -0
  248. package/dist/es/standards-sdk.es9.js.map +1 -0
  249. package/dist/es/standards-sdk.es90.js +5 -0
  250. package/dist/es/standards-sdk.es90.js.map +1 -0
  251. package/dist/es/standards-sdk.es91.js +139 -0
  252. package/dist/es/standards-sdk.es91.js.map +1 -0
  253. package/dist/es/standards-sdk.es92.js +175 -0
  254. package/dist/es/standards-sdk.es92.js.map +1 -0
  255. package/dist/es/standards-sdk.es93.js +35 -0
  256. package/dist/es/standards-sdk.es93.js.map +1 -0
  257. package/dist/es/standards-sdk.es94.js +18 -0
  258. package/dist/es/standards-sdk.es94.js.map +1 -0
  259. package/dist/es/standards-sdk.es95.js +7 -0
  260. package/dist/es/standards-sdk.es95.js.map +1 -0
  261. package/dist/es/standards-sdk.es96.js +7 -0
  262. package/dist/es/standards-sdk.es96.js.map +1 -0
  263. package/dist/es/standards-sdk.es97.js +16 -0
  264. package/dist/es/standards-sdk.es97.js.map +1 -0
  265. package/dist/es/standards-sdk.es98.js +16 -0
  266. package/dist/es/standards-sdk.es98.js.map +1 -0
  267. package/dist/es/standards-sdk.es99.js +19 -0
  268. package/dist/es/standards-sdk.es99.js.map +1 -0
  269. package/dist/es/utils/index.d.ts +1 -0
  270. package/dist/es/utils/index.d.ts.map +1 -0
  271. package/dist/es/utils/logger.d.ts +1 -0
  272. package/dist/es/utils/logger.d.ts.map +1 -0
  273. package/dist/es/utils/progress-reporter.d.ts +1 -0
  274. package/dist/es/utils/progress-reporter.d.ts.map +1 -0
  275. package/dist/es/utils/sleep.d.ts +1 -0
  276. package/dist/es/utils/sleep.d.ts.map +1 -0
  277. package/dist/es/utils/topic-fee-utils.d.ts +1 -0
  278. package/dist/es/utils/topic-fee-utils.d.ts.map +1 -0
  279. package/dist/umd/hcs-10/agent-builder.d.ts +2 -1
  280. package/dist/umd/hcs-10/agent-builder.d.ts.map +1 -0
  281. package/dist/umd/hcs-10/base-client.d.ts +1 -0
  282. package/dist/umd/hcs-10/base-client.d.ts.map +1 -0
  283. package/dist/umd/hcs-10/browser.d.ts +2 -1
  284. package/dist/umd/hcs-10/browser.d.ts.map +1 -0
  285. package/dist/umd/hcs-10/errors.d.ts +1 -0
  286. package/dist/umd/hcs-10/errors.d.ts.map +1 -0
  287. package/dist/umd/hcs-10/fee-config-builder.d.ts +2 -1
  288. package/dist/umd/hcs-10/fee-config-builder.d.ts.map +1 -0
  289. package/dist/umd/hcs-10/index.d.ts +1 -0
  290. package/dist/umd/hcs-10/index.d.ts.map +1 -0
  291. package/dist/umd/hcs-10/registrations.d.ts +1 -0
  292. package/dist/umd/hcs-10/registrations.d.ts.map +1 -0
  293. package/dist/umd/hcs-10/sdk.d.ts +3 -2
  294. package/dist/umd/hcs-10/sdk.d.ts.map +1 -0
  295. package/dist/umd/hcs-10/types.d.ts +176 -0
  296. package/dist/umd/hcs-10/types.d.ts.map +1 -0
  297. package/dist/umd/hcs-11/index.d.ts +1 -0
  298. package/dist/umd/hcs-11/index.d.ts.map +1 -0
  299. package/dist/umd/hcs-3/index.d.ts +1 -0
  300. package/dist/umd/hcs-3/index.d.ts.map +1 -0
  301. package/dist/umd/hcs-3/src/index.d.ts +1 -0
  302. package/dist/umd/hcs-3/src/index.d.ts.map +1 -0
  303. package/dist/umd/hcs-7/evm-bridge.d.ts +1 -0
  304. package/dist/umd/hcs-7/evm-bridge.d.ts.map +1 -0
  305. package/dist/umd/hcs-7/index.d.ts +1 -0
  306. package/dist/umd/hcs-7/index.d.ts.map +1 -0
  307. package/dist/umd/hcs-7/redis-cache.d.ts +1 -0
  308. package/dist/umd/hcs-7/redis-cache.d.ts.map +1 -0
  309. package/dist/umd/hcs-7/wasm-bridge.d.ts +1 -0
  310. package/dist/umd/hcs-7/wasm-bridge.d.ts.map +1 -0
  311. package/dist/umd/index.d.ts +1 -0
  312. package/dist/umd/index.d.ts.map +1 -0
  313. package/dist/umd/inscribe/index.d.ts +1 -0
  314. package/dist/umd/inscribe/index.d.ts.map +1 -0
  315. package/dist/umd/inscribe/inscriber.d.ts +1 -0
  316. package/dist/umd/inscribe/inscriber.d.ts.map +1 -0
  317. package/dist/umd/inscribe/types.d.ts +1 -0
  318. package/dist/umd/inscribe/types.d.ts.map +1 -0
  319. package/dist/umd/services/index.d.ts +1 -0
  320. package/dist/umd/services/index.d.ts.map +1 -0
  321. package/dist/umd/services/mirror-node.d.ts +1 -0
  322. package/dist/umd/services/mirror-node.d.ts.map +1 -0
  323. package/dist/umd/services/types.d.ts +1 -0
  324. package/dist/umd/services/types.d.ts.map +1 -0
  325. package/dist/umd/standards-sdk.umd.js +1 -1
  326. package/dist/umd/standards-sdk.umd.js.map +1 -1
  327. package/dist/umd/utils/index.d.ts +1 -0
  328. package/dist/umd/utils/index.d.ts.map +1 -0
  329. package/dist/umd/utils/logger.d.ts +1 -0
  330. package/dist/umd/utils/logger.d.ts.map +1 -0
  331. package/dist/umd/utils/progress-reporter.d.ts +1 -0
  332. package/dist/umd/utils/progress-reporter.d.ts.map +1 -0
  333. package/dist/umd/utils/sleep.d.ts +1 -0
  334. package/dist/umd/utils/sleep.d.ts.map +1 -0
  335. package/dist/umd/utils/topic-fee-utils.d.ts +1 -0
  336. package/dist/umd/utils/topic-fee-utils.d.ts.map +1 -0
  337. package/package.json +5 -9
@@ -0,0 +1,1058 @@
1
+ import { KeyList, TopicCreateTransaction, Transaction, TopicMessageSubmitTransaction } from "@hashgraph/sdk";
2
+ import { Logger } from "./standards-sdk.es13.js";
3
+ import { InscriptionSDK } from "./standards-sdk.es22.js";
4
+ import { HCS10BaseClient } from "./standards-sdk.es8.js";
5
+ import { m as mimeTypesExports } from "./standards-sdk.es19.js";
6
+ import { HCS11Client } from "./standards-sdk.es12.js";
7
+ import { ProgressReporter } from "./standards-sdk.es15.js";
8
+ const isBrowser = typeof window !== "undefined";
9
+ class BrowserHCSClient extends HCS10BaseClient {
10
+ constructor(config) {
11
+ super({
12
+ network: config.network,
13
+ logLevel: config.logLevel,
14
+ prettyPrint: config.prettyPrint
15
+ });
16
+ this.hcs11Client = null;
17
+ this.hwc = config.hwc;
18
+ this.guardedRegistryBaseUrl = config.guardedRegistryBaseUrl || "https://moonscape.tech";
19
+ this.logger = Logger.getInstance({
20
+ level: config.logLevel || "info",
21
+ module: "HCS-Browser",
22
+ prettyPrint: config.prettyPrint
23
+ });
24
+ if (isBrowser) {
25
+ try {
26
+ const { accountId, signer } = this.getAccountAndSigner();
27
+ this.hcs11Client = new HCS11Client({
28
+ network: config.network,
29
+ auth: {
30
+ operatorId: accountId,
31
+ signer
32
+ },
33
+ logLevel: config.logLevel
34
+ });
35
+ } catch (err) {
36
+ this.logger.warn(`Failed to initialize HCS11Client: ${err}`);
37
+ }
38
+ } else {
39
+ this.logger.error(
40
+ "BrowserHCSClient initialized in server environment - browser-specific features will not be available. Use HCS10Client instead."
41
+ );
42
+ }
43
+ }
44
+ async sendMessage(connectionTopicId, operatorId, data, memo) {
45
+ this.logger.info("Sending message");
46
+ const payload = {
47
+ p: "hcs-10",
48
+ op: "message",
49
+ operator_id: operatorId,
50
+ data,
51
+ m: memo
52
+ };
53
+ const payloadString = JSON.stringify(payload);
54
+ const isLargePayload = Buffer.from(payloadString).length > 1e3;
55
+ if (isLargePayload) {
56
+ this.logger.info(
57
+ "Message payload exceeds 1000 bytes, storing via inscription"
58
+ );
59
+ try {
60
+ const contentBuffer = Buffer.from(data);
61
+ const fileName = `message-${Date.now()}.json`;
62
+ const inscriptionResult = await this.inscribeFile(
63
+ contentBuffer,
64
+ fileName
65
+ );
66
+ if (inscriptionResult?.topic_id) {
67
+ payload.data = `hcs://1/${inscriptionResult.topic_id}`;
68
+ this.logger.info(
69
+ `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`
70
+ );
71
+ } else {
72
+ throw new Error("Failed to inscribe large message content");
73
+ }
74
+ } catch (error) {
75
+ this.logger.error("Error inscribing large message:", error);
76
+ throw new Error(
77
+ `Failed to handle large message: ${error instanceof Error ? error.message : "Unknown error"}`
78
+ );
79
+ }
80
+ }
81
+ await this.submitPayload(connectionTopicId, payload);
82
+ }
83
+ async submitConnectionRequest(inboundTopicId, requestingAccountId, operatorId, memo) {
84
+ this.logger.info("Submitting connection request");
85
+ const connectionRequestMessage = {
86
+ p: "hcs-10",
87
+ op: "connection_request",
88
+ requesting_account_id: requestingAccountId,
89
+ operator_id: operatorId,
90
+ m: memo
91
+ };
92
+ const response = await this.submitPayload(
93
+ inboundTopicId,
94
+ connectionRequestMessage
95
+ );
96
+ this.logger.info(
97
+ `Submitted connection request to topic ID: ${inboundTopicId}`
98
+ );
99
+ const outboundTopic = await this.retrieveOutboundConnectTopic(
100
+ requestingAccountId
101
+ );
102
+ if (!outboundTopic?.outboundTopic) {
103
+ this.logger.error(
104
+ `Failed to retrieve outbound topic for account ID: ${requestingAccountId}`
105
+ );
106
+ throw new Error(
107
+ `Failed to retrieve outbound topic for account ID: ${requestingAccountId}`
108
+ );
109
+ }
110
+ this.logger.info(
111
+ `Retrieved outbound topic ID: ${outboundTopic.outboundTopic} for account ID: ${requestingAccountId}`
112
+ );
113
+ const responseSequenceNumber = response?.result?.topicSequenceNumber?.toNumber();
114
+ if (!responseSequenceNumber) {
115
+ throw new Error("Failed to get response sequence number");
116
+ }
117
+ await this.submitPayload(outboundTopic.outboundTopic, {
118
+ ...connectionRequestMessage,
119
+ outbound_topic_id: inboundTopicId,
120
+ connection_request_id: responseSequenceNumber
121
+ });
122
+ return response.result;
123
+ }
124
+ async recordOutboundConnectionConfirmation({
125
+ outboundTopicId,
126
+ connectionRequestId,
127
+ confirmedRequestId,
128
+ connectionTopicId,
129
+ operatorId,
130
+ memo
131
+ }) {
132
+ const payload = {
133
+ p: "hcs-10",
134
+ op: "connection_created",
135
+ connection_topic_id: connectionTopicId,
136
+ outbound_topic_id: outboundTopicId,
137
+ confirmed_request_id: confirmedRequestId,
138
+ connection_request_id: connectionRequestId,
139
+ operator_id: operatorId,
140
+ m: memo
141
+ };
142
+ return await this.submitPayload(outboundTopicId, payload);
143
+ }
144
+ async getPublicKey(accountId) {
145
+ return await this.mirrorNode.getPublicKey(accountId);
146
+ }
147
+ async handleConnectionRequest(inboundTopicId, requestingAccountId, connectionId, connectionMemo = "Connection accepted. Looking forward to collaborating!") {
148
+ this.logger.info("Handling connection request");
149
+ const userAccountId = this.hwc.getAccountInfo().accountId;
150
+ if (!userAccountId) {
151
+ throw new Error("Failed to retrieve user account ID");
152
+ }
153
+ const requesterKey = await this.mirrorNode.getPublicKey(
154
+ requestingAccountId
155
+ );
156
+ const accountKey = await this.mirrorNode.getPublicKey(userAccountId);
157
+ if (!accountKey) {
158
+ throw new Error("Failed to retrieve public key");
159
+ }
160
+ const thresholdKey = new KeyList([accountKey, requesterKey], 1);
161
+ const memo = `hcs-10:${inboundTopicId}:${connectionId}`;
162
+ const transaction = new TopicCreateTransaction().setTopicMemo(memo).setAdminKey(thresholdKey).setSubmitKey(thresholdKey);
163
+ this.logger.debug("Executing topic creation transaction");
164
+ const receipt = await this.hwc.executeTransactionWithErrorHandling(
165
+ transaction,
166
+ false
167
+ );
168
+ if (receipt.error) {
169
+ this.logger.error(receipt.error);
170
+ throw new Error(receipt.error);
171
+ }
172
+ const result = receipt.result;
173
+ if (!result?.topicId) {
174
+ this.logger.error("Failed to create topic: topicId is null");
175
+ throw new Error("Failed to create topic: topicId is null");
176
+ }
177
+ const connectionTopicId = result.topicId.toString();
178
+ const operatorId = `${inboundTopicId}@${userAccountId}`;
179
+ const confirmedConnectionSequenceNumber = await this.confirmConnection(
180
+ inboundTopicId,
181
+ connectionTopicId,
182
+ requestingAccountId,
183
+ connectionId,
184
+ operatorId,
185
+ connectionMemo
186
+ );
187
+ return {
188
+ connectionTopicId,
189
+ confirmedConnectionSequenceNumber,
190
+ operatorId
191
+ };
192
+ }
193
+ async confirmConnection(inboundTopicId, connectionTopicId, connectedAccountId, connectionId, operatorId, memo) {
194
+ this.logger.info("Confirming connection");
195
+ const payload = {
196
+ p: "hcs-10",
197
+ op: "connection_created",
198
+ connection_topic_id: connectionTopicId,
199
+ connected_account_id: connectedAccountId,
200
+ operator_id: operatorId,
201
+ connection_id: connectionId,
202
+ m: memo
203
+ };
204
+ const transactionResponse = await this.submitPayload(
205
+ inboundTopicId,
206
+ payload
207
+ );
208
+ if (!transactionResponse?.result?.topicSequenceNumber) {
209
+ this.logger.error(
210
+ "Failed to confirm connection: sequence number is null"
211
+ );
212
+ throw new Error("Failed to confirm connection: sequence number is null");
213
+ }
214
+ return transactionResponse.result.topicSequenceNumber.toNumber();
215
+ }
216
+ async submitMessage(topicId, content, metadata = {}, memo = "") {
217
+ this.logger.info("Submitting message");
218
+ const payload = {
219
+ p: "hcs-10",
220
+ op: "message",
221
+ data: {
222
+ content,
223
+ metadata
224
+ },
225
+ m: memo
226
+ };
227
+ return await this.submitPayload(topicId, payload);
228
+ }
229
+ /**
230
+ * Creates an agent directly, but does not register.
231
+ * We highly recommend calling createAndRegisterAgent instead.
232
+ *
233
+ * @param pfpBuffer - The buffer containing the PFP image.
234
+ * @param pfpFileName - The name of the file containing the PFP image.
235
+ * @param agentName - The name of the agent.
236
+ * @param agentDescription - The description of the agent.
237
+ * @param capabilities - The capabilities of the agent.
238
+ * @param metadata - The metadata of the agent.
239
+ * @param existingPfpTopicId - The topic ID of the existing PFP.
240
+ * @param options - Optional configuration options.
241
+ * @returns A promise that resolves to the agent creation state.
242
+ */
243
+ async createAgent(pfpBuffer, pfpFileName, agentName, agentDescription, capabilities, metadata, existingPfpTopicId, options) {
244
+ try {
245
+ const progressCallback = options?.progressCallback;
246
+ const progressReporter = new ProgressReporter({
247
+ module: "AgentCreate",
248
+ logger: this.logger,
249
+ callback: progressCallback
250
+ });
251
+ let state = options?.existingState || {
252
+ currentStage: "init",
253
+ completedPercentage: 0,
254
+ createdResources: []
255
+ };
256
+ if (!state.outboundTopicId) {
257
+ state.currentStage = "topics";
258
+ progressReporter.preparing("Creating agent outbound topic", 0, {
259
+ state
260
+ });
261
+ const outboundResult = await this.createTopic(
262
+ "hcs-10:0:60:1",
263
+ true,
264
+ true
265
+ );
266
+ if (!outboundResult.success || !outboundResult.topicId) {
267
+ state.error = outboundResult.error || "Failed to create outbound topic";
268
+ progressReporter.failed(
269
+ `Failed to create outbound topic: ${state.error}`,
270
+ { state }
271
+ );
272
+ return {
273
+ outboundTopicId: "",
274
+ inboundTopicId: "",
275
+ pfpTopicId: "",
276
+ profileTopicId: "",
277
+ success: false,
278
+ error: state.error,
279
+ state
280
+ };
281
+ }
282
+ state.outboundTopicId = outboundResult.topicId;
283
+ if (state.createdResources) {
284
+ state.createdResources.push(`outbound:${state.outboundTopicId}`);
285
+ }
286
+ progressReporter.preparing("Outbound topic created", 20, { state });
287
+ } else {
288
+ progressReporter.preparing("Using existing outbound topic", 20, {
289
+ state
290
+ });
291
+ }
292
+ const accountId = this.hwc.getAccountInfo().accountId;
293
+ if (!accountId) {
294
+ throw new Error("Failed to retrieve user account ID");
295
+ }
296
+ if (!state.inboundTopicId) {
297
+ const memo = `hcs-10:0:60:0:${accountId}`;
298
+ const inboundResult = await this.createTopic(memo, true, true);
299
+ if (!inboundResult.success || !inboundResult.topicId) {
300
+ state.error = inboundResult.error || "Failed to create inbound topic";
301
+ progressReporter.failed(
302
+ `Failed to create inbound topic: ${state.error}`,
303
+ { state }
304
+ );
305
+ return {
306
+ outboundTopicId: state.outboundTopicId || "",
307
+ inboundTopicId: "",
308
+ pfpTopicId: "",
309
+ profileTopicId: "",
310
+ success: false,
311
+ error: state.error,
312
+ state
313
+ };
314
+ }
315
+ state.inboundTopicId = inboundResult.topicId;
316
+ if (state.createdResources) {
317
+ state.createdResources.push(`inbound:${state.inboundTopicId}`);
318
+ }
319
+ progressReporter.preparing("Inbound topic created", 40, { state });
320
+ } else {
321
+ progressReporter.preparing("Using existing inbound topic", 40, {
322
+ state
323
+ });
324
+ }
325
+ if (!state.pfpTopicId && !existingPfpTopicId) {
326
+ state.currentStage = "pfp";
327
+ progressReporter.preparing("Creating agent profile picture", 40, {
328
+ state
329
+ });
330
+ const pfpProgress = progressReporter.createSubProgress({
331
+ minPercent: 40,
332
+ maxPercent: 60,
333
+ logPrefix: "PFP"
334
+ });
335
+ const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName, {
336
+ progressCallback: (data) => {
337
+ pfpProgress.report({
338
+ stage: data.stage,
339
+ message: data.message,
340
+ progressPercent: data.progressPercent || 0,
341
+ details: { ...data.details, state }
342
+ });
343
+ }
344
+ });
345
+ if (!pfpResult.success) {
346
+ state.error = pfpResult.error || "Failed to inscribe profile picture";
347
+ progressReporter.failed(
348
+ `Failed to inscribe profile picture: ${state.error}`,
349
+ { state }
350
+ );
351
+ return {
352
+ outboundTopicId: state.outboundTopicId || "",
353
+ inboundTopicId: state.inboundTopicId || "",
354
+ pfpTopicId: "",
355
+ profileTopicId: "",
356
+ success: false,
357
+ error: state.error,
358
+ state
359
+ };
360
+ }
361
+ state.pfpTopicId = pfpResult.pfpTopicId;
362
+ state.completedPercentage = 60;
363
+ if (state.createdResources) {
364
+ state.createdResources.push(`pfp:${state.pfpTopicId}`);
365
+ }
366
+ progressReporter.preparing("Profile picture created", 60, { state });
367
+ } else {
368
+ state.pfpTopicId = existingPfpTopicId || state.pfpTopicId;
369
+ progressReporter.preparing(
370
+ `Using existing profile picture: ${state.pfpTopicId}`,
371
+ 60,
372
+ {
373
+ state
374
+ }
375
+ );
376
+ }
377
+ if (!state.profileTopicId) {
378
+ state.currentStage = "profile";
379
+ progressReporter.preparing("Creating agent profile", 60, { state });
380
+ const profileProgress = progressReporter.createSubProgress({
381
+ minPercent: 60,
382
+ maxPercent: 100,
383
+ logPrefix: "Profile"
384
+ });
385
+ if (!this.hcs11Client) {
386
+ state.error = "HCS11Client is not available in this environment";
387
+ progressReporter.failed(state.error, { state });
388
+ return {
389
+ outboundTopicId: state.outboundTopicId || "",
390
+ inboundTopicId: state.inboundTopicId || "",
391
+ pfpTopicId: state.pfpTopicId || "",
392
+ profileTopicId: "",
393
+ success: false,
394
+ error: state.error,
395
+ state
396
+ };
397
+ }
398
+ const storeProfileResult = await this.storeHCS11Profile(
399
+ agentName,
400
+ agentDescription,
401
+ state.inboundTopicId,
402
+ state.outboundTopicId,
403
+ capabilities,
404
+ metadata,
405
+ void 0,
406
+ void 0,
407
+ state.pfpTopicId,
408
+ {
409
+ progressCallback: (data) => {
410
+ profileProgress.report({
411
+ stage: data.stage,
412
+ message: data.message,
413
+ progressPercent: data.progressPercent || 0,
414
+ details: { ...data.details, state }
415
+ });
416
+ }
417
+ }
418
+ );
419
+ if (!storeProfileResult.success) {
420
+ state.error = storeProfileResult.error || "Failed to store agent profile";
421
+ progressReporter.failed(
422
+ `Failed to store agent profile: ${state.error}`,
423
+ { state }
424
+ );
425
+ return {
426
+ outboundTopicId: state.outboundTopicId || "",
427
+ inboundTopicId: state.inboundTopicId || "",
428
+ pfpTopicId: state.pfpTopicId || "",
429
+ profileTopicId: "",
430
+ success: false,
431
+ error: state.error,
432
+ state
433
+ };
434
+ }
435
+ state.profileTopicId = storeProfileResult.profileTopicId;
436
+ if (state.createdResources) {
437
+ state.createdResources.push(`profile:${state.profileTopicId}`);
438
+ }
439
+ state.currentStage = "complete";
440
+ state.completedPercentage = 100;
441
+ } else {
442
+ progressReporter.preparing("Using existing agent profile", 100, {
443
+ state
444
+ });
445
+ if (state.currentStage !== "complete") {
446
+ state.currentStage = "complete";
447
+ state.completedPercentage = 100;
448
+ }
449
+ }
450
+ progressReporter.completed("Agent successfully created", {
451
+ inboundTopicId: state.inboundTopicId,
452
+ outboundTopicId: state.outboundTopicId,
453
+ pfpTopicId: state.pfpTopicId,
454
+ profileTopicId: state.profileTopicId,
455
+ state
456
+ });
457
+ return {
458
+ outboundTopicId: state.outboundTopicId || "",
459
+ inboundTopicId: state.inboundTopicId || "",
460
+ pfpTopicId: state.pfpTopicId || "",
461
+ profileTopicId: state.profileTopicId || "",
462
+ success: true,
463
+ state
464
+ };
465
+ } catch (error) {
466
+ this.logger.error(`Error creating agent: ${error.message}`);
467
+ return {
468
+ outboundTopicId: "",
469
+ inboundTopicId: "",
470
+ pfpTopicId: "",
471
+ profileTopicId: "",
472
+ success: false,
473
+ error: `Error creating agent: ${error.message}`,
474
+ state: {
475
+ currentStage: "init",
476
+ completedPercentage: 0,
477
+ error: error.message
478
+ }
479
+ };
480
+ }
481
+ }
482
+ initializeRegistrationState(inboundTopicId, existingState) {
483
+ const state = existingState || {
484
+ inboundTopicId,
485
+ currentStage: "registration",
486
+ completedPercentage: 0,
487
+ createdResources: []
488
+ };
489
+ if (state.currentStage !== "registration" && state.currentStage !== "complete") {
490
+ state.currentStage = "registration";
491
+ }
492
+ return state;
493
+ }
494
+ updateStateForCompletedRegistration(state, inboundTopicId) {
495
+ state.currentStage = "complete";
496
+ state.completedPercentage = 100;
497
+ if (state.createdResources) {
498
+ state.createdResources.push(`registration:${inboundTopicId}`);
499
+ }
500
+ }
501
+ async registerAgentWithGuardedRegistry(accountId, network = this.network, options) {
502
+ try {
503
+ this.logger.info("Registering agent with guarded registry");
504
+ const agentProfile = await this.retrieveProfile(accountId);
505
+ const inboundTopicId = agentProfile.topicInfo.inboundTopic;
506
+ const state = this.initializeRegistrationState(
507
+ inboundTopicId,
508
+ options?.existingState
509
+ );
510
+ const progressReporter = new ProgressReporter({
511
+ module: "AgentRegistration",
512
+ logger: this.logger,
513
+ callback: options?.progressCallback
514
+ });
515
+ progressReporter.preparing("Preparing agent registration", 10, {
516
+ inboundTopicId,
517
+ accountId
518
+ });
519
+ const registrationResult = await this.executeRegistration(
520
+ accountId,
521
+ network,
522
+ this.guardedRegistryBaseUrl,
523
+ this.logger
524
+ );
525
+ if (!registrationResult.success) {
526
+ return {
527
+ ...registrationResult,
528
+ state
529
+ };
530
+ }
531
+ progressReporter.submitting("Submitting registration to registry", 30, {
532
+ transactionId: registrationResult.transactionId
533
+ });
534
+ if (registrationResult.transaction) {
535
+ const transaction = Transaction.fromBytes(
536
+ Buffer.from(registrationResult.transaction, "base64")
537
+ );
538
+ this.logger.info(`Processing registration transaction`);
539
+ const txResult = await this.hwc.executeTransactionWithErrorHandling(
540
+ transaction,
541
+ true
542
+ );
543
+ if (txResult.error) {
544
+ return {
545
+ ...registrationResult,
546
+ error: txResult.error,
547
+ success: false,
548
+ state
549
+ };
550
+ }
551
+ this.logger.info(`Successfully processed registration transaction`);
552
+ }
553
+ progressReporter.confirming("Confirming registration transaction", 60, {
554
+ accountId,
555
+ inboundTopicId,
556
+ transactionId: registrationResult.transactionId
557
+ });
558
+ const maxAttempts = options?.maxAttempts ?? 60;
559
+ const delayMs = options?.delayMs ?? 2e3;
560
+ const confirmed = await this.waitForRegistrationConfirmation(
561
+ registrationResult.transactionId,
562
+ network,
563
+ this.guardedRegistryBaseUrl,
564
+ maxAttempts,
565
+ delayMs,
566
+ this.logger
567
+ );
568
+ this.updateStateForCompletedRegistration(state, inboundTopicId);
569
+ progressReporter.completed("Agent registration complete", {
570
+ transactionId: registrationResult.transactionId,
571
+ inboundTopicId,
572
+ state,
573
+ confirmed
574
+ });
575
+ return {
576
+ ...registrationResult,
577
+ confirmed,
578
+ state
579
+ };
580
+ } catch (error) {
581
+ this.logger.error(`Registration error: ${error.message}`);
582
+ return {
583
+ error: `Error during registration: ${error.message}`,
584
+ success: false,
585
+ state: {
586
+ currentStage: "registration",
587
+ completedPercentage: 0,
588
+ error: error.message
589
+ }
590
+ };
591
+ }
592
+ }
593
+ async createAndRegisterAgent(builder, options) {
594
+ try {
595
+ const config = builder.build();
596
+ const progressCallback = options?.progressCallback;
597
+ const progressReporter = new ProgressReporter({
598
+ module: "AgentCreateRegister",
599
+ logger: this.logger,
600
+ callback: progressCallback
601
+ });
602
+ let state = options?.existingState || {
603
+ currentStage: "init",
604
+ completedPercentage: 0,
605
+ createdResources: []
606
+ };
607
+ state.agentMetadata = config.metadata;
608
+ progressReporter.preparing("Starting agent creation process", 0, {
609
+ state
610
+ });
611
+ if (state.currentStage !== "complete" || !state.inboundTopicId || !state.outboundTopicId || !state.profileTopicId) {
612
+ const agentResult = await this.createAgent(
613
+ config.pfpBuffer || Buffer.from([]),
614
+ config.pfpFileName || "default.png",
615
+ config.name,
616
+ config.description,
617
+ config.capabilities,
618
+ config.metadata,
619
+ config.existingPfpTopicId,
620
+ {
621
+ progressCallback: (progress) => {
622
+ const adjustedPercent = (progress.progressPercent || 0) * 0.3;
623
+ progressReporter.report({
624
+ stage: progress.stage,
625
+ message: progress.message,
626
+ progressPercent: adjustedPercent,
627
+ details: {
628
+ ...progress.details,
629
+ state: progress.details?.state || state
630
+ }
631
+ });
632
+ },
633
+ existingState: state
634
+ }
635
+ );
636
+ if (!agentResult.success) {
637
+ throw new Error(
638
+ agentResult.error || "Failed to create agent with topics"
639
+ );
640
+ }
641
+ state = agentResult.state;
642
+ state.agentMetadata = config.metadata;
643
+ }
644
+ progressReporter.preparing(
645
+ `Agent creation status: ${state.currentStage}, ${state.completedPercentage}%`,
646
+ 30,
647
+ { state }
648
+ );
649
+ const { accountId } = this.getAccountAndSigner();
650
+ if (state.currentStage !== "complete" || !state.createdResources?.includes(
651
+ `registration:${state.inboundTopicId}`
652
+ )) {
653
+ if (options?.baseUrl) {
654
+ this.guardedRegistryBaseUrl = options.baseUrl;
655
+ }
656
+ const registrationResult = await this.registerAgentWithGuardedRegistry(
657
+ accountId,
658
+ config.network,
659
+ {
660
+ progressCallback: (progress) => {
661
+ const adjustedPercent = 30 + (progress.progressPercent || 0) * 0.7;
662
+ progressReporter.report({
663
+ stage: progress.stage,
664
+ message: progress.message,
665
+ progressPercent: adjustedPercent,
666
+ details: {
667
+ ...progress.details,
668
+ state: progress.details?.state || state
669
+ }
670
+ });
671
+ },
672
+ maxAttempts: options?.maxAttempts,
673
+ delayMs: options?.delayMs,
674
+ existingState: state
675
+ }
676
+ );
677
+ if (!registrationResult.success) {
678
+ throw new Error(
679
+ registrationResult.error || "Failed to register agent with registry"
680
+ );
681
+ }
682
+ state = registrationResult.state;
683
+ }
684
+ progressReporter.completed("Agent creation and registration complete", {
685
+ state
686
+ });
687
+ return {
688
+ success: true,
689
+ state,
690
+ metadata: {
691
+ accountId,
692
+ operatorId: `${state.inboundTopicId}@${accountId}`,
693
+ inboundTopicId: state.inboundTopicId,
694
+ outboundTopicId: state.outboundTopicId,
695
+ profileTopicId: state.profileTopicId,
696
+ pfpTopicId: state.pfpTopicId,
697
+ privateKey: null,
698
+ ...state.agentMetadata
699
+ }
700
+ };
701
+ } catch (error) {
702
+ throw new Error(`Failed to create and register agent: ${error.message}`);
703
+ }
704
+ }
705
+ async storeHCS11Profile(agentName, agentDescription, inboundTopicId, outboundTopicId, capabilities = [], metadata = {}, pfpBuffer, pfpFileName, existingPfpTopicId, options) {
706
+ try {
707
+ const progressCallback = options?.progressCallback;
708
+ const progressReporter = new ProgressReporter({
709
+ module: "StoreHCS11Profile",
710
+ logger: this.logger,
711
+ callback: progressCallback
712
+ });
713
+ progressReporter.preparing("Preparing agent profile data", 0);
714
+ let pfpTopicId = existingPfpTopicId;
715
+ if (!pfpTopicId && pfpBuffer && pfpFileName) {
716
+ const pfpProgress = progressReporter.createSubProgress({
717
+ minPercent: 0,
718
+ maxPercent: 60,
719
+ logPrefix: "PFP"
720
+ });
721
+ const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName, {
722
+ progressCallback: (data) => {
723
+ pfpProgress.report({
724
+ stage: data.stage,
725
+ message: data.message,
726
+ progressPercent: data.progressPercent || 0,
727
+ details: data.details
728
+ });
729
+ }
730
+ });
731
+ if (!pfpResult.success) {
732
+ progressReporter.failed(
733
+ "Failed to inscribe profile picture, continuing without PFP"
734
+ );
735
+ } else {
736
+ pfpTopicId = pfpResult.pfpTopicId;
737
+ }
738
+ } else if (existingPfpTopicId) {
739
+ progressReporter.preparing(
740
+ `Using existing profile picture: ${existingPfpTopicId}`,
741
+ 30
742
+ );
743
+ } else {
744
+ progressReporter.preparing("No profile picture provided", 30);
745
+ }
746
+ const agentType = this.hcs11Client?.getAgentTypeFromMetadata({
747
+ type: metadata.type || "autonomous"
748
+ });
749
+ progressReporter.preparing("Building agent profile", 65);
750
+ const formattedSocials = [];
751
+ if (metadata.socials) {
752
+ if (metadata.socials.twitter) {
753
+ formattedSocials.push({
754
+ platform: "twitter",
755
+ handle: metadata.socials.twitter
756
+ });
757
+ }
758
+ if (metadata.socials.discord) {
759
+ formattedSocials.push({
760
+ platform: "discord",
761
+ handle: metadata.socials.discord
762
+ });
763
+ }
764
+ if (metadata.socials.github) {
765
+ formattedSocials.push({
766
+ platform: "github",
767
+ handle: metadata.socials.github
768
+ });
769
+ }
770
+ if (metadata.socials.website) {
771
+ formattedSocials.push({
772
+ platform: "website",
773
+ handle: metadata.socials.website
774
+ });
775
+ }
776
+ if (metadata.socials.x) {
777
+ formattedSocials.push({
778
+ platform: "twitter",
779
+ handle: metadata.socials.x
780
+ });
781
+ }
782
+ if (metadata.socials.linkedin) {
783
+ formattedSocials.push({
784
+ platform: "linkedin",
785
+ handle: metadata.socials.linkedin
786
+ });
787
+ }
788
+ if (metadata.socials.youtube) {
789
+ formattedSocials.push({
790
+ platform: "youtube",
791
+ handle: metadata.socials.youtube
792
+ });
793
+ }
794
+ if (metadata.socials.telegram) {
795
+ formattedSocials.push({
796
+ platform: "telegram",
797
+ handle: metadata.socials.telegram
798
+ });
799
+ }
800
+ }
801
+ if (!this.hcs11Client) {
802
+ progressReporter.failed(
803
+ "HCS11Client is not available in this environment"
804
+ );
805
+ return {
806
+ profileTopicId: "",
807
+ success: false,
808
+ error: "HCS11Client is not available in this environment",
809
+ transactionId: ""
810
+ };
811
+ }
812
+ const profile = this.hcs11Client.createAIAgentProfile(
813
+ agentName,
814
+ agentType,
815
+ capabilities,
816
+ metadata.model || "unknown",
817
+ {
818
+ alias: agentName.toLowerCase().replace(/\s+/g, "_"),
819
+ bio: agentDescription,
820
+ profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : void 0,
821
+ socials: formattedSocials.length > 0 ? formattedSocials : void 0,
822
+ properties: {
823
+ description: agentDescription,
824
+ version: metadata.version || "1.0.0",
825
+ creator: metadata.creator || "Unknown",
826
+ supported_languages: metadata.supported_languages || ["en"],
827
+ permissions: metadata.permissions || [],
828
+ model_details: metadata.model_details,
829
+ training: metadata.training,
830
+ capabilities_description: metadata.capabilities_description,
831
+ ...metadata
832
+ },
833
+ inboundTopicId,
834
+ outboundTopicId,
835
+ creator: metadata.creator
836
+ }
837
+ );
838
+ const profileProgress = progressReporter.createSubProgress({
839
+ minPercent: 65,
840
+ maxPercent: 100,
841
+ logPrefix: "Profile"
842
+ });
843
+ const profileResult = await this.hcs11Client.createAndInscribeProfile(
844
+ profile,
845
+ true,
846
+ {
847
+ progressCallback: (profileData) => {
848
+ profileProgress.report({
849
+ stage: profileData.stage,
850
+ message: profileData.message,
851
+ progressPercent: profileData.progressPercent || 0,
852
+ details: profileData.details
853
+ });
854
+ }
855
+ }
856
+ );
857
+ if (!profileResult.success) {
858
+ progressReporter.failed("Failed to inscribe profile");
859
+ return {
860
+ profileTopicId: "",
861
+ success: false,
862
+ error: profileResult.error || "Failed to inscribe profile",
863
+ transactionId: profileResult.transactionId || ""
864
+ };
865
+ }
866
+ progressReporter.completed("Profile stored successfully", {
867
+ profileTopicId: profileResult.profileTopicId
868
+ });
869
+ return {
870
+ profileTopicId: profileResult.profileTopicId,
871
+ pfpTopicId,
872
+ success: true,
873
+ transactionId: profileResult.transactionId || ""
874
+ };
875
+ } catch (error) {
876
+ this.logger.error(`Error storing HCS11 profile: ${error.message}`);
877
+ return {
878
+ profileTopicId: "",
879
+ success: false,
880
+ error: error.message,
881
+ transactionId: ""
882
+ };
883
+ }
884
+ }
885
+ async createTopic(memo, adminKey, submitKey) {
886
+ this.logger.info("Creating topic");
887
+ const { accountId, signer } = this.getAccountAndSigner();
888
+ const transaction = new TopicCreateTransaction().setTopicMemo(memo);
889
+ const publicKey = await this.mirrorNode.getPublicKey(accountId);
890
+ if (adminKey && publicKey) {
891
+ transaction.setAdminKey(publicKey);
892
+ transaction.setAutoRenewAccountId(accountId);
893
+ }
894
+ if (submitKey && publicKey) {
895
+ transaction.setSubmitKey(publicKey);
896
+ }
897
+ const transactionResponse = await this.hwc.executeTransactionWithErrorHandling(
898
+ transaction,
899
+ false
900
+ );
901
+ const error = transactionResponse.error;
902
+ if (error) {
903
+ this.logger.error(error);
904
+ return {
905
+ success: false,
906
+ error
907
+ };
908
+ }
909
+ const result = transactionResponse.result;
910
+ if (!result?.topicId) {
911
+ this.logger.error("Failed to create topic: topicId is null");
912
+ return {
913
+ success: false,
914
+ error: "Failed to create topic: topicId is null"
915
+ };
916
+ }
917
+ return {
918
+ success: true,
919
+ topicId: result.topicId.toString()
920
+ };
921
+ }
922
+ async submitPayload(topicId, payload) {
923
+ this.logger.debug("Submitting payload");
924
+ const transaction = new TopicMessageSubmitTransaction().setTopicId(topicId).setMessage(JSON.stringify(payload));
925
+ return await this.hwc.executeTransactionWithErrorHandling(
926
+ transaction,
927
+ false
928
+ );
929
+ }
930
+ async inscribeFile(buffer, fileName) {
931
+ const { accountId, signer } = this.getAccountAndSigner();
932
+ const mimeType = mimeTypesExports.lookup(fileName) || "application/octet-stream";
933
+ const sdk = await InscriptionSDK.createWithAuth({
934
+ type: "client",
935
+ accountId,
936
+ signer,
937
+ network: this.network
938
+ });
939
+ const result = await sdk.inscribe(
940
+ {
941
+ file: {
942
+ type: "base64",
943
+ base64: buffer.toString("base64"),
944
+ fileName,
945
+ mimeType
946
+ },
947
+ holderId: accountId.toString(),
948
+ mode: "file",
949
+ network: this.network
950
+ },
951
+ signer
952
+ );
953
+ if (!result.transactionId || !result.jobId) {
954
+ this.logger.error("Failed to inscribe, no transaction ID or job ID.");
955
+ throw new Error("Failed to inscribe, no transaction ID or job ID.");
956
+ }
957
+ if (result.transactionId && result.jobId) {
958
+ this.logger.info(
959
+ `Transaction ID: ${result.transactionId}, Job ID: ${result.jobId}`
960
+ );
961
+ }
962
+ const status = await sdk.waitForInscription(result.jobId, 30, 4e3, true);
963
+ return status;
964
+ }
965
+ getAccountAndSigner() {
966
+ const accountInfo = this.hwc.getAccountInfo();
967
+ const accountId = accountInfo.accountId.toString();
968
+ const signer = this.hwc.dAppConnector.signers.find((s) => {
969
+ return s.getAccountId().toString() === accountId;
970
+ });
971
+ if (!signer) {
972
+ this.logger.error("Failed to find signer");
973
+ throw new Error("Failed to find signer");
974
+ }
975
+ return { accountId, signer };
976
+ }
977
+ /**
978
+ * Inscribes a profile picture (PFP) on HCS-11.
979
+ *
980
+ * @param buffer - The buffer containing the PFP image.
981
+ * @param fileName - The name of the file containing the PFP image.
982
+ * @param options - Optional configuration options.
983
+ * @returns A promise that resolves to the topic ID of the inscribed PFP.
984
+ */
985
+ async inscribePfp(buffer, fileName, options) {
986
+ try {
987
+ const progressCallback = options?.progressCallback;
988
+ const progressReporter = new ProgressReporter({
989
+ module: "PFP-Inscription",
990
+ logger: this.logger,
991
+ callback: progressCallback
992
+ });
993
+ if (!this.hcs11Client) {
994
+ progressReporter.failed(
995
+ "HCS11Client is not available in this environment"
996
+ );
997
+ return {
998
+ pfpTopicId: "",
999
+ success: false,
1000
+ error: "HCS11Client is not available in this environment",
1001
+ transactionId: ""
1002
+ };
1003
+ }
1004
+ progressReporter.preparing("Preparing to inscribe profile picture", 10);
1005
+ this.logger.info("Inscribing profile picture using HCS-11 client");
1006
+ const wrappedProgressCallback = (data) => {
1007
+ progressReporter.report({
1008
+ stage: data.stage || "confirming",
1009
+ message: data.message || "Processing PFP inscription",
1010
+ progressPercent: data.progressPercent || 50,
1011
+ details: data.details
1012
+ });
1013
+ };
1014
+ const imageResult = await this.hcs11Client.inscribeImage(
1015
+ buffer,
1016
+ fileName,
1017
+ { progressCallback: wrappedProgressCallback }
1018
+ );
1019
+ if (!imageResult.success) {
1020
+ progressReporter.failed(
1021
+ `Failed to inscribe profile picture: ${imageResult.error}`
1022
+ );
1023
+ this.logger.error(
1024
+ `Failed to inscribe profile picture: ${imageResult.error}`
1025
+ );
1026
+ return {
1027
+ pfpTopicId: "",
1028
+ success: false,
1029
+ error: imageResult.error || "Failed to inscribe profile picture",
1030
+ transactionId: imageResult.transactionId || ""
1031
+ };
1032
+ }
1033
+ progressReporter.completed("Successfully inscribed profile picture", {
1034
+ pfpTopicId: imageResult.imageTopicId
1035
+ });
1036
+ this.logger.info(
1037
+ `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`
1038
+ );
1039
+ return {
1040
+ pfpTopicId: imageResult.imageTopicId,
1041
+ success: true,
1042
+ transactionId: imageResult.transactionId || ""
1043
+ };
1044
+ } catch (error) {
1045
+ this.logger.error(`Error inscribing profile picture: ${error.message}`);
1046
+ return {
1047
+ pfpTopicId: "",
1048
+ success: false,
1049
+ error: error.message,
1050
+ transactionId: ""
1051
+ };
1052
+ }
1053
+ }
1054
+ }
1055
+ export {
1056
+ BrowserHCSClient
1057
+ };
1058
+ //# sourceMappingURL=standards-sdk.es10.js.map