@hashgraphonline/standards-sdk 0.1.161 → 0.1.163
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.
- package/dist/cjs/hcs-14/index.d.ts +1 -0
- package/dist/cjs/hcs-14/index.d.ts.map +1 -1
- package/dist/cjs/hcs-14/resolvers/aid-dns-web-profile.d.ts +1 -0
- package/dist/cjs/hcs-14/resolvers/aid-dns-web-profile.d.ts.map +1 -1
- package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts +23 -0
- package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts.map +1 -0
- package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile.d.ts +32 -0
- package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile.d.ts.map +1 -0
- package/dist/cjs/hcs-14/resolvers/hcs-11-profile.d.ts +1 -0
- package/dist/cjs/hcs-14/resolvers/hcs-11-profile.d.ts.map +1 -1
- package/dist/cjs/hcs-14/resolvers/hiero.d.ts +1 -0
- package/dist/cjs/hcs-14/resolvers/hiero.d.ts.map +1 -1
- package/dist/cjs/hcs-14/resolvers/registry.d.ts +21 -0
- package/dist/cjs/hcs-14/resolvers/registry.d.ts.map +1 -1
- package/dist/cjs/hcs-14/resolvers/types.d.ts +40 -5
- package/dist/cjs/hcs-14/resolvers/types.d.ts.map +1 -1
- package/dist/cjs/hcs-14/resolvers/uaid-did-resolution-profile.d.ts +1 -0
- package/dist/cjs/hcs-14/resolvers/uaid-did-resolution-profile.d.ts.map +1 -1
- package/dist/cjs/hcs-14/resolvers/uaid-dns-web-profile.d.ts +1 -0
- package/dist/cjs/hcs-14/resolvers/uaid-dns-web-profile.d.ts.map +1 -1
- package/dist/cjs/hcs-14/sdk.d.ts +23 -1
- package/dist/cjs/hcs-14/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-2/client.d.ts +7 -1
- package/dist/cjs/hcs-2/client.d.ts.map +1 -1
- package/dist/cjs/hcs-2/types.d.ts +2 -0
- package/dist/cjs/hcs-2/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-14/index.d.ts +1 -0
- package/dist/es/hcs-14/index.d.ts.map +1 -1
- package/dist/es/hcs-14/resolvers/aid-dns-web-profile.d.ts +1 -0
- package/dist/es/hcs-14/resolvers/aid-dns-web-profile.d.ts.map +1 -1
- package/dist/es/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts +23 -0
- package/dist/es/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts.map +1 -0
- package/dist/es/hcs-14/resolvers/ans-dns-web-profile.d.ts +32 -0
- package/dist/es/hcs-14/resolvers/ans-dns-web-profile.d.ts.map +1 -0
- package/dist/es/hcs-14/resolvers/hcs-11-profile.d.ts +1 -0
- package/dist/es/hcs-14/resolvers/hcs-11-profile.d.ts.map +1 -1
- package/dist/es/hcs-14/resolvers/hiero.d.ts +1 -0
- package/dist/es/hcs-14/resolvers/hiero.d.ts.map +1 -1
- package/dist/es/hcs-14/resolvers/registry.d.ts +21 -0
- package/dist/es/hcs-14/resolvers/registry.d.ts.map +1 -1
- package/dist/es/hcs-14/resolvers/types.d.ts +40 -5
- package/dist/es/hcs-14/resolvers/types.d.ts.map +1 -1
- package/dist/es/hcs-14/resolvers/uaid-did-resolution-profile.d.ts +1 -0
- package/dist/es/hcs-14/resolvers/uaid-did-resolution-profile.d.ts.map +1 -1
- package/dist/es/hcs-14/resolvers/uaid-dns-web-profile.d.ts +1 -0
- package/dist/es/hcs-14/resolvers/uaid-dns-web-profile.d.ts.map +1 -1
- package/dist/es/hcs-14/sdk.d.ts +23 -1
- package/dist/es/hcs-14/sdk.d.ts.map +1 -1
- package/dist/es/hcs-2/client.d.ts +7 -1
- package/dist/es/hcs-2/client.d.ts.map +1 -1
- package/dist/es/hcs-2/types.d.ts +2 -0
- package/dist/es/hcs-2/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +89 -86
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +136 -124
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +138 -42
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +43 -259
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +245 -82
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +50 -49
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +100 -29
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +27 -229
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +228 -109
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +94 -15
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +30 -80
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es11.js +1 -1
- package/dist/es/standards-sdk.es110.js +80 -27
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +27 -248
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +246 -472
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +458 -85
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +96 -151
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +155 -29
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +26 -4
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +10 -140
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +140 -27
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +27 -20
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es120.js +18 -156
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +148 -191
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +160 -747
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +786 -9
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +13 -567
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +541 -576
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +601 -12
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +13 -2
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +2 -87
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +84 -37
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es130.js +40 -2
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +2 -235
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +204 -1109
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +1059 -225
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +303 -419
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +418 -351
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +347 -1108
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +1088 -180
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +153 -1512
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +1567 -1255
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es14.js +1 -1
- package/dist/es/standards-sdk.es140.js +1255 -17
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +15 -85
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +77 -71
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +79 -891
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +886 -53
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +53 -152
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +159 -7
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +7 -86
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +65 -44
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +65 -30
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es150.js +30 -34
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +34 -45
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +48 -138
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +133 -37
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +34 -12474
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +12477 -12
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +15 -54
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +48 -76
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +69 -66
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +71 -63
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +5 -5
- package/dist/es/standards-sdk.es160.js +188 -160
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +232 -312
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +64 -337
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +129 -410
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +200 -209
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +334 -64
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +442 -231
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +317 -158
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +61 -207
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +155 -222
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +178 -75
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +226 -113
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +77 -119
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +103 -162
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +141 -119
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +152 -298
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +120 -240
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +298 -83
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +262 -0
- package/dist/es/standards-sdk.es178.js.map +1 -0
- package/dist/es/standards-sdk.es179.js +119 -0
- package/dist/es/standards-sdk.es179.js.map +1 -0
- package/dist/es/standards-sdk.es18.js +12 -12
- package/dist/es/standards-sdk.es19.js +9 -9
- package/dist/es/standards-sdk.es2.js +2 -2
- package/dist/es/standards-sdk.es20.js +1 -1
- package/dist/es/standards-sdk.es21.js +1 -1
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es24.js +1 -1
- package/dist/es/standards-sdk.es25.js +1 -1
- package/dist/es/standards-sdk.es26.js +1 -1
- package/dist/es/standards-sdk.es27.js +12 -12
- package/dist/es/standards-sdk.es30.js +2 -2
- package/dist/es/standards-sdk.es31.js +4 -4
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es35.js +6 -6
- package/dist/es/standards-sdk.es36.js +4 -4
- package/dist/es/standards-sdk.es37.js +2 -2
- package/dist/es/standards-sdk.es38.js +2 -2
- package/dist/es/standards-sdk.es39.js +1 -1
- package/dist/es/standards-sdk.es4.js +2 -2
- package/dist/es/standards-sdk.es40.js +1 -1
- package/dist/es/standards-sdk.es41.js +2 -2
- package/dist/es/standards-sdk.es46.js +1 -1
- package/dist/es/standards-sdk.es5.js +2 -2
- package/dist/es/standards-sdk.es51.js +1 -1
- package/dist/es/standards-sdk.es53.js +1 -1
- package/dist/es/standards-sdk.es56.js +2 -2
- package/dist/es/standards-sdk.es58.js +37 -4
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +17 -10
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es6.js +2 -2
- package/dist/es/standards-sdk.es60.js +2 -1
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +1 -0
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +19 -5
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +214 -153
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +205 -84
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +125 -40
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +41 -261
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +262 -24
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +25 -87
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +95 -3
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +1 -1
- package/dist/es/standards-sdk.es70.js +3 -100
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +62 -61
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +98 -17
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +19 -77
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +77 -458
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +332 -107
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +286 -170
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +207 -71
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +72 -71
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +71 -143
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es80.js +136 -62
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +45 -380
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +130 -222
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +444 -313
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +364 -88
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +89 -125
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +125 -8
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +6 -45
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +44 -98
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +84 -331
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +2 -2
- package/dist/es/standards-sdk.es90.js +160 -93
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +275 -55
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +55 -43
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +44 -145
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +113 -30
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +59 -22
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +28 -23
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +23 -238
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +225 -267
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +220 -95
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/package.json +5 -1
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { buildMessageTx } from "./standards-sdk.
|
|
7
|
-
|
|
1
|
+
import { AccountId, Client, PublicKey } from "@hashgraph/sdk";
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
3
|
+
import { HCS2BaseClient } from "./standards-sdk.es77.js";
|
|
4
|
+
import { HCS2Operation, HCS2RegistryType } from "./standards-sdk.es74.js";
|
|
5
|
+
import { createNodeOperatorContext } from "./standards-sdk.es153.js";
|
|
6
|
+
import { buildMessageTx } from "./standards-sdk.es154.js";
|
|
7
|
+
import { buildHcs2CreateRegistryTx } from "./standards-sdk.es78.js";
|
|
8
|
+
import { inscribe } from "./standards-sdk.es137.js";
|
|
9
|
+
import { InscriptionSDK } from "./standards-sdk.es155.js";
|
|
10
|
+
import { getTopicId } from "./standards-sdk.es127.js";
|
|
11
|
+
const MAX_PAYLOAD_BYTES = 1024;
|
|
12
|
+
const HCS1_HRL_PATTERN = /^hcs:\/\/1\/(\d+\.\d+\.\d+)$/;
|
|
13
|
+
const _HCS2Client = class _HCS2Client extends HCS2BaseClient {
|
|
8
14
|
/**
|
|
9
|
-
* Create a new
|
|
15
|
+
* Create a new HCS-2 client
|
|
10
16
|
* @param config Client configuration
|
|
11
17
|
*/
|
|
12
18
|
constructor(config) {
|
|
@@ -17,25 +23,36 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
17
23
|
mirrorNodeUrl: config.mirrorNodeUrl,
|
|
18
24
|
logger: config.logger
|
|
19
25
|
});
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
this.registryTypeCache = /* @__PURE__ */ new Map();
|
|
27
|
+
this.operatorId = typeof config.operatorId === "string" ? AccountId.fromString(config.operatorId) : config.operatorId;
|
|
28
|
+
this.operatorCtx = createNodeOperatorContext({
|
|
29
|
+
network: this.network,
|
|
30
|
+
operatorId: this.operatorId,
|
|
31
|
+
operatorKey: config.operatorKey,
|
|
32
|
+
keyType: config.keyType,
|
|
33
|
+
mirrorNode: this.mirrorNode,
|
|
34
|
+
logger: this.logger,
|
|
35
|
+
client: this.createClient(config.network)
|
|
36
|
+
});
|
|
37
|
+
this.client = this.operatorCtx.client;
|
|
28
38
|
}
|
|
29
39
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @returns The operator account ID
|
|
40
|
+
* Initialize the Hedera client with operator information
|
|
32
41
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
async ensureInitialized() {
|
|
43
|
+
await this.operatorCtx.ensureInitialized();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a Hedera client for the specified network
|
|
47
|
+
* @param network The network to connect to
|
|
48
|
+
* @returns The Hedera client
|
|
49
|
+
*/
|
|
50
|
+
createClient(network) {
|
|
51
|
+
if (network === "mainnet") {
|
|
52
|
+
return Client.forMainnet();
|
|
53
|
+
} else {
|
|
54
|
+
return Client.forTestnet();
|
|
37
55
|
}
|
|
38
|
-
return accountInfo.accountId;
|
|
39
56
|
}
|
|
40
57
|
/**
|
|
41
58
|
* Create a new registry topic
|
|
@@ -44,70 +61,79 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
44
61
|
*/
|
|
45
62
|
async createRegistry(options = {}) {
|
|
46
63
|
try {
|
|
64
|
+
await this.ensureInitialized();
|
|
47
65
|
const registryType = options.registryType ?? HCS2RegistryType.INDEXED;
|
|
48
66
|
const ttl = options.ttl ?? 86400;
|
|
49
67
|
const memo = this.generateRegistryMemo(registryType, ttl);
|
|
50
|
-
let
|
|
68
|
+
let adminKeyPrivate;
|
|
69
|
+
let adminPublicKey;
|
|
51
70
|
if (options.adminKey) {
|
|
52
|
-
let adminPublicKey;
|
|
53
71
|
if (typeof options.adminKey === "string") {
|
|
54
72
|
try {
|
|
55
73
|
adminPublicKey = PublicKey.fromString(options.adminKey);
|
|
56
74
|
} catch {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
75
|
+
const keyBytes = Buffer.from(
|
|
76
|
+
options.adminKey.replace(/^0x/i, ""),
|
|
77
|
+
"hex"
|
|
78
|
+
);
|
|
79
|
+
adminPublicKey = this.operatorCtx.keyType === "ed25519" ? PublicKey.fromBytesED25519(keyBytes) : PublicKey.fromBytesECDSA(keyBytes);
|
|
63
80
|
}
|
|
64
81
|
} else if (typeof options.adminKey === "boolean") {
|
|
65
|
-
adminPublicKey =
|
|
66
|
-
this.getOperatorId()
|
|
67
|
-
);
|
|
82
|
+
adminPublicKey = this.operatorCtx.operatorKey.publicKey;
|
|
68
83
|
} else {
|
|
69
84
|
adminPublicKey = options.adminKey.publicKey;
|
|
85
|
+
adminKeyPrivate = options.adminKey;
|
|
70
86
|
}
|
|
71
|
-
transaction = transaction.setAdminKey(adminPublicKey);
|
|
72
87
|
}
|
|
88
|
+
let submitKeyPrivate;
|
|
89
|
+
let submitPublicKey;
|
|
73
90
|
if (options.submitKey) {
|
|
74
|
-
let submitPublicKey;
|
|
75
91
|
if (typeof options.submitKey === "string") {
|
|
76
92
|
try {
|
|
77
93
|
submitPublicKey = PublicKey.fromString(options.submitKey);
|
|
78
94
|
} catch {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
95
|
+
const keyBytes = Buffer.from(
|
|
96
|
+
options.submitKey.replace(/^0x/i, ""),
|
|
97
|
+
"hex"
|
|
98
|
+
);
|
|
99
|
+
submitPublicKey = this.operatorCtx.keyType === "ed25519" ? PublicKey.fromBytesED25519(keyBytes) : PublicKey.fromBytesECDSA(keyBytes);
|
|
85
100
|
}
|
|
86
101
|
} else if (typeof options.submitKey === "boolean") {
|
|
87
|
-
submitPublicKey =
|
|
88
|
-
this.getOperatorId()
|
|
89
|
-
);
|
|
102
|
+
submitPublicKey = this.operatorCtx.operatorKey.publicKey;
|
|
90
103
|
} else {
|
|
91
104
|
submitPublicKey = options.submitKey.publicKey;
|
|
105
|
+
submitKeyPrivate = options.submitKey;
|
|
92
106
|
}
|
|
93
|
-
transaction = transaction.setSubmitKey(submitPublicKey);
|
|
94
107
|
}
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
const transaction = buildHcs2CreateRegistryTx({
|
|
109
|
+
registryType,
|
|
110
|
+
ttl,
|
|
111
|
+
adminKey: adminPublicKey,
|
|
112
|
+
submitKey: submitPublicKey,
|
|
113
|
+
operatorPublicKey: this.operatorCtx.operatorKey.publicKey
|
|
114
|
+
});
|
|
115
|
+
const frozenTx = await transaction.freezeWith(this.client);
|
|
116
|
+
if (adminKeyPrivate) {
|
|
117
|
+
await frozenTx.sign(adminKeyPrivate);
|
|
118
|
+
}
|
|
119
|
+
if (submitKeyPrivate) {
|
|
120
|
+
await frozenTx.sign(submitKeyPrivate);
|
|
98
121
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
122
|
+
const txResponse = await frozenTx.execute(this.client);
|
|
123
|
+
const receipt = await txResponse.getReceipt(this.client);
|
|
124
|
+
const topicId = receipt.topicId;
|
|
125
|
+
if (!topicId) {
|
|
101
126
|
throw new Error("Failed to create registry: No topic ID in receipt");
|
|
102
127
|
}
|
|
103
|
-
const
|
|
128
|
+
const topicIdStr = topicId.toString();
|
|
129
|
+
this.registryTypeCache.set(topicIdStr, registryType);
|
|
104
130
|
this.logger.info(
|
|
105
|
-
`Created registry topic: ${
|
|
131
|
+
`Created registry topic: ${topicIdStr} (${registryType === HCS2RegistryType.INDEXED ? "Indexed" : "Non-indexed"}, TTL: ${ttl}s)`
|
|
106
132
|
);
|
|
107
133
|
return {
|
|
108
134
|
success: true,
|
|
109
|
-
topicId,
|
|
110
|
-
transactionId: txResponse.transactionId
|
|
135
|
+
topicId: topicIdStr,
|
|
136
|
+
transactionId: txResponse.transactionId.toString()
|
|
111
137
|
};
|
|
112
138
|
} catch (error) {
|
|
113
139
|
this.logger.error(`Failed to create registry: ${error}`);
|
|
@@ -121,23 +147,28 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
121
147
|
* Register a new entry in the registry
|
|
122
148
|
* @param registryTopicId The topic ID of the registry
|
|
123
149
|
* @param options Registration options
|
|
150
|
+
* @param protocol Optional protocol version (defaults to 'hcs-2')
|
|
124
151
|
* @returns Promise resolving to the operation result
|
|
125
152
|
*/
|
|
126
|
-
async registerEntry(registryTopicId, options) {
|
|
153
|
+
async registerEntry(registryTopicId, options, protocol = "hcs-2") {
|
|
127
154
|
try {
|
|
155
|
+
await this.ensureInitialized();
|
|
128
156
|
const message = this.createRegisterMessage(
|
|
129
157
|
options.targetTopicId,
|
|
130
158
|
options.metadata,
|
|
131
|
-
options.memo
|
|
159
|
+
options.memo,
|
|
160
|
+
protocol
|
|
161
|
+
);
|
|
162
|
+
const registryType = options.registryType ?? await this.resolveRegistryType(registryTopicId);
|
|
163
|
+
this.registryTypeCache.set(registryTopicId, registryType);
|
|
164
|
+
const analyticsMemo = options.analyticsMemo ?? this.buildAnalyticsMemo(HCS2Operation.REGISTER, registryType);
|
|
165
|
+
const receipt = await this.submitMessage(
|
|
166
|
+
registryTopicId,
|
|
167
|
+
message,
|
|
168
|
+
analyticsMemo
|
|
132
169
|
);
|
|
133
|
-
if (message.op !== HCS2Operation.REGISTER) {
|
|
134
|
-
throw new Error(
|
|
135
|
-
`Invalid operation type: ${message.op}, expected ${HCS2Operation.REGISTER}`
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
const receipt = await this.submitMessage(registryTopicId, message);
|
|
139
170
|
this.logger.info(
|
|
140
|
-
`Registered entry in registry ${registryTopicId} pointing to topic ${options.targetTopicId}`
|
|
171
|
+
`Registered entry in registry ${registryTopicId} pointing to topic ${options.targetTopicId} using protocol ${protocol}`
|
|
141
172
|
);
|
|
142
173
|
return {
|
|
143
174
|
success: true,
|
|
@@ -160,6 +191,7 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
160
191
|
*/
|
|
161
192
|
async updateEntry(registryTopicId, options) {
|
|
162
193
|
try {
|
|
194
|
+
await this.ensureInitialized();
|
|
163
195
|
const registryInfo = await this.mirrorNode.getTopicInfo(registryTopicId);
|
|
164
196
|
const memoInfo = this.parseRegistryTypeFromMemo(registryInfo.memo);
|
|
165
197
|
if (!memoInfo || memoInfo.registryType !== HCS2RegistryType.INDEXED) {
|
|
@@ -173,7 +205,14 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
173
205
|
options.metadata,
|
|
174
206
|
options.memo
|
|
175
207
|
);
|
|
176
|
-
const
|
|
208
|
+
const registryType = options.registryType ?? await this.resolveRegistryType(registryTopicId);
|
|
209
|
+
this.registryTypeCache.set(registryTopicId, registryType);
|
|
210
|
+
const analyticsMemo = options.analyticsMemo ?? this.buildAnalyticsMemo(HCS2Operation.UPDATE, registryType);
|
|
211
|
+
const receipt = await this.submitMessage(
|
|
212
|
+
registryTopicId,
|
|
213
|
+
message,
|
|
214
|
+
analyticsMemo
|
|
215
|
+
);
|
|
177
216
|
this.logger.info(
|
|
178
217
|
`Updated entry with UID ${options.uid} in registry ${registryTopicId}`
|
|
179
218
|
);
|
|
@@ -184,10 +223,7 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
184
223
|
};
|
|
185
224
|
} catch (error) {
|
|
186
225
|
this.logger.error(`Failed to update entry: ${error}`);
|
|
187
|
-
|
|
188
|
-
success: false,
|
|
189
|
-
error: `Failed to update entry: ${error}`
|
|
190
|
-
};
|
|
226
|
+
throw error;
|
|
191
227
|
}
|
|
192
228
|
}
|
|
193
229
|
/**
|
|
@@ -198,6 +234,7 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
198
234
|
*/
|
|
199
235
|
async deleteEntry(registryTopicId, options) {
|
|
200
236
|
try {
|
|
237
|
+
await this.ensureInitialized();
|
|
201
238
|
const registryInfo = await this.mirrorNode.getTopicInfo(registryTopicId);
|
|
202
239
|
const memoInfo = this.parseRegistryTypeFromMemo(registryInfo.memo);
|
|
203
240
|
if (!memoInfo || memoInfo.registryType !== HCS2RegistryType.INDEXED) {
|
|
@@ -206,7 +243,14 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
206
243
|
);
|
|
207
244
|
}
|
|
208
245
|
const message = this.createDeleteMessage(options.uid, options.memo);
|
|
209
|
-
const
|
|
246
|
+
const registryType = options.registryType ?? await this.resolveRegistryType(registryTopicId);
|
|
247
|
+
this.registryTypeCache.set(registryTopicId, registryType);
|
|
248
|
+
const analyticsMemo = options.analyticsMemo ?? this.buildAnalyticsMemo(HCS2Operation.DELETE, registryType);
|
|
249
|
+
const receipt = await this.submitMessage(
|
|
250
|
+
registryTopicId,
|
|
251
|
+
message,
|
|
252
|
+
analyticsMemo
|
|
253
|
+
);
|
|
210
254
|
this.logger.info(
|
|
211
255
|
`Deleted entry with UID ${options.uid} from registry ${registryTopicId}`
|
|
212
256
|
);
|
|
@@ -217,10 +261,7 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
217
261
|
};
|
|
218
262
|
} catch (error) {
|
|
219
263
|
this.logger.error(`Failed to delete entry: ${error}`);
|
|
220
|
-
|
|
221
|
-
success: false,
|
|
222
|
-
error: `Failed to delete entry: ${error}`
|
|
223
|
-
};
|
|
264
|
+
throw error;
|
|
224
265
|
}
|
|
225
266
|
}
|
|
226
267
|
/**
|
|
@@ -231,12 +272,20 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
231
272
|
*/
|
|
232
273
|
async migrateRegistry(registryTopicId, options) {
|
|
233
274
|
try {
|
|
275
|
+
await this.ensureInitialized();
|
|
234
276
|
const message = this.createMigrateMessage(
|
|
235
277
|
options.targetTopicId,
|
|
236
278
|
options.metadata,
|
|
237
279
|
options.memo
|
|
238
280
|
);
|
|
239
|
-
const
|
|
281
|
+
const registryType = options.registryType ?? await this.resolveRegistryType(registryTopicId);
|
|
282
|
+
this.registryTypeCache.set(registryTopicId, registryType);
|
|
283
|
+
const analyticsMemo = options.analyticsMemo ?? this.buildAnalyticsMemo(HCS2Operation.MIGRATE, registryType);
|
|
284
|
+
const receipt = await this.submitMessage(
|
|
285
|
+
registryTopicId,
|
|
286
|
+
message,
|
|
287
|
+
analyticsMemo
|
|
288
|
+
);
|
|
240
289
|
this.logger.info(
|
|
241
290
|
`Migrated registry ${registryTopicId} to ${options.targetTopicId}`
|
|
242
291
|
);
|
|
@@ -247,10 +296,7 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
247
296
|
};
|
|
248
297
|
} catch (error) {
|
|
249
298
|
this.logger.error(`Failed to migrate registry: ${error}`);
|
|
250
|
-
|
|
251
|
-
success: false,
|
|
252
|
-
error: `Failed to migrate registry: ${error}`
|
|
253
|
-
};
|
|
299
|
+
throw error;
|
|
254
300
|
}
|
|
255
301
|
}
|
|
256
302
|
/**
|
|
@@ -261,67 +307,246 @@ class BrowserHCS2Client extends HCS2BaseClient {
|
|
|
261
307
|
*/
|
|
262
308
|
async getRegistry(topicId, options = {}) {
|
|
263
309
|
try {
|
|
310
|
+
await this.ensureInitialized();
|
|
264
311
|
const topicInfo = await this.mirrorNode.getTopicInfo(topicId);
|
|
312
|
+
this.logger.debug(
|
|
313
|
+
`Retrieved topic info for ${topicId}: ${JSON.stringify(topicInfo)}`
|
|
314
|
+
);
|
|
265
315
|
const memoInfo = this.parseRegistryTypeFromMemo(topicInfo.memo);
|
|
266
316
|
if (!memoInfo) {
|
|
267
317
|
throw new Error(
|
|
268
318
|
`Topic ${topicId} is not an HCS-2 registry (invalid memo format)`
|
|
269
319
|
);
|
|
270
320
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
276
|
-
const messages = options.limit ? messagesResult.slice(0, options.limit) : messagesResult;
|
|
277
|
-
return this.parseRegistryEntries(
|
|
321
|
+
this.logger.debug(
|
|
322
|
+
`Retrieving messages for topic ${topicId} with limit ${options.limit ?? 100}`
|
|
323
|
+
);
|
|
324
|
+
const rawMessagesResult = await this.mirrorNode.getTopicMessages(
|
|
278
325
|
topicId,
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
326
|
+
{
|
|
327
|
+
sequenceNumber: options.skip && options.skip > 0 ? `gt:${options.skip}` : void 0,
|
|
328
|
+
limit: options.limit ?? 100,
|
|
329
|
+
order: options.order ?? "asc"
|
|
330
|
+
}
|
|
282
331
|
);
|
|
332
|
+
const rawMessages = options.limit ? rawMessagesResult.slice(0, options.limit) : rawMessagesResult;
|
|
333
|
+
this.logger.debug(
|
|
334
|
+
`Retrieved ${rawMessagesResult.length} messages, using ${rawMessages.length} after applying limit.`
|
|
335
|
+
);
|
|
336
|
+
const entries = [];
|
|
337
|
+
let latestEntry;
|
|
338
|
+
for (const msg of rawMessages) {
|
|
339
|
+
try {
|
|
340
|
+
let message;
|
|
341
|
+
message = {
|
|
342
|
+
p: msg.p || "hcs-2",
|
|
343
|
+
op: msg.op,
|
|
344
|
+
t_id: msg.t_id,
|
|
345
|
+
uid: msg.uid,
|
|
346
|
+
metadata: msg.metadata,
|
|
347
|
+
m: msg.m
|
|
348
|
+
};
|
|
349
|
+
if (options.resolveOverflow && typeof msg.metadata === "string" && HCS1_HRL_PATTERN.test(msg.metadata)) {
|
|
350
|
+
const hrlMatch = msg.metadata.match(HCS1_HRL_PATTERN);
|
|
351
|
+
if (hrlMatch) {
|
|
352
|
+
const refTopicId = hrlMatch[1];
|
|
353
|
+
try {
|
|
354
|
+
const refMessages = await this.mirrorNode.getTopicMessages(refTopicId);
|
|
355
|
+
if (refMessages.length > 0) {
|
|
356
|
+
const resolvedMsg = refMessages[0];
|
|
357
|
+
message = {
|
|
358
|
+
p: resolvedMsg.p || "hcs-2",
|
|
359
|
+
op: resolvedMsg.op,
|
|
360
|
+
t_id: resolvedMsg.t_id,
|
|
361
|
+
uid: resolvedMsg.uid,
|
|
362
|
+
metadata: resolvedMsg.metadata,
|
|
363
|
+
m: resolvedMsg.m
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
} catch (resolveErr) {
|
|
367
|
+
this.logger.warn(
|
|
368
|
+
`Failed to resolve overflow ${msg.metadata}: ${resolveErr}`
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const { valid, errors } = this.validateMessage(message);
|
|
374
|
+
if (!valid) {
|
|
375
|
+
this.logger.warn(`Invalid HCS-2 message: ${errors.join(", ")}`);
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
const entry = {
|
|
379
|
+
topicId,
|
|
380
|
+
sequence: msg.sequence_number,
|
|
381
|
+
timestamp: msg.consensus_timestamp,
|
|
382
|
+
payer: msg.payer_account_id || msg.payer || "",
|
|
383
|
+
message,
|
|
384
|
+
consensus_timestamp: msg.consensus_timestamp,
|
|
385
|
+
registry_type: memoInfo.registryType
|
|
386
|
+
};
|
|
387
|
+
entries.push(entry);
|
|
388
|
+
if (memoInfo.registryType === HCS2RegistryType.NON_INDEXED || !latestEntry || entry.timestamp > latestEntry.timestamp) {
|
|
389
|
+
latestEntry = entry;
|
|
390
|
+
}
|
|
391
|
+
} catch (error) {
|
|
392
|
+
this.logger.warn(`Error processing message: ${error}`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
this.logger.debug(
|
|
396
|
+
`Processed ${entries.length} valid entries for registry ${topicId}`
|
|
397
|
+
);
|
|
398
|
+
const registry = {
|
|
399
|
+
topicId,
|
|
400
|
+
registryType: memoInfo.registryType,
|
|
401
|
+
ttl: memoInfo.ttl,
|
|
402
|
+
entries: memoInfo.registryType === HCS2RegistryType.INDEXED ? entries : latestEntry ? [latestEntry] : [],
|
|
403
|
+
latestEntry
|
|
404
|
+
};
|
|
405
|
+
return registry;
|
|
283
406
|
} catch (error) {
|
|
284
407
|
this.logger.error(`Failed to get registry: ${error}`);
|
|
285
408
|
throw error;
|
|
286
409
|
}
|
|
287
410
|
}
|
|
411
|
+
buildAnalyticsMemo(operation, registryType) {
|
|
412
|
+
const opCode = _HCS2Client.operationAnalyticsCode[operation];
|
|
413
|
+
return `hcs-2:op:${opCode}:${registryType}`;
|
|
414
|
+
}
|
|
415
|
+
async resolveRegistryType(topicId) {
|
|
416
|
+
const cached = this.registryTypeCache.get(topicId);
|
|
417
|
+
if (cached !== void 0) {
|
|
418
|
+
return cached;
|
|
419
|
+
}
|
|
420
|
+
const topicInfo = await this.mirrorNode.getTopicInfo(topicId);
|
|
421
|
+
const memoInfo = this.parseRegistryTypeFromMemo(topicInfo.memo);
|
|
422
|
+
if (!memoInfo) {
|
|
423
|
+
throw new Error(
|
|
424
|
+
`Topic ${topicId} is not an HCS-2 registry (invalid memo format)`
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
this.registryTypeCache.set(topicId, memoInfo.registryType);
|
|
428
|
+
return memoInfo.registryType;
|
|
429
|
+
}
|
|
288
430
|
/**
|
|
289
|
-
* Submit a message to a topic
|
|
431
|
+
* Submit a message to a topic.
|
|
432
|
+
* If the serialized payload exceeds 1024 bytes, the full message is
|
|
433
|
+
* inscribed via HCS-1 (using the Inscriber) and a compact overflow
|
|
434
|
+
* wrapper containing the HRL reference + SHA-256 digest is submitted
|
|
435
|
+
* instead.
|
|
290
436
|
* @param topicId The topic ID to submit to
|
|
291
437
|
* @param payload The message payload
|
|
438
|
+
* @param analyticsMemo Optional analytics memo for the transaction
|
|
292
439
|
* @returns Promise resolving to the transaction receipt
|
|
293
440
|
*/
|
|
294
|
-
async submitMessage(topicId, payload) {
|
|
441
|
+
async submitMessage(topicId, payload, analyticsMemo) {
|
|
295
442
|
try {
|
|
443
|
+
await this.ensureInitialized();
|
|
296
444
|
const { valid, errors } = this.validateMessage(payload);
|
|
297
445
|
if (!valid) {
|
|
298
446
|
throw new Error(`Invalid HCS-2 message: ${errors.join(", ")}`);
|
|
299
447
|
}
|
|
448
|
+
let messageString = JSON.stringify(payload);
|
|
449
|
+
if (Buffer.byteLength(messageString, "utf8") > MAX_PAYLOAD_BYTES) {
|
|
450
|
+
this.logger.info(
|
|
451
|
+
`HCS-2 payload exceeds ${MAX_PAYLOAD_BYTES} bytes, inscribing via HCS-1`
|
|
452
|
+
);
|
|
453
|
+
const contentBuffer = Buffer.from(messageString, "utf8");
|
|
454
|
+
const fileName = `hcs2-overflow-${randomUUID()}.json`;
|
|
455
|
+
if (this.network !== "testnet" && this.network !== "mainnet") {
|
|
456
|
+
throw new Error(
|
|
457
|
+
`Overflow inscription is only supported on testnet and mainnet, but network is ${this.network}`
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
const authOptions = {
|
|
461
|
+
accountId: this.operatorId.toString(),
|
|
462
|
+
privateKey: this.operatorCtx.operatorKey,
|
|
463
|
+
network: this.network
|
|
464
|
+
};
|
|
465
|
+
if (!this.inscriptionSDK) {
|
|
466
|
+
this.inscriptionSDK = await InscriptionSDK.createWithAuth({
|
|
467
|
+
type: "server",
|
|
468
|
+
...authOptions
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
const inscriptionResult = await inscribe(
|
|
472
|
+
{
|
|
473
|
+
type: "buffer",
|
|
474
|
+
buffer: contentBuffer,
|
|
475
|
+
fileName,
|
|
476
|
+
mimeType: "application/json"
|
|
477
|
+
},
|
|
478
|
+
authOptions,
|
|
479
|
+
{
|
|
480
|
+
mode: "file",
|
|
481
|
+
waitForConfirmation: true,
|
|
482
|
+
waitMaxAttempts: 30,
|
|
483
|
+
waitIntervalMs: 4e3
|
|
484
|
+
},
|
|
485
|
+
this.inscriptionSDK
|
|
486
|
+
);
|
|
487
|
+
const inscriptionTopicId = getTopicId(inscriptionResult?.inscription);
|
|
488
|
+
if (!inscriptionTopicId) {
|
|
489
|
+
throw new Error(
|
|
490
|
+
"Failed to inscribe overflow HCS-2 payload: no topic ID returned"
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
const hrl = `hcs://1/${inscriptionTopicId}`;
|
|
494
|
+
const overflowMessage = {
|
|
495
|
+
...payload,
|
|
496
|
+
metadata: hrl
|
|
497
|
+
};
|
|
498
|
+
this.logger.info(
|
|
499
|
+
`HCS-2 payload inscribed to ${hrl}, submitting overflow wrapper`
|
|
500
|
+
);
|
|
501
|
+
messageString = JSON.stringify(overflowMessage);
|
|
502
|
+
}
|
|
300
503
|
const transaction = buildMessageTx({
|
|
301
504
|
topicId,
|
|
302
|
-
message:
|
|
505
|
+
message: messageString,
|
|
506
|
+
transactionMemo: analyticsMemo
|
|
303
507
|
});
|
|
304
|
-
const txResponse = await this.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
return txResponse.result;
|
|
508
|
+
const txResponse = await transaction.execute(this.client);
|
|
509
|
+
const receipt = await txResponse.getReceipt(this.client);
|
|
510
|
+
return receipt;
|
|
309
511
|
} catch (error) {
|
|
310
512
|
this.logger.error(`Failed to submit message: ${error}`);
|
|
311
513
|
throw error;
|
|
312
514
|
}
|
|
313
515
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
516
|
+
/**
|
|
517
|
+
* @param topicId The topic ID to query
|
|
518
|
+
* @returns Promise resolving to the topic information
|
|
519
|
+
*/
|
|
520
|
+
async getTopicInfo(topicId) {
|
|
521
|
+
return this.mirrorNode.getTopicInfo(topicId);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Close the client and release resources
|
|
525
|
+
*/
|
|
526
|
+
close() {
|
|
527
|
+
this.logger.info("HCS-2 client closed.");
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Get the configured key type (ed25519 or ecdsa)
|
|
531
|
+
*/
|
|
532
|
+
getKeyType() {
|
|
533
|
+
return this.operatorCtx.keyType;
|
|
322
534
|
}
|
|
323
|
-
|
|
535
|
+
/**
|
|
536
|
+
* Get the configured operator private key
|
|
537
|
+
*/
|
|
538
|
+
getOperatorKey() {
|
|
539
|
+
return this.operatorCtx.operatorKey;
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
_HCS2Client.operationAnalyticsCode = {
|
|
543
|
+
[HCS2Operation.REGISTER]: 0,
|
|
544
|
+
[HCS2Operation.UPDATE]: 1,
|
|
545
|
+
[HCS2Operation.DELETE]: 2,
|
|
546
|
+
[HCS2Operation.MIGRATE]: 3
|
|
547
|
+
};
|
|
548
|
+
let HCS2Client = _HCS2Client;
|
|
324
549
|
export {
|
|
325
|
-
|
|
550
|
+
HCS2Client
|
|
326
551
|
};
|
|
327
552
|
//# sourceMappingURL=standards-sdk.es75.js.map
|