@hashgraphonline/standards-sdk 0.1.147 → 0.1.148

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 (180) hide show
  1. package/dist/cjs/hcs-3/src/types.d.ts +64 -0
  2. package/dist/cjs/hcs-3/src/types.d.ts.map +1 -0
  3. package/dist/cjs/inscribe/inscriber.d.ts.map +1 -1
  4. package/dist/cjs/services/registry-broker/client/adapters.d.ts +15 -18
  5. package/dist/cjs/services/registry-broker/client/adapters.d.ts.map +1 -1
  6. package/dist/cjs/services/registry-broker/client/agents.d.ts +11 -14
  7. package/dist/cjs/services/registry-broker/client/agents.d.ts.map +1 -1
  8. package/dist/cjs/services/registry-broker/client/base-client.d.ts +100 -1
  9. package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
  10. package/dist/cjs/services/registry-broker/client/chat-history.d.ts +8 -12
  11. package/dist/cjs/services/registry-broker/client/chat-history.d.ts.map +1 -1
  12. package/dist/cjs/services/registry-broker/client/chat.d.ts +29 -30
  13. package/dist/cjs/services/registry-broker/client/chat.d.ts.map +1 -1
  14. package/dist/cjs/services/registry-broker/client/credits.d.ts +14 -18
  15. package/dist/cjs/services/registry-broker/client/credits.d.ts.map +1 -1
  16. package/dist/cjs/services/registry-broker/client/encrypted-chat-manager.d.ts +0 -5
  17. package/dist/cjs/services/registry-broker/client/encrypted-chat-manager.d.ts.map +1 -1
  18. package/dist/cjs/services/registry-broker/client/encryption.d.ts +32 -30
  19. package/dist/cjs/services/registry-broker/client/encryption.d.ts.map +1 -1
  20. package/dist/cjs/services/registry-broker/client/ledger-auth.d.ts +5 -8
  21. package/dist/cjs/services/registry-broker/client/ledger-auth.d.ts.map +1 -1
  22. package/dist/cjs/services/registry-broker/client/search.d.ts +14 -17
  23. package/dist/cjs/services/registry-broker/client/search.d.ts.map +1 -1
  24. package/dist/cjs/services/registry-broker/schemas.d.ts +9 -9
  25. package/dist/cjs/services/registry-broker/types.d.ts +1 -0
  26. package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
  27. package/dist/cjs/standards-sdk.cjs +3 -3
  28. package/dist/cjs/standards-sdk.cjs.map +1 -1
  29. package/dist/es/hcs-3/src/types.d.ts +64 -0
  30. package/dist/es/hcs-3/src/types.d.ts.map +1 -0
  31. package/dist/es/inscribe/inscriber.d.ts.map +1 -1
  32. package/dist/es/services/registry-broker/client/adapters.d.ts +15 -18
  33. package/dist/es/services/registry-broker/client/adapters.d.ts.map +1 -1
  34. package/dist/es/services/registry-broker/client/agents.d.ts +11 -14
  35. package/dist/es/services/registry-broker/client/agents.d.ts.map +1 -1
  36. package/dist/es/services/registry-broker/client/base-client.d.ts +100 -1
  37. package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
  38. package/dist/es/services/registry-broker/client/chat-history.d.ts +8 -12
  39. package/dist/es/services/registry-broker/client/chat-history.d.ts.map +1 -1
  40. package/dist/es/services/registry-broker/client/chat.d.ts +29 -30
  41. package/dist/es/services/registry-broker/client/chat.d.ts.map +1 -1
  42. package/dist/es/services/registry-broker/client/credits.d.ts +14 -18
  43. package/dist/es/services/registry-broker/client/credits.d.ts.map +1 -1
  44. package/dist/es/services/registry-broker/client/encrypted-chat-manager.d.ts +0 -5
  45. package/dist/es/services/registry-broker/client/encrypted-chat-manager.d.ts.map +1 -1
  46. package/dist/es/services/registry-broker/client/encryption.d.ts +32 -30
  47. package/dist/es/services/registry-broker/client/encryption.d.ts.map +1 -1
  48. package/dist/es/services/registry-broker/client/ledger-auth.d.ts +5 -8
  49. package/dist/es/services/registry-broker/client/ledger-auth.d.ts.map +1 -1
  50. package/dist/es/services/registry-broker/client/search.d.ts +14 -17
  51. package/dist/es/services/registry-broker/client/search.d.ts.map +1 -1
  52. package/dist/es/services/registry-broker/schemas.d.ts +9 -9
  53. package/dist/es/services/registry-broker/types.d.ts +1 -0
  54. package/dist/es/services/registry-broker/types.d.ts.map +1 -1
  55. package/dist/es/standards-sdk.es.js +13 -16
  56. package/dist/es/standards-sdk.es.js.map +1 -1
  57. package/dist/es/standards-sdk.es101.js +1 -1
  58. package/dist/es/standards-sdk.es103.js +1 -1
  59. package/dist/es/standards-sdk.es109.js +3 -10
  60. package/dist/es/standards-sdk.es109.js.map +1 -1
  61. package/dist/es/standards-sdk.es11.js +1 -1
  62. package/dist/es/standards-sdk.es110.js +5 -5
  63. package/dist/es/standards-sdk.es12.js +1 -1
  64. package/dist/es/standards-sdk.es120.js +1 -1
  65. package/dist/es/standards-sdk.es121.js +1 -1
  66. package/dist/es/standards-sdk.es122.js +5 -5
  67. package/dist/es/standards-sdk.es124.js +20 -1
  68. package/dist/es/standards-sdk.es124.js.map +1 -1
  69. package/dist/es/standards-sdk.es125.js +1 -1
  70. package/dist/es/standards-sdk.es127.js +960 -178
  71. package/dist/es/standards-sdk.es127.js.map +1 -1
  72. package/dist/es/standards-sdk.es128.js +15 -205
  73. package/dist/es/standards-sdk.es128.js.map +1 -1
  74. package/dist/es/standards-sdk.es129.js +79 -96
  75. package/dist/es/standards-sdk.es129.js.map +1 -1
  76. package/dist/es/standards-sdk.es130.js +72 -112
  77. package/dist/es/standards-sdk.es130.js.map +1 -1
  78. package/dist/es/standards-sdk.es131.js +760 -213
  79. package/dist/es/standards-sdk.es131.js.map +1 -1
  80. package/dist/es/standards-sdk.es132.js +53 -173
  81. package/dist/es/standards-sdk.es132.js.map +1 -1
  82. package/dist/es/standards-sdk.es133.js +156 -119
  83. package/dist/es/standards-sdk.es133.js.map +1 -1
  84. package/dist/es/standards-sdk.es134.js +8 -327
  85. package/dist/es/standards-sdk.es134.js.map +1 -1
  86. package/dist/es/standards-sdk.es135.js +74 -452
  87. package/dist/es/standards-sdk.es135.js.map +1 -1
  88. package/dist/es/standards-sdk.es136.js +61 -13
  89. package/dist/es/standards-sdk.es136.js.map +1 -1
  90. package/dist/es/standards-sdk.es137.js +30 -81
  91. package/dist/es/standards-sdk.es137.js.map +1 -1
  92. package/dist/es/standards-sdk.es138.js +34 -87
  93. package/dist/es/standards-sdk.es138.js.map +1 -1
  94. package/dist/es/standards-sdk.es139.js +28 -60
  95. package/dist/es/standards-sdk.es139.js.map +1 -1
  96. package/dist/es/standards-sdk.es140.js +12263 -133
  97. package/dist/es/standards-sdk.es140.js.map +1 -1
  98. package/dist/es/standards-sdk.es141.js +138 -7
  99. package/dist/es/standards-sdk.es141.js.map +1 -1
  100. package/dist/es/standards-sdk.es142.js +12 -81
  101. package/dist/es/standards-sdk.es142.js.map +1 -1
  102. package/dist/es/standards-sdk.es143.js +35 -58
  103. package/dist/es/standards-sdk.es143.js.map +1 -1
  104. package/dist/es/standards-sdk.es144.js +172 -30
  105. package/dist/es/standards-sdk.es144.js.map +1 -1
  106. package/dist/es/standards-sdk.es145.js +322 -34
  107. package/dist/es/standards-sdk.es145.js.map +1 -1
  108. package/dist/es/standards-sdk.es146.js +346 -28
  109. package/dist/es/standards-sdk.es146.js.map +1 -1
  110. package/dist/es/standards-sdk.es147.js +427 -112
  111. package/dist/es/standards-sdk.es147.js.map +1 -1
  112. package/dist/es/standards-sdk.es148.js +329 -40
  113. package/dist/es/standards-sdk.es148.js.map +1 -1
  114. package/dist/es/standards-sdk.es149.js +69 -49
  115. package/dist/es/standards-sdk.es149.js.map +1 -1
  116. package/dist/es/standards-sdk.es150.js +48 -76
  117. package/dist/es/standards-sdk.es150.js.map +1 -1
  118. package/dist/es/standards-sdk.es151.js +84 -959
  119. package/dist/es/standards-sdk.es151.js.map +1 -1
  120. package/dist/es/standards-sdk.es152.js +169 -14
  121. package/dist/es/standards-sdk.es152.js.map +1 -1
  122. package/dist/es/standards-sdk.es153.js +201 -12268
  123. package/dist/es/standards-sdk.es153.js.map +1 -1
  124. package/dist/es/standards-sdk.es154.js +223 -156
  125. package/dist/es/standards-sdk.es154.js.map +1 -1
  126. package/dist/es/standards-sdk.es155.js +112 -315
  127. package/dist/es/standards-sdk.es155.js.map +1 -1
  128. package/dist/es/standards-sdk.es156.js +116 -336
  129. package/dist/es/standards-sdk.es156.js.map +1 -1
  130. package/dist/es/standards-sdk.es157.js +151 -443
  131. package/dist/es/standards-sdk.es157.js.map +1 -1
  132. package/dist/es/standards-sdk.es158.js +170 -316
  133. package/dist/es/standards-sdk.es158.js.map +1 -1
  134. package/dist/es/standards-sdk.es159.js +132 -69
  135. package/dist/es/standards-sdk.es159.js.map +1 -1
  136. package/dist/es/standards-sdk.es16.js +3 -10
  137. package/dist/es/standards-sdk.es16.js.map +1 -1
  138. package/dist/es/standards-sdk.es160.js +300 -208
  139. package/dist/es/standards-sdk.es160.js.map +1 -1
  140. package/dist/es/standards-sdk.es161.js +16 -1
  141. package/dist/es/standards-sdk.es161.js.map +1 -1
  142. package/dist/es/standards-sdk.es18.js +6 -13
  143. package/dist/es/standards-sdk.es18.js.map +1 -1
  144. package/dist/es/standards-sdk.es19.js +4 -11
  145. package/dist/es/standards-sdk.es19.js.map +1 -1
  146. package/dist/es/standards-sdk.es22.js +1 -1
  147. package/dist/es/standards-sdk.es27.js +6 -13
  148. package/dist/es/standards-sdk.es27.js.map +1 -1
  149. package/dist/es/standards-sdk.es30.js +1 -1
  150. package/dist/es/standards-sdk.es31.js +1 -1
  151. package/dist/es/standards-sdk.es35.js +5 -11
  152. package/dist/es/standards-sdk.es35.js.map +1 -1
  153. package/dist/es/standards-sdk.es36.js +3 -3
  154. package/dist/es/standards-sdk.es37.js +1 -1
  155. package/dist/es/standards-sdk.es4.js +1 -1
  156. package/dist/es/standards-sdk.es53.js +1 -1
  157. package/dist/es/standards-sdk.es56.js +1 -1
  158. package/dist/es/standards-sdk.es58.js +1 -1
  159. package/dist/es/standards-sdk.es59.js +1 -1
  160. package/dist/es/standards-sdk.es60.js +4 -11
  161. package/dist/es/standards-sdk.es60.js.map +1 -1
  162. package/dist/es/standards-sdk.es62.js +1 -1
  163. package/dist/es/standards-sdk.es64.js +1 -1
  164. package/dist/es/standards-sdk.es65.js +2 -2
  165. package/dist/es/standards-sdk.es68.js +2 -2
  166. package/dist/es/standards-sdk.es69.js +1 -1
  167. package/dist/es/standards-sdk.es7.js +1 -1
  168. package/dist/es/standards-sdk.es71.js +1 -1
  169. package/dist/es/standards-sdk.es76.js +1 -1
  170. package/dist/es/standards-sdk.es77.js +3 -10
  171. package/dist/es/standards-sdk.es77.js.map +1 -1
  172. package/dist/es/standards-sdk.es78.js +1 -1
  173. package/dist/es/standards-sdk.es81.js +1 -1
  174. package/dist/es/standards-sdk.es83.js +1 -1
  175. package/dist/es/standards-sdk.es87.js +3 -3
  176. package/dist/es/standards-sdk.es91.js +1 -1
  177. package/dist/es/standards-sdk.es92.js +1 -1
  178. package/dist/es/standards-sdk.es97.js +1 -1
  179. package/dist/es/standards-sdk.es99.js +1 -1
  180. package/package.json +2 -1
