@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.
- package/README.md +13 -1
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/types.d.ts +1 -0
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/hcs-16/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-17/types.d.ts.map +1 -1
- package/dist/cjs/hcs-20/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-20/types.d.ts +9 -8
- package/dist/cjs/hcs-20/types.d.ts.map +1 -1
- package/dist/cjs/hcs-21/base-client.d.ts +5 -3
- package/dist/cjs/hcs-21/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-21/browser.d.ts +17 -7
- package/dist/cjs/hcs-21/browser.d.ts.map +1 -1
- package/dist/cjs/hcs-21/index.d.ts +1 -0
- package/dist/cjs/hcs-21/index.d.ts.map +1 -1
- package/dist/cjs/hcs-21/sdk.d.ts +62 -0
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-21/tx.d.ts.map +1 -1
- package/dist/cjs/hcs-21/types.d.ts +157 -73
- package/dist/cjs/hcs-21/types.d.ts.map +1 -1
- package/dist/cjs/hcs-21/verify.d.ts +6 -0
- package/dist/cjs/hcs-21/verify.d.ts.map +1 -0
- package/dist/cjs/inscribe/inscriber.d.ts +3 -1
- package/dist/cjs/inscribe/inscriber.d.ts.map +1 -1
- package/dist/cjs/inscribe/quote-cache.d.ts.map +1 -1
- package/dist/cjs/inscribe/types.d.ts +5 -0
- package/dist/cjs/inscribe/types.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client.d.ts +4 -3
- package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +24 -24
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/types.d.ts +1 -0
- package/dist/cjs/services/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/cjs/utils/dynamic-import.d.ts +1 -0
- package/dist/cjs/utils/dynamic-import.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/types.d.ts +1 -0
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/hcs-16/base-client.d.ts.map +1 -1
- package/dist/es/hcs-17/types.d.ts.map +1 -1
- package/dist/es/hcs-20/sdk.d.ts.map +1 -1
- package/dist/es/hcs-20/types.d.ts +9 -8
- package/dist/es/hcs-20/types.d.ts.map +1 -1
- package/dist/es/hcs-21/base-client.d.ts +5 -3
- package/dist/es/hcs-21/base-client.d.ts.map +1 -1
- package/dist/es/hcs-21/browser.d.ts +17 -7
- package/dist/es/hcs-21/browser.d.ts.map +1 -1
- package/dist/es/hcs-21/index.d.ts +1 -0
- package/dist/es/hcs-21/index.d.ts.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts +62 -0
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-21/tx.d.ts.map +1 -1
- package/dist/es/hcs-21/types.d.ts +157 -73
- package/dist/es/hcs-21/types.d.ts.map +1 -1
- package/dist/es/hcs-21/verify.d.ts +6 -0
- package/dist/es/hcs-21/verify.d.ts.map +1 -0
- package/dist/es/inscribe/inscriber.d.ts +3 -1
- package/dist/es/inscribe/inscriber.d.ts.map +1 -1
- package/dist/es/inscribe/quote-cache.d.ts.map +1 -1
- package/dist/es/inscribe/types.d.ts +5 -0
- package/dist/es/inscribe/types.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client.d.ts +4 -3
- package/dist/es/services/registry-broker/client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +24 -24
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/types.d.ts +1 -0
- package/dist/es/services/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +58 -50
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es10.js +2 -2
- package/dist/es/standards-sdk.es100.js +26 -229
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +228 -109
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +94 -15
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +30 -80
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +80 -27
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +25 -136
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +140 -27
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +27 -20
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +18 -156
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +148 -196
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +160 -747
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +786 -9
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +13 -567
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +541 -576
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +601 -12
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +13 -2
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +2 -83
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +80 -36
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +39 -2
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +2 -223
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es120.js +193 -1110
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +1059 -225
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +303 -419
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +418 -351
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +348 -785
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +854 -182
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +153 -1512
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +1373 -1977
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +2209 -69
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +59 -79
- 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 +80 -152
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +159 -7
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +7 -86
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +65 -44
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +65 -28
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +28 -12274
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +17 -760
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +1 -1
- package/dist/es/standards-sdk.es138.js +766 -42
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +40 -15
- 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 +12271 -53
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +49 -57
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +71 -161
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +139 -289
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +274 -298
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +262 -369
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +316 -194
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +319 -64
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +79 -0
- package/dist/es/standards-sdk.es148.js.map +1 -0
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es17.js +5 -11
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +11 -16
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +9 -14
- package/dist/es/standards-sdk.es20.js.map +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 +1 -1
- package/dist/es/standards-sdk.es28.js +15 -18
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es3.js +2 -2
- package/dist/es/standards-sdk.es31.js +2 -2
- package/dist/es/standards-sdk.es32.js +4 -4
- package/dist/es/standards-sdk.es33.js +1 -1
- package/dist/es/standards-sdk.es36.js +7 -12
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +3 -3
- package/dist/es/standards-sdk.es38.js +2 -2
- package/dist/es/standards-sdk.es39.js +2 -2
- package/dist/es/standards-sdk.es40.js +1 -1
- package/dist/es/standards-sdk.es41.js +1 -1
- package/dist/es/standards-sdk.es42.js +2 -2
- package/dist/es/standards-sdk.es47.js +1 -1
- package/dist/es/standards-sdk.es5.js +1 -1
- package/dist/es/standards-sdk.es52.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es57.js +2 -2
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es6.js +2 -2
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es61.js +6 -11
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +1 -1
- package/dist/es/standards-sdk.es65.js +2 -2
- package/dist/es/standards-sdk.es66.js +2 -2
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es7.js +2 -2
- package/dist/es/standards-sdk.es70.js +3 -3
- package/dist/es/standards-sdk.es71.js +2 -2
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +2 -2
- package/dist/es/standards-sdk.es77.js +4 -2
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +4 -10
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +1 -1
- package/dist/es/standards-sdk.es8.js +1 -1
- package/dist/es/standards-sdk.es80.js +27 -15
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +12 -4
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +31 -6
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +181 -6
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +256 -9
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +55 -21
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +22 -75
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +45 -30
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +57 -22
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es90.js +28 -23
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +23 -167
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +158 -119
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +68 -95
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +136 -119
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +139 -39
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +42 -257
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +243 -80
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +47 -48
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +100 -28
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/dynamic-import.d.ts +1 -0
- package/dist/es/utils/dynamic-import.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,793 +1,206 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { Logger } from "./standards-sdk.es106.js";
|
|
3
|
+
import { HederaMirrorNode } from "./standards-sdk.es127.js";
|
|
4
|
+
import "node:path";
|
|
5
|
+
import "node:buffer";
|
|
6
|
+
import "node:crypto";
|
|
7
|
+
import "@noble/curves/secp256k1.js";
|
|
8
|
+
import "./standards-sdk.es130.js";
|
|
9
|
+
import "./standards-sdk.es138.js";
|
|
10
|
+
import "zod";
|
|
11
|
+
class HRLResolver {
|
|
12
|
+
constructor(logLevel = "info") {
|
|
13
|
+
this.defaultEndpoint = "https://kiloscribe.com/api/inscription-cdn";
|
|
14
|
+
this.logger = Logger.getInstance({
|
|
15
|
+
level: logLevel,
|
|
16
|
+
module: "HRLResolver"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
void 0,
|
|
38
|
-
transactionBytes
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
let lastError;
|
|
42
|
-
let retryCount = 0;
|
|
43
|
-
while (retryCount <= maxRetries) {
|
|
44
|
-
try {
|
|
45
|
-
const result = await this.parseTransaction(transactionBytes, options);
|
|
46
|
-
result.formatDetection = {
|
|
47
|
-
originalFormat: validation.format || "base64",
|
|
48
|
-
wasConverted: validation.format === "hex",
|
|
49
|
-
length: transactionBytes.length
|
|
50
|
-
};
|
|
51
|
-
return result;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
54
|
-
retryCount++;
|
|
55
|
-
if (!enableFallback || retryCount > maxRetries) {
|
|
56
|
-
if (strictMode) {
|
|
57
|
-
throw new TransactionParsingError(
|
|
58
|
-
"Failed to parse transaction after all attempts",
|
|
59
|
-
"PARSING_FAILED",
|
|
60
|
-
lastError,
|
|
61
|
-
transactionBytes
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
const result = this.parseScheduledTransaction(
|
|
68
|
-
transactionBytes,
|
|
69
|
-
options
|
|
70
|
-
);
|
|
71
|
-
result.formatDetection = {
|
|
72
|
-
originalFormat: validation.format || "base64",
|
|
73
|
-
wasConverted: false,
|
|
74
|
-
length: transactionBytes.length
|
|
75
|
-
};
|
|
76
|
-
return result;
|
|
77
|
-
} catch (scheduledError) {
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const fallbackResult = this.createFallbackResult(
|
|
82
|
-
transactionBytes,
|
|
83
|
-
lastError,
|
|
84
|
-
void 0
|
|
85
|
-
);
|
|
86
|
-
if (fallbackResult.details) {
|
|
87
|
-
fallbackResult.details.parseAttempts = Math.max(retryCount, 1);
|
|
88
|
-
}
|
|
89
|
-
return fallbackResult;
|
|
20
|
+
* Determines if a MIME type represents binary content
|
|
21
|
+
*/
|
|
22
|
+
isBinaryContentType(mimeType) {
|
|
23
|
+
const binaryTypes = [
|
|
24
|
+
"image/",
|
|
25
|
+
"audio/",
|
|
26
|
+
"video/",
|
|
27
|
+
"application/octet-stream",
|
|
28
|
+
"application/pdf",
|
|
29
|
+
"application/zip",
|
|
30
|
+
"application/gzip",
|
|
31
|
+
"application/x-binary",
|
|
32
|
+
"application/vnd.ms-",
|
|
33
|
+
"application/x-msdownload",
|
|
34
|
+
"application/x-shockwave-flash",
|
|
35
|
+
"font/",
|
|
36
|
+
"application/wasm"
|
|
37
|
+
];
|
|
38
|
+
return binaryTypes.some((prefix) => mimeType.startsWith(prefix));
|
|
90
39
|
}
|
|
91
40
|
/**
|
|
92
|
-
*
|
|
93
|
-
* This method delegates to specialized parsers for clean separation of concerns
|
|
94
|
-
*
|
|
95
|
-
* @param transaction - The Transaction object to parse
|
|
96
|
-
* @param originalBytes - The original transaction bytes (optional, for protobuf parsing)
|
|
97
|
-
* @param options - Parsing options
|
|
98
|
-
* @returns Parsed transaction data
|
|
41
|
+
* Parses an HRL string into its components
|
|
99
42
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (originalBytesOrOptions && !Buffer.isBuffer(originalBytesOrOptions) && !(originalBytesOrOptions instanceof Uint8Array)) {
|
|
104
|
-
actualOptions = originalBytesOrOptions;
|
|
105
|
-
originalBytes = void 0;
|
|
106
|
-
} else {
|
|
107
|
-
originalBytes = originalBytesOrOptions;
|
|
108
|
-
actualOptions = options;
|
|
43
|
+
parseHRL(hrl) {
|
|
44
|
+
if (!hrl) {
|
|
45
|
+
return null;
|
|
109
46
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const hcsResult = HCSParser.parseFromTransactionObject(transaction);
|
|
115
|
-
const fileResult = FileParser.parseFromTransactionObject(transaction);
|
|
116
|
-
const scsResult = SCSParser.parseFromTransactionObject(transaction);
|
|
117
|
-
const scheduleResult = ScheduleParser.parseFromTransactionObject(transaction);
|
|
118
|
-
const utilResult = UtilParser.parseFromTransactionObject(transaction);
|
|
119
|
-
const results = [
|
|
120
|
-
htsResult,
|
|
121
|
-
cryptoResult,
|
|
122
|
-
hcsResult,
|
|
123
|
-
fileResult,
|
|
124
|
-
scsResult,
|
|
125
|
-
scheduleResult,
|
|
126
|
-
utilResult
|
|
127
|
-
];
|
|
128
|
-
const primaryResult = results.find((result2) => result2.type && result2.type !== "UNKNOWN") || {};
|
|
129
|
-
let finalType = "UNKNOWN";
|
|
130
|
-
let finalHumanReadableType = "Unknown Transaction";
|
|
131
|
-
let parsedTokenCreation;
|
|
132
|
-
let protoParsingResult = {};
|
|
133
|
-
if (originalBytes || transaction.toBytes) {
|
|
134
|
-
try {
|
|
135
|
-
const bytesToParse = originalBytes || transaction.toBytes();
|
|
136
|
-
const decoded = proto.TransactionList.decode(bytesToParse);
|
|
137
|
-
if (decoded.transactionList && decoded.transactionList.length > 0) {
|
|
138
|
-
const tx = decoded.transactionList[0];
|
|
139
|
-
if (tx.bodyBytes && tx.bodyBytes.length > 0) {
|
|
140
|
-
const txBody = proto.TransactionBody.decode(tx.bodyBytes);
|
|
141
|
-
const typeResult = this.detectTransactionTypeFromBody(txBody);
|
|
142
|
-
finalType = typeResult.type;
|
|
143
|
-
finalHumanReadableType = typeResult.humanReadableType;
|
|
144
|
-
protoParsingResult = this.parseTransactionBodyDetails(
|
|
145
|
-
txBody,
|
|
146
|
-
finalType
|
|
147
|
-
);
|
|
148
|
-
if (protoParsingResult.tokenCreation) {
|
|
149
|
-
parsedTokenCreation = protoParsingResult.tokenCreation;
|
|
150
|
-
}
|
|
151
|
-
} else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
|
|
152
|
-
const signedTx = proto.SignedTransaction.decode(
|
|
153
|
-
tx.signedTransactionBytes
|
|
154
|
-
);
|
|
155
|
-
if (signedTx.bodyBytes) {
|
|
156
|
-
const txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
|
|
157
|
-
const typeResult = this.detectTransactionTypeFromBody(txBody);
|
|
158
|
-
finalType = typeResult.type;
|
|
159
|
-
finalHumanReadableType = typeResult.humanReadableType;
|
|
160
|
-
protoParsingResult = this.parseTransactionBodyDetails(
|
|
161
|
-
txBody,
|
|
162
|
-
finalType
|
|
163
|
-
);
|
|
164
|
-
if (protoParsingResult.tokenCreation) {
|
|
165
|
-
parsedTokenCreation = protoParsingResult.tokenCreation;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
} catch (protoError) {
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (finalType === "UNKNOWN" && primaryResult.type) {
|
|
174
|
-
finalType = primaryResult.type;
|
|
175
|
-
finalHumanReadableType = primaryResult.humanReadableType || finalHumanReadableType;
|
|
176
|
-
}
|
|
177
|
-
const result = {
|
|
178
|
-
type: finalType,
|
|
179
|
-
humanReadableType: finalHumanReadableType,
|
|
180
|
-
transfers: [],
|
|
181
|
-
tokenTransfers: [],
|
|
182
|
-
...metadata,
|
|
183
|
-
...primaryResult,
|
|
184
|
-
raw: actualOptions.includeRaw ? transaction._transactionBody || {} : void 0
|
|
185
|
-
};
|
|
186
|
-
this.mergeProtoParsingResults(
|
|
187
|
-
result,
|
|
188
|
-
protoParsingResult,
|
|
189
|
-
htsResult,
|
|
190
|
-
transaction,
|
|
191
|
-
originalBytes
|
|
192
|
-
);
|
|
193
|
-
result.transfers = cryptoResult.transfers || result.transfers || [];
|
|
194
|
-
result.tokenTransfers = cryptoResult.tokenTransfers || result.tokenTransfers || [];
|
|
195
|
-
return result;
|
|
196
|
-
} catch (error) {
|
|
197
|
-
return {
|
|
198
|
-
type: "UNKNOWN",
|
|
199
|
-
humanReadableType: "Unknown Transaction",
|
|
200
|
-
transfers: [],
|
|
201
|
-
tokenTransfers: [],
|
|
202
|
-
raw: actualOptions.includeRaw ? {} : void 0,
|
|
203
|
-
details: {
|
|
204
|
-
error: `Failed to parse Transaction object: ${error instanceof Error ? error.message : String(error)}`
|
|
205
|
-
}
|
|
206
|
-
};
|
|
47
|
+
const hrlPattern = /^hcs:\/\/(\d+)\/([0-9]+\.[0-9]+\.[0-9]+)$/;
|
|
48
|
+
const match = hrl.match(hrlPattern);
|
|
49
|
+
if (!match) {
|
|
50
|
+
return null;
|
|
207
51
|
}
|
|
52
|
+
return {
|
|
53
|
+
standard: match[1],
|
|
54
|
+
topicId: match[2]
|
|
55
|
+
};
|
|
208
56
|
}
|
|
209
57
|
/**
|
|
210
|
-
*
|
|
211
|
-
* @param transactionBodyBase64 - The base64 encoded transaction body
|
|
212
|
-
* @returns The parsed transaction
|
|
58
|
+
* Validates if a string is a valid HRL
|
|
213
59
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const txBody = proto.SchedulableTransactionBody.decode(buffer);
|
|
218
|
-
const transactionType = this.getTransactionType(txBody);
|
|
219
|
-
const result = {
|
|
220
|
-
type: transactionType,
|
|
221
|
-
humanReadableType: this.getHumanReadableType(transactionType),
|
|
222
|
-
transfers: [],
|
|
223
|
-
tokenTransfers: [],
|
|
224
|
-
raw: txBody
|
|
225
|
-
};
|
|
226
|
-
if (txBody.memo) {
|
|
227
|
-
result.memo = txBody.memo;
|
|
228
|
-
}
|
|
229
|
-
if (txBody.transactionFee) {
|
|
230
|
-
const hbarAmount = Hbar.fromTinybars(
|
|
231
|
-
Long.fromValue(txBody.transactionFee)
|
|
232
|
-
);
|
|
233
|
-
result.transactionFee = hbarAmount.toString(HbarUnit.Hbar);
|
|
234
|
-
}
|
|
235
|
-
this.applySchedulableTransactionParsing(txBody, result);
|
|
236
|
-
return result;
|
|
237
|
-
} catch (error) {
|
|
238
|
-
return {
|
|
239
|
-
type: "UNKNOWN",
|
|
240
|
-
humanReadableType: "Unknown Transaction",
|
|
241
|
-
transfers: [],
|
|
242
|
-
tokenTransfers: [],
|
|
243
|
-
raw: void 0,
|
|
244
|
-
details: {
|
|
245
|
-
error: `Failed to parse transaction body: ${error instanceof Error ? error.message : String(error)}`
|
|
246
|
-
}
|
|
247
|
-
};
|
|
60
|
+
isValidHRL(hrl) {
|
|
61
|
+
if (!hrl || typeof hrl !== "string") {
|
|
62
|
+
return false;
|
|
248
63
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
* Uses registry pattern to eliminate massive if-else chain
|
|
253
|
-
*/
|
|
254
|
-
static detectTransactionTypeFromBody(txBody) {
|
|
255
|
-
return getTransactionTypeFromBody(txBody);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Parse details from a complete schedule response
|
|
259
|
-
* @param scheduleResponse - The schedule response to parse
|
|
260
|
-
* @returns The parsed transaction
|
|
261
|
-
*/
|
|
262
|
-
static parseScheduleResponse(scheduleResponse) {
|
|
263
|
-
if (!scheduleResponse.transaction_body) {
|
|
264
|
-
return {
|
|
265
|
-
type: "UNKNOWN",
|
|
266
|
-
humanReadableType: "Unknown Transaction",
|
|
267
|
-
transfers: [],
|
|
268
|
-
tokenTransfers: [],
|
|
269
|
-
raw: void 0,
|
|
270
|
-
details: {
|
|
271
|
-
error: "Schedule response missing transaction_body"
|
|
272
|
-
}
|
|
273
|
-
};
|
|
64
|
+
const parsed = this.parseHRL(hrl);
|
|
65
|
+
if (!parsed) {
|
|
66
|
+
return false;
|
|
274
67
|
}
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
|
|
68
|
+
const topicIdPattern = /^[0-9]+\.[0-9]+\.[0-9]+$/;
|
|
69
|
+
if (!topicIdPattern.test(parsed.topicId)) {
|
|
70
|
+
return false;
|
|
278
71
|
}
|
|
279
|
-
return
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Determine the transaction type using registry pattern
|
|
283
|
-
* @param txBody - The transaction body to determine the type of
|
|
284
|
-
* @returns The type of the transaction
|
|
285
|
-
*/
|
|
286
|
-
static getTransactionType(txBody) {
|
|
287
|
-
return getTransactionTypeFromBody(txBody).type;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Convert technical transaction type to human-readable format using registry pattern
|
|
291
|
-
* @param type - The technical transaction type
|
|
292
|
-
* @returns The human-readable transaction type
|
|
293
|
-
*/
|
|
294
|
-
static getHumanReadableType(type) {
|
|
295
|
-
return getHumanReadableTransactionType(type);
|
|
72
|
+
return true;
|
|
296
73
|
}
|
|
297
74
|
/**
|
|
298
|
-
*
|
|
299
|
-
* @param parsedTx - The parsed transaction
|
|
300
|
-
* @returns The human-readable summary of the transaction
|
|
75
|
+
* Validates if a string is a valid topic ID
|
|
301
76
|
*/
|
|
302
|
-
|
|
303
|
-
|
|
77
|
+
isValidTopicId(topicId) {
|
|
78
|
+
const topicIdPattern = /^[0-9]+\.[0-9]+\.[0-9]+$/;
|
|
79
|
+
return topicIdPattern.test(topicId);
|
|
304
80
|
}
|
|
305
81
|
/**
|
|
306
|
-
*
|
|
307
|
-
*
|
|
82
|
+
* Resolves content from either an HRL or a topic ID
|
|
83
|
+
* If a topic ID is provided, it queries the topic memo to determine the HCS standard
|
|
308
84
|
*/
|
|
309
|
-
|
|
310
|
-
if (
|
|
311
|
-
return
|
|
312
|
-
isValid: false,
|
|
313
|
-
error: "Transaction bytes must be a non-empty string"
|
|
314
|
-
};
|
|
85
|
+
async resolve(hrlOrTopicId, options) {
|
|
86
|
+
if (this.isValidHRL(hrlOrTopicId)) {
|
|
87
|
+
return this.resolveHRL(hrlOrTopicId, options);
|
|
315
88
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const hexRegex = /^0x[0-9a-fA-F]+$/;
|
|
319
|
-
let isValid = false;
|
|
320
|
-
let error;
|
|
321
|
-
if (format === "hex") {
|
|
322
|
-
isValid = hexRegex.test(transactionBytes) && transactionBytes.length > 2;
|
|
323
|
-
if (!isValid) {
|
|
324
|
-
error = "Invalid hex format";
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
isValid = base64Regex.test(transactionBytes) && transactionBytes.length > 0;
|
|
328
|
-
if (!isValid) {
|
|
329
|
-
error = "Invalid base64 format";
|
|
330
|
-
}
|
|
89
|
+
if (!this.isValidTopicId(hrlOrTopicId)) {
|
|
90
|
+
throw new Error(`Invalid HRL or topic ID format: ${hrlOrTopicId}`);
|
|
331
91
|
}
|
|
332
|
-
return {
|
|
333
|
-
isValid,
|
|
334
|
-
format,
|
|
335
|
-
error,
|
|
336
|
-
length: transactionBytes.length
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Detects the format of transaction bytes
|
|
341
|
-
* @param transactionBytes - The transaction bytes to analyze
|
|
342
|
-
* @returns The detected format ('base64' or 'hex')
|
|
343
|
-
*/
|
|
344
|
-
static detectTransactionFormat(transactionBytes) {
|
|
345
|
-
return transactionBytes.startsWith("0x") ? "hex" : "base64";
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Decodes transaction bytes from string to Uint8Array
|
|
349
|
-
* @param transactionBytes - The transaction bytes string (base64 or hex)
|
|
350
|
-
* @returns Decoded Uint8Array
|
|
351
|
-
* @throws TransactionParsingError if decoding fails
|
|
352
|
-
*/
|
|
353
|
-
static decodeTransactionBytes(transactionBytes) {
|
|
354
92
|
try {
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
93
|
+
const mirrorNode = new HederaMirrorNode(options.network, this.logger);
|
|
94
|
+
const topicInfo = await mirrorNode.getTopicInfo(hrlOrTopicId);
|
|
95
|
+
const memo = topicInfo?.memo || "";
|
|
96
|
+
let standard = "1";
|
|
97
|
+
if (memo) {
|
|
98
|
+
const hcsMatch = memo.match(/^hcs-(\d+)/);
|
|
99
|
+
if (hcsMatch && hcsMatch[1]) {
|
|
100
|
+
standard = hcsMatch[1];
|
|
101
|
+
}
|
|
361
102
|
}
|
|
103
|
+
const hrl = `hcs://${standard}/${hrlOrTopicId}`;
|
|
104
|
+
return this.resolveHRL(hrl, options);
|
|
362
105
|
} catch (error) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
"DECODE_ERROR",
|
|
366
|
-
error instanceof Error ? error : void 0,
|
|
367
|
-
transactionBytes
|
|
106
|
+
this.logger.error(
|
|
107
|
+
`Failed to get topic info for ${hrlOrTopicId}: ${error.message}`
|
|
368
108
|
);
|
|
109
|
+
const hrl = `hcs://1/${hrlOrTopicId}`;
|
|
110
|
+
return this.resolveHRL(hrl, options);
|
|
369
111
|
}
|
|
370
112
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
const bytes = this.decodeTransactionBytes(transactionBytes);
|
|
380
|
-
Transaction.fromBytes(bytes);
|
|
381
|
-
return true;
|
|
382
|
-
} catch {
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Legacy alias for decodeTransactionBytes - keeping for backward compatibility
|
|
388
|
-
*/
|
|
389
|
-
static decodeBytesLegacy(transactionBytes) {
|
|
390
|
-
return this.decodeTransactionBytes(transactionBytes);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Parse transaction bytes into structured data using thin orchestration
|
|
394
|
-
* Delegates to specialized parsers for clean separation of concerns
|
|
395
|
-
*/
|
|
396
|
-
static async parseTransaction(transactionBytes, options = {}) {
|
|
397
|
-
try {
|
|
398
|
-
const bytes = this.decodeTransactionBytes(transactionBytes);
|
|
399
|
-
const transaction = Transaction.fromBytes(bytes);
|
|
400
|
-
const metadata = this.extractTransactionMetadataEnhanced(transaction);
|
|
401
|
-
const parserResults = this.runAllParsers(transaction);
|
|
402
|
-
const primaryResult = parserResults.find(
|
|
403
|
-
(result2) => result2.type && result2.type !== "UNKNOWN"
|
|
404
|
-
) || {};
|
|
405
|
-
const protoParsingResult = this.parseFromProtobuf(bytes);
|
|
406
|
-
const finalType = protoParsingResult.type || primaryResult.type || "UNKNOWN";
|
|
407
|
-
const finalHumanReadableType = protoParsingResult.humanReadableType || primaryResult.humanReadableType || "Unknown Transaction";
|
|
408
|
-
const result = {
|
|
409
|
-
type: finalType,
|
|
410
|
-
humanReadableType: finalHumanReadableType,
|
|
411
|
-
transfers: [],
|
|
412
|
-
tokenTransfers: [],
|
|
413
|
-
details: { ...metadata },
|
|
414
|
-
memo: typeof metadata.memo === "string" ? metadata.memo : void 0,
|
|
415
|
-
transactionId: typeof metadata.transactionId === "string" ? metadata.transactionId : void 0,
|
|
416
|
-
nodeAccountIds: Array.isArray(metadata.nodeAccountIds) ? metadata.nodeAccountIds : [],
|
|
417
|
-
maxTransactionFee: typeof metadata.maxTransactionFee === "string" ? metadata.maxTransactionFee : void 0,
|
|
418
|
-
validStart: typeof metadata.validStart === "string" ? metadata.validStart : void 0,
|
|
419
|
-
validDuration: typeof metadata.validDuration === "string" ? metadata.validDuration : void 0,
|
|
420
|
-
raw: options.includeRaw ? {} : void 0
|
|
113
|
+
async getContentWithType(hrl, options) {
|
|
114
|
+
if (!this.isValidHRL(hrl)) {
|
|
115
|
+
return {
|
|
116
|
+
content: hrl,
|
|
117
|
+
contentType: "text/plain",
|
|
118
|
+
isBinary: false
|
|
421
119
|
};
|
|
422
|
-
this.mergeAllResults(
|
|
423
|
-
result,
|
|
424
|
-
protoParsingResult,
|
|
425
|
-
primaryResult,
|
|
426
|
-
parserResults
|
|
427
|
-
);
|
|
428
|
-
return result;
|
|
429
|
-
} catch (error) {
|
|
430
|
-
throw new TransactionParsingError(
|
|
431
|
-
"Failed to parse as regular transaction",
|
|
432
|
-
"REGULAR_PARSING_FAILED",
|
|
433
|
-
error instanceof Error ? error : void 0,
|
|
434
|
-
transactionBytes
|
|
435
|
-
);
|
|
436
120
|
}
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Parse scheduled transaction body
|
|
440
|
-
*/
|
|
441
|
-
static parseScheduledTransaction(transactionBytes, options = {}) {
|
|
442
121
|
try {
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
...parsedTx.details || {},
|
|
449
|
-
parseMethod: "scheduled",
|
|
450
|
-
validation,
|
|
451
|
-
parseAttempts: parsedTx.details?.parseAttempts || 1
|
|
452
|
-
},
|
|
453
|
-
formatDetection: {
|
|
454
|
-
originalFormat: validation.format || "base64",
|
|
455
|
-
wasConverted: false,
|
|
456
|
-
length: transactionBytes.length
|
|
457
|
-
}
|
|
122
|
+
const result = await this.resolveHRL(hrl, options);
|
|
123
|
+
return {
|
|
124
|
+
content: result.content,
|
|
125
|
+
contentType: result.contentType,
|
|
126
|
+
isBinary: result.isBinary
|
|
458
127
|
};
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
error instanceof Error ? error : void 0,
|
|
465
|
-
transactionBytes
|
|
466
|
-
);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
const error = e;
|
|
130
|
+
const logMessage = `Error resolving HRL for content and type: ${error.message}`;
|
|
131
|
+
this.logger.error(logMessage);
|
|
132
|
+
throw new Error(logMessage);
|
|
467
133
|
}
|
|
468
134
|
}
|
|
469
135
|
/**
|
|
470
|
-
*
|
|
471
|
-
*/
|
|
472
|
-
static extractTransactionMetadata(transaction) {
|
|
473
|
-
return {
|
|
474
|
-
transactionId: transaction.transactionId?.toString(),
|
|
475
|
-
nodeAccountIds: transaction.nodeAccountIds?.map((id) => id.toString()) || [],
|
|
476
|
-
maxTransactionFee: transaction.maxTransactionFee?.toTinybars().toString() || "0",
|
|
477
|
-
memo: transaction._transactionMemo || void 0,
|
|
478
|
-
transfers: [],
|
|
479
|
-
tokenTransfers: []
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Extract enhanced metadata from Transaction object
|
|
136
|
+
* Resolves HRL content with proper content type detection
|
|
484
137
|
*/
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
maxTransactionFee: transaction.maxTransactionFee?.toTinybars().toString() || "0",
|
|
490
|
-
memo: transaction._transactionMemo || void 0,
|
|
491
|
-
validStart: transaction._transactionValidStart?.toString(),
|
|
492
|
-
validDuration: transaction._transactionValidDuration?.toString()
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Run all available parsers on a transaction
|
|
497
|
-
*/
|
|
498
|
-
static runAllParsers(transaction) {
|
|
499
|
-
return [
|
|
500
|
-
HTSParser.parseFromTransactionObject(transaction),
|
|
501
|
-
CryptoParser.parseFromTransactionObject(transaction),
|
|
502
|
-
HCSParser.parseFromTransactionObject(transaction),
|
|
503
|
-
FileParser.parseFromTransactionObject(transaction),
|
|
504
|
-
SCSParser.parseFromTransactionObject(transaction),
|
|
505
|
-
ScheduleParser.parseFromTransactionObject(transaction),
|
|
506
|
-
UtilParser.parseFromTransactionObject(transaction)
|
|
507
|
-
];
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Parse transaction from protobuf bytes
|
|
511
|
-
*/
|
|
512
|
-
static parseFromProtobuf(bytes) {
|
|
513
|
-
const result = {};
|
|
514
|
-
try {
|
|
515
|
-
const decoded = proto.TransactionList.decode(bytes);
|
|
516
|
-
if (decoded.transactionList && decoded.transactionList.length > 0) {
|
|
517
|
-
const tx = decoded.transactionList[0];
|
|
518
|
-
let txBody = null;
|
|
519
|
-
if (tx.bodyBytes && tx.bodyBytes.length > 0) {
|
|
520
|
-
txBody = proto.TransactionBody.decode(tx.bodyBytes);
|
|
521
|
-
} else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
|
|
522
|
-
const signedTx = proto.SignedTransaction.decode(
|
|
523
|
-
tx.signedTransactionBytes
|
|
524
|
-
);
|
|
525
|
-
if (signedTx.bodyBytes) {
|
|
526
|
-
txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
if (txBody) {
|
|
530
|
-
const typeResult = this.detectTransactionTypeFromBody(txBody);
|
|
531
|
-
result.type = typeResult.type;
|
|
532
|
-
result.humanReadableType = typeResult.humanReadableType;
|
|
533
|
-
const details = this.parseTransactionBodyDetails(
|
|
534
|
-
txBody,
|
|
535
|
-
typeResult.type
|
|
536
|
-
);
|
|
537
|
-
Object.assign(result, details);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
} catch (error) {
|
|
138
|
+
async resolveHRL(hrl, options) {
|
|
139
|
+
const parsed = this.parseHRL(hrl);
|
|
140
|
+
if (!parsed) {
|
|
141
|
+
throw new Error(`Invalid HRL format: ${hrl}`);
|
|
541
142
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
143
|
+
const { standard, topicId } = parsed;
|
|
144
|
+
this.logger.debug(
|
|
145
|
+
`Resolving HRL reference: standard=${standard}, topicId=${topicId}`
|
|
146
|
+
);
|
|
147
|
+
try {
|
|
148
|
+
const cdnEndpoint = options.cdnEndpoint || this.defaultEndpoint;
|
|
149
|
+
const cdnUrl = `${cdnEndpoint}/${topicId}?network=${options.network}`;
|
|
150
|
+
this.logger.debug(`Fetching content from CDN: ${cdnUrl}`);
|
|
151
|
+
const headResponse = await axios.head(cdnUrl);
|
|
152
|
+
const contentType = headResponse.headers["content-type"] || "";
|
|
153
|
+
const isBinary = this.isBinaryContentType(contentType);
|
|
154
|
+
if (isBinary || options.returnRaw) {
|
|
155
|
+
const response2 = await axios.get(cdnUrl, {
|
|
156
|
+
responseType: "arraybuffer"
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
content: response2.data,
|
|
160
|
+
contentType,
|
|
161
|
+
topicId,
|
|
162
|
+
isBinary: true
|
|
163
|
+
};
|
|
559
164
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
static applySchedulableTransactionParsing(txBody, result) {
|
|
567
|
-
if (txBody.cryptoTransfer) {
|
|
568
|
-
CryptoParser.parseCryptoTransfers(txBody.cryptoTransfer, result);
|
|
569
|
-
}
|
|
570
|
-
if (txBody.cryptoDelete) {
|
|
571
|
-
result.cryptoDelete = CryptoParser.parseCryptoDelete(txBody.cryptoDelete);
|
|
572
|
-
}
|
|
573
|
-
if (txBody.cryptoCreateAccount) {
|
|
574
|
-
result.cryptoCreateAccount = CryptoParser.parseCryptoCreateAccount(
|
|
575
|
-
txBody.cryptoCreateAccount
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
if (txBody.cryptoUpdateAccount) {
|
|
579
|
-
result.cryptoUpdateAccount = CryptoParser.parseCryptoUpdateAccount(
|
|
580
|
-
txBody.cryptoUpdateAccount
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
if (txBody.cryptoApproveAllowance) {
|
|
584
|
-
result.cryptoApproveAllowance = CryptoParser.parseCryptoApproveAllowance(
|
|
585
|
-
txBody.cryptoApproveAllowance
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
|
-
if (txBody.cryptoDeleteAllowance) {
|
|
589
|
-
result.cryptoDeleteAllowance = CryptoParser.parseCryptoDeleteAllowance(
|
|
590
|
-
txBody.cryptoDeleteAllowance
|
|
591
|
-
);
|
|
592
|
-
}
|
|
593
|
-
if (txBody.contractCall) {
|
|
594
|
-
result.contractCall = SCSParser.parseContractCall(txBody.contractCall);
|
|
595
|
-
}
|
|
596
|
-
if (txBody.contractCreateInstance) {
|
|
597
|
-
result.contractCreate = SCSParser.parseContractCreate(
|
|
598
|
-
txBody.contractCreateInstance
|
|
599
|
-
);
|
|
600
|
-
}
|
|
601
|
-
if (txBody.contractUpdateInstance) {
|
|
602
|
-
result.contractUpdate = SCSParser.parseContractUpdate(
|
|
603
|
-
txBody.contractUpdateInstance
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
|
-
if (txBody.contractDeleteInstance) {
|
|
607
|
-
result.contractDelete = SCSParser.parseContractDelete(
|
|
608
|
-
txBody.contractDeleteInstance
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
if (txBody.tokenCreation) {
|
|
612
|
-
result.tokenCreation = HTSParser.parseTokenCreate(txBody.tokenCreation);
|
|
613
|
-
}
|
|
614
|
-
if (txBody.tokenMint) {
|
|
615
|
-
result.tokenMint = HTSParser.parseTokenMint(txBody.tokenMint);
|
|
616
|
-
}
|
|
617
|
-
if (txBody.tokenBurn) {
|
|
618
|
-
result.tokenBurn = HTSParser.parseTokenBurn(txBody.tokenBurn);
|
|
619
|
-
}
|
|
620
|
-
if (txBody.tokenUpdate) {
|
|
621
|
-
result.tokenUpdate = HTSParser.parseTokenUpdate(txBody.tokenUpdate);
|
|
622
|
-
}
|
|
623
|
-
if (txBody.tokenFeeScheduleUpdate) {
|
|
624
|
-
result.tokenFeeScheduleUpdate = HTSParser.parseTokenFeeScheduleUpdate(
|
|
625
|
-
txBody.tokenFeeScheduleUpdate
|
|
626
|
-
);
|
|
627
|
-
}
|
|
628
|
-
if (txBody.tokenFreeze) {
|
|
629
|
-
result.tokenFreeze = HTSParser.parseTokenFreeze(txBody.tokenFreeze);
|
|
630
|
-
}
|
|
631
|
-
if (txBody.tokenUnfreeze) {
|
|
632
|
-
result.tokenUnfreeze = HTSParser.parseTokenUnfreeze(txBody.tokenUnfreeze);
|
|
633
|
-
}
|
|
634
|
-
if (txBody.tokenGrantKyc) {
|
|
635
|
-
result.tokenGrantKyc = HTSParser.parseTokenGrantKyc(txBody.tokenGrantKyc);
|
|
636
|
-
}
|
|
637
|
-
if (txBody.tokenRevokeKyc) {
|
|
638
|
-
result.tokenRevokeKyc = HTSParser.parseTokenRevokeKyc(
|
|
639
|
-
txBody.tokenRevokeKyc
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
if (txBody.tokenPause) {
|
|
643
|
-
result.tokenPause = HTSParser.parseTokenPause(txBody.tokenPause);
|
|
644
|
-
}
|
|
645
|
-
if (txBody.tokenUnpause) {
|
|
646
|
-
result.tokenUnpause = HTSParser.parseTokenUnpause(txBody.tokenUnpause);
|
|
647
|
-
}
|
|
648
|
-
if (txBody.tokenWipe) {
|
|
649
|
-
result.tokenWipeAccount = HTSParser.parseTokenWipeAccount(
|
|
650
|
-
txBody.tokenWipe
|
|
651
|
-
);
|
|
652
|
-
}
|
|
653
|
-
if (txBody.tokenDeletion) {
|
|
654
|
-
result.tokenDelete = HTSParser.parseTokenDelete(txBody.tokenDeletion);
|
|
655
|
-
}
|
|
656
|
-
if (txBody.tokenAssociate) {
|
|
657
|
-
result.tokenAssociate = HTSParser.parseTokenAssociate(
|
|
658
|
-
txBody.tokenAssociate
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
if (txBody.tokenDissociate) {
|
|
662
|
-
result.tokenDissociate = HTSParser.parseTokenDissociate(
|
|
663
|
-
txBody.tokenDissociate
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
if (txBody.tokenAirdrop) {
|
|
667
|
-
result.tokenAirdrop = HTSParser.parseTokenAirdropFromProto(
|
|
668
|
-
txBody.tokenAirdrop
|
|
669
|
-
);
|
|
670
|
-
}
|
|
671
|
-
if (txBody.consensusCreateTopic) {
|
|
672
|
-
result.consensusCreateTopic = HCSParser.parseConsensusCreateTopic(
|
|
673
|
-
txBody.consensusCreateTopic
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
if (txBody.consensusSubmitMessage) {
|
|
677
|
-
result.consensusSubmitMessage = HCSParser.parseConsensusSubmitMessage(
|
|
678
|
-
txBody.consensusSubmitMessage
|
|
679
|
-
);
|
|
680
|
-
}
|
|
681
|
-
if (txBody.consensusUpdateTopic) {
|
|
682
|
-
result.consensusUpdateTopic = HCSParser.parseConsensusUpdateTopic(
|
|
683
|
-
txBody.consensusUpdateTopic
|
|
684
|
-
);
|
|
685
|
-
}
|
|
686
|
-
if (txBody.consensusDeleteTopic) {
|
|
687
|
-
result.consensusDeleteTopic = HCSParser.parseConsensusDeleteTopic(
|
|
688
|
-
txBody.consensusDeleteTopic
|
|
689
|
-
);
|
|
690
|
-
}
|
|
691
|
-
if (txBody.fileCreate) {
|
|
692
|
-
result.fileCreate = FileParser.parseFileCreate(txBody.fileCreate);
|
|
693
|
-
}
|
|
694
|
-
if (txBody.fileAppend) {
|
|
695
|
-
result.fileAppend = FileParser.parseFileAppend(txBody.fileAppend);
|
|
696
|
-
}
|
|
697
|
-
if (txBody.fileUpdate) {
|
|
698
|
-
result.fileUpdate = FileParser.parseFileUpdate(txBody.fileUpdate);
|
|
699
|
-
}
|
|
700
|
-
if (txBody.fileDelete) {
|
|
701
|
-
result.fileDelete = FileParser.parseFileDelete(txBody.fileDelete);
|
|
702
|
-
}
|
|
703
|
-
if (txBody.utilPrng) {
|
|
704
|
-
result.utilPrng = UtilParser.parseUtilPrng(txBody.utilPrng);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Parse transaction body details for all supported transaction types
|
|
709
|
-
* Uses a scalable registry pattern instead of if-else chains
|
|
710
|
-
*/
|
|
711
|
-
static parseTransactionBodyDetails(txBody, transactionType) {
|
|
712
|
-
const result = {};
|
|
713
|
-
const parserConfig = transactionParserRegistry[transactionType];
|
|
714
|
-
if (parserConfig) {
|
|
715
|
-
const bodyData = txBody[parserConfig.bodyField];
|
|
716
|
-
if (bodyData) {
|
|
717
|
-
const parserResult = parserConfig.parser(bodyData);
|
|
718
|
-
if (parserConfig.spreadResult) {
|
|
719
|
-
Object.assign(result, parserResult);
|
|
720
|
-
} else {
|
|
721
|
-
result[parserConfig.resultField] = parserResult;
|
|
165
|
+
if (contentType === "application/json") {
|
|
166
|
+
const response2 = await axios.get(cdnUrl, {
|
|
167
|
+
responseType: "json"
|
|
168
|
+
});
|
|
169
|
+
if (!response2.data) {
|
|
170
|
+
throw new Error(`Failed to fetch content from topic: ${topicId}`);
|
|
722
171
|
}
|
|
172
|
+
return {
|
|
173
|
+
content: response2.data,
|
|
174
|
+
contentType,
|
|
175
|
+
topicId,
|
|
176
|
+
isBinary: false
|
|
177
|
+
};
|
|
723
178
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* Merge protobuf parsing results with parser results using registry pattern
|
|
729
|
-
* Eliminates transactionFields array and forEach logic
|
|
730
|
-
*/
|
|
731
|
-
static mergeProtoParsingResults(result, protoResult, htsResult, transaction, originalBytes) {
|
|
732
|
-
const fieldsToMerge = Object.values(transactionParserRegistry).map(
|
|
733
|
-
(config) => config.resultField
|
|
734
|
-
);
|
|
735
|
-
for (const field of fieldsToMerge) {
|
|
736
|
-
const protoValue = protoResult[field];
|
|
737
|
-
const htsValue = htsResult[field];
|
|
738
|
-
if (protoValue !== void 0) {
|
|
739
|
-
result[field] = protoValue;
|
|
740
|
-
} else if (htsValue !== void 0) {
|
|
741
|
-
result[field] = htsValue;
|
|
742
|
-
} else {
|
|
743
|
-
this.handleSpecialFieldExtraction(result, field, transaction);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
/**
|
|
748
|
-
* Handle special field extraction cases using registry pattern
|
|
749
|
-
*/
|
|
750
|
-
static handleSpecialFieldExtraction(result, field, transaction) {
|
|
751
|
-
if (field === "tokenCreation" && result.type === "TOKENCREATE") {
|
|
752
|
-
const extracted = HTSParser.extractTokenCreationFromTransaction(transaction);
|
|
753
|
-
if (extracted) {
|
|
754
|
-
result[field] = extracted;
|
|
179
|
+
const response = await axios.get(cdnUrl);
|
|
180
|
+
if (!response.data) {
|
|
181
|
+
throw new Error(`Failed to fetch content from topic: ${topicId}`);
|
|
755
182
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
183
|
+
let content;
|
|
184
|
+
if (typeof response.data === "object") {
|
|
185
|
+
content = response.data.content || response.data.text || JSON.stringify(response.data);
|
|
186
|
+
} else {
|
|
187
|
+
content = response.data;
|
|
760
188
|
}
|
|
189
|
+
return {
|
|
190
|
+
content,
|
|
191
|
+
contentType,
|
|
192
|
+
topicId,
|
|
193
|
+
isBinary: false
|
|
194
|
+
};
|
|
195
|
+
} catch (e) {
|
|
196
|
+
const error = e;
|
|
197
|
+
const logMessage = `Error resolving HRL reference: ${error.message}`;
|
|
198
|
+
this.logger.error(logMessage);
|
|
199
|
+
throw new Error(logMessage);
|
|
761
200
|
}
|
|
762
201
|
}
|
|
763
|
-
/**
|
|
764
|
-
* Create fallback result when all parsing methods fail
|
|
765
|
-
*/
|
|
766
|
-
static createFallbackResult(transactionBytes, primaryError, secondaryError) {
|
|
767
|
-
const validation = this.validateTransactionBytes(transactionBytes);
|
|
768
|
-
return {
|
|
769
|
-
type: "UNKNOWN",
|
|
770
|
-
humanReadableType: "Unknown Transaction",
|
|
771
|
-
transfers: [],
|
|
772
|
-
tokenTransfers: [],
|
|
773
|
-
details: {
|
|
774
|
-
rawBytes: transactionBytes.length > 100 ? transactionBytes.substring(0, 100) + "..." : transactionBytes,
|
|
775
|
-
primaryError: primaryError?.message,
|
|
776
|
-
secondaryError: secondaryError?.message,
|
|
777
|
-
parseAttempts: secondaryError ? 2 : 1,
|
|
778
|
-
validation
|
|
779
|
-
},
|
|
780
|
-
formatDetection: {
|
|
781
|
-
originalFormat: validation.format || "base64",
|
|
782
|
-
wasConverted: false,
|
|
783
|
-
length: transactionBytes.length
|
|
784
|
-
},
|
|
785
|
-
raw: {}
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
202
|
}
|
|
789
203
|
export {
|
|
790
|
-
|
|
791
|
-
TransactionParsingError
|
|
204
|
+
HRLResolver
|
|
792
205
|
};
|
|
793
206
|
//# sourceMappingURL=standards-sdk.es110.js.map
|