@hashgraphonline/standards-sdk 0.1.168 → 0.1.169
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 +1 -0
- package/dist/browser/hcs-11/client.d.ts.map +1 -1
- package/dist/browser/hcs-21/sdk.d.ts.map +1 -1
- package/dist/browser/hcs-27/base-client.d.ts +41 -0
- package/dist/browser/hcs-27/base-client.d.ts.map +1 -0
- package/dist/browser/hcs-27/index.d.ts +6 -0
- package/dist/browser/hcs-27/index.d.ts.map +1 -0
- package/dist/browser/hcs-27/memos.d.ts +5 -0
- package/dist/browser/hcs-27/memos.d.ts.map +1 -0
- package/dist/browser/hcs-27/merkle.d.ts +23 -0
- package/dist/browser/hcs-27/merkle.d.ts.map +1 -0
- package/dist/browser/hcs-27/sdk.d.ts +23 -0
- package/dist/browser/hcs-27/sdk.d.ts.map +1 -0
- package/dist/browser/hcs-27/types.d.ts +1611 -0
- package/dist/browser/hcs-27/types.d.ts.map +1 -0
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/standards-sdk.browser.js +29 -5
- package/dist/browser/standards-sdk.browser.js.map +1 -1
- package/dist/browser/utils/key-type-detector.d.ts.map +1 -1
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-27/base-client.d.ts +41 -0
- package/dist/cjs/hcs-27/base-client.d.ts.map +1 -0
- package/dist/cjs/hcs-27/index.d.ts +6 -0
- package/dist/cjs/hcs-27/index.d.ts.map +1 -0
- package/dist/cjs/hcs-27/memos.d.ts +5 -0
- package/dist/cjs/hcs-27/memos.d.ts.map +1 -0
- package/dist/cjs/hcs-27/merkle.d.ts +23 -0
- package/dist/cjs/hcs-27/merkle.d.ts.map +1 -0
- package/dist/cjs/hcs-27/sdk.d.ts +23 -0
- package/dist/cjs/hcs-27/sdk.d.ts.map +1 -0
- package/dist/cjs/hcs-27/types.d.ts +1611 -0
- package/dist/cjs/hcs-27/types.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.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/key-type-detector.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-27/base-client.d.ts +41 -0
- package/dist/es/hcs-27/base-client.d.ts.map +1 -0
- package/dist/es/hcs-27/index.d.ts +6 -0
- package/dist/es/hcs-27/index.d.ts.map +1 -0
- package/dist/es/hcs-27/memos.d.ts +5 -0
- package/dist/es/hcs-27/memos.d.ts.map +1 -0
- package/dist/es/hcs-27/merkle.d.ts +23 -0
- package/dist/es/hcs-27/merkle.d.ts.map +1 -0
- package/dist/es/hcs-27/sdk.d.ts +23 -0
- package/dist/es/hcs-27/sdk.d.ts.map +1 -0
- package/dist/es/hcs-27/types.d.ts +1611 -0
- package/dist/es/hcs-27/types.d.ts.map +1 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +67 -38
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +2 -2
- package/dist/es/standards-sdk.es103.js +2 -2
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es106.js +1 -1
- package/dist/es/standards-sdk.es108.js +2 -2
- package/dist/es/standards-sdk.es11.js +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es111.js +2 -2
- package/dist/es/standards-sdk.es112.js +151 -234
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +20 -471
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +263 -104
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +167 -138
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +315 -29
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +250 -10
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +448 -152
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +101 -25
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es120.js +155 -17
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +29 -155
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +9 -200
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +146 -754
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +27 -11
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +19 -564
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +140 -582
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +202 -12
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +790 -2
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +10 -84
- 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 +567 -40
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +626 -2
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +12 -234
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +2 -1140
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +73 -292
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +36 -418
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +2 -355
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +198 -1079
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +1107 -175
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +218 -1479
- 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 +422 -1500
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +351 -13
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +1102 -73
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +203 -76
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +1459 -830
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +1499 -59
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +14 -156
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +87 -7
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +74 -79
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +934 -61
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es150.js +60 -30
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +159 -34
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +7 -48
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +70 -122
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +58 -35
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +30 -56
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +34 -84
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +48 -81
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +124 -186
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +34 -12474
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +5 -5
- package/dist/es/standards-sdk.es160.js +12477 -12
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +15 -71
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +48 -542
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +72 -160
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +71 -312
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +187 -333
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +538 -441
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +65 -323
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +162 -66
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +310 -160
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +336 -212
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +437 -223
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +324 -112
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +65 -115
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +151 -140
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +193 -156
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +221 -121
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +81 -293
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +114 -247
- package/dist/es/standards-sdk.es178.js.map +1 -1
- package/dist/es/standards-sdk.es179.js +119 -110
- package/dist/es/standards-sdk.es179.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +12 -12
- package/dist/es/standards-sdk.es180.js +188 -0
- package/dist/es/standards-sdk.es180.js.map +1 -0
- package/dist/es/standards-sdk.es181.js +142 -0
- package/dist/es/standards-sdk.es181.js.map +1 -0
- package/dist/es/standards-sdk.es182.js +334 -0
- package/dist/es/standards-sdk.es182.js.map +1 -0
- package/dist/es/standards-sdk.es183.js +262 -0
- package/dist/es/standards-sdk.es183.js.map +1 -0
- package/dist/es/standards-sdk.es184.js +155 -0
- package/dist/es/standards-sdk.es184.js.map +1 -0
- package/dist/es/standards-sdk.es19.js +9 -9
- package/dist/es/standards-sdk.es2.js +2 -2
- package/dist/es/standards-sdk.es20.js +1 -1
- package/dist/es/standards-sdk.es21.js +1 -1
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es24.js +1 -1
- package/dist/es/standards-sdk.es25.js +1 -1
- package/dist/es/standards-sdk.es26.js +1 -1
- package/dist/es/standards-sdk.es27.js +12 -12
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +2 -2
- package/dist/es/standards-sdk.es31.js +4 -4
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es35.js +6 -6
- package/dist/es/standards-sdk.es36.js +4 -4
- package/dist/es/standards-sdk.es37.js +2 -2
- package/dist/es/standards-sdk.es38.js +2 -2
- package/dist/es/standards-sdk.es39.js +1 -1
- package/dist/es/standards-sdk.es4.js +2 -2
- package/dist/es/standards-sdk.es40.js +1 -1
- package/dist/es/standards-sdk.es41.js +2 -2
- package/dist/es/standards-sdk.es46.js +1 -1
- package/dist/es/standards-sdk.es5.js +2 -2
- package/dist/es/standards-sdk.es51.js +1 -1
- package/dist/es/standards-sdk.es53.js +1 -1
- package/dist/es/standards-sdk.es56.js +2 -2
- package/dist/es/standards-sdk.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.es62.js +1 -1
- package/dist/es/standards-sdk.es63.js +2 -2
- package/dist/es/standards-sdk.es64.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es67.js +7 -7
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es7.js +1 -1
- package/dist/es/standards-sdk.es71.js +2 -2
- package/dist/es/standards-sdk.es72.js +3 -3
- package/dist/es/standards-sdk.es75.js +5 -5
- package/dist/es/standards-sdk.es76.js +3 -3
- package/dist/es/standards-sdk.es77.js +2 -2
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es81.js +2 -2
- package/dist/es/standards-sdk.es83.js +2 -2
- package/dist/es/standards-sdk.es84.js +4 -4
- package/dist/es/standards-sdk.es85.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es89.js +2 -2
- package/dist/es/standards-sdk.es9.js +2 -2
- package/dist/es/standards-sdk.es90.js +4 -4
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +3 -3
- package/dist/es/standards-sdk.es96.js +2 -2
- package/dist/es/standards-sdk.es98.js +1 -1
- package/dist/es/standards-sdk.es99.js +3 -3
- package/dist/es/utils/key-type-detector.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,793 +1,185 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param options - Parsing options and configuration
|
|
23
|
-
* @returns Promise resolving to ParsedTransaction
|
|
24
|
-
*/
|
|
25
|
-
static async parseTransactionBytes(transactionBytes, options = {}) {
|
|
26
|
-
const {
|
|
27
|
-
enableFallback = true,
|
|
28
|
-
strictMode = false,
|
|
29
|
-
includeRaw = true,
|
|
30
|
-
maxRetries = 2
|
|
31
|
-
} = options;
|
|
32
|
-
const validation = this.validateTransactionBytes(transactionBytes);
|
|
33
|
-
if (!validation.isValid && strictMode) {
|
|
34
|
-
throw new TransactionParsingError(
|
|
35
|
-
`Invalid transaction bytes format: ${validation.error}`,
|
|
36
|
-
"INVALID_FORMAT",
|
|
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;
|
|
1
|
+
let loggerFactory = null;
|
|
2
|
+
function normalizeErrorData(error) {
|
|
3
|
+
const normalizedData = {
|
|
4
|
+
name: error.name,
|
|
5
|
+
message: error.message
|
|
6
|
+
};
|
|
7
|
+
if (error.stack) {
|
|
8
|
+
normalizedData.stack = error.stack;
|
|
9
|
+
}
|
|
10
|
+
for (const [key, value] of Object.entries(error)) {
|
|
11
|
+
normalizedData[key] = value;
|
|
12
|
+
}
|
|
13
|
+
return normalizedData;
|
|
14
|
+
}
|
|
15
|
+
function serializeLogData(data) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.stringify(
|
|
18
|
+
data,
|
|
19
|
+
(_key, value) => {
|
|
20
|
+
if (value instanceof Error) {
|
|
21
|
+
return normalizeErrorData(value);
|
|
65
22
|
}
|
|
66
|
-
|
|
67
|
-
|
|
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) {
|
|
23
|
+
if (typeof value === "bigint") {
|
|
24
|
+
return value.toString();
|
|
78
25
|
}
|
|
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;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Parse a Transaction object directly using unified delegation approach
|
|
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
|
|
99
|
-
*/
|
|
100
|
-
static parseTransactionObject(transaction, originalBytesOrOptions, options = {}) {
|
|
101
|
-
let originalBytes;
|
|
102
|
-
let actualOptions;
|
|
103
|
-
if (originalBytesOrOptions && !Buffer.isBuffer(originalBytesOrOptions) && !(originalBytesOrOptions instanceof Uint8Array)) {
|
|
104
|
-
actualOptions = originalBytesOrOptions;
|
|
105
|
-
originalBytes = void 0;
|
|
106
|
-
} else {
|
|
107
|
-
originalBytes = originalBytesOrOptions;
|
|
108
|
-
actualOptions = options;
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
const metadata = this.extractTransactionMetadata(transaction);
|
|
112
|
-
const htsResult = HTSParser.parseFromTransactionObject(transaction);
|
|
113
|
-
const cryptoResult = CryptoParser.parseFromTransactionObject(transaction);
|
|
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) {
|
|
26
|
+
if (value instanceof Map) {
|
|
27
|
+
return Object.fromEntries(value);
|
|
171
28
|
}
|
|
172
|
-
|
|
173
|
-
|
|
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)}`
|
|
29
|
+
if (value instanceof Set) {
|
|
30
|
+
return Array.from(value);
|
|
205
31
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Parse a base64 encoded transaction body using registry pattern
|
|
211
|
-
* @param transactionBodyBase64 - The base64 encoded transaction body
|
|
212
|
-
* @returns The parsed transaction
|
|
213
|
-
*/
|
|
214
|
-
static parseTransactionBody(transactionBodyBase64) {
|
|
215
|
-
try {
|
|
216
|
-
const buffer = ethers.decodeBase64(transactionBodyBase64);
|
|
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)}`
|
|
32
|
+
if (value instanceof Uint8Array) {
|
|
33
|
+
return Array.from(value);
|
|
246
34
|
}
|
|
247
|
-
|
|
248
|
-
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
2
|
|
38
|
+
);
|
|
39
|
+
} catch {
|
|
40
|
+
return String(data);
|
|
249
41
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
42
|
+
}
|
|
43
|
+
function setLoggerFactory(factory) {
|
|
44
|
+
loggerFactory = factory;
|
|
45
|
+
Logger.clearInstances();
|
|
46
|
+
}
|
|
47
|
+
const _Logger = class _Logger {
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
if (loggerFactory) {
|
|
50
|
+
return loggerFactory(options);
|
|
51
|
+
}
|
|
52
|
+
const globalDisable = typeof process !== "undefined" && process.env?.DISABLE_LOGS === "true";
|
|
53
|
+
this.silent = options.silent || globalDisable;
|
|
54
|
+
this.level = this.silent ? "silent" : options.level || "info";
|
|
55
|
+
this.moduleContext = options.module || "app";
|
|
56
|
+
this.prettyPrint = !this.silent && options.prettyPrint !== false;
|
|
256
57
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
};
|
|
58
|
+
static getInstance(options = {}) {
|
|
59
|
+
const moduleKey = options.module || "default";
|
|
60
|
+
const globalDisable = typeof process !== "undefined" && process.env?.DISABLE_LOGS === "true";
|
|
61
|
+
if (globalDisable && _Logger.instances.has(moduleKey)) {
|
|
62
|
+
const existingLogger = _Logger.instances.get(moduleKey);
|
|
63
|
+
if (existingLogger.getLevel() !== "silent") {
|
|
64
|
+
_Logger.instances.delete(moduleKey);
|
|
65
|
+
}
|
|
274
66
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
67
|
+
if (!_Logger.instances.has(moduleKey)) {
|
|
68
|
+
const logger = loggerFactory ? loggerFactory(options) : new _Logger(options);
|
|
69
|
+
_Logger.instances.set(moduleKey, logger);
|
|
278
70
|
}
|
|
279
|
-
return
|
|
71
|
+
return _Logger.instances.get(moduleKey);
|
|
280
72
|
}
|
|
281
|
-
|
|
282
|
-
|
|
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;
|
|
73
|
+
setLogLevel(level) {
|
|
74
|
+
this.level = level;
|
|
288
75
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
* @param type - The technical transaction type
|
|
292
|
-
* @returns The human-readable transaction type
|
|
293
|
-
*/
|
|
294
|
-
static getHumanReadableType(type) {
|
|
295
|
-
return getHumanReadableTransactionType(type);
|
|
76
|
+
getLevel() {
|
|
77
|
+
return this.level;
|
|
296
78
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
static getTransactionSummary(parsedTx) {
|
|
303
|
-
return resolveTransactionSummary(parsedTx);
|
|
79
|
+
setSilent(silent) {
|
|
80
|
+
this.silent = silent;
|
|
81
|
+
if (silent) {
|
|
82
|
+
this.level = "silent";
|
|
83
|
+
}
|
|
304
84
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
isValid: false,
|
|
313
|
-
error: "Transaction bytes must be a non-empty string"
|
|
314
|
-
};
|
|
85
|
+
setModule(module) {
|
|
86
|
+
this.moduleContext = module;
|
|
87
|
+
}
|
|
88
|
+
formatArgs(args) {
|
|
89
|
+
if (args.length === 0) {
|
|
90
|
+
return { msg: "" };
|
|
315
91
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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";
|
|
92
|
+
if (args.length === 1) {
|
|
93
|
+
if (typeof args[0] === "string") {
|
|
94
|
+
return { msg: args[0] };
|
|
330
95
|
}
|
|
96
|
+
return { msg: "", data: args[0] };
|
|
331
97
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
try {
|
|
355
|
-
const format = this.detectTransactionFormat(transactionBytes);
|
|
356
|
-
if (format === "hex") {
|
|
357
|
-
const hexString = transactionBytes.slice(2);
|
|
358
|
-
return new Uint8Array(Buffer.from(hexString, "hex"));
|
|
98
|
+
const stringArgs = [];
|
|
99
|
+
const objectArgs = [];
|
|
100
|
+
args.forEach((arg) => {
|
|
101
|
+
if (typeof arg === "string" || typeof arg === "number" || typeof arg === "boolean") {
|
|
102
|
+
stringArgs.push(String(arg));
|
|
359
103
|
} else {
|
|
360
|
-
|
|
104
|
+
objectArgs.push(arg);
|
|
361
105
|
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
"DECODE_ERROR",
|
|
366
|
-
error instanceof Error ? error : void 0,
|
|
367
|
-
transactionBytes
|
|
368
|
-
);
|
|
369
|
-
}
|
|
106
|
+
});
|
|
107
|
+
const msg = stringArgs.join(" ");
|
|
108
|
+
return objectArgs.length > 0 ? { msg, data: objectArgs } : { msg };
|
|
370
109
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
*/
|
|
374
|
-
static async isValidHederaTransaction(transactionBytes) {
|
|
375
|
-
try {
|
|
376
|
-
if (!this.validateTransactionBytes(transactionBytes).isValid) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
const bytes = this.decodeTransactionBytes(transactionBytes);
|
|
380
|
-
Transaction.fromBytes(bytes);
|
|
381
|
-
return true;
|
|
382
|
-
} catch {
|
|
110
|
+
shouldLog(level) {
|
|
111
|
+
if (this.silent || this.level === "silent") {
|
|
383
112
|
return false;
|
|
384
113
|
}
|
|
114
|
+
const levels = ["trace", "debug", "info", "warn", "error", "silent"];
|
|
115
|
+
const currentLevelIndex = levels.indexOf(this.level);
|
|
116
|
+
const targetLevelIndex = levels.indexOf(level);
|
|
117
|
+
return targetLevelIndex >= currentLevelIndex;
|
|
385
118
|
}
|
|
386
|
-
|
|
387
|
-
|
|
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
|
|
421
|
-
};
|
|
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
|
-
);
|
|
119
|
+
getConsoleMethod(level) {
|
|
120
|
+
if (level === "error") {
|
|
121
|
+
return console.error;
|
|
436
122
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
* Parse scheduled transaction body
|
|
440
|
-
*/
|
|
441
|
-
static parseScheduledTransaction(transactionBytes, options = {}) {
|
|
442
|
-
try {
|
|
443
|
-
const parsedTx = this.parseTransactionBody(transactionBytes);
|
|
444
|
-
const validation = this.validateTransactionBytes(transactionBytes);
|
|
445
|
-
const enhancedResult = {
|
|
446
|
-
...parsedTx,
|
|
447
|
-
details: {
|
|
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
|
-
}
|
|
458
|
-
};
|
|
459
|
-
return enhancedResult;
|
|
460
|
-
} catch (error) {
|
|
461
|
-
throw new TransactionParsingError(
|
|
462
|
-
"Failed to parse as scheduled transaction",
|
|
463
|
-
"SCHEDULED_PARSING_FAILED",
|
|
464
|
-
error instanceof Error ? error : void 0,
|
|
465
|
-
transactionBytes
|
|
466
|
-
);
|
|
123
|
+
if (level === "warn") {
|
|
124
|
+
return console.warn;
|
|
467
125
|
}
|
|
126
|
+
if (level === "debug") {
|
|
127
|
+
return console.debug;
|
|
128
|
+
}
|
|
129
|
+
return console.log;
|
|
468
130
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Extract enhanced metadata from Transaction object
|
|
484
|
-
*/
|
|
485
|
-
static extractTransactionMetadataEnhanced(transaction) {
|
|
486
|
-
return {
|
|
487
|
-
transactionId: transaction.transactionId?.toString(),
|
|
488
|
-
nodeAccountIds: transaction.nodeAccountIds?.map((id) => id.toString()) || [],
|
|
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
|
-
}
|
|
131
|
+
writeLog(level, ...args) {
|
|
132
|
+
if (!this.shouldLog(level)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const { msg, data } = this.formatArgs(args);
|
|
136
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
137
|
+
const consoleMethod = this.getConsoleMethod(level);
|
|
138
|
+
if (this.prettyPrint) {
|
|
139
|
+
const levelFormatted = level.toUpperCase().padEnd(5);
|
|
140
|
+
let output = `${timestamp} ${levelFormatted} [${this.moduleContext}] ${msg}`;
|
|
141
|
+
if (data) {
|
|
142
|
+
output += "\n" + serializeLogData(data);
|
|
539
143
|
}
|
|
540
|
-
|
|
144
|
+
consoleMethod(output);
|
|
145
|
+
} else {
|
|
146
|
+
const logObj = {
|
|
147
|
+
timestamp,
|
|
148
|
+
level,
|
|
149
|
+
module: this.moduleContext,
|
|
150
|
+
message: msg,
|
|
151
|
+
...data && { data }
|
|
152
|
+
};
|
|
153
|
+
consoleMethod(JSON.stringify(logObj));
|
|
541
154
|
}
|
|
542
|
-
return result;
|
|
543
155
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
*/
|
|
547
|
-
static mergeAllResults(result, protoResult, primaryResult, parserResults) {
|
|
548
|
-
const cryptoResult = parserResults.find((r) => r.transfers || r.tokenTransfers) || {};
|
|
549
|
-
result.transfers = cryptoResult.transfers || result.transfers || [];
|
|
550
|
-
result.tokenTransfers = cryptoResult.tokenTransfers || result.tokenTransfers || [];
|
|
551
|
-
Object.keys(protoResult).forEach((key) => {
|
|
552
|
-
if (protoResult[key] !== void 0 && key !== "type" && key !== "humanReadableType") {
|
|
553
|
-
result[key] = protoResult[key];
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
Object.keys(primaryResult).forEach((key) => {
|
|
557
|
-
if (primaryResult[key] !== void 0 && !(key in result) && key !== "type" && key !== "humanReadableType") {
|
|
558
|
-
result[key] = primaryResult[key];
|
|
559
|
-
}
|
|
560
|
-
});
|
|
156
|
+
debug(...args) {
|
|
157
|
+
this.writeLog("debug", ...args);
|
|
561
158
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
* Eliminates conditional logic in parseTransactionBody
|
|
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
|
-
}
|
|
159
|
+
info(...args) {
|
|
160
|
+
this.writeLog("info", ...args);
|
|
706
161
|
}
|
|
707
|
-
|
|
708
|
-
|
|
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;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
return result;
|
|
162
|
+
warn(...args) {
|
|
163
|
+
this.writeLog("warn", ...args);
|
|
726
164
|
}
|
|
727
|
-
|
|
728
|
-
|
|
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
|
-
}
|
|
165
|
+
error(...args) {
|
|
166
|
+
this.writeLog("error", ...args);
|
|
746
167
|
}
|
|
747
|
-
|
|
748
|
-
|
|
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;
|
|
755
|
-
}
|
|
756
|
-
} else if (field === "tokenAirdrop" && result.type === "TOKENAIRDROP") {
|
|
757
|
-
const extracted = HTSParser.extractTokenAirdropFromTransaction(transaction);
|
|
758
|
-
if (extracted) {
|
|
759
|
-
result[field] = extracted;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
168
|
+
trace(...args) {
|
|
169
|
+
this.writeLog("trace", ...args);
|
|
762
170
|
}
|
|
763
171
|
/**
|
|
764
|
-
*
|
|
172
|
+
* Clear all logger instances
|
|
173
|
+
* Used when switching logger implementations
|
|
765
174
|
*/
|
|
766
|
-
static
|
|
767
|
-
|
|
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
|
-
};
|
|
175
|
+
static clearInstances() {
|
|
176
|
+
_Logger.instances.clear();
|
|
787
177
|
}
|
|
788
|
-
}
|
|
178
|
+
};
|
|
179
|
+
_Logger.instances = /* @__PURE__ */ new Map();
|
|
180
|
+
let Logger = _Logger;
|
|
789
181
|
export {
|
|
790
|
-
|
|
791
|
-
|
|
182
|
+
Logger,
|
|
183
|
+
setLoggerFactory
|
|
792
184
|
};
|
|
793
185
|
//# sourceMappingURL=standards-sdk.es123.js.map
|