@@ -1,10 +1,141 @@
1
- var CustomFeeType = /* @__PURE__ */ ((CustomFeeType2) => {
2
- CustomFeeType2["FIXED_FEE"] = "FIXED_FEE";
3
- CustomFeeType2["FRACTIONAL_FEE"] = "FRACTIONAL_FEE";
4
- CustomFeeType2["ROYALTY_FEE"] = "ROYALTY_FEE";
5
- return CustomFeeType2;
6
- })(CustomFeeType || {});
1
+ import { AccountId, Client, PrivateKey } from "@hashgraph/sdk";
2
+ import { detectKeyTypeFromString } from "./standards-sdk.es113.js";
3
+ class NodeOperatorResolver {
4
+ constructor(params) {
5
+ this.mirror = params.mirrorNode;
6
+ this.logger = params.logger;
7
+ }
8
+ /**
9
+ * Best-guess parsing for an operator key without network calls.
10
+ * - If PrivateKey: returns immediately with provided or fallback type.
11
+ * - If string with explicitType: parse directly.
12
+ * - If string without type: detect format; fallback to ECDSA.
13
+ */
14
+ bestGuessOperatorKey(operatorKeyInput, explicitType) {
15
+ if (typeof operatorKeyInput !== "string") {
16
+ return { keyType: explicitType || "ecdsa", privateKey: operatorKeyInput };
17
+ }
18
+ if (explicitType) {
19
+ const pk = explicitType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
20
+ return { keyType: explicitType, privateKey: pk };
21
+ }
22
+ try {
23
+ const detected = detectKeyTypeFromString(operatorKeyInput);
24
+ return {
25
+ keyType: detected.detectedType,
26
+ privateKey: detected.privateKey
27
+ };
28
+ } catch {
29
+ return {
30
+ keyType: "ecdsa",
31
+ privateKey: PrivateKey.fromStringECDSA(operatorKeyInput)
32
+ };
33
+ }
34
+ }
35
+ /**
36
+ * Resolve an operator key using Mirror Node for key type when possible.
37
+ * - If PrivateKey: return immediately.
38
+ * - If explicitType: parse directly.
39
+ * - Else: query Mirror Node; fallback to local detection.
40
+ */
41
+ async resolveOperatorKey(operatorId, operatorKeyInput, explicitType) {
42
+ if (typeof operatorKeyInput !== "string") {
43
+ return { keyType: explicitType || "ecdsa", privateKey: operatorKeyInput };
44
+ }
45
+ if (explicitType) {
46
+ const pk = explicitType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
47
+ return { keyType: explicitType, privateKey: pk };
48
+ }
49
+ const account = typeof operatorId === "string" ? operatorId : operatorId.toString();
50
+ try {
51
+ const info = await this.mirror.requestAccount(account);
52
+ const t = info?.key?._type || "";
53
+ const keyType = t.includes("ED25519") ? "ed25519" : "ecdsa";
54
+ const privateKey = keyType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
55
+ return { keyType, privateKey };
56
+ } catch {
57
+ this.logger.warn(
58
+ "Mirror node key detection failed; using local detection or default ECDSA"
59
+ );
60
+ return this.bestGuessOperatorKey(operatorKeyInput);
61
+ }
62
+ }
63
+ /**
64
+ * Resolve a supply key for the given token using Mirror Node token supply_key._type when possible.
65
+ */
66
+ async resolveSupplyKey(tokenId, keyInput, fallbackType, explicitType) {
67
+ try {
68
+ const info = await this.mirror.getTokenInfo(tokenId);
69
+ const t = info?.supply_key?._type || "";
70
+ if (typeof keyInput !== "string") {
71
+ return keyInput;
72
+ }
73
+ if (explicitType) {
74
+ return explicitType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
75
+ }
76
+ if (t.includes("ED25519")) {
77
+ return PrivateKey.fromStringED25519(keyInput);
78
+ }
79
+ if (t.includes("ECDSA")) {
80
+ return PrivateKey.fromStringECDSA(keyInput);
81
+ }
82
+ return fallbackType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
83
+ } catch {
84
+ if (typeof keyInput !== "string") {
85
+ return keyInput;
86
+ }
87
+ if (explicitType) {
88
+ return explicitType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
89
+ }
90
+ return fallbackType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
91
+ }
92
+ }
93
+ }
94
+ function createNodeOperatorContext(params) {
95
+ const operatorId = typeof params.operatorId === "string" ? AccountId.fromString(params.operatorId) : params.operatorId;
96
+ const client = params.client ? params.client : params.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
97
+ const resolver = new NodeOperatorResolver({
98
+ mirrorNode: params.mirrorNode,
99
+ logger: params.logger
100
+ });
101
+ let currentKeyType;
102
+ let currentPrivateKey;
103
+ const guess = resolver.bestGuessOperatorKey(
104
+ params.operatorKey,
105
+ params.keyType
106
+ );
107
+ currentKeyType = guess.keyType;
108
+ currentPrivateKey = guess.privateKey;
109
+ client.setOperator(operatorId.toString(), currentPrivateKey);
110
+ const initPromise = (async () => {
111
+ try {
112
+ const resolved = await resolver.resolveOperatorKey(
113
+ operatorId,
114
+ params.operatorKey,
115
+ params.keyType
116
+ );
117
+ currentKeyType = resolved.keyType;
118
+ currentPrivateKey = resolved.privateKey;
119
+ client.setOperator(operatorId.toString(), currentPrivateKey);
120
+ } catch {
121
+ }
122
+ })();
123
+ return {
124
+ client,
125
+ operatorId,
126
+ get operatorKey() {
127
+ return currentPrivateKey;
128
+ },
129
+ get keyType() {
130
+ return currentKeyType;
131
+ },
132
+ ensureInitialized: async () => {
133
+ await initPromise;
134
+ }
135
+ };
136
+ }
7
137
  export {
8
- CustomFeeType
138
+ NodeOperatorResolver,
139
+ createNodeOperatorContext
9
140
  };
