@hashgraphonline/standards-sdk 0.1.141-canary.4 → 0.1.141-canary.41

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 (270) hide show
  1. package/README.md +13 -1
  2. package/dist/cjs/hcs-11/client.d.ts.map +1 -1
  3. package/dist/cjs/hcs-11/types.d.ts +1 -0
  4. package/dist/cjs/hcs-11/types.d.ts.map +1 -1
  5. package/dist/cjs/hcs-16/base-client.d.ts.map +1 -1
  6. package/dist/cjs/hcs-17/types.d.ts.map +1 -1
  7. package/dist/cjs/hcs-20/sdk.d.ts.map +1 -1
  8. package/dist/cjs/hcs-20/types.d.ts +9 -8
  9. package/dist/cjs/hcs-20/types.d.ts.map +1 -1
  10. package/dist/cjs/hcs-21/base-client.d.ts +5 -3
  11. package/dist/cjs/hcs-21/base-client.d.ts.map +1 -1
  12. package/dist/cjs/hcs-21/browser.d.ts +17 -7
  13. package/dist/cjs/hcs-21/browser.d.ts.map +1 -1
  14. package/dist/cjs/hcs-21/index.d.ts +1 -0
  15. package/dist/cjs/hcs-21/index.d.ts.map +1 -1
  16. package/dist/cjs/hcs-21/sdk.d.ts +62 -0
  17. package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
  18. package/dist/cjs/hcs-21/tx.d.ts.map +1 -1
  19. package/dist/cjs/hcs-21/types.d.ts +157 -73
  20. package/dist/cjs/hcs-21/types.d.ts.map +1 -1
  21. package/dist/cjs/hcs-21/verify.d.ts +6 -0
  22. package/dist/cjs/hcs-21/verify.d.ts.map +1 -0
  23. package/dist/cjs/inscribe/inscriber.d.ts +3 -1
  24. package/dist/cjs/inscribe/inscriber.d.ts.map +1 -1
  25. package/dist/cjs/inscribe/quote-cache.d.ts.map +1 -1
  26. package/dist/cjs/inscribe/types.d.ts +5 -0
  27. package/dist/cjs/inscribe/types.d.ts.map +1 -1
  28. package/dist/cjs/services/registry-broker/client.d.ts +4 -3
  29. package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
  30. package/dist/cjs/services/registry-broker/private-key-signer.d.ts.map +1 -1
  31. package/dist/cjs/services/registry-broker/schemas.d.ts +24 -24
  32. package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
  33. package/dist/cjs/services/types.d.ts +1 -0
  34. package/dist/cjs/services/types.d.ts.map +1 -1
  35. package/dist/cjs/standards-sdk.cjs +2 -2
  36. package/dist/cjs/standards-sdk.cjs.map +1 -1
  37. package/dist/cjs/utils/dynamic-import.d.ts +1 -0
  38. package/dist/cjs/utils/dynamic-import.d.ts.map +1 -1
  39. package/dist/es/hcs-11/client.d.ts.map +1 -1
  40. package/dist/es/hcs-11/types.d.ts +1 -0
  41. package/dist/es/hcs-11/types.d.ts.map +1 -1
  42. package/dist/es/hcs-16/base-client.d.ts.map +1 -1
  43. package/dist/es/hcs-17/types.d.ts.map +1 -1
  44. package/dist/es/hcs-20/sdk.d.ts.map +1 -1
  45. package/dist/es/hcs-20/types.d.ts +9 -8
  46. package/dist/es/hcs-20/types.d.ts.map +1 -1
  47. package/dist/es/hcs-21/base-client.d.ts +5 -3
  48. package/dist/es/hcs-21/base-client.d.ts.map +1 -1
  49. package/dist/es/hcs-21/browser.d.ts +17 -7
  50. package/dist/es/hcs-21/browser.d.ts.map +1 -1
  51. package/dist/es/hcs-21/index.d.ts +1 -0
  52. package/dist/es/hcs-21/index.d.ts.map +1 -1
  53. package/dist/es/hcs-21/sdk.d.ts +62 -0
  54. package/dist/es/hcs-21/sdk.d.ts.map +1 -1
  55. package/dist/es/hcs-21/tx.d.ts.map +1 -1
  56. package/dist/es/hcs-21/types.d.ts +157 -73
  57. package/dist/es/hcs-21/types.d.ts.map +1 -1
  58. package/dist/es/hcs-21/verify.d.ts +6 -0
  59. package/dist/es/hcs-21/verify.d.ts.map +1 -0
  60. package/dist/es/inscribe/inscriber.d.ts +3 -1
  61. package/dist/es/inscribe/inscriber.d.ts.map +1 -1
  62. package/dist/es/inscribe/quote-cache.d.ts.map +1 -1
  63. package/dist/es/inscribe/types.d.ts +5 -0
  64. package/dist/es/inscribe/types.d.ts.map +1 -1
  65. package/dist/es/services/registry-broker/client.d.ts +4 -3
  66. package/dist/es/services/registry-broker/client.d.ts.map +1 -1
  67. package/dist/es/services/registry-broker/private-key-signer.d.ts.map +1 -1
  68. package/dist/es/services/registry-broker/schemas.d.ts +24 -24
  69. package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
  70. package/dist/es/services/types.d.ts +1 -0
  71. package/dist/es/services/types.d.ts.map +1 -1
  72. package/dist/es/standards-sdk.es.js +58 -50
  73. package/dist/es/standards-sdk.es.js.map +1 -1
  74. package/dist/es/standards-sdk.es10.js +2 -2
  75. package/dist/es/standards-sdk.es100.js +26 -229
  76. package/dist/es/standards-sdk.es100.js.map +1 -1
  77. package/dist/es/standards-sdk.es101.js +228 -109
  78. package/dist/es/standards-sdk.es101.js.map +1 -1
  79. package/dist/es/standards-sdk.es102.js +94 -15
  80. package/dist/es/standards-sdk.es102.js.map +1 -1
  81. package/dist/es/standards-sdk.es103.js +30 -80
  82. package/dist/es/standards-sdk.es103.js.map +1 -1
  83. package/dist/es/standards-sdk.es104.js +80 -27
  84. package/dist/es/standards-sdk.es104.js.map +1 -1
  85. package/dist/es/standards-sdk.es105.js +25 -136
  86. package/dist/es/standards-sdk.es105.js.map +1 -1
  87. package/dist/es/standards-sdk.es106.js +140 -27
  88. package/dist/es/standards-sdk.es106.js.map +1 -1
  89. package/dist/es/standards-sdk.es107.js +27 -20
  90. package/dist/es/standards-sdk.es107.js.map +1 -1
  91. package/dist/es/standards-sdk.es108.js +18 -156
  92. package/dist/es/standards-sdk.es108.js.map +1 -1
  93. package/dist/es/standards-sdk.es109.js +148 -196
  94. package/dist/es/standards-sdk.es109.js.map +1 -1
  95. package/dist/es/standards-sdk.es110.js +160 -747
  96. package/dist/es/standards-sdk.es110.js.map +1 -1
  97. package/dist/es/standards-sdk.es111.js +786 -9
  98. package/dist/es/standards-sdk.es111.js.map +1 -1
  99. package/dist/es/standards-sdk.es112.js +13 -567
  100. package/dist/es/standards-sdk.es112.js.map +1 -1
  101. package/dist/es/standards-sdk.es113.js +541 -576
  102. package/dist/es/standards-sdk.es113.js.map +1 -1
  103. package/dist/es/standards-sdk.es114.js +601 -12
  104. package/dist/es/standards-sdk.es114.js.map +1 -1
  105. package/dist/es/standards-sdk.es115.js +13 -2
  106. package/dist/es/standards-sdk.es115.js.map +1 -1
  107. package/dist/es/standards-sdk.es116.js +2 -83
  108. package/dist/es/standards-sdk.es116.js.map +1 -1
  109. package/dist/es/standards-sdk.es117.js +80 -36
  110. package/dist/es/standards-sdk.es117.js.map +1 -1
  111. package/dist/es/standards-sdk.es118.js +39 -2
  112. package/dist/es/standards-sdk.es118.js.map +1 -1
  113. package/dist/es/standards-sdk.es119.js +2 -223
  114. package/dist/es/standards-sdk.es119.js.map +1 -1
  115. package/dist/es/standards-sdk.es120.js +193 -1110
  116. package/dist/es/standards-sdk.es120.js.map +1 -1
  117. package/dist/es/standards-sdk.es121.js +1059 -225
  118. package/dist/es/standards-sdk.es121.js.map +1 -1
  119. package/dist/es/standards-sdk.es122.js +303 -419
  120. package/dist/es/standards-sdk.es122.js.map +1 -1
  121. package/dist/es/standards-sdk.es123.js +418 -351
  122. package/dist/es/standards-sdk.es123.js.map +1 -1
  123. package/dist/es/standards-sdk.es124.js +348 -785
  124. package/dist/es/standards-sdk.es124.js.map +1 -1
  125. package/dist/es/standards-sdk.es125.js +854 -182
  126. package/dist/es/standards-sdk.es125.js.map +1 -1
  127. package/dist/es/standards-sdk.es126.js +153 -1512
  128. package/dist/es/standards-sdk.es126.js.map +1 -1
  129. package/dist/es/standards-sdk.es127.js +1373 -1977
  130. package/dist/es/standards-sdk.es127.js.map +1 -1
  131. package/dist/es/standards-sdk.es128.js +2209 -69
  132. package/dist/es/standards-sdk.es128.js.map +1 -1
  133. package/dist/es/standards-sdk.es129.js +59 -79
  134. package/dist/es/standards-sdk.es129.js.map +1 -1
  135. package/dist/es/standards-sdk.es13.js +1 -1
  136. package/dist/es/standards-sdk.es130.js +80 -152
  137. package/dist/es/standards-sdk.es130.js.map +1 -1
  138. package/dist/es/standards-sdk.es131.js +159 -7
  139. package/dist/es/standards-sdk.es131.js.map +1 -1
  140. package/dist/es/standards-sdk.es132.js +7 -86
  141. package/dist/es/standards-sdk.es132.js.map +1 -1
  142. package/dist/es/standards-sdk.es133.js +65 -44
  143. package/dist/es/standards-sdk.es133.js.map +1 -1
  144. package/dist/es/standards-sdk.es134.js +65 -28
  145. package/dist/es/standards-sdk.es134.js.map +1 -1
  146. package/dist/es/standards-sdk.es135.js +28 -12274
  147. package/dist/es/standards-sdk.es135.js.map +1 -1
  148. package/dist/es/standards-sdk.es136.js +17 -760
  149. package/dist/es/standards-sdk.es136.js.map +1 -1
  150. package/dist/es/standards-sdk.es137.js +1 -1
  151. package/dist/es/standards-sdk.es138.js +766 -42
  152. package/dist/es/standards-sdk.es138.js.map +1 -1
  153. package/dist/es/standards-sdk.es139.js +40 -15
  154. package/dist/es/standards-sdk.es139.js.map +1 -1
  155. package/dist/es/standards-sdk.es14.js +1 -1
  156. package/dist/es/standards-sdk.es140.js +12271 -53
  157. package/dist/es/standards-sdk.es140.js.map +1 -1
  158. package/dist/es/standards-sdk.es141.js +49 -57
  159. package/dist/es/standards-sdk.es141.js.map +1 -1
  160. package/dist/es/standards-sdk.es142.js +71 -161
  161. package/dist/es/standards-sdk.es142.js.map +1 -1
  162. package/dist/es/standards-sdk.es143.js +139 -289
  163. package/dist/es/standards-sdk.es143.js.map +1 -1
  164. package/dist/es/standards-sdk.es144.js +274 -298
  165. package/dist/es/standards-sdk.es144.js.map +1 -1
  166. package/dist/es/standards-sdk.es145.js +262 -369
  167. package/dist/es/standards-sdk.es145.js.map +1 -1
  168. package/dist/es/standards-sdk.es146.js +316 -194
  169. package/dist/es/standards-sdk.es146.js.map +1 -1
  170. package/dist/es/standards-sdk.es147.js +319 -64
  171. package/dist/es/standards-sdk.es147.js.map +1 -1
  172. package/dist/es/standards-sdk.es148.js +79 -0
  173. package/dist/es/standards-sdk.es148.js.map +1 -0
  174. package/dist/es/standards-sdk.es15.js +1 -1
  175. package/dist/es/standards-sdk.es16.js +1 -1
  176. package/dist/es/standards-sdk.es17.js +5 -11
  177. package/dist/es/standards-sdk.es17.js.map +1 -1
  178. package/dist/es/standards-sdk.es19.js +11 -16
  179. package/dist/es/standards-sdk.es19.js.map +1 -1
  180. package/dist/es/standards-sdk.es20.js +9 -14
  181. package/dist/es/standards-sdk.es20.js.map +1 -1
  182. package/dist/es/standards-sdk.es21.js +1 -1
  183. package/dist/es/standards-sdk.es22.js +1 -1
  184. package/dist/es/standards-sdk.es23.js +1 -1
  185. package/dist/es/standards-sdk.es24.js +1 -1
  186. package/dist/es/standards-sdk.es25.js +1 -1
  187. package/dist/es/standards-sdk.es26.js +1 -1
  188. package/dist/es/standards-sdk.es27.js +1 -1
  189. package/dist/es/standards-sdk.es28.js +15 -18
  190. package/dist/es/standards-sdk.es28.js.map +1 -1
  191. package/dist/es/standards-sdk.es29.js.map +1 -1
  192. package/dist/es/standards-sdk.es3.js +2 -2
  193. package/dist/es/standards-sdk.es31.js +2 -2
  194. package/dist/es/standards-sdk.es32.js +4 -4
  195. package/dist/es/standards-sdk.es33.js +1 -1
  196. package/dist/es/standards-sdk.es36.js +7 -12
  197. package/dist/es/standards-sdk.es36.js.map +1 -1
  198. package/dist/es/standards-sdk.es37.js +3 -3
  199. package/dist/es/standards-sdk.es38.js +2 -2
  200. package/dist/es/standards-sdk.es39.js +2 -2
  201. package/dist/es/standards-sdk.es40.js +1 -1
  202. package/dist/es/standards-sdk.es41.js +1 -1
  203. package/dist/es/standards-sdk.es42.js +2 -2
  204. package/dist/es/standards-sdk.es47.js +1 -1
  205. package/dist/es/standards-sdk.es5.js +1 -1
  206. package/dist/es/standards-sdk.es52.js +1 -1
  207. package/dist/es/standards-sdk.es54.js +1 -1
  208. package/dist/es/standards-sdk.es57.js +2 -2
  209. package/dist/es/standards-sdk.es59.js +1 -1
  210. package/dist/es/standards-sdk.es6.js +2 -2
  211. package/dist/es/standards-sdk.es60.js +1 -1
  212. package/dist/es/standards-sdk.es61.js +6 -11
  213. package/dist/es/standards-sdk.es61.js.map +1 -1
  214. package/dist/es/standards-sdk.es63.js +1 -1
  215. package/dist/es/standards-sdk.es65.js +2 -2
  216. package/dist/es/standards-sdk.es66.js +2 -2
  217. package/dist/es/standards-sdk.es69.js +1 -1
  218. package/dist/es/standards-sdk.es7.js +2 -2
  219. package/dist/es/standards-sdk.es70.js +3 -3
  220. package/dist/es/standards-sdk.es71.js +2 -2
  221. package/dist/es/standards-sdk.es72.js +1 -1
  222. package/dist/es/standards-sdk.es73.js.map +1 -1
  223. package/dist/es/standards-sdk.es75.js +2 -2
  224. package/dist/es/standards-sdk.es77.js +4 -2
  225. package/dist/es/standards-sdk.es77.js.map +1 -1
  226. package/dist/es/standards-sdk.es78.js +4 -10
  227. package/dist/es/standards-sdk.es78.js.map +1 -1
  228. package/dist/es/standards-sdk.es79.js +1 -1
  229. package/dist/es/standards-sdk.es8.js +1 -1
  230. package/dist/es/standards-sdk.es80.js +27 -15
  231. package/dist/es/standards-sdk.es80.js.map +1 -1
  232. package/dist/es/standards-sdk.es82.js +12 -4
  233. package/dist/es/standards-sdk.es82.js.map +1 -1
  234. package/dist/es/standards-sdk.es83.js +31 -6
  235. package/dist/es/standards-sdk.es83.js.map +1 -1
  236. package/dist/es/standards-sdk.es84.js +181 -6
  237. package/dist/es/standards-sdk.es84.js.map +1 -1
  238. package/dist/es/standards-sdk.es85.js +256 -9
  239. package/dist/es/standards-sdk.es85.js.map +1 -1
  240. package/dist/es/standards-sdk.es86.js +55 -21
  241. package/dist/es/standards-sdk.es86.js.map +1 -1
  242. package/dist/es/standards-sdk.es87.js +22 -75
  243. package/dist/es/standards-sdk.es87.js.map +1 -1
  244. package/dist/es/standards-sdk.es88.js +45 -30
  245. package/dist/es/standards-sdk.es88.js.map +1 -1
  246. package/dist/es/standards-sdk.es89.js +57 -22
  247. package/dist/es/standards-sdk.es89.js.map +1 -1
  248. package/dist/es/standards-sdk.es90.js +28 -23
  249. package/dist/es/standards-sdk.es90.js.map +1 -1
  250. package/dist/es/standards-sdk.es91.js +23 -167
  251. package/dist/es/standards-sdk.es91.js.map +1 -1
  252. package/dist/es/standards-sdk.es92.js +158 -119
  253. package/dist/es/standards-sdk.es92.js.map +1 -1
  254. package/dist/es/standards-sdk.es93.js +68 -95
  255. package/dist/es/standards-sdk.es93.js.map +1 -1
  256. package/dist/es/standards-sdk.es94.js +136 -119
  257. package/dist/es/standards-sdk.es94.js.map +1 -1
  258. package/dist/es/standards-sdk.es95.js +139 -39
  259. package/dist/es/standards-sdk.es95.js.map +1 -1
  260. package/dist/es/standards-sdk.es96.js +42 -257
  261. package/dist/es/standards-sdk.es96.js.map +1 -1
  262. package/dist/es/standards-sdk.es97.js +243 -80
  263. package/dist/es/standards-sdk.es97.js.map +1 -1
  264. package/dist/es/standards-sdk.es98.js +47 -48
  265. package/dist/es/standards-sdk.es98.js.map +1 -1
  266. package/dist/es/standards-sdk.es99.js +100 -28
  267. package/dist/es/standards-sdk.es99.js.map +1 -1
  268. package/dist/es/utils/dynamic-import.d.ts +1 -0
  269. package/dist/es/utils/dynamic-import.d.ts.map +1 -1
  270. package/package.json +3 -3
