@hashgraphonline/standards-sdk 0.0.49 → 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 (336) 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.map +1 -1
  326. package/dist/umd/utils/index.d.ts +1 -0
  327. package/dist/umd/utils/index.d.ts.map +1 -0
  328. package/dist/umd/utils/logger.d.ts +1 -0
  329. package/dist/umd/utils/logger.d.ts.map +1 -0
  330. package/dist/umd/utils/progress-reporter.d.ts +1 -0
  331. package/dist/umd/utils/progress-reporter.d.ts.map +1 -0
  332. package/dist/umd/utils/sleep.d.ts +1 -0
  333. package/dist/umd/utils/sleep.d.ts.map +1 -0
  334. package/dist/umd/utils/topic-fee-utils.d.ts +1 -0
  335. package/dist/umd/utils/topic-fee-utils.d.ts.map +1 -0
  336. package/package.json +5 -9
@@ -0,0 +1,1042 @@
1
+ import { Client, PrivateKey, AccountCreateTransaction, Hbar, CustomFixedFee, AccountId, KeyList, TopicCreateTransaction, PublicKey, TopicMessageSubmitTransaction, TopicId, Transaction } from "@hashgraph/sdk";
2
+ import { AccountCreationError, TopicCreationError, ConnectionConfirmationError, PayloadSizeError } from "./standards-sdk.es6.js";
3
+ import { InscriptionSDK } from "./standards-sdk.es22.js";
4
+ import { Logger } from "./standards-sdk.es13.js";
5
+ import { HCS10BaseClient } from "./standards-sdk.es8.js";
6
+ import { m as mimeTypesExports } from "./standards-sdk.es19.js";
7
+ import { InboundTopicType } from "./standards-sdk.es18.js";
8
+ import { HCS11Client } from "./standards-sdk.es12.js";
9
+ import { accountIdsToExemptKeys } from "./standards-sdk.es14.js";
10
+ class HCS10Client extends HCS10BaseClient {
11
+ constructor(config) {
12
+ super({
13
+ network: config.network,
14
+ logLevel: config.logLevel,
15
+ prettyPrint: config.prettyPrint
16
+ });
17
+ this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
18
+ this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);
19
+ this.network = config.network;
20
+ this.client.setOperator(
21
+ config.operatorId,
22
+ this.operatorPrivateKey.toString()
23
+ );
24
+ this.logger = Logger.getInstance({
25
+ level: config.logLevel || "info",
26
+ module: "HCS-SDK"
27
+ });
28
+ this.guardedRegistryBaseUrl = config.guardedRegistryBaseUrl || "https://moonscape.tech";
29
+ this.feeAmount = config.feeAmount || 5;
30
+ this.hcs11Client = new HCS11Client({
31
+ network: config.network,
32
+ auth: {
33
+ operatorId: config.operatorId,
34
+ privateKey: config.operatorPrivateKey
35
+ },
36
+ logLevel: config.logLevel
37
+ });
38
+ }
39
+ getClient() {
40
+ return this.client;
41
+ }
42
+ /**
43
+ * Creates a new Hedera account
44
+ * @returns Object with account ID and private key
45
+ */
46
+ async createAccount() {
47
+ this.logger.info("Creating new account");
48
+ const newKey = PrivateKey.generate();
49
+ const accountTransaction = new AccountCreateTransaction().setKey(newKey.publicKey).setInitialBalance(new Hbar(10));
50
+ this.logger.debug("Executing account creation transaction");
51
+ const accountResponse = await accountTransaction.execute(this.client);
52
+ const accountReceipt = await accountResponse.getReceipt(this.client);
53
+ const newAccountId = accountReceipt.accountId;
54
+ if (!newAccountId) {
55
+ this.logger.error("Account creation failed: accountId is null");
56
+ throw new AccountCreationError(
57
+ "Failed to create account: accountId is null"
58
+ );
59
+ }
60
+ this.logger.info(
61
+ `Account created successfully: ${newAccountId.toString()}`
62
+ );
63
+ return {
64
+ accountId: newAccountId.toString(),
65
+ privateKey: newKey.toString()
66
+ };
67
+ }
68
+ /**
69
+ * Creates an inbound topic with the specified configuration
70
+ * @param accountId Account ID associated with the topic
71
+ * @param topicType Type of inbound topic (public, controlled, or fee-based)
72
+ * @param feeConfig Optional fee configuration for fee-based topics
73
+ * @returns The topic ID of the created inbound topic
74
+ */
75
+ async createInboundTopic(accountId, topicType, feeConfig) {
76
+ this.logger.info(`Creating ${topicType} inbound topic`);
77
+ const memo = `hcs-10:0:60:0:${accountId}`;
78
+ switch (topicType) {
79
+ case InboundTopicType.PUBLIC:
80
+ return this.createTopic(memo, true, false);
81
+ case InboundTopicType.CONTROLLED:
82
+ return this.createTopic(memo, true, true);
83
+ case InboundTopicType.FEE_BASED:
84
+ if (!feeConfig) {
85
+ throw new Error("Fee configuration is required for fee-based topics");
86
+ }
87
+ return this.createTopic(memo, true, true, feeConfig.build());
88
+ default:
89
+ throw new Error(`Unsupported inbound topic type: ${topicType}`);
90
+ }
91
+ }
92
+ /**
93
+ * Creates a new agent with inbound and outbound topics
94
+ * @param builder The agent builder object
95
+ * @returns Object with topic IDs
96
+ */
97
+ async createAgent(builder) {
98
+ const config = builder.build();
99
+ const outboundTopicId = await this.createTopic("hcs-10:0:60:1", true, true);
100
+ this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);
101
+ const accountId = this.client.operatorAccountId?.toString();
102
+ if (!accountId) {
103
+ throw new Error("Failed to retrieve operator account ID");
104
+ }
105
+ const inboundTopicId = await this.createInboundTopic(
106
+ accountId,
107
+ config.inboundTopicType,
108
+ config.inboundTopicType === InboundTopicType.FEE_BASED ? config.feeConfig : void 0
109
+ );
110
+ this.logger.info(`Created new inbound topic ID: ${inboundTopicId}`);
111
+ let pfpTopicId = config.existingPfpTopicId || "";
112
+ if (!pfpTopicId && config.pfpBuffer && config.pfpBuffer.length > 0) {
113
+ this.logger.info("Inscribing new profile picture");
114
+ const pfpResult = await this.inscribePfp(
115
+ config.pfpBuffer,
116
+ config.pfpFileName
117
+ );
118
+ pfpTopicId = pfpResult.pfpTopicId;
119
+ this.logger.info(`Profile picture inscribed with topic ID: ${pfpTopicId}`);
120
+ } else if (config.existingPfpTopicId) {
121
+ this.logger.info(`Using existing profile picture with topic ID: ${config.existingPfpTopicId}`);
122
+ }
123
+ const profileResult = await this.storeHCS11Profile(
124
+ config.name,
125
+ config.description,
126
+ inboundTopicId,
127
+ outboundTopicId,
128
+ config.capabilities,
129
+ config.metadata,
130
+ config.pfpBuffer && config.pfpBuffer.length > 0 ? config.pfpBuffer : void 0,
131
+ config.pfpFileName,
132
+ config.existingPfpTopicId
133
+ );
134
+ const profileTopicId = profileResult.profileTopicId;
135
+ this.logger.info(`Profile stored with topic ID: ${profileTopicId}`);
136
+ return {
137
+ outboundTopicId,
138
+ inboundTopicId,
139
+ pfpTopicId,
140
+ profileTopicId
141
+ };
142
+ }
143
+ /**
144
+ * Inscribes a profile picture to Hedera
145
+ * @param buffer Profile picture buffer
146
+ * @param fileName Filename
147
+ * @returns Response with topic ID and transaction ID
148
+ */
149
+ async inscribePfp(buffer, fileName) {
150
+ try {
151
+ this.logger.info("Inscribing profile picture using HCS-11 client");
152
+ const imageResult = await this.hcs11Client.inscribeImage(
153
+ buffer,
154
+ fileName
155
+ );
156
+ if (!imageResult.success) {
157
+ this.logger.error(
158
+ `Failed to inscribe profile picture: ${imageResult.error}`
159
+ );
160
+ throw new Error(
161
+ imageResult?.error || "Failed to inscribe profile picture"
162
+ );
163
+ }
164
+ this.logger.info(
165
+ `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`
166
+ );
167
+ return {
168
+ pfpTopicId: imageResult.imageTopicId,
169
+ transactionId: imageResult.transactionId,
170
+ success: true
171
+ };
172
+ } catch (error) {
173
+ this.logger.error(`Error inscribing profile picture: ${error.message}`);
174
+ return {
175
+ pfpTopicId: "",
176
+ transactionId: "",
177
+ success: false,
178
+ error: error.message
179
+ };
180
+ }
181
+ }
182
+ /**
183
+ * Stores an HCS-11 profile for an agent
184
+ * @param agentName Agent name
185
+ * @param agentDescription Agent description
186
+ * @param inboundTopicId Inbound topic ID
187
+ * @param outboundTopicId Outbound topic ID
188
+ * @param capabilities Agent capability tags
189
+ * @param metadata Additional metadata
190
+ * @param pfpBuffer Optional profile picture buffer
191
+ * @param pfpFileName Optional profile picture filename
192
+ * @returns Response with topic IDs and transaction ID
193
+ */
194
+ async storeHCS11Profile(agentName, agentDescription, inboundTopicId, outboundTopicId, capabilities = [], metadata, pfpBuffer, pfpFileName, existingPfpTopicId) {
195
+ try {
196
+ let pfpTopicId = existingPfpTopicId || "";
197
+ if (!pfpTopicId && pfpBuffer && pfpFileName) {
198
+ this.logger.info("Inscribing profile picture for HCS-11 profile");
199
+ const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);
200
+ if (!pfpResult.success) {
201
+ this.logger.error("Failed to inscribe profile picture, continuing without PFP");
202
+ } else {
203
+ pfpTopicId = pfpResult.pfpTopicId;
204
+ }
205
+ } else if (existingPfpTopicId) {
206
+ this.logger.info(`Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`);
207
+ }
208
+ const agentType = this.hcs11Client.getAgentTypeFromMetadata({
209
+ type: metadata.type || "autonomous"
210
+ });
211
+ const formattedSocials = metadata.socials ? Object.entries(metadata.socials).filter(([_, handle]) => handle).map(([platform, handle]) => ({
212
+ platform: platform === "x" ? "twitter" : platform,
213
+ handle
214
+ })) : void 0;
215
+ const profile = this.hcs11Client.createAIAgentProfile(
216
+ agentName,
217
+ agentType,
218
+ capabilities,
219
+ metadata.model || "unknown",
220
+ {
221
+ alias: agentName.toLowerCase().replace(/\s+/g, "_"),
222
+ bio: agentDescription,
223
+ profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : void 0,
224
+ socials: formattedSocials,
225
+ properties: metadata.properties,
226
+ inboundTopicId,
227
+ outboundTopicId,
228
+ creator: metadata.creator
229
+ }
230
+ );
231
+ const profileResult = await this.hcs11Client.createAndInscribeProfile(
232
+ profile,
233
+ true
234
+ );
235
+ if (!profileResult.success) {
236
+ this.logger.error(`Failed to inscribe profile: ${profileResult.error}`);
237
+ throw new Error(profileResult.error || "Failed to inscribe profile");
238
+ }
239
+ this.logger.info(
240
+ `Profile inscribed with topic ID: ${profileResult.profileTopicId}, transaction ID: ${profileResult.transactionId}`
241
+ );
242
+ return {
243
+ profileTopicId: profileResult.profileTopicId,
244
+ pfpTopicId,
245
+ transactionId: profileResult.transactionId,
246
+ success: true
247
+ };
248
+ } catch (error) {
249
+ this.logger.error(`Error storing HCS-11 profile: ${error.message}`);
250
+ return {
251
+ profileTopicId: "",
252
+ pfpTopicId: "",
253
+ transactionId: "",
254
+ success: false,
255
+ error: error.message
256
+ };
257
+ }
258
+ }
259
+ async setupFees(transaction, feeConfig, additionalExemptAccounts = []) {
260
+ if (!this.client.operatorPublicKey) {
261
+ return;
262
+ }
263
+ this.logger.info("Setting up topic with custom fees");
264
+ const customFee = new CustomFixedFee().setAmount(Number(feeConfig.feeAmount.amount)).setFeeCollectorAccountId(
265
+ AccountId.fromString(feeConfig.feeCollectorAccountId)
266
+ );
267
+ let exemptAccountIds = [
268
+ ...feeConfig.exemptAccounts || [],
269
+ ...additionalExemptAccounts
270
+ ];
271
+ console.log("exemptAccountIds", exemptAccountIds);
272
+ if (exemptAccountIds.length > 0) {
273
+ const uniqueExemptAccountIds = Array.from(new Set(exemptAccountIds));
274
+ const filteredExemptAccounts = uniqueExemptAccountIds.filter(
275
+ (account) => account !== this.client.operatorAccountId?.toString()
276
+ );
277
+ let exemptKeys = [];
278
+ if (filteredExemptAccounts.length > 0) {
279
+ try {
280
+ exemptKeys = await accountIdsToExemptKeys(
281
+ filteredExemptAccounts,
282
+ this.network,
283
+ this.logger
284
+ );
285
+ } catch (error) {
286
+ this.logger.warn(
287
+ `Error getting exempt keys: ${error}, continuing without exempt keys`
288
+ );
289
+ }
290
+ }
291
+ if (exemptKeys.length > 0) {
292
+ transaction.setFeeExemptKeys(exemptKeys);
293
+ }
294
+ }
295
+ transaction.setFeeScheduleKey(this.client.operatorPublicKey).setCustomFees([customFee]);
296
+ }
297
+ /**
298
+ * Handles a connection request from another account
299
+ * @param inboundTopicId Inbound topic ID
300
+ * @param requestingAccountId Requesting account ID
301
+ * @param connectionRequestId Connection request ID
302
+ * @param connectionFeeConfig Optional fee configuration for the connection topic
303
+ * @returns Response with connection details
304
+ */
305
+ async handleConnectionRequest(inboundTopicId, requestingAccountId, connectionRequestId, connectionFeeConfig) {
306
+ const memo = `hcs-10:${inboundTopicId}:${connectionRequestId}`;
307
+ this.logger.info(
308
+ `Handling connection request ${connectionRequestId} from ${requestingAccountId}`
309
+ );
310
+ const accountId = this.getClient().operatorAccountId?.toString();
311
+ if (!accountId) {
312
+ throw new Error("Failed to retrieve operator account ID");
313
+ }
314
+ let requesterKey = await this.mirrorNode.getPublicKey(requestingAccountId);
315
+ const accountKey = await this.mirrorNode.getPublicKey(accountId);
316
+ if (!accountKey) {
317
+ throw new Error("Failed to retrieve public key");
318
+ }
319
+ const thresholdKey = new KeyList([accountKey, requesterKey], 1);
320
+ let connectionTopicId;
321
+ try {
322
+ if (connectionFeeConfig) {
323
+ const feeConfig = connectionFeeConfig.build();
324
+ const modifiedFeeConfig = {
325
+ ...feeConfig,
326
+ exemptAccounts: [...feeConfig.exemptAccounts || []]
327
+ };
328
+ connectionTopicId = await this.createTopic(
329
+ memo,
330
+ thresholdKey,
331
+ thresholdKey,
332
+ modifiedFeeConfig
333
+ );
334
+ } else {
335
+ connectionTopicId = await this.createTopic(
336
+ memo,
337
+ thresholdKey,
338
+ thresholdKey
339
+ );
340
+ }
341
+ this.logger.info(`Created new connection topic ID: ${connectionTopicId}`);
342
+ } catch (error) {
343
+ this.logger.error(`Failed to create connection topic: ${error}`);
344
+ throw new TopicCreationError(
345
+ `Failed to create connection topic: ${error}`
346
+ );
347
+ }
348
+ const operatorId = `${inboundTopicId}@${accountId}`;
349
+ const confirmedConnectionSequenceNumber = await this.confirmConnection(
350
+ inboundTopicId,
351
+ connectionTopicId,
352
+ requestingAccountId,
353
+ connectionRequestId,
354
+ operatorId,
355
+ "Connection accepted. Looking forward to collaborating!"
356
+ );
357
+ return {
358
+ connectionTopicId,
359
+ confirmedConnectionSequenceNumber,
360
+ operatorId
361
+ };
362
+ }
363
+ async confirmConnection(inboundTopicId, connectionTopicId, connectedAccountId, connectionId, operatorId, memo, submitKey) {
364
+ this.logger.info(`Confirming connection with ID ${connectionId}`);
365
+ const payload = {
366
+ p: "hcs-10",
367
+ op: "connection_created",
368
+ connection_topic_id: connectionTopicId,
369
+ connected_account_id: connectedAccountId,
370
+ operator_id: operatorId,
371
+ connection_id: connectionId,
372
+ m: memo
373
+ };
374
+ const result = await this.submitPayload(inboundTopicId, payload, submitKey);
375
+ const sequenceNumber = result.topicSequenceNumber?.toNumber();
376
+ if (!sequenceNumber) {
377
+ throw new ConnectionConfirmationError(
378
+ "Failed to confirm connection: sequence number is null"
379
+ );
380
+ }
381
+ return sequenceNumber;
382
+ }
383
+ async sendMessage(connectionTopicId, operatorId, data, memo, submitKey) {
384
+ const submissionCheck = await this.canSubmitToInboundTopic(
385
+ connectionTopicId,
386
+ this.client.operatorAccountId?.toString() || ""
387
+ );
388
+ const payload = {
389
+ p: "hcs-10",
390
+ op: "message",
391
+ operator_id: operatorId,
392
+ data,
393
+ m: memo
394
+ };
395
+ const payloadString = JSON.stringify(payload);
396
+ const isLargePayload = Buffer.from(payloadString).length > 1e3;
397
+ if (isLargePayload) {
398
+ this.logger.info(
399
+ "Message payload exceeds 1000 bytes, storing via inscription"
400
+ );
401
+ try {
402
+ const contentBuffer = Buffer.from(data);
403
+ const fileName = `message-${Date.now()}.json`;
404
+ const inscriptionResult = await this.inscribeFile(
405
+ contentBuffer,
406
+ fileName
407
+ );
408
+ if (inscriptionResult?.topic_id) {
409
+ payload.data = `hcs://1/${inscriptionResult.topic_id}`;
410
+ this.logger.info(
411
+ `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`
412
+ );
413
+ } else {
414
+ throw new Error("Failed to inscribe large message content");
415
+ }
416
+ } catch (error) {
417
+ this.logger.error("Error inscribing large message:", error);
418
+ throw new Error(
419
+ `Failed to handle large message: ${error instanceof Error ? error.message : "Unknown error"}`
420
+ );
421
+ }
422
+ }
423
+ this.logger.info("Submitting message to connection topic", payload);
424
+ await this.submitPayload(
425
+ connectionTopicId,
426
+ payload,
427
+ submitKey,
428
+ submissionCheck.requiresFee
429
+ );
430
+ }
431
+ async createTopic(memo, adminKey, submitKey, feeConfig) {
432
+ this.logger.info("Creating topic");
433
+ const transaction = new TopicCreateTransaction().setTopicMemo(memo);
434
+ if (adminKey) {
435
+ if (typeof adminKey === "boolean" && adminKey && this.client.operatorPublicKey) {
436
+ transaction.setAdminKey(this.client.operatorPublicKey);
437
+ transaction.setAutoRenewAccountId(this.client.operatorAccountId);
438
+ } else if (adminKey instanceof PublicKey || adminKey instanceof KeyList) {
439
+ transaction.setAdminKey(adminKey);
440
+ if (this.client.operatorAccountId) {
441
+ transaction.setAutoRenewAccountId(this.client.operatorAccountId);
442
+ }
443
+ }
444
+ }
445
+ if (submitKey) {
446
+ if (typeof submitKey === "boolean" && submitKey && this.client.operatorPublicKey) {
447
+ transaction.setSubmitKey(this.client.operatorPublicKey);
448
+ } else if (submitKey instanceof PublicKey || submitKey instanceof KeyList) {
449
+ transaction.setSubmitKey(submitKey);
450
+ }
451
+ }
452
+ if (feeConfig) {
453
+ await this.setupFees(transaction, feeConfig);
454
+ }
455
+ this.logger.debug("Executing topic creation transaction");
456
+ const txResponse = await transaction.execute(this.client);
457
+ const receipt = await txResponse.getReceipt(this.client);
458
+ if (!receipt.topicId) {
459
+ this.logger.error("Failed to create topic: topicId is null");
460
+ throw new Error("Failed to create topic: topicId is null");
461
+ }
462
+ const topicId = receipt.topicId.toString();
463
+ return topicId;
464
+ }
465
+ async submitMessage(topicId, message, submitKey) {
466
+ const submissionCheck = await this.canSubmitToInboundTopic(
467
+ topicId,
468
+ this.client.operatorAccountId?.toString() || ""
469
+ );
470
+ return this.submitPayload(
471
+ topicId,
472
+ message,
473
+ submitKey,
474
+ submissionCheck.requiresFee
475
+ );
476
+ }
477
+ async submitPayload(topicId, payload, submitKey, requiresFee = false) {
478
+ const message = typeof payload === "string" ? payload : JSON.stringify(payload);
479
+ const payloadSizeInBytes = Buffer.byteLength(message, "utf8");
480
+ if (payloadSizeInBytes > 1e3) {
481
+ throw new PayloadSizeError(
482
+ "Payload size exceeds 1000 bytes limit",
483
+ payloadSizeInBytes
484
+ );
485
+ }
486
+ const transaction = new TopicMessageSubmitTransaction().setTopicId(TopicId.fromString(topicId)).setMessage(message);
487
+ if (requiresFee) {
488
+ this.logger.info(
489
+ "Topic requires fee payment, setting max transaction fee"
490
+ );
491
+ transaction.setMaxTransactionFee(new Hbar(this.feeAmount));
492
+ transaction.setTransactionMemo("HIP-991 Fee Payment");
493
+ }
494
+ let transactionResponse;
495
+ if (submitKey) {
496
+ transaction.freezeWith(this.client);
497
+ const signedTransaction = await transaction.sign(submitKey);
498
+ transactionResponse = await signedTransaction.execute(this.client);
499
+ } else {
500
+ transactionResponse = await transaction.execute(this.client);
501
+ }
502
+ const receipt = await transactionResponse.getReceipt(this.client);
503
+ if (!receipt) {
504
+ this.logger.error("Failed to submit message: receipt is null");
505
+ throw new Error("Failed to submit message: receipt is null");
506
+ }
507
+ this.logger.info("Message submitted successfully");
508
+ return receipt;
509
+ }
510
+ async submitConnectionRequest(inboundTopicId, requestingAccountId, operatorId, memo) {
511
+ const submissionCheck = await this.canSubmitToInboundTopic(
512
+ inboundTopicId,
513
+ requestingAccountId
514
+ );
515
+ if (!submissionCheck.canSubmit) {
516
+ throw new Error(`Cannot submit to topic: ${submissionCheck.reason}`);
517
+ }
518
+ const connectionRequestMessage = {
519
+ p: "hcs-10",
520
+ op: "connection_request",
521
+ operator_id: operatorId,
522
+ memo
523
+ };
524
+ const requiresFee = submissionCheck.requiresFee;
525
+ const response = await this.submitPayload(
526
+ inboundTopicId,
527
+ connectionRequestMessage,
528
+ void 0,
529
+ requiresFee
530
+ );
531
+ this.logger.info(
532
+ `Submitted connection request to topic ID: ${inboundTopicId}`
533
+ );
534
+ const outboundTopic = await this.retrieveOutboundConnectTopic(
535
+ requestingAccountId
536
+ );
537
+ const responseSequenceNumber = response.topicSequenceNumber?.toNumber();
538
+ if (!responseSequenceNumber) {
539
+ throw new Error("Failed to get response sequence number");
540
+ }
541
+ await this.submitPayload(
542
+ outboundTopic.outboundTopic,
543
+ {
544
+ ...connectionRequestMessage,
545
+ outbound_topic_id: outboundTopic.outboundTopic,
546
+ connection_request_id: responseSequenceNumber
547
+ },
548
+ this.operatorPrivateKey
549
+ );
550
+ return response;
551
+ }
552
+ async recordOutboundConnectionConfirmation({
553
+ outboundTopicId,
554
+ connectionRequestId,
555
+ confirmedRequestId,
556
+ connectionTopicId,
557
+ operatorId,
558
+ memo
559
+ }) {
560
+ const payload = {
561
+ p: "hcs-10",
562
+ op: "connection_created",
563
+ connection_topic_id: connectionTopicId,
564
+ outbound_topic_id: outboundTopicId,
565
+ confirmed_request_id: confirmedRequestId,
566
+ connection_request_id: connectionRequestId,
567
+ operator_id: operatorId,
568
+ m: memo
569
+ };
570
+ return await this.submitPayload(outboundTopicId, payload);
571
+ }
572
+ async inscribeFile(buffer, fileName) {
573
+ this.logger.info("Inscribing file");
574
+ if (!this.client.operatorAccountId) {
575
+ this.logger.error("Operator account ID is not set");
576
+ throw new Error("Operator account ID is not set");
577
+ }
578
+ if (!this.operatorPrivateKey) {
579
+ this.logger.error("Operator private key is not set");
580
+ throw new Error("Operator private key is not set");
581
+ }
582
+ const mimeType = mimeTypesExports.lookup(fileName) || "application/octet-stream";
583
+ const sdk = await InscriptionSDK.createWithAuth({
584
+ type: "server",
585
+ accountId: this.client.operatorAccountId.toString(),
586
+ privateKey: this.operatorPrivateKey.toString(),
587
+ network: this.network
588
+ });
589
+ const result = await sdk.inscribeAndExecute(
590
+ {
591
+ file: {
592
+ type: "base64",
593
+ base64: buffer.toString("base64"),
594
+ fileName,
595
+ mimeType
596
+ },
597
+ holderId: this.client.operatorAccountId.toString(),
598
+ mode: "file",
599
+ network: this.network
600
+ },
601
+ {
602
+ accountId: this.client.operatorAccountId.toString(),
603
+ privateKey: this.operatorPrivateKey.toString(),
604
+ network: this.network
605
+ }
606
+ );
607
+ if (!result.transactionId || !result.jobId) {
608
+ this.logger.error("Failed to inscribe, no transaction ID or job ID.");
609
+ throw new Error("Failed to inscribe, no transaction ID or job ID.");
610
+ }
611
+ if (result.transactionId && result.jobId) {
612
+ this.logger.info(
613
+ `Transaction ID: ${result.transactionId}, Job ID: ${result.jobId}`
614
+ );
615
+ }
616
+ const status = await sdk.waitForInscription(result.jobId, 30, 4e3, true);
617
+ return status;
618
+ }
619
+ /**
620
+ * Waits for confirmation of a connection request
621
+ * @param inboundTopicId Inbound topic ID
622
+ * @param connectionRequestId Connection request ID
623
+ * @param maxAttempts Maximum number of attempts
624
+ * @param delayMs Delay between attempts in milliseconds
625
+ * @returns Connection confirmation details
626
+ */
627
+ async waitForConnectionConfirmation(inboundTopicId, connectionRequestId, maxAttempts = 60, delayMs = 2e3) {
628
+ this.logger.info(
629
+ `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`
630
+ );
631
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
632
+ this.logger.info(
633
+ `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`
634
+ );
635
+ const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);
636
+ const connectionCreatedMessages = messages.filter(
637
+ (m) => m.op === "connection_created"
638
+ );
639
+ this.logger.info(
640
+ `Found ${connectionCreatedMessages.length} connection_created messages`
641
+ );
642
+ if (connectionCreatedMessages.length > 0) {
643
+ for (const message of connectionCreatedMessages) {
644
+ if (Number(message.connection_id) === Number(connectionRequestId)) {
645
+ this.logger.info("Connection confirmation found");
646
+ return {
647
+ connectionTopicId: message.connection_topic_id,
648
+ sequence_number: Number(message.sequence_number),
649
+ confirmedBy: message.operator_id,
650
+ memo: message.m
651
+ };
652
+ }
653
+ }
654
+ }
655
+ if (attempt < maxAttempts - 1) {
656
+ this.logger.info(
657
+ `No matching confirmation found, waiting ${delayMs}ms before retrying...`
658
+ );
659
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
660
+ }
661
+ }
662
+ throw new Error(
663
+ `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`
664
+ );
665
+ }
666
+ getAccountAndSigner() {
667
+ return {
668
+ accountId: this.client.operatorAccountId.toString(),
669
+ signer: this.operatorPrivateKey
670
+ };
671
+ }
672
+ /**
673
+ * Checks if a user can submit to a topic and determines if a fee is required
674
+ * @param topicId The topic ID to check
675
+ * @param userAccountId The account ID of the user attempting to submit
676
+ * @returns Object with canSubmit, requiresFee, and optional reason
677
+ */
678
+ async canSubmitToInboundTopic(topicId, userAccountId) {
679
+ try {
680
+ const topicInfo = await this.mirrorNode.getTopicInfo(topicId);
681
+ if (!topicInfo) {
682
+ return {
683
+ canSubmit: false,
684
+ requiresFee: false,
685
+ reason: "Topic does not exist"
686
+ };
687
+ }
688
+ if (!topicInfo.submit_key?.key) {
689
+ return { canSubmit: true, requiresFee: false };
690
+ }
691
+ try {
692
+ const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);
693
+ if (topicInfo.submit_key._type === "ProtobufEncoded") {
694
+ const keyBytes = Buffer.from(topicInfo.submit_key.key, "hex");
695
+ const hasAccess = await this.mirrorNode.checkKeyListAccess(
696
+ keyBytes,
697
+ userPublicKey
698
+ );
699
+ if (hasAccess) {
700
+ return { canSubmit: true, requiresFee: false };
701
+ }
702
+ } else {
703
+ const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);
704
+ if (userPublicKey.toString() === topicSubmitKey.toString()) {
705
+ return { canSubmit: true, requiresFee: false };
706
+ }
707
+ }
708
+ } catch (error) {
709
+ this.logger.error(
710
+ `Key validation error: ${error instanceof Error ? error.message : String(error)}`
711
+ );
712
+ }
713
+ if (topicInfo.fee_schedule_key?.key && topicInfo.custom_fees?.fixed_fees?.length > 0) {
714
+ return {
715
+ canSubmit: true,
716
+ requiresFee: true,
717
+ reason: "Requires fee payment via HIP-991"
718
+ };
719
+ }
720
+ return {
721
+ canSubmit: false,
722
+ requiresFee: false,
723
+ reason: "User does not have submit permission for this topic"
724
+ };
725
+ } catch (error) {
726
+ const errorMessage = error instanceof Error ? error.message : String(error);
727
+ this.logger.error(`Topic submission validation error: ${errorMessage}`);
728
+ return {
729
+ canSubmit: false,
730
+ requiresFee: false,
731
+ reason: `Error: ${errorMessage}`
732
+ };
733
+ }
734
+ }
735
+ /**
736
+ * Creates and registers an agent with a Guarded registry.
737
+ *
738
+ * This function performs the following steps:
739
+ * 1. Creates a new account if no existing account is provided.
740
+ * 2. Initializes an HCS10 client with the new account.
741
+ * 3. Creates an agent on the client.
742
+ * 4. Registers the agent with the Hashgraph Online Guarded Registry.
743
+ *
744
+ * @param builder The agent builder object
745
+ * @param options Optional configuration including progress callback and state management
746
+ * @returns Agent registration result
747
+ */
748
+ async createAndRegisterAgent(builder, options) {
749
+ try {
750
+ const config = builder.build();
751
+ const progressCallback = options?.progressCallback;
752
+ const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;
753
+ let state = options?.existingState || void 0;
754
+ if (progressCallback) {
755
+ progressCallback({
756
+ stage: "preparing",
757
+ message: "Preparing agent registration",
758
+ progressPercent: 10,
759
+ details: { state }
760
+ });
761
+ }
762
+ const account = config.existingAccount || await this.createAccount();
763
+ if (progressCallback) {
764
+ progressCallback({
765
+ stage: "preparing",
766
+ message: "Created account or using existing account",
767
+ progressPercent: 20,
768
+ details: { state, account }
769
+ });
770
+ }
771
+ const agentClient = new HCS10Client({
772
+ network: config.network,
773
+ operatorId: account.accountId,
774
+ operatorPrivateKey: account.privateKey,
775
+ operatorPublicKey: PrivateKey.fromString(
776
+ account.privateKey
777
+ ).publicKey.toString(),
778
+ logLevel: "info",
779
+ guardedRegistryBaseUrl: baseUrl
780
+ });
781
+ if (progressCallback) {
782
+ progressCallback({
783
+ stage: "preparing",
784
+ message: "Initialized agent client",
785
+ progressPercent: 30,
786
+ details: { state }
787
+ });
788
+ }
789
+ const { outboundTopicId, inboundTopicId, pfpTopicId, profileTopicId } = await agentClient.createAgent(builder);
790
+ if (progressCallback) {
791
+ progressCallback({
792
+ stage: "submitting",
793
+ message: "Created agent with topics and profile",
794
+ progressPercent: 60,
795
+ details: {
796
+ state,
797
+ outboundTopicId,
798
+ inboundTopicId,
799
+ pfpTopicId,
800
+ profileTopicId
801
+ }
802
+ });
803
+ }
804
+ const operatorId = `${inboundTopicId}@${account.accountId}`;
805
+ const registrationResult = await agentClient.registerAgentWithGuardedRegistry(
806
+ account.accountId,
807
+ config.network,
808
+ {
809
+ progressCallback: (data) => {
810
+ const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;
811
+ if (progressCallback) {
812
+ progressCallback({
813
+ stage: data.stage,
814
+ message: data.message,
815
+ progressPercent: adjustedPercent,
816
+ details: {
817
+ ...data.details,
818
+ outboundTopicId,
819
+ inboundTopicId,
820
+ pfpTopicId,
821
+ profileTopicId,
822
+ operatorId,
823
+ state: data.details?.state || state
824
+ }
825
+ });
826
+ }
827
+ },
828
+ existingState: state
829
+ }
830
+ );
831
+ if (!registrationResult.success) {
832
+ return registrationResult;
833
+ }
834
+ if (progressCallback) {
835
+ progressCallback({
836
+ stage: "completed",
837
+ message: "Agent creation and registration complete",
838
+ progressPercent: 100,
839
+ details: {
840
+ outboundTopicId,
841
+ inboundTopicId,
842
+ pfpTopicId,
843
+ profileTopicId,
844
+ operatorId,
845
+ state: registrationResult.state
846
+ }
847
+ });
848
+ }
849
+ return {
850
+ ...registrationResult,
851
+ metadata: {
852
+ accountId: account.accountId,
853
+ privateKey: account.privateKey,
854
+ operatorId,
855
+ inboundTopicId,
856
+ outboundTopicId,
857
+ profileTopicId,
858
+ pfpTopicId
859
+ }
860
+ };
861
+ } catch (error) {
862
+ this.logger.error(
863
+ `Failed to create and register agent: ${error.message}`
864
+ );
865
+ return {
866
+ error: error.message,
867
+ success: false
868
+ };
869
+ }
870
+ }
871
+ /**
872
+ * Registers an agent with the guarded registry
873
+ * @param accountId Account ID to register
874
+ * @param inboundTopicId Inbound topic ID for the agent
875
+ * @param network Network type ('mainnet' or 'testnet')
876
+ * @param options Optional configuration including progress callback and confirmation settings
877
+ * @returns Registration result
878
+ */
879
+ async registerAgentWithGuardedRegistry(accountId, network = this.network, options) {
880
+ try {
881
+ this.logger.info("Registering agent with guarded registry");
882
+ const maxAttempts = options?.maxAttempts ?? 60;
883
+ const delayMs = options?.delayMs ?? 2e3;
884
+ const progressCallback = options?.progressCallback;
885
+ let state = options?.existingState || {
886
+ currentStage: "registration",
887
+ completedPercentage: 0,
888
+ createdResources: []
889
+ };
890
+ if (progressCallback) {
891
+ progressCallback({
892
+ stage: "preparing",
893
+ message: "Preparing agent registration",
894
+ progressPercent: 10,
895
+ details: {
896
+ state
897
+ }
898
+ });
899
+ }
900
+ const registrationResult = await this.executeRegistration(
901
+ accountId,
902
+ network,
903
+ this.guardedRegistryBaseUrl,
904
+ this.logger
905
+ );
906
+ if (!registrationResult.success) {
907
+ return {
908
+ ...registrationResult,
909
+ state
910
+ };
911
+ }
912
+ if (progressCallback) {
913
+ progressCallback({
914
+ stage: "submitting",
915
+ message: "Submitting registration to registry",
916
+ progressPercent: 30,
917
+ details: {
918
+ transactionId: registrationResult.transactionId,
919
+ state
920
+ }
921
+ });
922
+ }
923
+ if (registrationResult.transaction) {
924
+ const transaction = Transaction.fromBytes(
925
+ Buffer.from(registrationResult.transaction, "base64")
926
+ );
927
+ this.logger.info(`Processing registration transaction`);
928
+ await transaction.execute(this.client);
929
+ this.logger.info(`Successfully processed registration transaction`);
930
+ }
931
+ if (progressCallback) {
932
+ progressCallback({
933
+ stage: "confirming",
934
+ message: "Confirming registration transaction",
935
+ progressPercent: 60,
936
+ details: {
937
+ accountId,
938
+ transactionId: registrationResult.transactionId,
939
+ state
940
+ }
941
+ });
942
+ }
943
+ const confirmed = await this.waitForRegistrationConfirmation(
944
+ registrationResult.transactionId,
945
+ network,
946
+ this.guardedRegistryBaseUrl,
947
+ maxAttempts,
948
+ delayMs,
949
+ this.logger
950
+ );
951
+ state.currentStage = "complete";
952
+ state.completedPercentage = 100;
953
+ if (!state.createdResources) {
954
+ state.createdResources = [];
955
+ }
956
+ if (registrationResult.transactionId) {
957
+ state.createdResources.push(
958
+ `registration:${registrationResult.transactionId}`
959
+ );
960
+ }
961
+ if (progressCallback) {
962
+ progressCallback({
963
+ stage: "completed",
964
+ message: "Agent registration complete",
965
+ progressPercent: 100,
966
+ details: {
967
+ confirmed,
968
+ transactionId: registrationResult.transactionId,
969
+ state
970
+ }
971
+ });
972
+ }
973
+ return {
974
+ ...registrationResult,
975
+ confirmed,
976
+ state
977
+ };
978
+ } catch (error) {
979
+ this.logger.error(`Failed to register agent: ${error.message}`);
980
+ return {
981
+ error: error.message,
982
+ success: false
983
+ };
984
+ }
985
+ }
986
+ /**
987
+ * Registers an agent with the guarded registry. Should be called by a registry.
988
+ * @param registryTopicId - The topic ID of the guarded registry.
989
+ * @param accountId - The account ID of the agent
990
+ * @param inboundTopicId - The topic ID of the inbound topic
991
+ * @param memo - The memo of the agent
992
+ * @param submitKey - The submit key of the agent
993
+ */
994
+ async registerAgent(registryTopicId, accountId, inboundTopicId, memo, submitKey) {
995
+ this.logger.info("Registering agent");
996
+ const payload = {
997
+ p: "hcs-10",
998
+ op: "register",
999
+ account_id: accountId,
1000
+ inbound_topic_id: inboundTopicId,
1001
+ m: memo
1002
+ };
1003
+ await this.submitPayload(registryTopicId, payload, submitKey);
1004
+ }
1005
+ async getInboundTopicType(topicId) {
1006
+ try {
1007
+ const topicInfo = await this.mirrorNode.getTopicInfo(topicId);
1008
+ if (!topicInfo) {
1009
+ throw new Error("Topic does not exist");
1010
+ }
1011
+ const hasSubmitKey = topicInfo.submit_key && topicInfo.submit_key.key;
1012
+ if (!hasSubmitKey) {
1013
+ return InboundTopicType.PUBLIC;
1014
+ }
1015
+ const hasFeeScheduleKey = topicInfo.fee_schedule_key && topicInfo.fee_schedule_key.key;
1016
+ if (hasFeeScheduleKey && topicInfo.custom_fees) {
1017
+ const customFees = topicInfo.custom_fees;
1018
+ if (customFees && customFees.fixed_fees && customFees.fixed_fees.length > 0) {
1019
+ this.logger.info(
1020
+ `Topic ${topicId} is fee-based with ${customFees.fixed_fees.length} custom fees`
1021
+ );
1022
+ return InboundTopicType.FEE_BASED;
1023
+ }
1024
+ }
1025
+ return InboundTopicType.CONTROLLED;
1026
+ } catch (error) {
1027
+ this.logger.error(`Error determining topic type: ${error.message}`);
1028
+ throw new Error(`Failed to determine topic type: ${error.message}`);
1029
+ }
1030
+ }
1031
+ getNetwork() {
1032
+ return this.network;
1033
+ }
1034
+ getLogger() {
1035
+ return this.logger;
1036
+ }
1037
+ }
1038
+ export {
1039
+ HCS10Client,
1040
+ InboundTopicType
1041
+ };
1042
+ //# sourceMappingURL=standards-sdk.es5.js.map