@hashgraphonline/standards-sdk 0.1.160 → 0.1.161

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 (293) hide show
  1. package/dist/cjs/hcs-14/resolvers/registry.d.ts +18 -1
  2. package/dist/cjs/hcs-14/resolvers/registry.d.ts.map +1 -1
  3. package/dist/cjs/hcs-14/resolvers/types.d.ts +17 -0
  4. package/dist/cjs/hcs-14/resolvers/types.d.ts.map +1 -1
  5. package/dist/cjs/hcs-14/sdk.d.ts +24 -13
  6. package/dist/cjs/hcs-14/sdk.d.ts.map +1 -1
  7. package/dist/cjs/standards-sdk.cjs +3 -3
  8. package/dist/cjs/standards-sdk.cjs.map +1 -1
  9. package/dist/es/hcs-14/resolvers/registry.d.ts +18 -1
  10. package/dist/es/hcs-14/resolvers/registry.d.ts.map +1 -1
  11. package/dist/es/hcs-14/resolvers/types.d.ts +17 -0
  12. package/dist/es/hcs-14/resolvers/types.d.ts.map +1 -1
  13. package/dist/es/hcs-14/sdk.d.ts +24 -13
  14. package/dist/es/hcs-14/sdk.d.ts.map +1 -1
  15. package/dist/es/standards-sdk.es.js +94 -90
  16. package/dist/es/standards-sdk.es.js.map +1 -1
  17. package/dist/es/standards-sdk.es100.js +138 -42
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +43 -259
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +245 -82
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +50 -49
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +100 -29
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +27 -229
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +228 -109
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +94 -15
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +30 -80
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es109.js +80 -27
  36. package/dist/es/standards-sdk.es109.js.map +1 -1
  37. package/dist/es/standards-sdk.es11.js +1 -1
  38. package/dist/es/standards-sdk.es110.js +27 -248
  39. package/dist/es/standards-sdk.es110.js.map +1 -1
  40. package/dist/es/standards-sdk.es111.js +246 -472
  41. package/dist/es/standards-sdk.es111.js.map +1 -1
  42. package/dist/es/standards-sdk.es112.js +458 -85
  43. package/dist/es/standards-sdk.es112.js.map +1 -1
  44. package/dist/es/standards-sdk.es113.js +96 -151
  45. package/dist/es/standards-sdk.es113.js.map +1 -1
  46. package/dist/es/standards-sdk.es114.js +155 -29
  47. package/dist/es/standards-sdk.es114.js.map +1 -1
  48. package/dist/es/standards-sdk.es115.js +26 -4
  49. package/dist/es/standards-sdk.es115.js.map +1 -1
  50. package/dist/es/standards-sdk.es116.js +10 -140
  51. package/dist/es/standards-sdk.es116.js.map +1 -1
  52. package/dist/es/standards-sdk.es117.js +140 -27
  53. package/dist/es/standards-sdk.es117.js.map +1 -1
  54. package/dist/es/standards-sdk.es118.js +27 -20
  55. package/dist/es/standards-sdk.es118.js.map +1 -1
  56. package/dist/es/standards-sdk.es119.js +18 -156
  57. package/dist/es/standards-sdk.es119.js.map +1 -1
  58. package/dist/es/standards-sdk.es12.js +1 -1
  59. package/dist/es/standards-sdk.es120.js +148 -191
  60. package/dist/es/standards-sdk.es120.js.map +1 -1
  61. package/dist/es/standards-sdk.es121.js +160 -747
  62. package/dist/es/standards-sdk.es121.js.map +1 -1
  63. package/dist/es/standards-sdk.es122.js +786 -9
  64. package/dist/es/standards-sdk.es122.js.map +1 -1
  65. package/dist/es/standards-sdk.es123.js +13 -567
  66. package/dist/es/standards-sdk.es123.js.map +1 -1
  67. package/dist/es/standards-sdk.es124.js +541 -576
  68. package/dist/es/standards-sdk.es124.js.map +1 -1
  69. package/dist/es/standards-sdk.es125.js +601 -12
  70. package/dist/es/standards-sdk.es125.js.map +1 -1
  71. package/dist/es/standards-sdk.es126.js +13 -2
  72. package/dist/es/standards-sdk.es126.js.map +1 -1
  73. package/dist/es/standards-sdk.es127.js +2 -87
  74. package/dist/es/standards-sdk.es127.js.map +1 -1
  75. package/dist/es/standards-sdk.es128.js +84 -37
  76. package/dist/es/standards-sdk.es128.js.map +1 -1
  77. package/dist/es/standards-sdk.es129.js +40 -2
  78. package/dist/es/standards-sdk.es129.js.map +1 -1
  79. package/dist/es/standards-sdk.es13.js +1 -1
  80. package/dist/es/standards-sdk.es130.js +2 -235
  81. package/dist/es/standards-sdk.es130.js.map +1 -1
  82. package/dist/es/standards-sdk.es131.js +204 -1109
  83. package/dist/es/standards-sdk.es131.js.map +1 -1
  84. package/dist/es/standards-sdk.es132.js +1059 -225
  85. package/dist/es/standards-sdk.es132.js.map +1 -1
  86. package/dist/es/standards-sdk.es133.js +303 -419
  87. package/dist/es/standards-sdk.es133.js.map +1 -1
  88. package/dist/es/standards-sdk.es134.js +418 -351
  89. package/dist/es/standards-sdk.es134.js.map +1 -1
  90. package/dist/es/standards-sdk.es135.js +347 -1108
  91. package/dist/es/standards-sdk.es135.js.map +1 -1
  92. package/dist/es/standards-sdk.es136.js +1088 -180
  93. package/dist/es/standards-sdk.es136.js.map +1 -1
  94. package/dist/es/standards-sdk.es137.js +153 -1512
  95. package/dist/es/standards-sdk.es137.js.map +1 -1
  96. package/dist/es/standards-sdk.es138.js +1567 -1255
  97. package/dist/es/standards-sdk.es138.js.map +1 -1
  98. package/dist/es/standards-sdk.es139.js +1255 -17
  99. package/dist/es/standards-sdk.es139.js.map +1 -1
  100. package/dist/es/standards-sdk.es14.js +1 -1
  101. package/dist/es/standards-sdk.es140.js +15 -85
  102. package/dist/es/standards-sdk.es140.js.map +1 -1
  103. package/dist/es/standards-sdk.es141.js +77 -71
  104. package/dist/es/standards-sdk.es141.js.map +1 -1
  105. package/dist/es/standards-sdk.es142.js +79 -891
  106. package/dist/es/standards-sdk.es142.js.map +1 -1
  107. package/dist/es/standards-sdk.es143.js +886 -53
  108. package/dist/es/standards-sdk.es143.js.map +1 -1
  109. package/dist/es/standards-sdk.es144.js +53 -152
  110. package/dist/es/standards-sdk.es144.js.map +1 -1
  111. package/dist/es/standards-sdk.es145.js +159 -7
  112. package/dist/es/standards-sdk.es145.js.map +1 -1
  113. package/dist/es/standards-sdk.es146.js +7 -86
  114. package/dist/es/standards-sdk.es146.js.map +1 -1
  115. package/dist/es/standards-sdk.es147.js +65 -44
  116. package/dist/es/standards-sdk.es147.js.map +1 -1
  117. package/dist/es/standards-sdk.es148.js +65 -30
  118. package/dist/es/standards-sdk.es148.js.map +1 -1
  119. package/dist/es/standards-sdk.es149.js +30 -34
  120. package/dist/es/standards-sdk.es149.js.map +1 -1
  121. package/dist/es/standards-sdk.es15.js +1 -1
  122. package/dist/es/standards-sdk.es150.js +34 -41
  123. package/dist/es/standards-sdk.es150.js.map +1 -1
  124. package/dist/es/standards-sdk.es151.js +45 -138
  125. package/dist/es/standards-sdk.es151.js.map +1 -1
  126. package/dist/es/standards-sdk.es152.js +133 -37
  127. package/dist/es/standards-sdk.es152.js.map +1 -1
  128. package/dist/es/standards-sdk.es153.js +34 -12474
  129. package/dist/es/standards-sdk.es153.js.map +1 -1
  130. package/dist/es/standards-sdk.es154.js +12444 -134
  131. package/dist/es/standards-sdk.es154.js.map +1 -1
  132. package/dist/es/standards-sdk.es155.js +13 -318
  133. package/dist/es/standards-sdk.es155.js.map +1 -1
  134. package/dist/es/standards-sdk.es156.js +55 -345
  135. package/dist/es/standards-sdk.es156.js.map +1 -1
  136. package/dist/es/standards-sdk.es157.js +68 -437
  137. package/dist/es/standards-sdk.es157.js.map +1 -1
  138. package/dist/es/standards-sdk.es158.js +71 -321
  139. package/dist/es/standards-sdk.es158.js.map +1 -1
  140. package/dist/es/standards-sdk.es159.js +63 -66
  141. package/dist/es/standards-sdk.es159.js.map +1 -1
  142. package/dist/es/standards-sdk.es16.js +5 -5
  143. package/dist/es/standards-sdk.es160.js +168 -13
  144. package/dist/es/standards-sdk.es160.js.map +1 -1
  145. package/dist/es/standards-sdk.es161.js +312 -232
  146. package/dist/es/standards-sdk.es161.js.map +1 -1
  147. package/dist/es/standards-sdk.es162.js +345 -55
  148. package/dist/es/standards-sdk.es162.js.map +1 -1
  149. package/dist/es/standards-sdk.es163.js +437 -68
  150. package/dist/es/standards-sdk.es163.js.map +1 -1
  151. package/dist/es/standards-sdk.es164.js +321 -71
  152. package/dist/es/standards-sdk.es164.js.map +1 -1
  153. package/dist/es/standards-sdk.es165.js +66 -63
  154. package/dist/es/standards-sdk.es165.js.map +1 -1
  155. package/dist/es/standards-sdk.es166.js +220 -150
  156. package/dist/es/standards-sdk.es166.js.map +1 -1
  157. package/dist/es/standards-sdk.es167.js +152 -202
  158. package/dist/es/standards-sdk.es167.js.map +1 -1
  159. package/dist/es/standards-sdk.es168.js +206 -223
  160. package/dist/es/standards-sdk.es168.js.map +1 -1
  161. package/dist/es/standards-sdk.es169.js +227 -107
  162. package/dist/es/standards-sdk.es169.js.map +1 -1
  163. package/dist/es/standards-sdk.es170.js +98 -105
  164. package/dist/es/standards-sdk.es170.js.map +1 -1
  165. package/dist/es/standards-sdk.es171.js +105 -140
  166. package/dist/es/standards-sdk.es171.js.map +1 -1
  167. package/dist/es/standards-sdk.es172.js +140 -164
  168. package/dist/es/standards-sdk.es172.js.map +1 -1
  169. package/dist/es/standards-sdk.es173.js +165 -119
  170. package/dist/es/standards-sdk.es173.js.map +1 -1
  171. package/dist/es/standards-sdk.es174.js +111 -303
  172. package/dist/es/standards-sdk.es174.js.map +1 -1
  173. package/dist/es/standards-sdk.es175.js +297 -225
  174. package/dist/es/standards-sdk.es175.js.map +1 -1
  175. package/dist/es/standards-sdk.es176.js +253 -110
  176. package/dist/es/standards-sdk.es176.js.map +1 -1
  177. package/dist/es/standards-sdk.es177.js +119 -0
  178. package/dist/es/standards-sdk.es177.js.map +1 -0
  179. package/dist/es/standards-sdk.es18.js +12 -12
  180. package/dist/es/standards-sdk.es19.js +9 -9
  181. package/dist/es/standards-sdk.es2.js +2 -2
  182. package/dist/es/standards-sdk.es20.js +1 -1
  183. package/dist/es/standards-sdk.es21.js +1 -1
  184. package/dist/es/standards-sdk.es22.js +1 -1
  185. package/dist/es/standards-sdk.es23.js +1 -1
  186. package/dist/es/standards-sdk.es24.js +1 -1
  187. package/dist/es/standards-sdk.es25.js +1 -1
  188. package/dist/es/standards-sdk.es26.js +1 -1
  189. package/dist/es/standards-sdk.es27.js +12 -12
  190. package/dist/es/standards-sdk.es30.js +2 -2
  191. package/dist/es/standards-sdk.es31.js +4 -4
  192. package/dist/es/standards-sdk.es32.js +1 -1
  193. package/dist/es/standards-sdk.es35.js +6 -6
  194. package/dist/es/standards-sdk.es36.js +4 -4
  195. package/dist/es/standards-sdk.es37.js +2 -2
  196. package/dist/es/standards-sdk.es38.js +2 -2
  197. package/dist/es/standards-sdk.es39.js +1 -1
  198. package/dist/es/standards-sdk.es4.js +2 -2
  199. package/dist/es/standards-sdk.es40.js +1 -1
  200. package/dist/es/standards-sdk.es41.js +2 -2
  201. package/dist/es/standards-sdk.es46.js +1 -1
  202. package/dist/es/standards-sdk.es5.js +2 -2
  203. package/dist/es/standards-sdk.es51.js +1 -1
  204. package/dist/es/standards-sdk.es53.js +1 -1
  205. package/dist/es/standards-sdk.es56.js +2 -2
  206. package/dist/es/standards-sdk.es58.js +11 -236
  207. package/dist/es/standards-sdk.es58.js.map +1 -1
  208. package/dist/es/standards-sdk.es59.js +321 -35
  209. package/dist/es/standards-sdk.es59.js.map +1 -1
  210. package/dist/es/standards-sdk.es6.js +2 -2
  211. package/dist/es/standards-sdk.es60.js +32 -101
  212. package/dist/es/standards-sdk.es60.js.map +1 -1
  213. package/dist/es/standards-sdk.es61.js +86 -156
  214. package/dist/es/standards-sdk.es61.js.map +1 -1
  215. package/dist/es/standards-sdk.es62.js +112 -153
  216. package/dist/es/standards-sdk.es62.js.map +1 -1
  217. package/dist/es/standards-sdk.es63.js +179 -87
  218. package/dist/es/standards-sdk.es63.js.map +1 -1
  219. package/dist/es/standards-sdk.es64.js +124 -40
  220. package/dist/es/standards-sdk.es64.js.map +1 -1
  221. package/dist/es/standards-sdk.es65.js +41 -251
  222. package/dist/es/standards-sdk.es65.js.map +1 -1
  223. package/dist/es/standards-sdk.es66.js +257 -24
  224. package/dist/es/standards-sdk.es66.js.map +1 -1
  225. package/dist/es/standards-sdk.es67.js +25 -87
  226. package/dist/es/standards-sdk.es67.js.map +1 -1
  227. package/dist/es/standards-sdk.es68.js +95 -3
  228. package/dist/es/standards-sdk.es68.js.map +1 -1
  229. package/dist/es/standards-sdk.es69.js +3 -100
  230. package/dist/es/standards-sdk.es69.js.map +1 -1
  231. package/dist/es/standards-sdk.es7.js +1 -1
  232. package/dist/es/standards-sdk.es70.js +62 -61
  233. package/dist/es/standards-sdk.es70.js.map +1 -1
  234. package/dist/es/standards-sdk.es71.js +98 -17
  235. package/dist/es/standards-sdk.es71.js.map +1 -1
  236. package/dist/es/standards-sdk.es72.js +19 -77
  237. package/dist/es/standards-sdk.es72.js.map +1 -1
  238. package/dist/es/standards-sdk.es73.js +77 -458
  239. package/dist/es/standards-sdk.es73.js.map +1 -1
  240. package/dist/es/standards-sdk.es74.js +240 -106
  241. package/dist/es/standards-sdk.es74.js.map +1 -1
  242. package/dist/es/standards-sdk.es75.js +286 -170
  243. package/dist/es/standards-sdk.es75.js.map +1 -1
  244. package/dist/es/standards-sdk.es76.js +207 -71
  245. package/dist/es/standards-sdk.es76.js.map +1 -1
  246. package/dist/es/standards-sdk.es77.js +72 -71
  247. package/dist/es/standards-sdk.es77.js.map +1 -1
  248. package/dist/es/standards-sdk.es78.js +71 -143
  249. package/dist/es/standards-sdk.es78.js.map +1 -1
  250. package/dist/es/standards-sdk.es79.js +136 -62
  251. package/dist/es/standards-sdk.es79.js.map +1 -1
  252. package/dist/es/standards-sdk.es80.js +45 -380
  253. package/dist/es/standards-sdk.es80.js.map +1 -1
  254. package/dist/es/standards-sdk.es81.js +130 -222
  255. package/dist/es/standards-sdk.es81.js.map +1 -1
  256. package/dist/es/standards-sdk.es82.js +444 -313
  257. package/dist/es/standards-sdk.es82.js.map +1 -1
  258. package/dist/es/standards-sdk.es83.js +364 -88
  259. package/dist/es/standards-sdk.es83.js.map +1 -1
  260. package/dist/es/standards-sdk.es84.js +89 -125
  261. package/dist/es/standards-sdk.es84.js.map +1 -1
  262. package/dist/es/standards-sdk.es85.js +125 -8
  263. package/dist/es/standards-sdk.es85.js.map +1 -1
  264. package/dist/es/standards-sdk.es86.js +6 -45
  265. package/dist/es/standards-sdk.es86.js.map +1 -1
  266. package/dist/es/standards-sdk.es87.js +44 -98
  267. package/dist/es/standards-sdk.es87.js.map +1 -1
  268. package/dist/es/standards-sdk.es88.js +84 -331
  269. package/dist/es/standards-sdk.es88.js.map +1 -1
  270. package/dist/es/standards-sdk.es89.js +160 -93
  271. package/dist/es/standards-sdk.es89.js.map +1 -1
  272. package/dist/es/standards-sdk.es9.js +2 -2
  273. package/dist/es/standards-sdk.es90.js +275 -55
  274. package/dist/es/standards-sdk.es90.js.map +1 -1
  275. package/dist/es/standards-sdk.es91.js +55 -43
  276. package/dist/es/standards-sdk.es91.js.map +1 -1
  277. package/dist/es/standards-sdk.es92.js +44 -145
  278. package/dist/es/standards-sdk.es92.js.map +1 -1
  279. package/dist/es/standards-sdk.es93.js +113 -30
  280. package/dist/es/standards-sdk.es93.js.map +1 -1
  281. package/dist/es/standards-sdk.es94.js +59 -22
  282. package/dist/es/standards-sdk.es94.js.map +1 -1
  283. package/dist/es/standards-sdk.es95.js +28 -23
  284. package/dist/es/standards-sdk.es95.js.map +1 -1
  285. package/dist/es/standards-sdk.es96.js +23 -238
  286. package/dist/es/standards-sdk.es96.js.map +1 -1
  287. package/dist/es/standards-sdk.es97.js +225 -267
  288. package/dist/es/standards-sdk.es97.js.map +1 -1
  289. package/dist/es/standards-sdk.es98.js +220 -95
  290. package/dist/es/standards-sdk.es98.js.map +1 -1
  291. package/dist/es/standards-sdk.es99.js +136 -124
  292. package/dist/es/standards-sdk.es99.js.map +1 -1
  293. package/package.json +4 -1