10
141
  //# sourceMappingURL=standards-sdk.es141.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es141.js","sources":["../../src/fees/types.ts"],"sourcesContent":["export interface FeeConfigBuilderInterface {\n addHbarFee(\n hbarAmount: number,\n collectorAccountId?: string,\n exemptAccountIds?: string[],\n ): FeeConfigBuilderInterface;\n addTokenFee(\n tokenAmount: number,\n feeTokenId: string,\n collectorAccountId?: string,\n decimals?: number,\n exemptAccountIds?: string[],\n ): Promise<FeeConfigBuilderInterface>;\n build(): TopicFeeConfig;\n}\n\nexport enum CustomFeeType {\n FIXED_FEE = 'FIXED_FEE',\n FRACTIONAL_FEE = 'FRACTIONAL_FEE',\n ROYALTY_FEE = 'ROYALTY_FEE',\n}\n\nexport type FeeAmount = {\n amount: number;\n decimals?: number;\n};\n\nexport interface TokenFeeConfig {\n feeAmount: FeeAmount;\n feeCollectorAccountId: string;\n feeTokenId?: string;\n exemptAccounts: string[];\n type: CustomFeeType;\n}\n\nexport interface TopicFeeConfig {\n customFees: TokenFeeConfig[];\n exemptAccounts: string[];\n}\n"],"names":["CustomFeeType"],"mappings":"AAgBO,IAAK,kCAAAA,mBAAL;AACLA,iBAAA,WAAA,IAAY;AACZA,iBAAA,gBAAA,IAAiB;AACjBA,iBAAA,aAAA,IAAc;AAHJ,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"standards-sdk.es141.js","sources":["../../src/common/node-operator-resolver.ts"],"sourcesContent":["import { AccountId, Client, PrivateKey } from '@hashgraph/sdk';\nimport { HederaMirrorNode } from '../services/mirror-node';\nimport { ILogger } from '../utils/logger';\nimport { detectKeyTypeFromString } from '../utils/key-type-detector';\nimport { NetworkType } from '../utils/types';\n\n/**\n * Resolves operator and supply private keys using Mirror Node as source of truth\n * with format-detection fallbacks for string keys.\n */\nexport class NodeOperatorResolver {\n private readonly mirror: HederaMirrorNode;\n private readonly logger: ILogger;\n\n constructor(params: { mirrorNode: HederaMirrorNode; logger: ILogger }) {\n this.mirror = params.mirrorNode;\n this.logger = params.logger;\n }\n\n /**\n * Best-guess parsing for an operator key without network calls.\n * - If PrivateKey: returns immediately with provided or fallback type.\n * - If string with explicitType: parse directly.\n * - If string without type: detect format; fallback to ECDSA.\n */\n bestGuessOperatorKey(\n operatorKeyInput: string | PrivateKey,\n explicitType?: 'ed25519' | 'ecdsa',\n ): { keyType: 'ed25519' | 'ecdsa'; privateKey: PrivateKey } {\n if (typeof operatorKeyInput !== 'string') {\n return { keyType: explicitType || 'ecdsa', privateKey: operatorKeyInput };\n }\n if (explicitType) {\n const pk =\n explicitType === 'ed25519'\n ? PrivateKey.fromStringED25519(operatorKeyInput)\n : PrivateKey.fromStringECDSA(operatorKeyInput);\n return { keyType: explicitType, privateKey: pk };\n }\n try {\n const detected = detectKeyTypeFromString(operatorKeyInput);\n return {\n keyType: detected.detectedType,\n privateKey: detected.privateKey,\n };\n } catch {\n return {\n keyType: 'ecdsa',\n privateKey: PrivateKey.fromStringECDSA(operatorKeyInput),\n };\n }\n }\n\n /**\n * Resolve an operator key using Mirror Node for key type when possible.\n * - If PrivateKey: return immediately.\n * - If explicitType: parse directly.\n * - Else: query Mirror Node; fallback to local detection.\n */\n async resolveOperatorKey(\n operatorId: string | AccountId,\n operatorKeyInput: string | PrivateKey,\n explicitType?: 'ed25519' | 'ecdsa',\n ): Promise<{ keyType: 'ed25519' | 'ecdsa'; privateKey: PrivateKey }> {\n if (typeof operatorKeyInput !== 'string') {\n return { keyType: explicitType || 'ecdsa', privateKey: operatorKeyInput };\n }\n if (explicitType) {\n const pk =\n explicitType === 'ed25519'\n ? PrivateKey.fromStringED25519(operatorKeyInput)\n : PrivateKey.fromStringECDSA(operatorKeyInput);\n return { keyType: explicitType, privateKey: pk };\n }\n const account =\n typeof operatorId === 'string' ? operatorId : operatorId.toString();\n try {\n const info = await this.mirror.requestAccount(account);\n const t = info?.key?._type || '';\n const keyType: 'ed25519' | 'ecdsa' = t.includes('ED25519')\n ? 'ed25519'\n : 'ecdsa';\n const privateKey =\n keyType === 'ed25519'\n ? PrivateKey.fromStringED25519(operatorKeyInput)\n : PrivateKey.fromStringECDSA(operatorKeyInput);\n return { keyType, privateKey };\n } catch {\n this.logger.warn(\n 'Mirror node key detection failed; using local detection or default ECDSA',\n );\n return this.bestGuessOperatorKey(operatorKeyInput);\n }\n }\n\n /**\n * Resolve a supply key for the given token using Mirror Node token supply_key._type when possible.\n */\n async resolveSupplyKey(\n tokenId: string,\n keyInput: string | PrivateKey,\n fallbackType: 'ed25519' | 'ecdsa',\n explicitType?: 'ed25519' | 'ecdsa',\n ): Promise<PrivateKey> {\n try {\n const info = await this.mirror.getTokenInfo(tokenId);\n const t = info?.supply_key?._type || '';\n if (typeof keyInput !== 'string') {\n return keyInput;\n }\n if (explicitType) {\n return explicitType === 'ed25519'\n ? PrivateKey.fromStringED25519(keyInput)\n : PrivateKey.fromStringECDSA(keyInput);\n }\n if (t.includes('ED25519')) {\n return PrivateKey.fromStringED25519(keyInput);\n }\n if (t.includes('ECDSA')) {\n return PrivateKey.fromStringECDSA(keyInput);\n }\n return fallbackType === 'ed25519'\n ? PrivateKey.fromStringED25519(keyInput)\n : PrivateKey.fromStringECDSA(keyInput);\n } catch {\n if (typeof keyInput !== 'string') {\n return keyInput;\n }\n if (explicitType) {\n return explicitType === 'ed25519'\n ? PrivateKey.fromStringED25519(keyInput)\n : PrivateKey.fromStringECDSA(keyInput);\n }\n return fallbackType === 'ed25519'\n ? PrivateKey.fromStringED25519(keyInput)\n : PrivateKey.fromStringECDSA(keyInput);\n }\n }\n}\n\nexport interface NodeOperatorInitParams {\n network: NetworkType;\n operatorId: string | AccountId;\n operatorKey: string | PrivateKey;\n keyType?: 'ed25519' | 'ecdsa';\n mirrorNode: HederaMirrorNode;\n logger: ILogger;\n client?: Client;\n}\n\nexport interface NodeOperatorContext {\n client: Client;\n operatorId: AccountId;\n readonly operatorKey: PrivateKey;\n readonly keyType: 'ed25519' | 'ecdsa';\n ensureInitialized(): Promise<void>;\n}\n\nexport function createNodeOperatorContext(\n params: NodeOperatorInitParams,\n): NodeOperatorContext {\n const operatorId: AccountId =\n typeof params.operatorId === 'string'\n ? AccountId.fromString(params.operatorId)\n : params.operatorId;\n\n const client: Client = params.client\n ? params.client\n : params.network === 'mainnet'\n ? Client.forMainnet()\n : Client.forTestnet();\n\n const resolver = new NodeOperatorResolver({\n mirrorNode: params.mirrorNode,\n logger: params.logger,\n });\n\n let currentKeyType: 'ed25519' | 'ecdsa';\n let currentPrivateKey: PrivateKey;\n\n const guess = resolver.bestGuessOperatorKey(\n params.operatorKey,\n params.keyType,\n );\n currentKeyType = guess.keyType;\n currentPrivateKey = guess.privateKey;\n client.setOperator(operatorId.toString(), currentPrivateKey);\n\n const initPromise = (async () => {\n try {\n const resolved = await resolver.resolveOperatorKey(\n operatorId,\n params.operatorKey,\n params.keyType,\n );\n currentKeyType = resolved.keyType;\n currentPrivateKey = resolved.privateKey;\n client.setOperator(operatorId.toString(), currentPrivateKey);\n } catch {}\n })();\n\n return {\n client,\n operatorId,\n get operatorKey() {\n return currentPrivateKey;\n },\n get keyType() {\n return currentKeyType;\n },\n ensureInitialized: async () => {\n await initPromise;\n },\n };\n}\n"],"names":[],"mappings":";;AAUO,MAAM,qBAAqB;AAAA,EAIhC,YAAY,QAA2D;AACrE,SAAK,SAAS,OAAO;AACrB,SAAK,SAAS,OAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,qBACE,kBACA,cAC0D;AAC1D,QAAI,OAAO,qBAAqB,UAAU;AACxC,aAAO,EAAE,SAAS,gBAAgB,SAAS,YAAY,iBAAA;AAAA,IACzD;AACA,QAAI,cAAc;AAChB,YAAM,KACJ,iBAAiB,YACb,WAAW,kBAAkB,gBA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AAA,QAC9B;AAAA,QACA,OAAO;AAAA,QACP,OAAO;AAAA,MAAA;AAET,uBAAiB,SAAS;AAC1B,0BAAoB,SAAS;AAC7B,aAAO,YAAY,WAAW,SAAA,GAAY,iBAAiB;AAAA,IAC7D,QAAQ;AAAA,IAAC;AAAA,EACX,GAAA;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,cAAc;AAChB,aAAO;AAAA,IACT;AAAA,IACA,IAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAAA,IACA,mBAAmB,YAAY;AAC7B,YAAM;AAAA,IACR;AAAA,EAAA;AAEJ;"}
