@hashgraphonline/standards-sdk 0.1.143-feat-solana-register.canary.5c63f60.63 → 0.1.143-feat-solana-register.canary.2844378.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hcs-16/sdk.d.ts +9 -0
- package/dist/cjs/hcs-16/sdk.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +6 -6
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-16/sdk.d.ts +9 -0
- package/dist/es/hcs-16/sdk.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +6 -6
- package/dist/es/standards-sdk.es100.js +1 -1
- package/dist/es/standards-sdk.es102.js +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es111.js +5 -5
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es122.js +1 -1
- package/dist/es/standards-sdk.es123.js +5 -5
- package/dist/es/standards-sdk.es125.js +1 -1
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es145.js +105 -12256
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +37 -133
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +12280 -33
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es150.js +168 -13
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +289 -139
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +298 -274
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +369 -262
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +194 -316
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +64 -319
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +15 -74
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +3 -3
- package/dist/es/standards-sdk.es20.js +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es28.js +2 -2
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es36.js +1 -1
- package/dist/es/standards-sdk.es37.js +3 -3
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es5.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es61.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +2 -2
- package/dist/es/standards-sdk.es69.js +2 -2
- package/dist/es/standards-sdk.es70.js +1 -1
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es77.js +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.es82.js +1 -1
- package/dist/es/standards-sdk.es84.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/dist/es/standards-sdk.es93.js +30 -3
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Long, AccountId } from "@hashgraph/sdk";
|
|
2
|
+
import { parseKey } from "./standards-sdk.es155.js";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
class HCSParser {
|
|
5
|
+
static parseConsensusCreateTopic(body) {
|
|
6
|
+
if (!body) return void 0;
|
|
7
|
+
const data = {};
|
|
8
|
+
if (body.memo) {
|
|
9
|
+
data.memo = body.memo;
|
|
10
|
+
}
|
|
11
|
+
data.adminKey = parseKey(body.adminKey);
|
|
12
|
+
data.submitKey = parseKey(body.submitKey);
|
|
13
|
+
if (body.autoRenewPeriod?.seconds) {
|
|
14
|
+
data.autoRenewPeriod = Long.fromValue(
|
|
15
|
+
body.autoRenewPeriod.seconds
|
|
16
|
+
).toString();
|
|
17
|
+
}
|
|
18
|
+
if (body.autoRenewAccount) {
|
|
19
|
+
data.autoRenewAccountId = new AccountId(
|
|
20
|
+
body.autoRenewAccount.shardNum ?? 0,
|
|
21
|
+
body.autoRenewAccount.realmNum ?? 0,
|
|
22
|
+
body.autoRenewAccount.accountNum ?? 0
|
|
23
|
+
).toString();
|
|
24
|
+
}
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
static parseConsensusSubmitMessage(body) {
|
|
28
|
+
if (!body) return void 0;
|
|
29
|
+
const data = {};
|
|
30
|
+
if (body.topicID) {
|
|
31
|
+
data.topicId = `${body.topicID.shardNum ?? 0}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
|
|
32
|
+
}
|
|
33
|
+
if (body.message?.length > 0) {
|
|
34
|
+
const messageBuffer = Buffer.from(body.message);
|
|
35
|
+
const utf8String = messageBuffer.toString("utf8");
|
|
36
|
+
if (/[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(utf8String) || utf8String.includes("�")) {
|
|
37
|
+
data.message = messageBuffer.toString("base64");
|
|
38
|
+
data.messageEncoding = "base64";
|
|
39
|
+
} else {
|
|
40
|
+
data.message = utf8String;
|
|
41
|
+
data.messageEncoding = "utf8";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (body.chunkInfo) {
|
|
45
|
+
if (body.chunkInfo.initialTransactionID) {
|
|
46
|
+
const txId = body.chunkInfo.initialTransactionID.accountID;
|
|
47
|
+
const taValidStart = body.chunkInfo.initialTransactionID.transactionValidStart;
|
|
48
|
+
if (txId && taValidStart) {
|
|
49
|
+
data.chunkInfoInitialTransactionID = `${txId.shardNum ?? 0}.${txId.realmNum ?? 0}.${txId.accountNum ?? 0}@${taValidStart.seconds ?? 0}.${taValidStart.nanos ?? 0}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (body.chunkInfo.number !== void 0 && body.chunkInfo.number !== null) {
|
|
53
|
+
data.chunkInfoNumber = body.chunkInfo.number;
|
|
54
|
+
}
|
|
55
|
+
if (body.chunkInfo.total !== void 0 && body.chunkInfo.total !== null) {
|
|
56
|
+
data.chunkInfoTotal = body.chunkInfo.total;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return data;
|
|
60
|
+
}
|
|
61
|
+
static parseConsensusUpdateTopic(body) {
|
|
62
|
+
if (!body) return void 0;
|
|
63
|
+
const data = {};
|
|
64
|
+
if (body.topicID) {
|
|
65
|
+
data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum}.${body.topicID.topicNum}`;
|
|
66
|
+
}
|
|
67
|
+
if (body.memo?.value !== void 0) {
|
|
68
|
+
data.memo = body.memo.value;
|
|
69
|
+
}
|
|
70
|
+
if (body.adminKey === null) {
|
|
71
|
+
data.clearAdminKey = true;
|
|
72
|
+
data.adminKey = void 0;
|
|
73
|
+
} else if (body.adminKey) {
|
|
74
|
+
data.adminKey = parseKey(body.adminKey);
|
|
75
|
+
} else {
|
|
76
|
+
data.adminKey = void 0;
|
|
77
|
+
}
|
|
78
|
+
if (body.submitKey === null) {
|
|
79
|
+
data.clearSubmitKey = true;
|
|
80
|
+
data.submitKey = void 0;
|
|
81
|
+
} else if (body.submitKey) {
|
|
82
|
+
data.submitKey = parseKey(body.submitKey);
|
|
83
|
+
} else {
|
|
84
|
+
data.submitKey = void 0;
|
|
85
|
+
}
|
|
86
|
+
if (body.autoRenewPeriod?.seconds) {
|
|
87
|
+
data.autoRenewPeriod = Long.fromValue(
|
|
88
|
+
body.autoRenewPeriod.seconds
|
|
89
|
+
).toString();
|
|
90
|
+
}
|
|
91
|
+
if (body.autoRenewAccount) {
|
|
92
|
+
data.autoRenewAccountId = new AccountId(
|
|
93
|
+
body.autoRenewAccount.shardNum ?? 0,
|
|
94
|
+
body.autoRenewAccount.realmNum ?? 0,
|
|
95
|
+
body.autoRenewAccount.accountNum ?? 0
|
|
96
|
+
).toString();
|
|
97
|
+
}
|
|
98
|
+
return data;
|
|
99
|
+
}
|
|
100
|
+
static parseConsensusDeleteTopic(body) {
|
|
101
|
+
if (!body) return void 0;
|
|
102
|
+
const data = {};
|
|
103
|
+
if (body.topicID) {
|
|
104
|
+
data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
|
|
105
|
+
}
|
|
106
|
+
return data;
|
|
107
|
+
}
|
|
4
108
|
/**
|
|
5
|
-
*
|
|
109
|
+
* Parse HCS transaction from Transaction object with comprehensive extraction
|
|
110
|
+
* This is the unified entry point that handles both protobuf and internal field extraction
|
|
6
111
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
112
|
+
static parseFromTransactionObject(transaction) {
|
|
113
|
+
try {
|
|
114
|
+
const transactionBody = transaction._transactionBody;
|
|
115
|
+
if (!transactionBody) {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
if (transactionBody.consensusCreateTopic) {
|
|
119
|
+
const consensusCreateTopic = this.parseConsensusCreateTopic(
|
|
120
|
+
transactionBody.consensusCreateTopic
|
|
121
|
+
);
|
|
122
|
+
if (consensusCreateTopic) {
|
|
123
|
+
return {
|
|
124
|
+
type: "TOPICCREATE",
|
|
125
|
+
humanReadableType: "Topic Create",
|
|
126
|
+
consensusCreateTopic
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (transactionBody.consensusSubmitMessage) {
|
|
131
|
+
const consensusSubmitMessage = this.parseConsensusSubmitMessage(
|
|
132
|
+
transactionBody.consensusSubmitMessage
|
|
133
|
+
);
|
|
134
|
+
if (consensusSubmitMessage) {
|
|
135
|
+
return {
|
|
136
|
+
type: "CONSENSUSSUBMITMESSAGE",
|
|
137
|
+
humanReadableType: "Submit Message",
|
|
138
|
+
consensusSubmitMessage
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (transactionBody.consensusUpdateTopic) {
|
|
143
|
+
const consensusUpdateTopic = this.parseConsensusUpdateTopic(
|
|
144
|
+
transactionBody.consensusUpdateTopic
|
|
145
|
+
);
|
|
146
|
+
if (consensusUpdateTopic) {
|
|
147
|
+
return {
|
|
148
|
+
type: "TOPICUPDATE",
|
|
149
|
+
humanReadableType: "Topic Update",
|
|
150
|
+
consensusUpdateTopic
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (transactionBody.consensusDeleteTopic) {
|
|
155
|
+
const consensusDeleteTopic = this.parseConsensusDeleteTopic(
|
|
156
|
+
transactionBody.consensusDeleteTopic
|
|
157
|
+
);
|
|
158
|
+
if (consensusDeleteTopic) {
|
|
159
|
+
return {
|
|
160
|
+
type: "TOPICDELETE",
|
|
161
|
+
humanReadableType: "Topic Delete",
|
|
162
|
+
consensusDeleteTopic
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {};
|
|
167
|
+
} catch (error) {
|
|
168
|
+
return {};
|
|
169
|
+
}
|
|
15
170
|
}
|
|
16
171
|
}
|
|
17
172
|
export {
|
|
18
|
-
|
|
173
|
+
HCSParser
|
|
19
174
|
};
|
|
20
175
|
//# sourceMappingURL=standards-sdk.es150.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es150.js","sources":["../../src/hcs-5/base-client.ts"],"sourcesContent":["import { Logger, ILogger } from '../utils/logger';\nimport { HederaMirrorNode } from '../services/mirror-node';\nimport { HCS5ClientConfig } from './types';\nimport { NetworkType } from '../utils/types';\n\n/**\n * Base client for HCS-5 operations\n */\nexport abstract class HCS5BaseClient {\n protected logger: ILogger;\n protected mirrorNode: HederaMirrorNode;\n protected network: NetworkType;\n\n /**\n * Create a new HCS-5 base client\n */\n constructor(config: HCS5ClientConfig) {\n this.network = config.network;\n this.logger =\n config.logger ||\n Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS5Client',\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(this.network, this.logger);\n }\n}\n"],"names":[],"mappings":";;AAQO,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAY,QAA0B;AACpC,SAAK,UAAU,OAAO;AACtB,SAAK,SACH,OAAO,UACP,OAAO,YAAY;AAAA,MACjB,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IAAA,CAChB;AAEH,SAAK,aAAa,IAAI,iBAAiB,KAAK,SAAS,KAAK,MAAM;AAAA,EAClE;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es150.js","sources":["../../src/utils/parsers/hcs-parser.ts"],"sourcesContent":["import { proto } from '@hashgraph/proto';\nimport { AccountId, Long, Transaction } from '@hashgraph/sdk';\nimport {\n ConsensusCreateTopicData,\n ConsensusSubmitMessageData,\n ConsensusUpdateTopicData,\n ConsensusDeleteTopicData,\n} from '../transaction-parser-types';\nimport { parseKey } from './parser-utils';\nimport { Buffer } from 'buffer';\n\nexport class HCSParser {\n static parseConsensusCreateTopic(\n body: proto.IConsensusCreateTopicTransactionBody,\n ): ConsensusCreateTopicData | undefined {\n if (!body) return undefined;\n const data: ConsensusCreateTopicData = {};\n if (body.memo) {\n data.memo = body.memo;\n }\n data.adminKey = parseKey(body.adminKey);\n data.submitKey = parseKey(body.submitKey);\n if (body.autoRenewPeriod?.seconds) {\n data.autoRenewPeriod = Long.fromValue(\n body.autoRenewPeriod.seconds,\n ).toString();\n }\n if (body.autoRenewAccount) {\n data.autoRenewAccountId = new AccountId(\n body.autoRenewAccount.shardNum ?? 0,\n body.autoRenewAccount.realmNum ?? 0,\n body.autoRenewAccount.accountNum ?? 0,\n ).toString();\n }\n return data;\n }\n\n static parseConsensusSubmitMessage(\n body: proto.IConsensusSubmitMessageTransactionBody,\n ): ConsensusSubmitMessageData | undefined {\n if (!body) return undefined;\n const data: ConsensusSubmitMessageData = {};\n if (body.topicID) {\n data.topicId = `${body.topicID.shardNum ?? 0}.${\n body.topicID.realmNum ?? 0\n }.${body.topicID.topicNum ?? 0}`;\n }\n if (body.message?.length > 0) {\n const messageBuffer = Buffer.from(body.message);\n const utf8String = messageBuffer.toString('utf8');\n if (\n /[\\x00-\\x08\\x0B\\x0E-\\x1F\\x7F]/.test(utf8String) ||\n utf8String.includes('\\uFFFD')\n ) {\n data.message = messageBuffer.toString('base64');\n data.messageEncoding = 'base64';\n } else {\n data.message = utf8String;\n data.messageEncoding = 'utf8';\n }\n }\n if (body.chunkInfo) {\n if (body.chunkInfo.initialTransactionID) {\n const txId = body.chunkInfo.initialTransactionID.accountID;\n const taValidStart =\n body.chunkInfo.initialTransactionID.transactionValidStart;\n if (txId && taValidStart) {\n data.chunkInfoInitialTransactionID = `${txId.shardNum ?? 0}.${\n txId.realmNum ?? 0\n }.${txId.accountNum ?? 0}@${taValidStart.seconds ?? 0}.${\n taValidStart.nanos ?? 0\n }`;\n }\n }\n if (\n body.chunkInfo.number !== undefined &&\n body.chunkInfo.number !== null\n ) {\n data.chunkInfoNumber = body.chunkInfo.number;\n }\n if (body.chunkInfo.total !== undefined && body.chunkInfo.total !== null) {\n data.chunkInfoTotal = body.chunkInfo.total;\n }\n }\n return data;\n }\n\n static parseConsensusUpdateTopic(\n body: proto.IConsensusUpdateTopicTransactionBody,\n ): ConsensusUpdateTopicData | undefined {\n if (!body) return undefined;\n const data: ConsensusUpdateTopicData = {};\n if (body.topicID) {\n data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum}.${body.topicID.topicNum}`;\n }\n if (body.memo?.value !== undefined) {\n data.memo = body.memo.value;\n }\n if (body.adminKey === null) {\n data.clearAdminKey = true;\n data.adminKey = undefined;\n } else if (body.adminKey) {\n data.adminKey = parseKey(body.adminKey);\n } else {\n data.adminKey = undefined;\n }\n if (body.submitKey === null) {\n data.clearSubmitKey = true;\n data.submitKey = undefined;\n } else if (body.submitKey) {\n data.submitKey = parseKey(body.submitKey);\n } else {\n data.submitKey = undefined;\n }\n if (body.autoRenewPeriod?.seconds) {\n data.autoRenewPeriod = Long.fromValue(\n body.autoRenewPeriod.seconds,\n ).toString();\n }\n if (body.autoRenewAccount) {\n data.autoRenewAccountId = new AccountId(\n body.autoRenewAccount.shardNum ?? 0,\n body.autoRenewAccount.realmNum ?? 0,\n body.autoRenewAccount.accountNum ?? 0,\n ).toString();\n }\n return data;\n }\n\n static parseConsensusDeleteTopic(\n body: proto.IConsensusDeleteTopicTransactionBody,\n ): ConsensusDeleteTopicData | undefined {\n if (!body) return undefined;\n const data: ConsensusDeleteTopicData = {};\n if (body.topicID) {\n data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum ?? 0}.${\n body.topicID.topicNum ?? 0\n }`;\n }\n return data;\n }\n\n /**\n * Parse HCS transaction from Transaction object with comprehensive extraction\n * This is the unified entry point that handles both protobuf and internal field extraction\n */\n static parseFromTransactionObject(transaction: Transaction): {\n type?: string;\n humanReadableType?: string;\n [key: string]: unknown;\n } {\n try {\n const transactionBody = (\n transaction as unknown as { _transactionBody?: unknown }\n )._transactionBody as proto.ITransactionBody | undefined;\n\n if (!transactionBody) {\n return {};\n }\n\n if (transactionBody.consensusCreateTopic) {\n const consensusCreateTopic = this.parseConsensusCreateTopic(\n transactionBody.consensusCreateTopic,\n );\n if (consensusCreateTopic) {\n return {\n type: 'TOPICCREATE',\n humanReadableType: 'Topic Create',\n consensusCreateTopic,\n };\n }\n }\n\n if (transactionBody.consensusSubmitMessage) {\n const consensusSubmitMessage = this.parseConsensusSubmitMessage(\n transactionBody.consensusSubmitMessage,\n );\n if (consensusSubmitMessage) {\n return {\n type: 'CONSENSUSSUBMITMESSAGE',\n humanReadableType: 'Submit Message',\n consensusSubmitMessage,\n };\n }\n }\n\n if (transactionBody.consensusUpdateTopic) {\n const consensusUpdateTopic = this.parseConsensusUpdateTopic(\n transactionBody.consensusUpdateTopic,\n );\n if (consensusUpdateTopic) {\n return {\n type: 'TOPICUPDATE',\n humanReadableType: 'Topic Update',\n consensusUpdateTopic,\n };\n }\n }\n\n if (transactionBody.consensusDeleteTopic) {\n const consensusDeleteTopic = this.parseConsensusDeleteTopic(\n transactionBody.consensusDeleteTopic,\n );\n if (consensusDeleteTopic) {\n return {\n type: 'TOPICDELETE',\n humanReadableType: 'Topic Delete',\n consensusDeleteTopic,\n };\n }\n }\n\n return {};\n } catch (error) {\n return {};\n }\n }\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,175 +1,325 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { proto } from "@hashgraph/proto";
|
|
2
|
+
import { Long } from "@hashgraph/sdk";
|
|
3
|
+
import { hasTransactionType, parseKey } from "./standards-sdk.es155.js";
|
|
3
4
|
import { Buffer } from "buffer";
|
|
4
|
-
class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
class FileParser {
|
|
6
|
+
/**
|
|
7
|
+
* Parse File Service transaction using unified dual-branch approach
|
|
8
|
+
* This handles both regular transactions and signed transaction variants
|
|
9
|
+
*/
|
|
10
|
+
static parseFileTransaction(transaction, originalBytes) {
|
|
11
|
+
try {
|
|
12
|
+
if (originalBytes || transaction.toBytes) {
|
|
13
|
+
try {
|
|
14
|
+
const bytesToParse = originalBytes || transaction.toBytes();
|
|
15
|
+
const decoded = proto.TransactionList.decode(bytesToParse);
|
|
16
|
+
if (decoded.transactionList && decoded.transactionList.length > 0) {
|
|
17
|
+
const tx = decoded.transactionList[0];
|
|
18
|
+
let txBody = null;
|
|
19
|
+
if (tx.bodyBytes && tx.bodyBytes.length > 0) {
|
|
20
|
+
txBody = proto.TransactionBody.decode(tx.bodyBytes);
|
|
21
|
+
} else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
|
|
22
|
+
const signedTx = proto.SignedTransaction.decode(
|
|
23
|
+
tx.signedTransactionBytes
|
|
24
|
+
);
|
|
25
|
+
if (signedTx.bodyBytes) {
|
|
26
|
+
txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (txBody) {
|
|
30
|
+
const protoResult = this.parseFromProtobufTxBody(txBody);
|
|
31
|
+
if (protoResult.type && protoResult.type !== "UNKNOWN") {
|
|
32
|
+
return protoResult;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch (protoError) {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return this.parseFromTransactionInternals(transaction);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return { type: "UNKNOWN", humanReadableType: "Unknown File Transaction" };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse file transaction from protobuf TransactionBody
|
|
46
|
+
* Handles all file operations from decoded protobuf data
|
|
47
|
+
*/
|
|
48
|
+
static parseFromProtobufTxBody(txBody) {
|
|
49
|
+
if (txBody.fileCreate) {
|
|
50
|
+
const fileCreate = this.parseFileCreate(txBody.fileCreate);
|
|
51
|
+
if (fileCreate) {
|
|
52
|
+
return {
|
|
53
|
+
type: "FILECREATE",
|
|
54
|
+
humanReadableType: "File Create",
|
|
55
|
+
fileCreate
|
|
56
|
+
};
|
|
57
|
+
}
|
|
10
58
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
59
|
+
if (txBody.fileAppend) {
|
|
60
|
+
const fileAppend = this.parseFileAppend(txBody.fileAppend);
|
|
61
|
+
if (fileAppend) {
|
|
62
|
+
return {
|
|
63
|
+
type: "FILEAPPEND",
|
|
64
|
+
humanReadableType: "File Append",
|
|
65
|
+
fileAppend
|
|
66
|
+
};
|
|
67
|
+
}
|
|
17
68
|
}
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
69
|
+
if (txBody.fileUpdate) {
|
|
70
|
+
const fileUpdate = this.parseFileUpdate(txBody.fileUpdate);
|
|
71
|
+
if (fileUpdate) {
|
|
72
|
+
return {
|
|
73
|
+
type: "FILEUPDATE",
|
|
74
|
+
humanReadableType: "File Update",
|
|
75
|
+
fileUpdate
|
|
76
|
+
};
|
|
77
|
+
}
|
|
24
78
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (body.message?.length > 0) {
|
|
34
|
-
const messageBuffer = Buffer.from(body.message);
|
|
35
|
-
const utf8String = messageBuffer.toString("utf8");
|
|
36
|
-
if (/[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(utf8String) || utf8String.includes("�")) {
|
|
37
|
-
data.message = messageBuffer.toString("base64");
|
|
38
|
-
data.messageEncoding = "base64";
|
|
39
|
-
} else {
|
|
40
|
-
data.message = utf8String;
|
|
41
|
-
data.messageEncoding = "utf8";
|
|
79
|
+
if (txBody.fileDelete) {
|
|
80
|
+
const fileDelete = this.parseFileDelete(txBody.fileDelete);
|
|
81
|
+
if (fileDelete) {
|
|
82
|
+
return {
|
|
83
|
+
type: "FILEDELETE",
|
|
84
|
+
humanReadableType: "File Delete",
|
|
85
|
+
fileDelete
|
|
86
|
+
};
|
|
42
87
|
}
|
|
43
88
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Extract file data from Transaction internal fields
|
|
93
|
+
* This handles cases where data is stored in Transaction object internals
|
|
94
|
+
*/
|
|
95
|
+
static parseFromTransactionInternals(transaction) {
|
|
96
|
+
try {
|
|
97
|
+
const tx = transaction;
|
|
98
|
+
if (hasTransactionType(transaction, "fileCreate")) {
|
|
99
|
+
const fileCreate = {};
|
|
100
|
+
if (tx._contents) {
|
|
101
|
+
const contentInfo = this.analyzeContent(tx._contents);
|
|
102
|
+
fileCreate.contents = contentInfo.encoded;
|
|
103
|
+
if (contentInfo.contentType) {
|
|
104
|
+
fileCreate.contentType = contentInfo.contentType;
|
|
105
|
+
}
|
|
106
|
+
if (contentInfo.size) {
|
|
107
|
+
fileCreate.contentSize = contentInfo.size;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (tx._keys && tx._keys.length > 0) {
|
|
111
|
+
const keyList = {
|
|
112
|
+
keys: tx._keys
|
|
113
|
+
};
|
|
114
|
+
fileCreate.keys = parseKey({ keyList });
|
|
115
|
+
}
|
|
116
|
+
if (tx._expirationTime) {
|
|
117
|
+
fileCreate.expirationTime = tx._expirationTime.toString();
|
|
118
|
+
}
|
|
119
|
+
if (tx._memo) {
|
|
120
|
+
fileCreate.memo = tx._memo;
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
type: "FILECREATE",
|
|
124
|
+
humanReadableType: "File Create",
|
|
125
|
+
fileCreate
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (hasTransactionType(transaction, "fileAppend")) {
|
|
129
|
+
const fileAppend = {
|
|
130
|
+
fileId: tx._fileId.toString()
|
|
131
|
+
};
|
|
132
|
+
if (tx._contents) {
|
|
133
|
+
const contentInfo = this.analyzeContent(tx._contents);
|
|
134
|
+
fileAppend.contents = contentInfo.encoded;
|
|
135
|
+
if (contentInfo.size) {
|
|
136
|
+
fileAppend.contentSize = contentInfo.size;
|
|
137
|
+
}
|
|
50
138
|
}
|
|
139
|
+
return {
|
|
140
|
+
type: "FILEAPPEND",
|
|
141
|
+
humanReadableType: "File Append",
|
|
142
|
+
fileAppend
|
|
143
|
+
};
|
|
51
144
|
}
|
|
52
|
-
if (
|
|
53
|
-
|
|
145
|
+
if (hasTransactionType(transaction, "fileUpdate")) {
|
|
146
|
+
const fileUpdate = {
|
|
147
|
+
fileId: tx._fileId.toString()
|
|
148
|
+
};
|
|
149
|
+
if (tx._contents) {
|
|
150
|
+
const contentInfo = this.analyzeContent(tx._contents);
|
|
151
|
+
fileUpdate.contents = contentInfo.encoded;
|
|
152
|
+
if (contentInfo.size) {
|
|
153
|
+
fileUpdate.contentSize = contentInfo.size;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (tx._keys && tx._keys.length > 0) {
|
|
157
|
+
const keyList = {
|
|
158
|
+
keys: tx._keys
|
|
159
|
+
};
|
|
160
|
+
fileUpdate.keys = parseKey({ keyList });
|
|
161
|
+
}
|
|
162
|
+
if (tx._expirationTime) {
|
|
163
|
+
fileUpdate.expirationTime = tx._expirationTime.toString();
|
|
164
|
+
}
|
|
165
|
+
if (tx._memo) {
|
|
166
|
+
fileUpdate.memo = tx._memo;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
type: "FILEUPDATE",
|
|
170
|
+
humanReadableType: "File Update",
|
|
171
|
+
fileUpdate
|
|
172
|
+
};
|
|
54
173
|
}
|
|
55
|
-
if (
|
|
56
|
-
|
|
174
|
+
if (hasTransactionType(transaction, "fileDelete")) {
|
|
175
|
+
const fileDelete = {
|
|
176
|
+
fileId: tx._fileId.toString()
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
type: "FILEDELETE",
|
|
180
|
+
humanReadableType: "File Delete",
|
|
181
|
+
fileDelete
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return {};
|
|
185
|
+
} catch (error) {
|
|
186
|
+
return {};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Enhanced content analysis with type detection and metadata
|
|
191
|
+
*/
|
|
192
|
+
static analyzeContent(contents) {
|
|
193
|
+
const size = contents.length;
|
|
194
|
+
const contentBuffer = Buffer.from(contents);
|
|
195
|
+
let contentType;
|
|
196
|
+
if (size >= 4) {
|
|
197
|
+
const header = contentBuffer.subarray(0, 4);
|
|
198
|
+
const headerHex = header.toString("hex");
|
|
199
|
+
const signatures = {
|
|
200
|
+
"89504e47": "image/png",
|
|
201
|
+
ffd8ffe0: "image/jpeg",
|
|
202
|
+
ffd8ffe1: "image/jpeg",
|
|
203
|
+
"47494638": "image/gif",
|
|
204
|
+
"25504446": "application/pdf",
|
|
205
|
+
"504b0304": "application/zip",
|
|
206
|
+
"7f454c46": "application/x-executable",
|
|
207
|
+
d0cf11e0: "application/msoffice"
|
|
208
|
+
};
|
|
209
|
+
contentType = signatures[headerHex.toLowerCase()];
|
|
210
|
+
}
|
|
211
|
+
if (!contentType) {
|
|
212
|
+
try {
|
|
213
|
+
const textContent = contentBuffer.toString("utf8");
|
|
214
|
+
const hasControlChars = /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(
|
|
215
|
+
textContent
|
|
216
|
+
);
|
|
217
|
+
const hasReplacementChars = textContent.includes("�");
|
|
218
|
+
if (!hasControlChars && !hasReplacementChars) {
|
|
219
|
+
if (textContent.trim().startsWith("{") && textContent.trim().endsWith("}")) {
|
|
220
|
+
contentType = "application/json";
|
|
221
|
+
} else if (textContent.includes("<?xml") || textContent.includes("<html")) {
|
|
222
|
+
contentType = "text/xml";
|
|
223
|
+
} else if (textContent.includes("<!DOCTYPE html")) {
|
|
224
|
+
contentType = "text/html";
|
|
225
|
+
} else {
|
|
226
|
+
contentType = "text/plain";
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
contentType = "application/octet-stream";
|
|
230
|
+
}
|
|
231
|
+
} catch {
|
|
232
|
+
contentType = "application/octet-stream";
|
|
57
233
|
}
|
|
58
234
|
}
|
|
235
|
+
let encoded;
|
|
236
|
+
if (contentType?.startsWith("text/") || contentType === "application/json") {
|
|
237
|
+
try {
|
|
238
|
+
encoded = contentBuffer.toString("utf8");
|
|
239
|
+
if (encoded.includes("�") || /[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(encoded)) {
|
|
240
|
+
encoded = contentBuffer.toString("base64");
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
encoded = contentBuffer.toString("base64");
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
encoded = contentBuffer.toString("base64");
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
encoded,
|
|
250
|
+
contentType,
|
|
251
|
+
size
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
static parseFileCreate(body) {
|
|
255
|
+
if (!body) return void 0;
|
|
256
|
+
const data = {};
|
|
257
|
+
if (body.expirationTime?.seconds) {
|
|
258
|
+
data.expirationTime = `${Long.fromValue(
|
|
259
|
+
body.expirationTime.seconds
|
|
260
|
+
).toString()}.${body.expirationTime.nanos}`;
|
|
261
|
+
}
|
|
262
|
+
if (body.keys) {
|
|
263
|
+
data.keys = parseKey({ keyList: body.keys });
|
|
264
|
+
}
|
|
265
|
+
if (body.contents) {
|
|
266
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
267
|
+
}
|
|
268
|
+
if (body.memo) {
|
|
269
|
+
data.memo = body.memo;
|
|
270
|
+
}
|
|
59
271
|
return data;
|
|
60
272
|
}
|
|
61
|
-
static
|
|
273
|
+
static parseFileAppend(body) {
|
|
62
274
|
if (!body) return void 0;
|
|
63
275
|
const data = {};
|
|
64
|
-
if (body.
|
|
65
|
-
data.
|
|
276
|
+
if (body.fileID) {
|
|
277
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
66
278
|
}
|
|
67
|
-
if (body.
|
|
68
|
-
data.
|
|
279
|
+
if (body.contents) {
|
|
280
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
69
281
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
data.
|
|
282
|
+
return data;
|
|
283
|
+
}
|
|
284
|
+
static parseFileUpdate(body) {
|
|
285
|
+
if (!body) return void 0;
|
|
286
|
+
const data = {};
|
|
287
|
+
if (body.fileID) {
|
|
288
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
77
289
|
}
|
|
78
|
-
if (body.
|
|
79
|
-
data.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
data.submitKey = parseKey(body.submitKey);
|
|
83
|
-
} else {
|
|
84
|
-
data.submitKey = void 0;
|
|
290
|
+
if (body.expirationTime?.seconds) {
|
|
291
|
+
data.expirationTime = `${Long.fromValue(
|
|
292
|
+
body.expirationTime.seconds
|
|
293
|
+
).toString()}.${body.expirationTime.nanos}`;
|
|
85
294
|
}
|
|
86
|
-
if (body.
|
|
87
|
-
data.
|
|
88
|
-
body.autoRenewPeriod.seconds
|
|
89
|
-
).toString();
|
|
295
|
+
if (body.keys) {
|
|
296
|
+
data.keys = parseKey({ keyList: body.keys });
|
|
90
297
|
}
|
|
91
|
-
if (body.
|
|
92
|
-
data.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
).toString();
|
|
298
|
+
if (body.contents) {
|
|
299
|
+
data.contents = Buffer.from(body.contents).toString("base64");
|
|
300
|
+
}
|
|
301
|
+
if (body.memo?.value !== void 0) {
|
|
302
|
+
data.memo = body.memo.value;
|
|
97
303
|
}
|
|
98
304
|
return data;
|
|
99
305
|
}
|
|
100
|
-
static
|
|
306
|
+
static parseFileDelete(body) {
|
|
101
307
|
if (!body) return void 0;
|
|
102
308
|
const data = {};
|
|
103
|
-
if (body.
|
|
104
|
-
data.
|
|
309
|
+
if (body.fileID) {
|
|
310
|
+
data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
|
|
105
311
|
}
|
|
106
312
|
return data;
|
|
107
313
|
}
|
|
108
314
|
/**
|
|
109
|
-
* Parse
|
|
110
|
-
* This is the unified entry point that
|
|
315
|
+
* Parse File Service transaction from Transaction object
|
|
316
|
+
* This is the unified entry point that delegates to the comprehensive parsing logic
|
|
111
317
|
*/
|
|
112
318
|
static parseFromTransactionObject(transaction) {
|
|
113
|
-
|
|
114
|
-
const transactionBody = transaction._transactionBody;
|
|
115
|
-
if (!transactionBody) {
|
|
116
|
-
return {};
|
|
117
|
-
}
|
|
118
|
-
if (transactionBody.consensusCreateTopic) {
|
|
119
|
-
const consensusCreateTopic = this.parseConsensusCreateTopic(
|
|
120
|
-
transactionBody.consensusCreateTopic
|
|
121
|
-
);
|
|
122
|
-
if (consensusCreateTopic) {
|
|
123
|
-
return {
|
|
124
|
-
type: "TOPICCREATE",
|
|
125
|
-
humanReadableType: "Topic Create",
|
|
126
|
-
consensusCreateTopic
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (transactionBody.consensusSubmitMessage) {
|
|
131
|
-
const consensusSubmitMessage = this.parseConsensusSubmitMessage(
|
|
132
|
-
transactionBody.consensusSubmitMessage
|
|
133
|
-
);
|
|
134
|
-
if (consensusSubmitMessage) {
|
|
135
|
-
return {
|
|
136
|
-
type: "CONSENSUSSUBMITMESSAGE",
|
|
137
|
-
humanReadableType: "Submit Message",
|
|
138
|
-
consensusSubmitMessage
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (transactionBody.consensusUpdateTopic) {
|
|
143
|
-
const consensusUpdateTopic = this.parseConsensusUpdateTopic(
|
|
144
|
-
transactionBody.consensusUpdateTopic
|
|
145
|
-
);
|
|
146
|
-
if (consensusUpdateTopic) {
|
|
147
|
-
return {
|
|
148
|
-
type: "TOPICUPDATE",
|
|
149
|
-
humanReadableType: "Topic Update",
|
|
150
|
-
consensusUpdateTopic
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (transactionBody.consensusDeleteTopic) {
|
|
155
|
-
const consensusDeleteTopic = this.parseConsensusDeleteTopic(
|
|
156
|
-
transactionBody.consensusDeleteTopic
|
|
157
|
-
);
|
|
158
|
-
if (consensusDeleteTopic) {
|
|
159
|
-
return {
|
|
160
|
-
type: "TOPICDELETE",
|
|
161
|
-
humanReadableType: "Topic Delete",
|
|
162
|
-
consensusDeleteTopic
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return {};
|
|
167
|
-
} catch (error) {
|
|
168
|
-
return {};
|
|
169
|
-
}
|
|
319
|
+
return this.parseFileTransaction(transaction);
|
|
170
320
|
}
|
|
171
321
|
}
|
|
172
322
|
export {
|
|
173
|
-
|
|
323
|
+
FileParser
|
|
174
324
|
};
|
|
175
325
|
//# sourceMappingURL=standards-sdk.es151.js.map
|