@@ -1,368 +1,499 @@
1
- import { Logger } from "./standards-sdk.es116.js";
2
- import { HederaMirrorNode } from "./standards-sdk.es137.js";
3
- import "path";
4
- import "buffer";
5
- import "crypto";
6
- import "@noble/curves/secp256k1.js";
7
- import "./standards-sdk.es138.js";
8
- import "./standards-sdk.es140.js";
9
- import "zod";
10
- import { HCS20_CONSTANTS, HCS20MessageSchema } from "./standards-sdk.es77.js";
11
- class HCS20PointsIndexer {
12
- constructor(network, logger, mirrorNodeUrl) {
13
- this.isProcessing = false;
14
- this.lastIndexedSequence = /* @__PURE__ */ new Map();
15
- this.logger = logger || new Logger({
16
- level: "info",
17
- module: "HCS20PointsIndexer"
1
+ import { AccountId, Client, Status, TopicCreateTransaction } from "@hashgraph/sdk";
2
+ import { HCS20BaseClient } from "./standards-sdk.es80.js";
3
+ import { PointsDeploymentError, PointsValidationError, PointsTransferError, PointsBurnError } from "./standards-sdk.es79.js";
4
+ import { sleep } from "./standards-sdk.es127.js";
5
+ import { createNodeOperatorContext } from "./standards-sdk.es152.js";
6
+ import { HCS2Client } from "./standards-sdk.es74.js";
7
+ import { buildHcs20DeployTx, buildHcs20MintTx, buildHcs20TransferTx, buildHcs20BurnTx, buildHcs20RegisterTx } from "./standards-sdk.es84.js";
8
+ class HCS20Client extends HCS20BaseClient {
9
+ constructor(config) {
10
+ super(config);
11
+ this.operatorAccountId = typeof config.operatorId === "string" ? AccountId.fromString(config.operatorId) : config.operatorId;
12
+ this.operatorId = this.operatorAccountId.toString();
13
+ const baseClient = this.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
14
+ this.operatorCtx = createNodeOperatorContext({
15
+ network: this.network,
16
+ operatorId: this.operatorId,
17
+ operatorKey: config.operatorKey,
18
+ keyType: config.keyType,
19
+ mirrorNode: this.mirrorNode,
20
+ logger: this.logger,
21
+ client: baseClient
18
22
  });
19
- this.mirrorNode = new HederaMirrorNode(network, this.logger, {
20
- customUrl: mirrorNodeUrl
21
- });
22
- this.state = this.initializeState();
23
+ this.client = this.operatorCtx.client;
24
+ void this.operatorCtx.ensureInitialized();
23
25
  }
24
26
  /**
25
- * Initialize empty state
27
+ * Ensure operator is initialized before operations
26
28
  */
27
- initializeState() {
28
- return {
29
- deployedPoints: /* @__PURE__ */ new Map(),
30
- balances: /* @__PURE__ */ new Map(),
31
- transactions: [],
32
- lastProcessedSequence: 0,
33
- lastProcessedTimestamp: (/* @__PURE__ */ new Date()).toISOString()
34
- };
29
+ async ensureInitialized() {
30
+ await this.operatorCtx.ensureInitialized();
35
31
  }
36
32
  /**
37
- * Get current state snapshot
33
+ * Submit a payload to a topic
38
34
  */
39
- getState() {
35
+ async submitPayload(transaction, submitKey) {
36
+ let transactionResponse;
37
+ if (submitKey) {
38
+ const frozenTransaction = transaction.freezeWith(this.client);
39
+ const signedTransaction = await frozenTransaction.sign(submitKey);
40
+ transactionResponse = await signedTransaction.execute(this.client);
41
+ } else {
42
+ transactionResponse = await transaction.execute(this.client);
43
+ }
44
+ const receipt = await transactionResponse.getReceipt(this.client);
45
+ if (!receipt || receipt.status !== Status.Success) {
46
+ throw new Error("Failed to submit message to topic");
47
+ }
40
48
  return {
41
- ...this.state,
42
- deployedPoints: new Map(this.state.deployedPoints),
43
- balances: new Map(this.state.balances),
44
- transactions: [...this.state.transactions]
49
+ receipt,
50
+ transactionId: transactionResponse.transactionId.toString()
45
51
  };
46
52
  }
47
53
  /**
48
- * Get points info for a specific tick
54
+ * Create a public topic for HCS-20 (for testnet)
49
55
  */
50
- getPointsInfo(tick) {
51
- return this.state.deployedPoints.get(this.normalizeTick(tick));
56
+ async createPublicTopic(memo) {
57
+ await this.ensureInitialized();
58
+ this.logger.info("Creating public HCS-20 topic...");
59
+ const topicCreateTx = await new TopicCreateTransaction().setTopicMemo(memo || "HCS-20 Public Topic").execute(this.client);
60
+ const receipt = await topicCreateTx.getReceipt(this.client);
61
+ if (receipt.status !== Status.Success || !receipt.topicId) {
62
+ throw new Error("Failed to create public topic");
63
+ }
64
+ const topicId = receipt.topicId.toString();
65
+ this.logger.info(`Created public topic: ${topicId}`);
66
+ this.publicTopicId = topicId;
67
+ return topicId;
52
68
  }
53
69
  /**
54
- * Get balance for an account and tick
70
+ * Create a registry topic for HCS-20
55
71
  */
56
- getBalance(tick, accountId) {
57
- const normalizedTick = this.normalizeTick(tick);
58
- const tickBalances = this.state.balances.get(normalizedTick);
59
- if (!tickBalances) return "0";
60
- const balance = tickBalances.get(accountId);
61
- return balance?.balance || "0";
72
+ async createRegistryTopic() {
73
+ await this.ensureInitialized();
74
+ this.logger.info("Creating HCS-20 registry topic...");
75
+ const hcs2Client = new HCS2Client({
76
+ operatorId: this.operatorId,
77
+ operatorKey: this.operatorCtx.operatorKey,
78
+ network: this.network
79
+ });
80
+ const topicCreateResponse = await hcs2Client.createRegistry({
81
+ submitKey: this.operatorCtx.operatorKey,
82
+ adminKey: this.operatorCtx.operatorKey
83
+ });
84
+ if (!topicCreateResponse.success) {
85
+ throw new Error("Failed to create registry topic");
86
+ }
87
+ const topicId = topicCreateResponse.topicId;
88
+ this.logger.info(`Created registry topic: ${topicId}`);
89
+ this.registryTopicId = topicId;
90
+ return topicId;
62
91
  }
63
92
  /**
64
- * Start indexing process
93
+ * Deploy new points
65
94
  */
66
- async startIndexing(options) {
67
- if (this.isProcessing) {
68
- this.logger.warn("Indexing already in progress");
69
- return;
70
- }
71
- this.isProcessing = true;
72
- const includePublicTopic = options?.includePublicTopic !== false;
73
- const includeRegistryTopic = options?.includeRegistryTopic !== false;
74
- const publicTopicId = includePublicTopic ? options?.publicTopicId || HCS20_CONSTANTS.PUBLIC_TOPIC_ID : null;
75
- const registryTopicId = includeRegistryTopic ? options?.registryTopicId || HCS20_CONSTANTS.REGISTRY_TOPIC_ID : null;
76
- const pollInterval = options?.pollInterval || 3e4;
77
- await this.indexTopics(
78
- publicTopicId,
79
- registryTopicId,
80
- options?.privateTopics
81
- );
82
- const pollTopics = async () => {
83
- if (!this.isProcessing) return;
84
- try {
85
- await this.indexTopics(
86
- publicTopicId,
87
- registryTopicId,
88
- options?.privateTopics
89
- );
90
- } catch (error) {
91
- this.logger.error("Polling error:", error);
95
+ async deployPoints(options) {
96
+ await this.ensureInitialized();
97
+ const { progressCallback } = options;
98
+ try {
99
+ progressCallback?.({
100
+ stage: "creating-topic",
101
+ percentage: 20
102
+ });
103
+ let topicId;
104
+ const hcs2Client = new HCS2Client({
105
+ operatorId: this.operatorId,
106
+ operatorKey: this.operatorCtx.operatorKey,
107
+ network: this.network
108
+ });
109
+ if (options.usePrivateTopic) {
110
+ const topicCreateResponse = await hcs2Client.createRegistry({
111
+ submitKey: this.operatorCtx.operatorKey,
112
+ adminKey: this.operatorCtx.operatorKey
113
+ });
114
+ if (!topicCreateResponse.success) {
115
+ throw new PointsDeploymentError(
116
+ "Failed to create topic",
117
+ options.tick
118
+ );
119
+ }
120
+ topicId = topicCreateResponse.topicId;
121
+ this.logger.info(`Created private topic: ${topicId}`);
122
+ } else {
123
+ topicId = this.publicTopicId;
92
124
  }
93
- if (this.isProcessing) {
94
- setTimeout(pollTopics, pollInterval);
125
+ progressCallback?.({
126
+ stage: "submitting-deploy",
127
+ percentage: 50,
128
+ topicId
129
+ });
130
+ const deployMessage = {
131
+ p: "hcs-20",
132
+ op: "deploy",
133
+ name: options.name,
134
+ tick: this.normalizeTick(options.tick),
135
+ max: options.maxSupply,
136
+ lim: options.limitPerMint,
137
+ metadata: options.metadata,
138
+ m: options.topicMemo
139
+ };
140
+ const validation = this.validateMessage(deployMessage);
141
+ if (!validation.valid) {
142
+ throw new PointsValidationError(
143
+ "Invalid deploy message",
144
+ validation.errors
145
+ );
95
146
  }
96
- };
97
- setTimeout(pollTopics, pollInterval);
98
- }
99
- /**
100
- * Index topics once and wait for completion
101
- */
102
- async indexOnce(options) {
103
- const includePublicTopic = options?.includePublicTopic !== false;
104
- const includeRegistryTopic = options?.includeRegistryTopic !== false;
105
- const publicTopicId = includePublicTopic ? options?.publicTopicId || HCS20_CONSTANTS.PUBLIC_TOPIC_ID : null;
106
- const registryTopicId = includeRegistryTopic ? options?.registryTopicId || HCS20_CONSTANTS.REGISTRY_TOPIC_ID : null;
107
- await this.indexTopics(
108
- publicTopicId,
109
- registryTopicId,
110
- options?.privateTopics
111
- );
112
- }
113
- /**
114
- * Stop indexing process
115
- */
116
- stopIndexing() {
117
- this.isProcessing = false;
118
- this.logger.info("Indexing stopped");
119
- }
120
- /**
121
- * Index topics and update state
122
- */
123
- async indexTopics(publicTopicId, registryTopicId, privateTopics) {
124
- this.logger.debug("Starting indexing cycle");
125
- if (publicTopicId) {
126
- await this.indexTopic(publicTopicId, false);
127
- }
128
- const registeredTopics = registryTopicId ? await this.getRegisteredTopics(registryTopicId) : [];
129
- const topicsToIndex = [...registeredTopics, ...privateTopics || []];
130
- for (const topicId of topicsToIndex) {
131
- await this.indexTopic(topicId, true);
147
+ const deployTransaction = buildHcs20DeployTx({
148
+ topicId,
149
+ name: options.name,
150
+ tick: options.tick,
151
+ max: options.maxSupply,
152
+ lim: options.limitPerMint,
153
+ metadata: options.metadata,
154
+ memo: options.topicMemo
155
+ });
156
+ const { transactionId: deployTxId } = await this.submitPayload(deployTransaction);
157
+ progressCallback?.({
158
+ stage: "confirming",
159
+ percentage: 80,
160
+ topicId,
161
+ deployTxId
162
+ });
163
+ await this.waitForMirrorNodeConfirmation(topicId, deployTxId);
164
+ progressCallback?.({
165
+ stage: "complete",
166
+ percentage: 100,
167
+ topicId,
168
+ deployTxId
169
+ });
170
+ const pointsInfo = {
171
+ name: options.name,
172
+ tick: this.normalizeTick(options.tick),
173
+ maxSupply: options.maxSupply,
174
+ limitPerMint: options.limitPerMint,
175
+ metadata: options.metadata,
176
+ topicId,
177
+ deployerAccountId: this.operatorId,
178
+ currentSupply: "0",
179
+ deploymentTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
180
+ isPrivate: options.usePrivateTopic || false
181
+ };
182
+ return pointsInfo;
183
+ } catch (error) {
184
+ progressCallback?.({
185
+ stage: "complete",
186
+ percentage: 100,
187
+ error: error instanceof Error ? error.message : "Unknown error"
188
+ });
189
+ throw error;
132
190
  }
133
- this.logger.debug("Indexing cycle complete");
134
191
  }
135
192
  /**
136
- * Get registered topics from registry
193
+ * Mint points
137
194
  */
138
- async getRegisteredTopics(registryTopicId) {
139
- const topics = [];
195
+ async mintPoints(options) {
196
+ await this.ensureInitialized();
197
+ const { progressCallback } = options;
140
198
  try {
141
- const messages = await this.mirrorNode.getTopicMessages(registryTopicId, {
142
- limit: 100,
143
- order: "asc"
199
+ progressCallback?.({
200
+ stage: "validating",
201
+ percentage: 20
202
+ });
203
+ const normalizedTick = this.normalizeTick(options.tick);
204
+ progressCallback?.({
205
+ stage: "submitting",
206
+ percentage: 50
144
207
  });
145
- messages.filter(
146
- (message) => message.p === "hcs-20" && message.op === "register" && typeof message.t_id === "string"
147
- ).forEach((message) => {
148
- topics.push(message.t_id);
208
+ const topicId = options.topicId ? this.topicToString(options.topicId) : this.publicTopicId;
209
+ const mintTransaction = buildHcs20MintTx({
210
+ topicId,
211
+ tick: options.tick,
212
+ amt: options.amount,
213
+ to: this.accountToString(options.to),
214
+ memo: options.memo
149
215
  });
216
+ const { transactionId: mintTxId } = await this.submitPayload(mintTransaction);
217
+ progressCallback?.({
218
+ stage: "confirming",
219
+ percentage: 80,
220
+ mintTxId
221
+ });
222
+ if (!options.disableMirrorCheck) {
223
+ await this.waitForMirrorNodeConfirmation(topicId, mintTxId);
224
+ }
225
+ progressCallback?.({
226
+ stage: "complete",
227
+ percentage: 100,
228
+ mintTxId
229
+ });
230
+ const transaction = {
231
+ id: mintTxId,
232
+ operation: "mint",
233
+ tick: normalizedTick,
234
+ amount: options.amount,
235
+ to: this.accountToString(options.to),
236
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
237
+ sequenceNumber: 0,
238
+ topicId,
239
+ transactionId: mintTxId,
240
+ memo: options.memo
241
+ };
242
+ return transaction;
150
243
  } catch (error) {
151
- this.logger.error("Failed to fetch registry messages:", error);
244
+ progressCallback?.({
245
+ stage: "complete",
246
+ percentage: 100,
247
+ error: error instanceof Error ? error.message : "Unknown error"
248
+ });
249
+ throw error;
152
250
  }
153
- return topics;
154
251
  }
155
252
  /**
156
- * Index a single topic
253
+ * Transfer points
157
254
  */
158
- async indexTopic(topicId, isPrivate) {
255
+ async transferPoints(options) {
256
+ await this.ensureInitialized();
257
+ const { progressCallback } = options;
159
258
  try {
160
- const lastSequence = this.lastIndexedSequence.get(topicId);
161
- this.logger.debug(
162
- `Indexing topic ${topicId}, starting from sequence ${lastSequence || 0}`
163
- );
164
- const messages = await this.mirrorNode.getTopicMessages(topicId, {
165
- sequenceNumber: lastSequence ? lastSequence + 1 : void 0,
166
- limit: 1e3,
167
- order: "asc"
259
+ progressCallback?.({
260
+ stage: "validating-balance",
261
+ percentage: 20
168
262
  });
169
- this.logger.debug(
170
- `Fetched ${messages.length} messages from topic ${topicId}`
171
- );
172
- let maxSequence = lastSequence || 0;
173
- for (const message of messages) {
174
- if (message.p !== "hcs-20") {
175
- continue;
176
- }
177
- const parseResult = HCS20MessageSchema.safeParse(message);
178
- if (!parseResult.success) {
179
- this.logger.debug("Skipping message due to schema mismatch");
180
- continue;
181
- }
182
- const parsedMsg = parseResult.data;
183
- const sequenceNumber = message.sequence_number ?? 0;
184
- this.logger.debug(
185
- `Found HCS-20 message: op=${parsedMsg.op}, sequence=${sequenceNumber}`
263
+ const normalizedTick = this.normalizeTick(options.tick);
264
+ const fromAccount = this.accountToString(options.from);
265
+ const toAccount = this.accountToString(options.to);
266
+ if (fromAccount !== this.operatorId) {
267
+ throw new PointsTransferError(
268
+ "For public topics, transaction payer must match sender",
269
+ options.tick,
270
+ fromAccount,
271
+ toAccount,
272
+ options.amount
186
273
  );
187
- if (sequenceNumber > maxSequence) {
188
- maxSequence = sequenceNumber;
189
- }
190
- const topicMessage = {
191
- consensus_timestamp: message.consensus_timestamp ?? "",
192
- sequence_number: sequenceNumber,
193
- payer_account_id: message.payer_account_id ?? message.payer ?? "",
194
- transaction_id: message.transaction_id ?? ""
195
- };
196
- this.processMessage(parsedMsg, topicMessage, topicId, isPrivate);
197
- this.state.lastProcessedSequence++;
198
- this.state.lastProcessedTimestamp = message.consensus_timestamp || "";
199
- }
200
- if (maxSequence > (lastSequence || 0)) {
201
- this.lastIndexedSequence.set(topicId, maxSequence);
202
274
  }
275
+ progressCallback?.({
276
+ stage: "submitting",
277
+ percentage: 50
278
+ });
279
+ const topicId = options.topicId ? this.topicToString(options.topicId) : this.publicTopicId;
280
+ const transferTransaction = buildHcs20TransferTx({
281
+ topicId,
282
+ tick: options.tick,
283
+ amt: options.amount,
284
+ from: fromAccount,
285
+ to: toAccount,
286
+ memo: options.memo
287
+ });
288
+ const { transactionId: transferTxId } = await this.submitPayload(transferTransaction);
289
+ progressCallback?.({
290
+ stage: "confirming",
291
+ percentage: 80,
292
+ transferTxId
293
+ });
294
+ await this.waitForMirrorNodeConfirmation(topicId, transferTxId);
295
+ progressCallback?.({
296
+ stage: "complete",
297
+ percentage: 100,
298
+ transferTxId
299
+ });
300
+ const transaction = {
301
+ id: transferTxId,
302
+ operation: "transfer",
303
+ tick: normalizedTick,
304
+ amount: options.amount,
305
+ from: fromAccount,
306
+ to: toAccount,
307
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
308
+ sequenceNumber: 0,
309
+ topicId,
310
+ transactionId: transferTxId,
311
+ memo: options.memo
312
+ };
313
+ return transaction;
203
314
  } catch (error) {
204
- this.logger.error(`Failed to index topic ${topicId}:`, error);
205
- }
206
- }
207
- /**
208
- * Process a single message
209
- */
210
- processMessage(msg, hcsMsg, topicId, isPrivate) {
211
- switch (msg.op) {
212
- case "deploy":
213
- this.processDeployMessage(msg, hcsMsg, topicId, isPrivate);
214
- break;
215
- case "mint":
216
- this.processMintMessage(msg, hcsMsg, topicId, isPrivate);
217
- break;
218
- case "transfer":
219
- this.processTransferMessage(msg, hcsMsg, topicId, isPrivate);
220
- break;
221
- case "burn":
222
- this.processBurnMessage(msg, hcsMsg, topicId, isPrivate);
223
- break;
224
- }
225
- }
226
- /**
227
- * Process deploy message
228
- */
229
- processDeployMessage(msg, hcsMsg, topicId, isPrivate) {
230
- const normalizedTick = this.normalizeTick(msg.tick);
231
- if (this.state.deployedPoints.has(normalizedTick)) {
232
- return;
233
- }
234
- const pointsInfo = {
235
- name: msg.name,
236
- tick: normalizedTick,
237
- maxSupply: msg.max,
238
- limitPerMint: msg.lim,
239
- metadata: msg.metadata,
240
- topicId,
241
- deployerAccountId: hcsMsg.payer_account_id,
242
- currentSupply: "0",
243
- deploymentTimestamp: hcsMsg.consensus_timestamp,
244
- isPrivate
245
- };
246
- this.state.deployedPoints.set(normalizedTick, pointsInfo);
247
- this.logger.info(`Deployed points: ${normalizedTick}`);
248
- }
249
- /**
250
- * Process mint message
251
- */
252
- processMintMessage(msg, hcsMsg, topicId, isPrivate) {
253
- const normalizedTick = this.normalizeTick(msg.tick);
254
- const pointsInfo = this.state.deployedPoints.get(normalizedTick);
255
- if (!pointsInfo) return;
256
- const mintAmount = BigInt(msg.amt);
257
- const currentSupply = BigInt(pointsInfo.currentSupply);
258
- const maxSupply = BigInt(pointsInfo.maxSupply);
259
- if (currentSupply + mintAmount > maxSupply) return;
260
- if (pointsInfo.limitPerMint && mintAmount > BigInt(pointsInfo.limitPerMint))
261
- return;
262
- pointsInfo.currentSupply = (currentSupply + mintAmount).toString();
263
- let tickBalances = this.state.balances.get(normalizedTick);
264
- if (!tickBalances) {
265
- tickBalances = /* @__PURE__ */ new Map();
266
- this.state.balances.set(normalizedTick, tickBalances);
315
+ progressCallback?.({
316
+ stage: "complete",
317
+ percentage: 100,
318
+ error: error instanceof Error ? error.message : "Unknown error"
319
+ });
320
+ throw error;
267
321
  }
268
- const currentBalance = tickBalances.get(msg.to);
269
- const newBalance = currentBalance ? (BigInt(currentBalance.balance) + mintAmount).toString() : msg.amt;
270
- tickBalances.set(msg.to, {
271
- tick: normalizedTick,
272
- accountId: msg.to,
273
- balance: newBalance,
274
- lastUpdated: hcsMsg.consensus_timestamp
275
- });
276
- this.state.transactions.push({
277
- id: hcsMsg.transaction_id || `${topicId}-${hcsMsg.sequence_number}`,
278
- operation: "mint",
279
- tick: normalizedTick,
280
- amount: msg.amt,
281
- to: msg.to,
282
- timestamp: hcsMsg.consensus_timestamp,
283
- sequenceNumber: hcsMsg.sequence_number,
284
- topicId,
285
- transactionId: hcsMsg.transaction_id || "",
286
- memo: msg.m
287
- });
288
322
  }
289
323
  /**
290
- * Process transfer message
324
+ * Burn points
291
325
  */
292
- processTransferMessage(msg, hcsMsg, topicId, isPrivate) {
293
- const normalizedTick = this.normalizeTick(msg.tick);
294
- const tickBalances = this.state.balances.get(normalizedTick);
295
- if (!tickBalances) return;
296
- if (!isPrivate && hcsMsg.payer_account_id !== msg.from) return;
297
- const senderBalance = tickBalances.get(msg.from);
298
- if (!senderBalance || BigInt(senderBalance.balance) < BigInt(msg.amt))
299
- return;
300
- const transferAmount = BigInt(msg.amt);
301
- senderBalance.balance = (BigInt(senderBalance.balance) - transferAmount).toString();
302
- senderBalance.lastUpdated = hcsMsg.consensus_timestamp;
303
- const receiverBalance = tickBalances.get(msg.to);
304
- if (receiverBalance) {
305
- receiverBalance.balance = (BigInt(receiverBalance.balance) + transferAmount).toString();
306
- receiverBalance.lastUpdated = hcsMsg.consensus_timestamp;
307
- } else {
308
- tickBalances.set(msg.to, {
326
+ async burnPoints(options) {
327
+ await this.ensureInitialized();
328
+ const { progressCallback } = options;
329
+ try {
330
+ progressCallback?.({
331
+ stage: "validating-balance",
332
+ percentage: 20
333
+ });
334
+ const normalizedTick = this.normalizeTick(options.tick);
335
+ const fromAccount = this.accountToString(options.from);
336
+ if (fromAccount !== this.operatorId) {
337
+ throw new PointsBurnError(
338
+ "For public topics, transaction payer must match burner",
339
+ options.tick,
340
+ fromAccount,
341
+ options.amount
342
+ );
343
+ }
344
+ progressCallback?.({
345
+ stage: "submitting",
346
+ percentage: 50
347
+ });
348
+ const topicId = options.topicId ? this.topicToString(options.topicId) : this.publicTopicId;
349
+ const burnTransaction = buildHcs20BurnTx({
350
+ topicId,
351
+ tick: options.tick,
352
+ amt: options.amount,
353
+ from: fromAccount,
354
+ memo: options.memo
355
+ });
356
+ const { transactionId: burnTxId } = await this.submitPayload(burnTransaction);
357
+ progressCallback?.({
358
+ stage: "confirming",
359
+ percentage: 80,
360
+ burnTxId
361
+ });
362
+ await this.waitForMirrorNodeConfirmation(topicId, burnTxId);
363
+ progressCallback?.({
364
+ stage: "complete",
365
+ percentage: 100,
366
+ burnTxId
367
+ });
368
+ const transaction = {
369
+ id: burnTxId,
370
+ operation: "burn",
309
371
  tick: normalizedTick,
310
- accountId: msg.to,
311
- balance: msg.amt,
312
- lastUpdated: hcsMsg.consensus_timestamp
372
+ amount: options.amount,
373
+ from: fromAccount,
374
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
375
+ sequenceNumber: 0,
376
+ topicId,
377
+ transactionId: burnTxId,
378
+ memo: options.memo
379
+ };
380
+ return transaction;
381
+ } catch (error) {
382
+ progressCallback?.({
383
+ stage: "complete",
384
+ percentage: 100,
385
+ error: error instanceof Error ? error.message : "Unknown error"
313
386
  });
387
+ throw error;
314
388
  }
315
- this.state.transactions.push({
316
- id: hcsMsg.transaction_id || `${topicId}-${hcsMsg.sequence_number}`,
317
- operation: "transfer",
318
- tick: normalizedTick,
319
- amount: msg.amt,
320
- from: msg.from,
321
- to: msg.to,
322
- timestamp: hcsMsg.consensus_timestamp,
323
- sequenceNumber: hcsMsg.sequence_number,
324
- topicId,
325
- transactionId: hcsMsg.transaction_id || "",
326
- memo: msg.m
327
- });
328
389
  }
329
390
  /**
330
- * Process burn message
391
+ * Register a topic in the registry
331
392
  */
332
- processBurnMessage(msg, hcsMsg, topicId, isPrivate) {
333
- const normalizedTick = this.normalizeTick(msg.tick);
334
- const pointsInfo = this.state.deployedPoints.get(normalizedTick);
335
- const tickBalances = this.state.balances.get(normalizedTick);
336
- if (!pointsInfo || !tickBalances) return;
337
- if (!isPrivate && hcsMsg.payer_account_id !== msg.from) return;
338
- const accountBalance = tickBalances.get(msg.from);
339
- if (!accountBalance || BigInt(accountBalance.balance) < BigInt(msg.amt))
340
- return;
341
- const burnAmount = BigInt(msg.amt);
342
- accountBalance.balance = (BigInt(accountBalance.balance) - burnAmount).toString();
343
- accountBalance.lastUpdated = hcsMsg.consensus_timestamp;
344
- pointsInfo.currentSupply = (BigInt(pointsInfo.currentSupply) - burnAmount).toString();
345
- this.state.transactions.push({
346
- id: hcsMsg.transaction_id || `${topicId}-${hcsMsg.sequence_number}`,
347
- operation: "burn",
348
- tick: normalizedTick,
349
- amount: msg.amt,
350
- from: msg.from,
351
- timestamp: hcsMsg.consensus_timestamp,
352
- sequenceNumber: hcsMsg.sequence_number,
353
- topicId,
354
- transactionId: hcsMsg.transaction_id || "",
355
- memo: msg.m
356
- });
393
+ async registerTopic(options) {
394
+ await this.ensureInitialized();
395
+ const { progressCallback } = options;
396
+ try {
397
+ progressCallback?.({
398
+ stage: "validating",
399
+ percentage: 20
400
+ });
401
+ const registerMessage = {
402
+ p: "hcs-20",
403
+ op: "register",
404
+ name: options.name,
405
+ metadata: options.metadata,
406
+ private: options.isPrivate,
407
+ t_id: this.topicToString(options.topicId),
408
+ m: options.memo
409
+ };
410
+ const validation = this.validateMessage(registerMessage);
411
+ if (!validation.valid) {
412
+ throw new PointsValidationError(
413
+ "Invalid register message",
414
+ validation.errors
415
+ );
416
+ }
417
+ if (!this.registryTopicId) {
418
+ throw new PointsDeploymentError(
419
+ "Registry topic not available",
420
+ options.name
421
+ );
422
+ }
423
+ progressCallback?.({
424
+ stage: "submitting",
425
+ percentage: 50
426
+ });
427
+ const registerTransaction = buildHcs20RegisterTx({
428
+ registryTopicId: this.registryTopicId,
429
+ name: options.name,
430
+ topicId: this.topicToString(options.topicId),
431
+ isPrivate: options.isPrivate,
432
+ metadata: options.metadata,
433
+ memo: options.memo
434
+ });
435
+ const { transactionId: registerTxId } = await this.submitPayload(
436
+ registerTransaction,
437
+ this.operatorCtx.operatorKey
438
+ );
439
+ progressCallback?.({
440
+ stage: "confirming",
441
+ percentage: 80,
442
+ registerTxId
443
+ });
444
+ await this.waitForMirrorNodeConfirmation(
445
+ this.registryTopicId,
446
+ registerTxId
447
+ );
448
+ progressCallback?.({
449
+ stage: "complete",
450
+ percentage: 100,
451
+ registerTxId
452
+ });
453
+ this.logger.info(`Registered topic ${options.topicId} in registry`);
454
+ } catch (error) {
455
+ progressCallback?.({
456
+ stage: "complete",
457
+ percentage: 100,
458
+ error: error instanceof Error ? error.message : "Unknown error"
459
+ });
460
+ throw error;
461
+ }
357
462
  }
358
463
  /**
359
- * Normalize tick to lowercase and trim
464
+ * Wait for mirror node to index a message
360
465
  */
361
- normalizeTick(tick) {
362
- return tick.toLowerCase().trim();
466
+ async waitForMirrorNodeConfirmation(topicId, transactionId, maxRetries = 10) {
467
+ for (let i = 0; i < maxRetries; i++) {
468
+ try {
469
+ const messages = await this.mirrorNode.getTopicMessages(topicId, {
470
+ limit: 10,
471
+ order: "desc"
472
+ });
473
+ const found = messages.some((message) => {
474
+ if (typeof message !== "object" || message === null) {
475
+ return false;
476
+ }
477
+ const candidate = message;
478
+ return typeof candidate.consensus_timestamp === "string";
479
+ });
480
+ if (found) {
481
+ this.logger.debug(
482
+ `Transaction ${transactionId} confirmed on mirror node`
483
+ );
484
+ return;
485
+ }
486
+ } catch (error) {
487
+ this.logger.debug(`Mirror node check attempt ${i + 1} failed:`, error);
488
+ }
489
+ await sleep(2e3);
490
+ }
491
+ this.logger.warn(
492
+ `Transaction ${transactionId} not found on mirror node after ${maxRetries} attempts`
493
+ );
363
494
  }
364
495
  }
365
496
  export {
366
- HCS20PointsIndexer
497
+ HCS20Client
367
498
  };
368
499
  //# sourceMappingURL=standards-sdk.es82.js.map