@@ -1,89 +1,20 @@
1
1
  import { Logger } from "./standards-sdk.es105.js";
2
- class ContentResolverRegistryImpl {
3
- constructor() {
4
- this.resolver = null;
5
- this.onUnavailableCallbacks = [];
6
- this.logger = Logger.getInstance({ module: "ContentResolverRegistry" });
7
- }
8
- static getInstance() {
9
- if (!ContentResolverRegistryImpl._instance) {
10
- ContentResolverRegistryImpl._instance = new ContentResolverRegistryImpl();
11
- }
12
- return ContentResolverRegistryImpl._instance;
13
- }
14
- /**
15
- * Register a content resolver (typically called by ContentStoreManager)
16
- */
17
- register(resolver) {
18
- if (this.resolver) {
19
- this.logger.warn("Resolver already registered, replacing existing");
20
- }
21
- this.resolver = resolver;
22
- this.logger.info("Content resolver registered");
23
- }
24
- /**
25
- * Get the registered content resolver
26
- */
27
- getResolver() {
28
- return this.resolver;
29
- }
30
- /**
31
- * Check if a resolver is available
32
- */
33
- isAvailable() {
34
- return this.resolver !== null;
35
- }
36
- /**
37
- * Unregister the current resolver
38
- */
39
- unregister() {
40
- if (this.resolver) {
41
- this.resolver = null;
42
- this.logger.info("Content resolver unregistered");
43
- this.onUnavailableCallbacks.forEach((callback) => {
44
- try {
45
- callback();
46
- } catch (error) {
47
- this.logger.error("Error in unavailable callback:", error);
48
- }
49
- });
50
- }
51
- }
52
- /**
53
- * Register callback for when resolver becomes unavailable
54
- */
55
- onUnavailable(callback) {
56
- this.onUnavailableCallbacks.push(callback);
57
- }
58
- /**
59
- * Remove unavailable callback
60
- */
61
- offUnavailable(callback) {
62
- const index = this.onUnavailableCallbacks.indexOf(callback);
63
- if (index !== -1) {
64
- this.onUnavailableCallbacks.splice(index, 1);
65
- }
66
- }
2
+ import { HederaMirrorNode } from "./standards-sdk.es126.js";
3
+ class HCS5BaseClient {
67
4
  /**
68
- * Execute operation with resolver or fallback
5
+ * Create a new HCS-5 base client
69
6
  */
70
- async withResolver(operation, fallback) {
71
- if (this.resolver) {
72
- try {
73
- return await operation(this.resolver);
74
- } catch (error) {
75
- this.logger.warn("Resolver operation failed, using fallback:", error);
76
- return await fallback();
77
- }
78
- } else {
79
- this.logger.warn("No resolver available, using fallback");
80
- return await fallback();
81
- }
7
+ constructor(config) {
8
+ this.network = config.network;
9
+ this.logger = config.logger || Logger.getInstance({
10
+ level: config.logLevel || "info",
11
+ module: "HCS5Client",
12
+ silent: config.silent
13
+ });
14
+ this.mirrorNode = new HederaMirrorNode(this.network, this.logger);
82
15
  }
83
16
  }
84
- const ContentResolverRegistry = ContentResolverRegistryImpl.getInstance();
85
17
  export {
86
- ContentResolverRegistry,
87
- ContentResolverRegistryImpl
18
+ HCS5BaseClient
88
19
  };
89
20
  //# sourceMappingURL=standards-sdk.es142.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es142.js","sources":["../../src/content-store/ContentResolverRegistry.ts"],"sourcesContent":["/**\n * Content Resolver Registry\n *\n * Dependency injection registry for content resolvers.\n * Allows tools to access content resolution without circular dependencies.\n */\n\nimport type { ContentResolverInterface } from './types';\nimport { Logger } from '../utils/logger';\n\nexport class ContentResolverRegistryImpl {\n private static _instance: ContentResolverRegistryImpl;\n private resolver: ContentResolverInterface | null = null;\n private onUnavailableCallbacks: (() => void)[] = [];\n private logger = Logger.getInstance({ module: 'ContentResolverRegistry' });\n\n static getInstance(): ContentResolverRegistryImpl {\n if (!ContentResolverRegistryImpl._instance) {\n ContentResolverRegistryImpl._instance = new ContentResolverRegistryImpl();\n }\n return ContentResolverRegistryImpl._instance;\n }\n\n /**\n * Register a content resolver (typically called by ContentStoreManager)\n */\n register(resolver: ContentResolverInterface): void {\n if (this.resolver) {\n this.logger.warn('Resolver already registered, replacing existing');\n }\n this.resolver = resolver;\n this.logger.info('Content resolver registered');\n }\n\n /**\n * Get the registered content resolver\n */\n getResolver(): ContentResolverInterface | null {\n return this.resolver;\n }\n\n /**\n * Check if a resolver is available\n */\n isAvailable(): boolean {\n return this.resolver !== null;\n }\n\n /**\n * Unregister the current resolver\n */\n unregister(): void {\n if (this.resolver) {\n this.resolver = null;\n this.logger.info('Content resolver unregistered');\n this.onUnavailableCallbacks.forEach(callback => {\n try {\n callback();\n } catch (error) {\n this.logger.error('Error in unavailable callback:', error);\n }\n });\n }\n }\n\n /**\n * Register callback for when resolver becomes unavailable\n */\n onUnavailable(callback: () => void): void {\n this.onUnavailableCallbacks.push(callback);\n }\n\n /**\n * Remove unavailable callback\n */\n offUnavailable(callback: () => void): void {\n const index = this.onUnavailableCallbacks.indexOf(callback);\n if (index !== -1) {\n this.onUnavailableCallbacks.splice(index, 1);\n }\n }\n\n /**\n * Execute operation with resolver or fallback\n */\n async withResolver<T>(\n operation: (resolver: ContentResolverInterface) => Promise<T>,\n fallback: () => Promise<T>,\n ): Promise<T> {\n if (this.resolver) {\n try {\n return await operation(this.resolver);\n } catch (error) {\n this.logger.warn('Resolver operation failed, using fallback:', error);\n return await fallback();\n }\n } else {\n this.logger.warn('No resolver available, using fallback');\n return await fallback();\n }\n }\n}\n\nexport const ContentResolverRegistry =\n ContentResolverRegistryImpl.getInstance();\n"],"names":[],"mappings":";AAUO,MAAM,4BAA4B;AAAA,EAAlC,cAAA;AAEL,SAAQ,WAA4C;AACpD,SAAQ,yBAAyC,CAAA;AACjD,SAAQ,SAAS,OAAO,YAAY,EAAE,QAAQ,2BAA2B;AAAA,EAAA;AAAA,EAEzE,OAAO,cAA2C;AAChD,QAAI,CA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CAAuC;AACxD,aAAO,MAAM,SAAA;AAAA,IACf;AAAA,EACF;AACF;AAEO,MAAM,0BACX,4BAA4B,YAAA;"}
1
+ {"version":3,"file":"standards-sdk.es142.js","sources":["../../src/hcs-5/base-client.ts"],"sourcesContent":["import { Logger, ILogger } from '../utils/logger';\nimport { HederaMirrorNode } from '../services/mirror-node';\nimport { HCS5ClientConfig } from './types';\nimport { NetworkType } from '../utils/types';\n\n/**\n * Base client for HCS-5 operations\n */\nexport abstract class HCS5BaseClient {\n protected logger: ILogger;\n protected mirrorNode: HederaMirrorNode;\n protected network: NetworkType;\n\n /**\n * Create a new HCS-5 base client\n */\n constructor(config: HCS5ClientConfig) {\n this.network = config.network;\n this.logger =\n config.logger ||\n Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS5Client',\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(this.network, this.logger);\n }\n}\n"],"names":[],"mappings":";;AAQO,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAY,QAA0B;AACpC,SAAK,UAAU,OAAO;AACtB,SAAK,SACH,OAAO,UACP,OAAO,YAAY;AAAA,MACjB,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IAAA,CAChB;AAEH,SAAK,aAAa,IAAI,iBAAiB,KAAK,SAAS,KAAK,MAAM;AAAA,EAClE;AACF;"}
@@ -1,68 +1,45 @@
1
- import { Logger } from "./standards-sdk.es105.js";
2
- const REFERENCE_THRESHOLD = 50 * 1024;
3
- class ContentStoreServiceImpl {
4
- constructor() {
5
- this.contentStore = null;
6
- this.logger = Logger.getInstance({ module: "ContentStoreService" });
7
- }
8
- static getInstance() {
9
- if (!ContentStoreServiceImpl._instance) {
10
- ContentStoreServiceImpl._instance = new ContentStoreServiceImpl();
1
+ import { TopicMessageSubmitTransaction, TopicId, TopicCreateTransaction, PublicKey, KeyList } from "@hashgraph/sdk";
2
+ function encodeHcs2RegistryMemo(indexedFlag, ttl) {
3
+ return `hcs-2:${indexedFlag}:${ttl}`;
4
+ }
5
+ function buildTopicCreateTx(params) {
6
+ const { memo, adminKey, submitKey, operatorPublicKey } = params;
7
+ const tx = new TopicCreateTransaction().setTopicMemo(memo);
8
+ const coerceKey = (k) => {
9
+ if (!k) return void 0;
10
+ if (k instanceof PublicKey || k instanceof KeyList) return k;
11
+ if (typeof k === "boolean") {
12
+ return k ? operatorPublicKey : void 0;
11
13
  }
12
- return ContentStoreServiceImpl._instance;
13
- }
14
- /**
15
- * Set the content store instance
16
- */
17
- async setInstance(store) {
18
- if (this.contentStore) {
19
- this.logger.warn("Content store already set, replacing");
14
+ if (typeof k === "string") {
15
+ try {
16
+ return PublicKey.fromString(k);
17
+ } catch {
18
+ return void 0;
19
+ }
20
20
  }
21
- this.contentStore = store;
22
- this.logger.info("Content store instance set");
23
- }
24
- /**
25
- * Get the content store instance
26
- */
27
- getInstance() {
28
- return this.contentStore;
21
+ return void 0;
22
+ };
23
+ const admin = coerceKey(adminKey);
24
+ if (admin) {
25
+ tx.setAdminKey(admin);
29
26
  }
30
- /**
31
- * Clear the content store instance
32
- */
33
- dispose() {
34
- this.contentStore = null;
35
- this.logger.info("Content store disposed");
36
- }
37
- /**
38
- * Check if content store is available
39
- */
40
- isAvailable() {
41
- return this.contentStore !== null;
27
+ const submit = coerceKey(submitKey);
28
+ if (submit) {
29
+ tx.setSubmitKey(submit);
42
30
  }
31
+ return tx;
43
32
  }
44
- function extractReferenceId(input) {
45
- const trimmed = input.trim();
46
- const exactMatch = trimmed.match(/^content-ref:([a-f0-9]+)$/);
47
- if (exactMatch) {
48
- return exactMatch[1];
49
- }
50
- const embeddedMatch = trimmed.match(/content-ref:([a-f0-9]+)/);
51
- if (embeddedMatch) {
52
- return embeddedMatch[1];
33
+ function buildMessageTx(params) {
34
+ const tx = new TopicMessageSubmitTransaction().setTopicId(TopicId.fromString(params.topicId)).setMessage(params.message);
35
+ if (params.transactionMemo) {
36
+ tx.setTransactionMemo(params.transactionMemo);
53
37
  }
54
- return null;
55
- }
56
- function shouldUseReference(content) {
57
- const size = typeof content === "string" ? Buffer.byteLength(content, "utf8") : content.length;
58
- return size > REFERENCE_THRESHOLD;
38
+ return tx;
59
39
  }
60
- const ContentStoreService = ContentStoreServiceImpl.getInstance();
61
40
  export {
62
- ContentStoreService,
63
- ContentStoreServiceImpl,
64
- REFERENCE_THRESHOLD,
65
- extractReferenceId,
66
- shouldUseReference
41
+ buildMessageTx,
42
+ buildTopicCreateTx,
43
+ encodeHcs2RegistryMemo
67
44
  };
68
45
  //# sourceMappingURL=standards-sdk.es143.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es143.js","sources":["../../src/content-store/ContentStoreService.ts"],"sourcesContent":["/**\n * Content Store Service\n *\n * Provides utility functions for content storage and reference handling.\n */\n\nimport type { ContentStoreInterface } from './types';\nimport { Logger } from '../utils/logger';\n\n/**\n * Maximum content size before using references (50KB)\n */\nexport const REFERENCE_THRESHOLD = 50 * 1024;\n\n/**\n * Content store service for managing large content\n */\nexport class ContentStoreServiceImpl {\n private static _instance: ContentStoreServiceImpl;\n private contentStore: ContentStoreInterface | null = null;\n private logger = Logger.getInstance({ module: 'ContentStoreService' });\n\n static getInstance(): ContentStoreServiceImpl {\n if (!ContentStoreServiceImpl._instance) {\n ContentStoreServiceImpl._instance = new ContentStoreServiceImpl();\n }\n return ContentStoreServiceImpl._instance;\n }\n\n /**\n * Set the content store instance\n */\n async setInstance(store: ContentStoreInterface): Promise<void> {\n if (this.contentStore) {\n this.logger.warn('Content store already set, replacing');\n }\n this.contentStore = store;\n this.logger.info('Content store instance set');\n }\n\n /**\n * Get the content store instance\n */\n getInstance(): ContentStoreInterface | null {\n return this.contentStore;\n }\n\n /**\n * Clear the content store instance\n */\n dispose(): void {\n this.contentStore = null;\n this.logger.info('Content store disposed');\n }\n\n /**\n * Check if content store is available\n */\n isAvailable(): boolean {\n return this.contentStore !== null;\n }\n}\n\n/**\n * Extract reference ID from input string\n */\nexport function extractReferenceId(input: string): string | null {\n const trimmed = input.trim();\n\n const exactMatch = trimmed.match(/^content-ref:([a-f0-9]+)$/);\n if (exactMatch) {\n return exactMatch[1];\n }\n\n const embeddedMatch = trimmed.match(/content-ref:([a-f0-9]+)/);\n if (embeddedMatch) {\n return embeddedMatch[1];\n }\n\n return null;\n}\n\n/**\n * Check if content should use reference based on size\n */\nexport function shouldUseReference(content: string | Buffer): boolean {\n const size =\n typeof content === 'string'\n ? Buffer.byteLength(content, 'utf8')\n : content.length;\n\n return size > REFERENCE_THRESHOLD;\n}\n\nexport const ContentStoreService = ContentStoreServiceImpl.getInstance();\n"],"names":[],"mappings":";AAYO,MAAM,sBAAsB,KAAK;AAKjC,MAAM,wBAAwB;AAAA,EAA9B,cAAA;AAEL,SAAQ,eAA6C;AACrD,SAAQ,SAAS,OAAO,YAAY,EAAE,QAAQ,uBAAuB;AAAA,EAAA;AAAA,EAErE,OAAO,cAAuC;AAC5C,QAAI,CAAC,wBAAwB,WAAW;AACtC,8BAAwB,YAAY,IAAI,wBAAA;AAAA,IAC1C;AACA,WAAO,wBAAwB;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAY,OAA6C;AAC7D,QAAI,KAAK,cAAc;AACrB,WAAK,OAAO,KAAK,sCAAsC;AAAA,IACzD;AACA,SAAK,eAAe;AACpB,SAAK,OAAO,KAAK,4BAA4B;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKA,cAA4C;AAC1C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACd,SAAK,eAAe;AACpB,SAAK,OAAO,KAAK,wBAAwB;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,cAAuB;AACrB,WAAO,KAAK,iBAAiB;AAAA,EAC/B;AACF;AAKO,SAAS,mBAAmB,OAA8B;AAC/D,QAAM,UAAU,MAAM,KAAA;AAEtB,QAAM,aAAa,QAAQ,MAAM,2BAA2B;AAC5D,MAAI,YAAY;AACd,WAAO,WAAW,CAAC;AAAA,EACrB;AAEA,QAAM,gBAAgB,QAAQ,MAAM,yBAAyB;AAC7D,MAAI,eAAe;AACjB,WAAO,cAAc,CAAC;AAAA,EACxB;AAEA,SAAO;AACT;AAKO,SAAS,mBAAmB,SAAmC;AACpE,QAAM,OACJ,OAAO,YAAY,WACf,OAAO,WAAW,SAAS,MAAM,IACjC,QAAQ;AAEd,SAAO,OAAO;AAChB;AAEO,MAAM,sBAAsB,wBAAwB,YAAA;"}
1
+ {"version":3,"file":"standards-sdk.es143.js","sources":["../../src/common/tx/tx-utils.ts"],"sourcesContent":["import {\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n PublicKey,\n KeyList,\n TopicId,\n} from '@hashgraph/sdk';\n\nexport type MaybeKey = boolean | string | PublicKey | KeyList | undefined;\n\nexport function encodeHcs2RegistryMemo(\n indexedFlag: 0 | 1,\n ttl: number,\n): string {\n return `hcs-2:${indexedFlag}:${ttl}`;\n}\n\nexport function buildTopicCreateTx(params: {\n memo: string;\n adminKey?: MaybeKey;\n submitKey?: MaybeKey;\n operatorPublicKey?: PublicKey;\n}): TopicCreateTransaction {\n const { memo, adminKey, submitKey, operatorPublicKey } = params;\n const tx = new TopicCreateTransaction().setTopicMemo(memo);\n\n const coerceKey = (k?: MaybeKey): PublicKey | KeyList | undefined => {\n if (!k) return undefined;\n if (k instanceof PublicKey || k instanceof KeyList) return k;\n if (typeof k === 'boolean') {\n return k ? operatorPublicKey : undefined;\n }\n if (typeof k === 'string') {\n try {\n return PublicKey.fromString(k);\n } catch {\n return undefined;\n }\n }\n return undefined;\n };\n\n const admin = coerceKey(adminKey);\n if (admin) {\n tx.setAdminKey(admin);\n }\n\n const submit = coerceKey(submitKey);\n if (submit) {\n tx.setSubmitKey(submit);\n }\n\n return tx;\n}\n\nexport function buildMessageTx(params: {\n topicId: string;\n message: string | Uint8Array;\n transactionMemo?: string;\n}): TopicMessageSubmitTransaction {\n const tx = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(params.topicId))\n .setMessage(params.message);\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n return tx;\n}\n"],"names":[],"mappings":";AAUO,SAAS,uBACd,aACA,KACQ;AACR,SAAO,SAAS,WAAW,IAAI,GAAG;AACpC;AAEO,SAAS,mBAAmB,QAKR;AACzB,QAAM,EAAE,MAAM,UAAU,WAAW,sBAAsB;AACzD,QAAM,KAAK,IAAI,yBAAyB,aAAa,IAAI;AAEzD,QAAM,YAAY,CAAC,MAAkD;AACnE,QAAI,CAAC,EAAG,QAAO;AACf,QAAI,aAAa,aAAa,aAAa,QAAS,QAAO;AAC3D,QAAI,OAAO,MAAM,WAAW;AAC1B,aAAO,IAAI,oBAAoB;AAAA,IACjC;AACA,QAAI,OAAO,MAAM,UAAU;AACzB,UAAI;AACF,eAAO,UAAU,WAAW,CAAC;AAAA,MAC/B,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,UAAU,QAAQ;AAChC,MAAI,OAAO;AACT,OAAG,YAAY,KAAK;AAAA,EACtB;AAEA,QAAM,SAAS,UAAU,SAAS;AAClC,MAAI,QAAQ;AACV,OAAG,aAAa,MAAM;AAAA,EACxB;AAEA,SAAO;AACT;AAEO,SAAS,eAAe,QAIG;AAChC,QAAM,KAAK,IAAI,gCACZ,WAAW,QAAQ,WAAW,OAAO,OAAO,CAAC,EAC7C,WAAW,OAAO,OAAO;AAC5B,MAAI,OAAO,iBAAiB;AAC1B,OAAG,mBAAmB,OAAO,eAAe;AAAA,EAC9C;AACA,SAAO;AACT;"}
@@ -1,33 +1,175 @@
1
- import { HCS10BaseClient, HCS10Cache, Hcs10MemoType } from "./standards-sdk.es16.js";
2
- import { AccountCreationError, ConnectionConfirmationError, PayloadSizeError, TopicCreationError } from "./standards-sdk.es17.js";
3
- import { HCS10Client } from "./standards-sdk.es18.js";
4
- import { BrowserHCSClient } from "./standards-sdk.es19.js";
5
- import { Registration } from "./standards-sdk.es20.js";
6
- import { ConnectionsManager } from "./standards-sdk.es21.js";
7
- import { buildHcs10ConfirmConnectionTx, buildHcs10CreateConnectionTopicTx, buildHcs10CreateInboundTopicTx, buildHcs10CreateOutboundTopicTx, buildHcs10CreateRegistryTopicTx, buildHcs10OutboundConnectionCreatedRecordTx, buildHcs10OutboundConnectionRequestRecordTx, buildHcs10RegistryDeleteTx, buildHcs10RegistryMigrateTx, buildHcs10RegistryRegisterTx, buildHcs10SendMessageTx, buildHcs10SubmitConnectionRequestTx } from "./standards-sdk.es22.js";
1
+ import { Long, AccountId } from "@hashgraph/sdk";
2
+ import { parseKey } from "./standards-sdk.es149.js";
3
+ import { Buffer } from "buffer";
4
+ class HCSParser {
5
+ static parseConsensusCreateTopic(body) {
6
+ if (!body) return void 0;
7
+ const data = {};
8
+ if (body.memo) {
9
+ data.memo = body.memo;
10
+ }
11
+ data.adminKey = parseKey(body.adminKey);
12
+ data.submitKey = parseKey(body.submitKey);
13
+ if (body.autoRenewPeriod?.seconds) {
14
+ data.autoRenewPeriod = Long.fromValue(
15
+ body.autoRenewPeriod.seconds
16
+ ).toString();
17
+ }
18
+ if (body.autoRenewAccount) {
19
+ data.autoRenewAccountId = new AccountId(
20
+ body.autoRenewAccount.shardNum ?? 0,
21
+ body.autoRenewAccount.realmNum ?? 0,
22
+ body.autoRenewAccount.accountNum ?? 0
23
+ ).toString();
24
+ }
25
+ return data;
26
+ }
27
+ static parseConsensusSubmitMessage(body) {
28
+ if (!body) return void 0;
29
+ const data = {};
30
+ if (body.topicID) {
31
+ data.topicId = `${body.topicID.shardNum ?? 0}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
32
+ }
33
+ if (body.message?.length > 0) {
34
+ const messageBuffer = Buffer.from(body.message);
35
+ const utf8String = messageBuffer.toString("utf8");
36
+ if (/[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(utf8String) || utf8String.includes("�")) {
37
+ data.message = messageBuffer.toString("base64");
38
+ data.messageEncoding = "base64";
39
+ } else {
40
+ data.message = utf8String;
41
+ data.messageEncoding = "utf8";
42
+ }
43
+ }
44
+ if (body.chunkInfo) {
45
+ if (body.chunkInfo.initialTransactionID) {
46
+ const txId = body.chunkInfo.initialTransactionID.accountID;
47
+ const taValidStart = body.chunkInfo.initialTransactionID.transactionValidStart;
48
+ if (txId && taValidStart) {
49
+ data.chunkInfoInitialTransactionID = `${txId.shardNum ?? 0}.${txId.realmNum ?? 0}.${txId.accountNum ?? 0}@${taValidStart.seconds ?? 0}.${taValidStart.nanos ?? 0}`;
50
+ }
51
+ }
52
+ if (body.chunkInfo.number !== void 0 && body.chunkInfo.number !== null) {
53
+ data.chunkInfoNumber = body.chunkInfo.number;
54
+ }
55
+ if (body.chunkInfo.total !== void 0 && body.chunkInfo.total !== null) {
56
+ data.chunkInfoTotal = body.chunkInfo.total;
57
+ }
58
+ }
59
+ return data;
60
+ }
61
+ static parseConsensusUpdateTopic(body) {
62
+ if (!body) return void 0;
63
+ const data = {};
64
+ if (body.topicID) {
65
+ data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum}.${body.topicID.topicNum}`;
66
+ }
67
+ if (body.memo?.value !== void 0) {
68
+ data.memo = body.memo.value;
69
+ }
70
+ if (body.adminKey === null) {
71
+ data.clearAdminKey = true;
72
+ data.adminKey = void 0;
73
+ } else if (body.adminKey) {
74
+ data.adminKey = parseKey(body.adminKey);
75
+ } else {
76
+ data.adminKey = void 0;
77
+ }
78
+ if (body.submitKey === null) {
79
+ data.clearSubmitKey = true;
80
+ data.submitKey = void 0;
81
+ } else if (body.submitKey) {
82
+ data.submitKey = parseKey(body.submitKey);
83
+ } else {
84
+ data.submitKey = void 0;
85
+ }
86
+ if (body.autoRenewPeriod?.seconds) {
87
+ data.autoRenewPeriod = Long.fromValue(
88
+ body.autoRenewPeriod.seconds
89
+ ).toString();
90
+ }
91
+ if (body.autoRenewAccount) {
92
+ data.autoRenewAccountId = new AccountId(
93
+ body.autoRenewAccount.shardNum ?? 0,
94
+ body.autoRenewAccount.realmNum ?? 0,
95
+ body.autoRenewAccount.accountNum ?? 0
96
+ ).toString();
97
+ }
98
+ return data;
99
+ }
100
+ static parseConsensusDeleteTopic(body) {
101
+ if (!body) return void 0;
102
+ const data = {};
103
+ if (body.topicID) {
104
+ data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
105
+ }
106
+ return data;
107
+ }
108
+ /**
109
+ * Parse HCS transaction from Transaction object with comprehensive extraction
110
+ * This is the unified entry point that handles both protobuf and internal field extraction
111
+ */
112
+ static parseFromTransactionObject(transaction) {
113
+ try {
114
+ const transactionBody = transaction._transactionBody;
115
+ if (!transactionBody) {
116
+ return {};
117
+ }
118
+ if (transactionBody.consensusCreateTopic) {
119
+ const consensusCreateTopic = this.parseConsensusCreateTopic(
120
+ transactionBody.consensusCreateTopic
121
+ );
122
+ if (consensusCreateTopic) {
123
+ return {
124
+ type: "TOPICCREATE",
125
+ humanReadableType: "Topic Create",
126
+ consensusCreateTopic
127
+ };
128
+ }
129
+ }
130
+ if (transactionBody.consensusSubmitMessage) {
131
+ const consensusSubmitMessage = this.parseConsensusSubmitMessage(
132
+ transactionBody.consensusSubmitMessage
133
+ );
134
+ if (consensusSubmitMessage) {
135
+ return {
136
+ type: "CONSENSUSSUBMITMESSAGE",
137
+ humanReadableType: "Submit Message",
138
+ consensusSubmitMessage
139
+ };
140
+ }
141
+ }
142
+ if (transactionBody.consensusUpdateTopic) {
143
+ const consensusUpdateTopic = this.parseConsensusUpdateTopic(
144
+ transactionBody.consensusUpdateTopic
145
+ );
146
+ if (consensusUpdateTopic) {
147
+ return {
148
+ type: "TOPICUPDATE",
149
+ humanReadableType: "Topic Update",
150
+ consensusUpdateTopic
151
+ };
152
+ }
153
+ }
154
+ if (transactionBody.consensusDeleteTopic) {
155
+ const consensusDeleteTopic = this.parseConsensusDeleteTopic(
156
+ transactionBody.consensusDeleteTopic
157
+ );
158
+ if (consensusDeleteTopic) {
159
+ return {
160
+ type: "TOPICDELETE",
161
+ humanReadableType: "Topic Delete",
162
+ consensusDeleteTopic
163
+ };
164
+ }
165
+ }
166
+ return {};
167
+ } catch (error) {
168
+ return {};
169
+ }
170
+ }
171
+ }
8
172
  export {
9
- AccountCreationError,
10
- BrowserHCSClient,
11
- ConnectionConfirmationError,
12
- ConnectionsManager,
13
- HCS10BaseClient,
14
- HCS10Cache,
15
- HCS10Client,
16
- Hcs10MemoType,
17
- PayloadSizeError,
18
- Registration,
19
- TopicCreationError,
20
- buildHcs10ConfirmConnectionTx,
21
- buildHcs10CreateConnectionTopicTx,
22
- buildHcs10CreateInboundTopicTx,
23
- buildHcs10CreateOutboundTopicTx,
24
- buildHcs10CreateRegistryTopicTx,
25
- buildHcs10OutboundConnectionCreatedRecordTx,
26
- buildHcs10OutboundConnectionRequestRecordTx,
27
- buildHcs10RegistryDeleteTx,
28
- buildHcs10RegistryMigrateTx,
29
- buildHcs10RegistryRegisterTx,
30
- buildHcs10SendMessageTx,
31
- buildHcs10SubmitConnectionRequestTx
173
+ HCSParser
32
174
  };
33
175
  //# sourceMappingURL=standards-sdk.es144.js.map