@@ -1,349 +1,325 @@
1
- import { AccountId, Hbar, Long, HbarUnit, TokenId } from "@hashgraph/sdk";
2
- import { parseKey } from "./standards-sdk.es147.js";
3
- class CryptoParser {
4
- static parseCryptoTransfers(cryptoTransfer, result) {
5
- if (cryptoTransfer.transfers?.accountAmounts) {
6
- result.transfers = cryptoTransfer.transfers.accountAmounts.map((aa) => {
7
- const accountId = new AccountId(
8
- aa.accountID.shardNum ?? 0,
9
- aa.accountID.realmNum ?? 0,
10
- aa.accountID.accountNum ?? 0
11
- );
12
- const hbarAmount = Hbar.fromTinybars(Long.fromValue(aa.amount));
1
+ import { proto } from "@hashgraph/proto";
2
+ import { Long } from "@hashgraph/sdk";
3
+ import { hasTransactionType, parseKey } from "./standards-sdk.es148.js";
4
+ import { Buffer } from "buffer";
5
+ class FileParser {
6
+ /**
7
+ * Parse File Service transaction using unified dual-branch approach
8
+ * This handles both regular transactions and signed transaction variants
9
+ */
10
+ static parseFileTransaction(transaction, originalBytes) {
11
+ try {
12
+ if (originalBytes || transaction.toBytes) {
13
+ try {
14
+ const bytesToParse = originalBytes || transaction.toBytes();
15
+ const decoded = proto.TransactionList.decode(bytesToParse);
16
+ if (decoded.transactionList && decoded.transactionList.length > 0) {
17
+ const tx = decoded.transactionList[0];
18
+ let txBody = null;
19
+ if (tx.bodyBytes && tx.bodyBytes.length > 0) {
20
+ txBody = proto.TransactionBody.decode(tx.bodyBytes);
21
+ } else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
22
+ const signedTx = proto.SignedTransaction.decode(
23
+ tx.signedTransactionBytes
24
+ );
25
+ if (signedTx.bodyBytes) {
26
+ txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
27
+ }
28
+ }
29
+ if (txBody) {
30
+ const protoResult = this.parseFromProtobufTxBody(txBody);
31
+ if (protoResult.type && protoResult.type !== "UNKNOWN") {
32
+ return protoResult;
33
+ }
34
+ }
35
+ }
36
+ } catch (protoError) {
37
+ }
38
+ }
39
+ return this.parseFromTransactionInternals(transaction);
40
+ } catch (error) {
41
+ return { type: "UNKNOWN", humanReadableType: "Unknown File Transaction" };
42
+ }
43
+ }
44
+ /**
45
+ * Parse file transaction from protobuf TransactionBody
46
+ * Handles all file operations from decoded protobuf data
47
+ */
48
+ static parseFromProtobufTxBody(txBody) {
49
+ if (txBody.fileCreate) {
50
+ const fileCreate = this.parseFileCreate(txBody.fileCreate);
51
+ if (fileCreate) {
13
52
  return {
14
- accountId: accountId.toString(),
15
- amount: hbarAmount.toString(HbarUnit.Hbar),
16
- isDecimal: true
53
+ type: "FILECREATE",
54
+ humanReadableType: "File Create",
55
+ fileCreate
17
56
  };
18
- });
57
+ }
19
58
  }
20
- if (cryptoTransfer.tokenTransfers) {
21
- for (const tokenTransferList of cryptoTransfer.tokenTransfers) {
22
- const tokenId = new TokenId(
23
- tokenTransferList.token.shardNum ?? 0,
24
- tokenTransferList.token.realmNum ?? 0,
25
- tokenTransferList.token.tokenNum ?? 0
26
- );
27
- if (tokenTransferList.transfers) {
28
- for (const transfer of tokenTransferList.transfers) {
29
- const accountId = new AccountId(
30
- transfer.accountID.shardNum ?? 0,
31
- transfer.accountID.realmNum ?? 0,
32
- transfer.accountID.accountNum ?? 0
33
- );
34
- const tokenAmount = Long.fromValue(transfer.amount).toNumber();
35
- result.tokenTransfers.push({
36
- tokenId: tokenId.toString(),
37
- accountId: accountId.toString(),
38
- amount: tokenAmount
39
- });
59
+ if (txBody.fileAppend) {
60
+ const fileAppend = this.parseFileAppend(txBody.fileAppend);
61
+ if (fileAppend) {
62
+ return {
63
+ type: "FILEAPPEND",
64
+ humanReadableType: "File Append",
65
+ fileAppend
66
+ };
67
+ }
68
+ }
69
+ if (txBody.fileUpdate) {
70
+ const fileUpdate = this.parseFileUpdate(txBody.fileUpdate);
71
+ if (fileUpdate) {
72
+ return {
73
+ type: "FILEUPDATE",
74
+ humanReadableType: "File Update",
75
+ fileUpdate
76
+ };
77
+ }
78
+ }
79
+ if (txBody.fileDelete) {
80
+ const fileDelete = this.parseFileDelete(txBody.fileDelete);
81
+ if (fileDelete) {
82
+ return {
83
+ type: "FILEDELETE",
84
+ humanReadableType: "File Delete",
85
+ fileDelete
86
+ };
87
+ }
88
+ }
89
+ return {};
90
+ }
91
+ /**
92
+ * Extract file data from Transaction internal fields
93
+ * This handles cases where data is stored in Transaction object internals
94
+ */
95
+ static parseFromTransactionInternals(transaction) {
96
+ try {
97
+ const tx = transaction;
98
+ if (hasTransactionType(transaction, "fileCreate")) {
99
+ const fileCreate = {};
100
+ if (tx._contents) {
101
+ const contentInfo = this.analyzeContent(tx._contents);
102
+ fileCreate.contents = contentInfo.encoded;
103
+ if (contentInfo.contentType) {
104
+ fileCreate.contentType = contentInfo.contentType;
105
+ }
106
+ if (contentInfo.size) {
107
+ fileCreate.contentSize = contentInfo.size;
40
108
  }
41
109
  }
110
+ if (tx._keys && tx._keys.length > 0) {
111
+ const keyList = {
112
+ keys: tx._keys
113
+ };
114
+ fileCreate.keys = parseKey({ keyList });
115
+ }
116
+ if (tx._expirationTime) {
117
+ fileCreate.expirationTime = tx._expirationTime.toString();
118
+ }
119
+ if (tx._memo) {
120
+ fileCreate.memo = tx._memo;
121
+ }
122
+ return {
123
+ type: "FILECREATE",
124
+ humanReadableType: "File Create",
125
+ fileCreate
126
+ };
127
+ }
128
+ if (hasTransactionType(transaction, "fileAppend")) {
129
+ const fileAppend = {
130
+ fileId: tx._fileId.toString()
131
+ };
132
+ if (tx._contents) {
133
+ const contentInfo = this.analyzeContent(tx._contents);
134
+ fileAppend.contents = contentInfo.encoded;
135
+ if (contentInfo.size) {
136
+ fileAppend.contentSize = contentInfo.size;
137
+ }
138
+ }
139
+ return {
140
+ type: "FILEAPPEND",
141
+ humanReadableType: "File Append",
142
+ fileAppend
143
+ };
144
+ }
145
+ if (hasTransactionType(transaction, "fileUpdate")) {
146
+ const fileUpdate = {
147
+ fileId: tx._fileId.toString()
148
+ };
149
+ if (tx._contents) {
150
+ const contentInfo = this.analyzeContent(tx._contents);
151
+ fileUpdate.contents = contentInfo.encoded;
152
+ if (contentInfo.size) {
153
+ fileUpdate.contentSize = contentInfo.size;
154
+ }
155
+ }
156
+ if (tx._keys && tx._keys.length > 0) {
157
+ const keyList = {
158
+ keys: tx._keys
159
+ };
160
+ fileUpdate.keys = parseKey({ keyList });
161
+ }
162
+ if (tx._expirationTime) {
163
+ fileUpdate.expirationTime = tx._expirationTime.toString();
164
+ }
165
+ if (tx._memo) {
166
+ fileUpdate.memo = tx._memo;
167
+ }
168
+ return {
169
+ type: "FILEUPDATE",
170
+ humanReadableType: "File Update",
171
+ fileUpdate
172
+ };
42
173
  }
174
+ if (hasTransactionType(transaction, "fileDelete")) {
175
+ const fileDelete = {
176
+ fileId: tx._fileId.toString()
177
+ };
178
+ return {
179
+ type: "FILEDELETE",
180
+ humanReadableType: "File Delete",
181
+ fileDelete
182
+ };
183
+ }
184
+ return {};
185
+ } catch (error) {
186
+ return {};
43
187
  }
44
188
  }
45
- static parseCryptoDelete(body) {
46
- if (!body) return void 0;
47
- const data = {};
48
- if (body.deleteAccountID) {
49
- data.deleteAccountId = new AccountId(
50
- body.deleteAccountID.shardNum ?? 0,
51
- body.deleteAccountID.realmNum ?? 0,
52
- body.deleteAccountID.accountNum ?? 0
53
- ).toString();
189
+ /**
190
+ * Enhanced content analysis with type detection and metadata
191
+ */
192
+ static analyzeContent(contents) {
193
+ const size = contents.length;
194
+ const contentBuffer = Buffer.from(contents);
195
+ let contentType;
196
+ if (size >= 4) {
197
+ const header = contentBuffer.subarray(0, 4);
198
+ const headerHex = header.toString("hex");
199
+ const signatures = {
200
+ "89504e47": "image/png",
201
+ ffd8ffe0: "image/jpeg",
202
+ ffd8ffe1: "image/jpeg",
203
+ "47494638": "image/gif",
204
+ "25504446": "application/pdf",
205
+ "504b0304": "application/zip",
206
+ "7f454c46": "application/x-executable",
207
+ d0cf11e0: "application/msoffice"
208
+ };
209
+ contentType = signatures[headerHex.toLowerCase()];
54
210
  }
55
- if (body.transferAccountID) {
56
- data.transferAccountId = new AccountId(
57
- body.transferAccountID.shardNum ?? 0,
58
- body.transferAccountID.realmNum ?? 0,
59
- body.transferAccountID.accountNum ?? 0
60
- ).toString();
211
+ if (!contentType) {
212
+ try {
213
+ const textContent = contentBuffer.toString("utf8");
214
+ const hasControlChars = /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(
215
+ textContent
216
+ );
217
+ const hasReplacementChars = textContent.includes("�");
218
+ if (!hasControlChars && !hasReplacementChars) {
219
+ if (textContent.trim().startsWith("{") && textContent.trim().endsWith("}")) {
220
+ contentType = "application/json";
221
+ } else if (textContent.includes("<?xml") || textContent.includes("<html")) {
222
+ contentType = "text/xml";
223
+ } else if (textContent.includes("<!DOCTYPE html")) {
224
+ contentType = "text/html";
225
+ } else {
226
+ contentType = "text/plain";
227
+ }
228
+ } else {
229
+ contentType = "application/octet-stream";
230
+ }
231
+ } catch {
232
+ contentType = "application/octet-stream";
233
+ }
61
234
  }
62
- return data;
235
+ let encoded;
236
+ if (contentType?.startsWith("text/") || contentType === "application/json") {
237
+ try {
238
+ encoded = contentBuffer.toString("utf8");
239
+ if (encoded.includes("�") || /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(encoded)) {
240
+ encoded = contentBuffer.toString("base64");
241
+ }
242
+ } catch {
243
+ encoded = contentBuffer.toString("base64");
244
+ }
245
+ } else {
246
+ encoded = contentBuffer.toString("base64");
247
+ }
248
+ return {
249
+ encoded,
250
+ contentType,
251
+ size
252
+ };
63
253
  }
64
- static parseCryptoCreateAccount(body) {
254
+ static parseFileCreate(body) {
65
255
  if (!body) return void 0;
66
256
  const data = {};
67
- if (body.initialBalance) {
68
- data.initialBalance = Hbar.fromTinybars(
69
- Long.fromValue(body.initialBalance)
70
- ).toString(HbarUnit.Hbar);
71
- }
72
- if (body.key) {
73
- data.key = parseKey(body.key);
257
+ if (body.expirationTime?.seconds) {
258
+ data.expirationTime = `${Long.fromValue(
259
+ body.expirationTime.seconds
260
+ ).toString()}.${body.expirationTime.nanos}`;
74
261
  }
75
- if (body.receiverSigRequired !== void 0) {
76
- data.receiverSigRequired = body.receiverSigRequired;
262
+ if (body.keys) {
263
+ data.keys = parseKey({ keyList: body.keys });
77
264
  }
78
- if (body.autoRenewPeriod?.seconds) {
79
- data.autoRenewPeriod = Long.fromValue(
80
- body.autoRenewPeriod.seconds
81
- ).toString();
265
+ if (body.contents) {
266
+ data.contents = Buffer.from(body.contents).toString("base64");
82
267
  }
83
268
  if (body.memo) {
84
269
  data.memo = body.memo;
85
270
  }
86
- if (body.maxAutomaticTokenAssociations !== void 0) {
87
- data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations;
88
- }
89
- if (body.stakedAccountId) {
90
- data.stakedAccountId = new AccountId(
91
- body.stakedAccountId.shardNum ?? 0,
92
- body.stakedAccountId.realmNum ?? 0,
93
- body.stakedAccountId.accountNum ?? 0
94
- ).toString();
95
- } else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0) {
96
- data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
97
- }
98
- if (body.declineReward !== void 0) {
99
- data.declineReward = body.declineReward;
271
+ return data;
272
+ }
273
+ static parseFileAppend(body) {
274
+ if (!body) return void 0;
275
+ const data = {};
276
+ if (body.fileID) {
277
+ data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
100
278
  }
101
- if (body.alias && body.alias.length > 0) {
102
- data.alias = Buffer.from(body.alias).toString("hex");
279
+ if (body.contents) {
280
+ data.contents = Buffer.from(body.contents).toString("base64");
103
281
  }
104
282
  return data;
105
283
  }
106
- static parseCryptoUpdateAccount(body) {
284
+ static parseFileUpdate(body) {
107
285
  if (!body) return void 0;
108
286
  const data = {};
109
- if (body.accountIDToUpdate) {
110
- data.accountIdToUpdate = new AccountId(
111
- body.accountIDToUpdate.shardNum ?? 0,
112
- body.accountIDToUpdate.realmNum ?? 0,
113
- body.accountIDToUpdate.accountNum ?? 0
114
- ).toString();
115
- }
116
- if (body.key) {
117
- data.key = parseKey(body.key);
287
+ if (body.fileID) {
288
+ data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
118
289
  }
119
290
  if (body.expirationTime?.seconds) {
120
291
  data.expirationTime = `${Long.fromValue(
121
292
  body.expirationTime.seconds
122
293
  ).toString()}.${body.expirationTime.nanos}`;
123
294
  }
124
- if (body.receiverSigRequired !== null && body.receiverSigRequired !== void 0) {
125
- data.receiverSigRequired = Boolean(body.receiverSigRequired);
295
+ if (body.keys) {
296
+ data.keys = parseKey({ keyList: body.keys });
126
297
  }
127
- if (body.autoRenewPeriod?.seconds) {
128
- data.autoRenewPeriod = Long.fromValue(
129
- body.autoRenewPeriod.seconds
130
- ).toString();
298
+ if (body.contents) {
299
+ data.contents = Buffer.from(body.contents).toString("base64");
131
300
  }
132
301
  if (body.memo?.value !== void 0) {
133
302
  data.memo = body.memo.value;
134
303
  }
135
- if (body.maxAutomaticTokenAssociations?.value !== void 0) {
136
- data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations.value;
137
- }
138
- if (body.stakedAccountId) {
139
- data.stakedAccountId = new AccountId(
140
- body.stakedAccountId.shardNum ?? 0,
141
- body.stakedAccountId.realmNum ?? 0,
142
- body.stakedAccountId.accountNum ?? 0
143
- ).toString();
144
- data.stakedNodeId = void 0;
145
- } else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0) {
146
- data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
147
- data.stakedAccountId = void 0;
148
- } else {
149
- data.stakedAccountId = void 0;
150
- data.stakedNodeId = void 0;
151
- }
152
- if (body.declineReward !== null && body.declineReward !== void 0) {
153
- data.declineReward = Boolean(body.declineReward);
154
- }
155
304
  return data;
156
305
  }
157
- static parseCryptoApproveAllowance(body) {
306
+ static parseFileDelete(body) {
158
307
  if (!body) return void 0;
159
308
  const data = {};
160
- if (body.cryptoAllowances && body.cryptoAllowances.length > 0) {
161
- data.hbarAllowances = body.cryptoAllowances.map((a) => ({
162
- ownerAccountId: new AccountId(
163
- a.owner.shardNum ?? 0,
164
- a.owner.realmNum ?? 0,
165
- a.owner.accountNum ?? 0
166
- ).toString(),
167
- spenderAccountId: new AccountId(
168
- a.spender.shardNum ?? 0,
169
- a.spender.realmNum ?? 0,
170
- a.spender.accountNum ?? 0
171
- ).toString(),
172
- amount: Hbar.fromTinybars(Long.fromValue(a.amount)).toString(
173
- HbarUnit.Hbar
174
- )
175
- }));
176
- }
177
- if (body.tokenAllowances && body.tokenAllowances.length > 0) {
178
- data.tokenAllowances = body.tokenAllowances.map((a) => ({
179
- tokenId: new TokenId(
180
- a.tokenId.shardNum ?? 0,
181
- a.tokenId.realmNum ?? 0,
182
- a.tokenId.tokenNum ?? 0
183
- ).toString(),
184
- ownerAccountId: new AccountId(
185
- a.owner.shardNum ?? 0,
186
- a.owner.realmNum ?? 0,
187
- a.owner.accountNum ?? 0
188
- ).toString(),
189
- spenderAccountId: new AccountId(
190
- a.spender.shardNum ?? 0,
191
- a.spender.realmNum ?? 0,
192
- a.spender.accountNum ?? 0
193
- ).toString(),
194
- amount: Long.fromValue(a.amount).toString()
195
- }));
196
- }
197
- if (body.nftAllowances && body.nftAllowances.length > 0) {
198
- data.nftAllowances = body.nftAllowances.map((a) => {
199
- const allowance = {};
200
- if (a.tokenId)
201
- allowance.tokenId = new TokenId(
202
- a.tokenId.shardNum ?? 0,
203
- a.tokenId.realmNum ?? 0,
204
- a.tokenId.tokenNum ?? 0
205
- ).toString();
206
- if (a.owner)
207
- allowance.ownerAccountId = new AccountId(
208
- a.owner.shardNum ?? 0,
209
- a.owner.realmNum ?? 0,
210
- a.owner.accountNum ?? 0
211
- ).toString();
212
- if (a.spender)
213
- allowance.spenderAccountId = new AccountId(
214
- a.spender.shardNum ?? 0,
215
- a.spender.realmNum ?? 0,
216
- a.spender.accountNum ?? 0
217
- ).toString();
218
- if (a.serialNumbers && a.serialNumbers.length > 0)
219
- allowance.serialNumbers = a.serialNumbers.map(
220
- (sn) => Long.fromValue(sn).toString()
221
- );
222
- if (a.approvedForAll?.value !== void 0)
223
- allowance.approvedForAll = a.approvedForAll.value;
224
- if (a.delegatingSpender)
225
- allowance.delegatingSpender = new AccountId(
226
- a.delegatingSpender.shardNum ?? 0,
227
- a.delegatingSpender.realmNum ?? 0,
228
- a.delegatingSpender.accountNum ?? 0
229
- ).toString();
230
- return allowance;
231
- });
309
+ if (body.fileID) {
310
+ data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
232
311
  }
233
312
  return data;
234
313
  }
235
- static parseCryptoDeleteAllowance(body) {
236
- if (!body) return void 0;
237
- const data = {};
238
- if (body.nftAllowances && body.nftAllowances.length > 0) {
239
- data.nftAllowancesToRemove = body.nftAllowances.map((a) => ({
240
- ownerAccountId: new AccountId(
241
- a.owner.shardNum ?? 0,
242
- a.owner.realmNum ?? 0,
243
- a.owner.accountNum ?? 0
244
- ).toString(),
245
- tokenId: new TokenId(
246
- a.tokenId.shardNum ?? 0,
247
- a.tokenId.realmNum ?? 0,
248
- a.tokenId.tokenNum ?? 0
249
- ).toString(),
250
- serialNumbers: a.serialNumbers ? a.serialNumbers.map((sn) => Long.fromValue(sn).toString()) : []
251
- }));
252
- }
253
- return data;
254
- }
255
- /**
256
- * Extract HBAR transfers from Transaction object
257
- */
258
- static extractHbarTransfersFromTransaction(transaction) {
259
- const transfers = [];
260
- try {
261
- const hbarTransfers = transaction._hbarTransfers;
262
- if (Array.isArray(hbarTransfers)) {
263
- hbarTransfers.forEach((transfer) => {
264
- if (transfer.accountId && transfer.amount) {
265
- const amountInTinybars = transfer.amount.toTinybars();
266
- const amountInHbar = Number(amountInTinybars) / 1e8;
267
- transfers.push({
268
- accountId: transfer.accountId.toString(),
269
- amount: amountInHbar
270
- });
271
- }
272
- });
273
- }
274
- } catch (error) {
275
- }
276
- return transfers;
277
- }
278
- /**
279
- * Extract token transfers from Transaction object
280
- */
281
- static extractTokenTransfersFromTransaction(transaction) {
282
- const tokenTransfers = [];
283
- try {
284
- const tokenTransfersList = transaction._tokenTransfers;
285
- if (Array.isArray(tokenTransfersList)) {
286
- tokenTransfersList.forEach((tokenTransfer) => {
287
- if (tokenTransfer.tokenId && Array.isArray(tokenTransfer.transfers)) {
288
- const transfers = tokenTransfer.transfers.map((transfer) => ({
289
- accountId: transfer.accountId?.toString() || "Unknown",
290
- amount: Number(transfer.amount || 0)
291
- }));
292
- tokenTransfers.push({
293
- tokenId: tokenTransfer.tokenId.toString(),
294
- transfers
295
- });
296
- }
297
- });
298
- }
299
- } catch (error) {
300
- }
301
- return tokenTransfers;
302
- }
303
314
  /**
304
- * Parse crypto transaction from Transaction object with comprehensive extraction
305
- * This is the unified entry point that handles both protobuf and internal field extraction
315
+ * Parse File Service transaction from Transaction object
316
+ * This is the unified entry point that delegates to the comprehensive parsing logic
306
317
  */
307
318
  static parseFromTransactionObject(transaction) {
308
- try {
309
- const hbarTransfers = this.extractHbarTransfersFromTransaction(transaction);
310
- const tokenTransfers = this.extractTokenTransfersFromTransaction(transaction);
311
- if (hbarTransfers.length > 0 || tokenTransfers.length > 0) {
312
- const convertedTransfers = hbarTransfers.map((transfer) => ({
313
- accountId: transfer.accountId,
314
- amount: transfer.amount.toString() + " ℏ",
315
- isDecimal: true
316
- }));
317
- const convertedTokenTransfers = tokenTransfers.flatMap(
318
- (tokenGroup) => tokenGroup.transfers.map((transfer) => ({
319
- tokenId: tokenGroup.tokenId,
320
- accountId: transfer.accountId,
321
- amount: transfer.amount
322
- }))
323
- );
324
- if (hbarTransfers.length > 0) {
325
- return {
326
- type: "CRYPTOTRANSFER",
327
- humanReadableType: "Crypto Transfer",
328
- transfers: convertedTransfers,
329
- tokenTransfers: convertedTokenTransfers
330
- };
331
- } else if (tokenTransfers.length > 0) {
332
- return {
333
- type: "TOKENTRANSFER",
334
- humanReadableType: "Token Transfer",
335
- transfers: convertedTransfers,
336
- tokenTransfers: convertedTokenTransfers
337
- };
338
- }
339
- }
340
- return {};
341
- } catch (error) {
342
- return {};
343
- }
319
+ return this.parseFileTransaction(transaction);
344
320
  }
345
321
  }
346
322
  export {
347
- CryptoParser
323
+ FileParser
348
324
  };
349
325
  //# sourceMappingURL=standards-sdk.es144.js.map