@hashgraphonline/standards-sdk 0.0.112 → 0.0.113

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.
@@ -1,112 +1,5 @@
1
- import { Long, AccountId } from "@hashgraph/sdk";
2
- import { parseKey } from "./standards-sdk.es32.js";
3
- import { Buffer } from "buffer";
4
- class HCSParser {
5
- static parseConsensusCreateTopic(body) {
6
- if (!body) return void 0;
7
- const data = {};
8
- if (body.memo) {
9
- data.memo = body.memo;
10
- }
11
- data.adminKey = parseKey(body.adminKey);
12
- data.submitKey = parseKey(body.submitKey);
13
- if (body.autoRenewPeriod?.seconds) {
14
- data.autoRenewPeriod = Long.fromValue(
15
- body.autoRenewPeriod.seconds
16
- ).toString();
17
- }
18
- if (body.autoRenewAccount) {
19
- data.autoRenewAccountId = new AccountId(
20
- body.autoRenewAccount.shardNum ?? 0,
21
- body.autoRenewAccount.realmNum ?? 0,
22
- body.autoRenewAccount.accountNum ?? 0
23
- ).toString();
24
- }
25
- return data;
26
- }
27
- static parseConsensusSubmitMessage(body) {
28
- if (!body) return void 0;
29
- const data = {};
30
- if (body.topicID) {
31
- data.topicId = `${body.topicID.shardNum ?? 0}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
32
- }
33
- if (body.message?.length > 0) {
34
- const messageBuffer = Buffer.from(body.message);
35
- const utf8String = messageBuffer.toString("utf8");
36
- if (/[\x00-\x08\x0B\x0E-\x1F\x7F]/.test(utf8String) || utf8String.includes("�")) {
37
- data.message = messageBuffer.toString("base64");
38
- data.messageEncoding = "base64";
39
- } else {
40
- data.message = utf8String;
41
- data.messageEncoding = "utf8";
42
- }
43
- }
44
- if (body.chunkInfo) {
45
- if (body.chunkInfo.initialTransactionID) {
46
- const txId = body.chunkInfo.initialTransactionID.accountID;
47
- const taValidStart = body.chunkInfo.initialTransactionID.transactionValidStart;
48
- if (txId && taValidStart) {
49
- data.chunkInfoInitialTransactionID = `${txId.shardNum ?? 0}.${txId.realmNum ?? 0}.${txId.accountNum ?? 0}@${taValidStart.seconds ?? 0}.${taValidStart.nanos ?? 0}`;
50
- }
51
- }
52
- if (body.chunkInfo.number !== void 0 && body.chunkInfo.number !== null) {
53
- data.chunkInfoNumber = body.chunkInfo.number;
54
- }
55
- if (body.chunkInfo.total !== void 0 && body.chunkInfo.total !== null) {
56
- data.chunkInfoTotal = body.chunkInfo.total;
57
- }
58
- }
59
- return data;
60
- }
61
- static parseConsensusUpdateTopic(body) {
62
- if (!body) return void 0;
63
- const data = {};
64
- if (body.topicID) {
65
- data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum}.${body.topicID.topicNum}`;
66
- }
67
- if (body.memo?.value !== void 0) {
68
- data.memo = body.memo.value;
69
- }
70
- if (body.adminKey === null) {
71
- data.clearAdminKey = true;
72
- data.adminKey = void 0;
73
- } else if (body.adminKey) {
74
- data.adminKey = parseKey(body.adminKey);
75
- } else {
76
- data.adminKey = void 0;
77
- }
78
- if (body.submitKey === null) {
79
- data.clearSubmitKey = true;
80
- data.submitKey = void 0;
81
- } else if (body.submitKey) {
82
- data.submitKey = parseKey(body.submitKey);
83
- } else {
84
- data.submitKey = void 0;
85
- }
86
- if (body.autoRenewPeriod?.seconds) {
87
- data.autoRenewPeriod = Long.fromValue(
88
- body.autoRenewPeriod.seconds
89
- ).toString();
90
- }
91
- if (body.autoRenewAccount) {
92
- data.autoRenewAccountId = new AccountId(
93
- body.autoRenewAccount.shardNum ?? 0,
94
- body.autoRenewAccount.realmNum ?? 0,
95
- body.autoRenewAccount.accountNum ?? 0
96
- ).toString();
97
- }
98
- return data;
99
- }
100
- static parseConsensusDeleteTopic(body) {
101
- if (!body) return void 0;
102
- const data = {};
103
- if (body.topicID) {
104
- data.topicId = `${body.topicID.shardNum}.${body.topicID.realmNum ?? 0}.${body.topicID.topicNum ?? 0}`;
105
- }
106
- return data;
107
- }
108
- }
1
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
109
2
  export {
110
- HCSParser
3
+ sleep
111
4
  };
112
5
  //# sourceMappingURL=standards-sdk.es25.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es25.js","sources":["../../src/utils/parsers/hcs-parser.ts"],"sourcesContent":["import { proto } from '@hashgraph/proto';\nimport { AccountId, Long } 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"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"standards-sdk.es25.js","sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n"],"names":[],"mappings":"AAAa,MAAA,QAAQ,CAAC,OACpB,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;"}
@@ -1,69 +1,504 @@
1
- import { Long } from "@hashgraph/sdk";
2
- import { parseKey } from "./standards-sdk.es32.js";
1
+ import { proto } from "@hashgraph/proto";
2
+ import { AccountId, Long, TokenId } from "@hashgraph/sdk";
3
+ import { parseKey } from "./standards-sdk.es33.js";
3
4
  import { Buffer } from "buffer";
4
- class FileParser {
5
- static parseFileCreate(body) {
5
+ class HTSParser {
6
+ static parseTokenCreate(body) {
6
7
  if (!body) return void 0;
7
8
  const data = {};
8
- if (body.expirationTime?.seconds) {
9
- data.expirationTime = `${Long.fromValue(
10
- body.expirationTime.seconds
11
- ).toString()}.${body.expirationTime.nanos}`;
9
+ if (body.name) {
10
+ data.tokenName = body.name;
12
11
  }
13
- if (body.keys) {
14
- data.keys = parseKey({ keyList: body.keys });
12
+ if (body.symbol) {
13
+ data.tokenSymbol = body.symbol;
15
14
  }
16
- if (body.contents) {
17
- data.contents = Buffer.from(body.contents).toString("base64");
15
+ if (body.treasury) {
16
+ data.treasuryAccountId = new AccountId(
17
+ body.treasury.shardNum ?? 0,
18
+ body.treasury.realmNum ?? 0,
19
+ body.treasury.accountNum ?? 0
20
+ ).toString();
21
+ }
22
+ if (body.initialSupply) {
23
+ data.initialSupply = Long.fromValue(body.initialSupply).toString();
24
+ }
25
+ if (body.decimals !== void 0 && body.decimals !== null) {
26
+ data.decimals = Long.fromValue(body.decimals).toNumber();
27
+ }
28
+ if (body.maxSupply) {
29
+ data.maxSupply = Long.fromValue(body.maxSupply).toString();
18
30
  }
19
31
  if (body.memo) {
20
32
  data.memo = body.memo;
21
33
  }
34
+ if (body.tokenType !== null && body.tokenType !== void 0) {
35
+ data.tokenType = proto.TokenType[body.tokenType];
36
+ }
37
+ if (body.supplyType !== null && body.supplyType !== void 0) {
38
+ data.supplyType = proto.TokenSupplyType[body.supplyType];
39
+ }
40
+ data.adminKey = parseKey(body.adminKey);
41
+ data.kycKey = parseKey(body.kycKey);
42
+ data.freezeKey = parseKey(body.freezeKey);
43
+ data.wipeKey = parseKey(body.wipeKey);
44
+ data.supplyKey = parseKey(body.supplyKey);
45
+ data.feeScheduleKey = parseKey(body.feeScheduleKey);
46
+ data.pauseKey = parseKey(body.pauseKey);
47
+ if (body.autoRenewAccount) {
48
+ data.autoRenewAccount = new AccountId(
49
+ body.autoRenewAccount.shardNum ?? 0,
50
+ body.autoRenewAccount.realmNum ?? 0,
51
+ body.autoRenewAccount.accountNum ?? 0
52
+ ).toString();
53
+ }
54
+ if (body.autoRenewPeriod?.seconds) {
55
+ data.autoRenewPeriod = Long.fromValue(
56
+ body.autoRenewPeriod.seconds
57
+ ).toString();
58
+ }
59
+ if (body.customFees && body.customFees.length > 0) {
60
+ data.customFees = body.customFees.map((fee) => {
61
+ const feeCollectorAccountId = fee.feeCollectorAccountId ? new AccountId(
62
+ fee.feeCollectorAccountId.shardNum ?? 0,
63
+ fee.feeCollectorAccountId.realmNum ?? 0,
64
+ fee.feeCollectorAccountId.accountNum ?? 0
65
+ ).toString() : "Not Set";
66
+ const commonFeeData = {
67
+ feeCollectorAccountId,
68
+ allCollectorsAreExempt: fee.allCollectorsAreExempt || false
69
+ };
70
+ if (fee.fixedFee) {
71
+ return {
72
+ ...commonFeeData,
73
+ feeType: "FIXED_FEE",
74
+ fixedFee: {
75
+ amount: Long.fromValue(fee.fixedFee.amount || 0).toString(),
76
+ denominatingTokenId: fee.fixedFee.denominatingTokenId ? new TokenId(
77
+ fee.fixedFee.denominatingTokenId.shardNum ?? 0,
78
+ fee.fixedFee.denominatingTokenId.realmNum ?? 0,
79
+ fee.fixedFee.denominatingTokenId.tokenNum ?? 0
80
+ ).toString() : void 0
81
+ }
82
+ };
83
+ } else if (fee.fractionalFee) {
84
+ return {
85
+ ...commonFeeData,
86
+ feeType: "FRACTIONAL_FEE",
87
+ fractionalFee: {
88
+ numerator: Long.fromValue(
89
+ fee.fractionalFee.fractionalAmount?.numerator || 0
90
+ ).toString(),
91
+ denominator: Long.fromValue(
92
+ fee.fractionalFee.fractionalAmount?.denominator || 1
93
+ ).toString(),
94
+ minimumAmount: Long.fromValue(
95
+ fee.fractionalFee.minimumAmount || 0
96
+ ).toString(),
97
+ maximumAmount: Long.fromValue(
98
+ fee.fractionalFee.maximumAmount || 0
99
+ ).toString(),
100
+ netOfTransfers: fee.fractionalFee.netOfTransfers || false
101
+ }
102
+ };
103
+ } else if (fee.royaltyFee) {
104
+ let fallbackFeeData = void 0;
105
+ if (fee.royaltyFee.fallbackFee) {
106
+ fallbackFeeData = {
107
+ amount: Long.fromValue(
108
+ fee.royaltyFee.fallbackFee.amount || 0
109
+ ).toString(),
110
+ denominatingTokenId: fee.royaltyFee.fallbackFee.denominatingTokenId ? new TokenId(
111
+ fee.royaltyFee.fallbackFee.denominatingTokenId.shardNum ?? 0,
112
+ fee.royaltyFee.fallbackFee.denominatingTokenId.realmNum ?? 0,
113
+ fee.royaltyFee.fallbackFee.denominatingTokenId.tokenNum ?? 0
114
+ ).toString() : void 0
115
+ };
116
+ }
117
+ return {
118
+ ...commonFeeData,
119
+ feeType: "ROYALTY_FEE",
120
+ royaltyFee: {
121
+ numerator: Long.fromValue(
122
+ fee.royaltyFee.exchangeValueFraction?.numerator || 0
123
+ ).toString(),
124
+ denominator: Long.fromValue(
125
+ fee.royaltyFee.exchangeValueFraction?.denominator || 1
126
+ ).toString(),
127
+ fallbackFee: fallbackFeeData
128
+ }
129
+ };
130
+ }
131
+ return {
132
+ ...commonFeeData,
133
+ feeType: "FIXED_FEE",
134
+ fixedFee: { amount: "0" }
135
+ };
136
+ });
137
+ }
22
138
  return data;
23
139
  }
24
- static parseFileAppend(body) {
25
- if (!body) return void 0;
26
- const data = {};
27
- if (body.fileID) {
28
- data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
140
+ static parseTokenMint(body) {
141
+ if (!body || !body.token || body.amount === null || body.amount === void 0) {
142
+ return void 0;
29
143
  }
30
- if (body.contents) {
31
- data.contents = Buffer.from(body.contents).toString("base64");
144
+ const data = {
145
+ tokenId: new TokenId(
146
+ body.token.shardNum ?? 0,
147
+ body.token.realmNum ?? 0,
148
+ body.token.tokenNum ?? 0
149
+ ).toString(),
150
+ amount: Long.fromValue(body.amount).toNumber()
151
+ };
152
+ if (body.metadata && body.metadata.length > 0) {
153
+ data.metadata = body.metadata.map(
154
+ (meta) => Buffer.from(meta).toString("base64")
155
+ );
32
156
  }
33
157
  return data;
34
158
  }
35
- static parseFileUpdate(body) {
159
+ static parseTokenBurn(body) {
160
+ if (!body || !body.token || body.amount === null || body.amount === void 0) {
161
+ return void 0;
162
+ }
163
+ const data = {
164
+ tokenId: new TokenId(
165
+ body.token.shardNum ?? 0,
166
+ body.token.realmNum ?? 0,
167
+ body.token.tokenNum ?? 0
168
+ ).toString(),
169
+ amount: Long.fromValue(body.amount).toNumber()
170
+ };
171
+ if (body.serialNumbers && body.serialNumbers.length > 0) {
172
+ data.serialNumbers = body.serialNumbers.map(
173
+ (sn) => Long.fromValue(sn).toNumber()
174
+ );
175
+ }
176
+ return data;
177
+ }
178
+ static parseTokenUpdate(body) {
36
179
  if (!body) return void 0;
37
180
  const data = {};
38
- if (body.fileID) {
39
- data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
181
+ if (body.token) {
182
+ data.tokenId = new TokenId(
183
+ body.token.shardNum ?? 0,
184
+ body.token.realmNum ?? 0,
185
+ body.token.tokenNum ?? 0
186
+ ).toString();
187
+ }
188
+ if (body.name) {
189
+ data.name = body.name;
40
190
  }
41
- if (body.expirationTime?.seconds) {
42
- data.expirationTime = `${Long.fromValue(
43
- body.expirationTime.seconds
44
- ).toString()}.${body.expirationTime.nanos}`;
191
+ if (body.symbol) {
192
+ data.symbol = body.symbol;
45
193
  }
46
- if (body.keys) {
47
- data.keys = parseKey({ keyList: body.keys });
194
+ if (body.treasury) {
195
+ data.treasuryAccountId = new AccountId(
196
+ body.treasury.shardNum ?? 0,
197
+ body.treasury.realmNum ?? 0,
198
+ body.treasury.accountNum ?? 0
199
+ ).toString();
48
200
  }
49
- if (body.contents) {
50
- data.contents = Buffer.from(body.contents).toString("base64");
201
+ data.adminKey = parseKey(body.adminKey);
202
+ data.kycKey = parseKey(body.kycKey);
203
+ data.freezeKey = parseKey(body.freezeKey);
204
+ data.wipeKey = parseKey(body.wipeKey);
205
+ data.supplyKey = parseKey(body.supplyKey);
206
+ data.feeScheduleKey = parseKey(body.feeScheduleKey);
207
+ data.pauseKey = parseKey(body.pauseKey);
208
+ if (body.autoRenewAccount) {
209
+ data.autoRenewAccountId = new AccountId(
210
+ body.autoRenewAccount.shardNum ?? 0,
211
+ body.autoRenewAccount.realmNum ?? 0,
212
+ body.autoRenewAccount.accountNum ?? 0
213
+ ).toString();
214
+ }
215
+ if (body.autoRenewPeriod?.seconds) {
216
+ data.autoRenewPeriod = Long.fromValue(
217
+ body.autoRenewPeriod.seconds
218
+ ).toString();
51
219
  }
52
220
  if (body.memo?.value !== void 0) {
53
221
  data.memo = body.memo.value;
54
222
  }
223
+ if (body.expiry?.seconds) {
224
+ data.expiry = `${Long.fromValue(body.expiry.seconds).toString()}.${body.expiry.nanos}`;
225
+ }
55
226
  return data;
56
227
  }
57
- static parseFileDelete(body) {
228
+ static parseTokenFeeScheduleUpdate(body) {
58
229
  if (!body) return void 0;
59
230
  const data = {};
60
- if (body.fileID) {
61
- data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`;
231
+ if (body.tokenId) {
232
+ data.tokenId = new TokenId(
233
+ body.tokenId.shardNum ?? 0,
234
+ body.tokenId.realmNum ?? 0,
235
+ body.tokenId.tokenNum ?? 0
236
+ ).toString();
237
+ }
238
+ if (body.customFees && body.customFees.length > 0) {
239
+ data.customFees = body.customFees.map((fee) => {
240
+ const feeCollectorAccountId = fee.feeCollectorAccountId ? new AccountId(
241
+ fee.feeCollectorAccountId.shardNum ?? 0,
242
+ fee.feeCollectorAccountId.realmNum ?? 0,
243
+ fee.feeCollectorAccountId.accountNum ?? 0
244
+ ).toString() : "Not Set";
245
+ const commonFeeData = {
246
+ feeCollectorAccountId,
247
+ allCollectorsAreExempt: fee.allCollectorsAreExempt || false
248
+ };
249
+ if (fee.fixedFee) {
250
+ return {
251
+ ...commonFeeData,
252
+ feeType: "FIXED_FEE",
253
+ fixedFee: {
254
+ amount: Long.fromValue(fee.fixedFee.amount || 0).toString(),
255
+ denominatingTokenId: fee.fixedFee.denominatingTokenId ? new TokenId(
256
+ fee.fixedFee.denominatingTokenId.shardNum ?? 0,
257
+ fee.fixedFee.denominatingTokenId.realmNum ?? 0,
258
+ fee.fixedFee.denominatingTokenId.tokenNum ?? 0
259
+ ).toString() : void 0
260
+ }
261
+ };
262
+ } else if (fee.fractionalFee) {
263
+ return {
264
+ ...commonFeeData,
265
+ feeType: "FRACTIONAL_FEE",
266
+ fractionalFee: {
267
+ numerator: Long.fromValue(
268
+ fee.fractionalFee.fractionalAmount?.numerator || 0
269
+ ).toString(),
270
+ denominator: Long.fromValue(
271
+ fee.fractionalFee.fractionalAmount?.denominator || 1
272
+ ).toString(),
273
+ minimumAmount: Long.fromValue(
274
+ fee.fractionalFee.minimumAmount || 0
275
+ ).toString(),
276
+ maximumAmount: Long.fromValue(
277
+ fee.fractionalFee.maximumAmount || 0
278
+ ).toString(),
279
+ netOfTransfers: fee.fractionalFee.netOfTransfers || false
280
+ }
281
+ };
282
+ } else if (fee.royaltyFee) {
283
+ let fallbackFeeData = void 0;
284
+ if (fee.royaltyFee.fallbackFee) {
285
+ fallbackFeeData = {
286
+ amount: Long.fromValue(
287
+ fee.royaltyFee.fallbackFee.amount || 0
288
+ ).toString(),
289
+ denominatingTokenId: fee.royaltyFee.fallbackFee.denominatingTokenId ? new TokenId(
290
+ fee.royaltyFee.fallbackFee.denominatingTokenId.shardNum ?? 0,
291
+ fee.royaltyFee.fallbackFee.denominatingTokenId.realmNum ?? 0,
292
+ fee.royaltyFee.fallbackFee.denominatingTokenId.tokenNum ?? 0
293
+ ).toString() : void 0
294
+ };
295
+ }
296
+ return {
297
+ ...commonFeeData,
298
+ feeType: "ROYALTY_FEE",
299
+ royaltyFee: {
300
+ numerator: Long.fromValue(
301
+ fee.royaltyFee.exchangeValueFraction?.numerator || 0
302
+ ).toString(),
303
+ denominator: Long.fromValue(
304
+ fee.royaltyFee.exchangeValueFraction?.denominator || 1
305
+ ).toString(),
306
+ fallbackFee: fallbackFeeData
307
+ }
308
+ };
309
+ }
310
+ return {
311
+ ...commonFeeData,
312
+ feeType: "FIXED_FEE",
313
+ fixedFee: { amount: "0" }
314
+ };
315
+ });
316
+ }
317
+ return data;
318
+ }
319
+ static parseTokenFreeze(body) {
320
+ if (!body) return void 0;
321
+ const data = {};
322
+ if (body.token) {
323
+ data.tokenId = new TokenId(
324
+ body.token.shardNum ?? 0,
325
+ body.token.realmNum ?? 0,
326
+ body.token.tokenNum ?? 0
327
+ ).toString();
328
+ }
329
+ if (body.account) {
330
+ data.accountId = new AccountId(
331
+ body.account.shardNum ?? 0,
332
+ body.account.realmNum ?? 0,
333
+ body.account.accountNum ?? 0
334
+ ).toString();
335
+ }
336
+ return data;
337
+ }
338
+ static parseTokenUnfreeze(body) {
339
+ if (!body) return void 0;
340
+ const data = {};
341
+ if (body.token) {
342
+ data.tokenId = new TokenId(
343
+ body.token.shardNum ?? 0,
344
+ body.token.realmNum ?? 0,
345
+ body.token.tokenNum ?? 0
346
+ ).toString();
347
+ }
348
+ if (body.account) {
349
+ data.accountId = new AccountId(
350
+ body.account.shardNum ?? 0,
351
+ body.account.realmNum ?? 0,
352
+ body.account.accountNum ?? 0
353
+ ).toString();
354
+ }
355
+ return data;
356
+ }
357
+ static parseTokenGrantKyc(body) {
358
+ if (!body) return void 0;
359
+ const data = {};
360
+ if (body.token) {
361
+ data.tokenId = new TokenId(
362
+ body.token.shardNum ?? 0,
363
+ body.token.realmNum ?? 0,
364
+ body.token.tokenNum ?? 0
365
+ ).toString();
366
+ }
367
+ if (body.account) {
368
+ data.accountId = new AccountId(
369
+ body.account.shardNum ?? 0,
370
+ body.account.realmNum ?? 0,
371
+ body.account.accountNum ?? 0
372
+ ).toString();
373
+ }
374
+ return data;
375
+ }
376
+ static parseTokenRevokeKyc(body) {
377
+ if (!body) return void 0;
378
+ const data = {};
379
+ if (body.token) {
380
+ data.tokenId = new TokenId(
381
+ body.token.shardNum ?? 0,
382
+ body.token.realmNum ?? 0,
383
+ body.token.tokenNum ?? 0
384
+ ).toString();
385
+ }
386
+ if (body.account) {
387
+ data.accountId = new AccountId(
388
+ body.account.shardNum ?? 0,
389
+ body.account.realmNum ?? 0,
390
+ body.account.accountNum ?? 0
391
+ ).toString();
392
+ }
393
+ return data;
394
+ }
395
+ static parseTokenPause(body) {
396
+ if (!body) return void 0;
397
+ const data = {};
398
+ if (body.token) {
399
+ data.tokenId = new TokenId(
400
+ body.token.shardNum ?? 0,
401
+ body.token.realmNum ?? 0,
402
+ body.token.tokenNum ?? 0
403
+ ).toString();
404
+ }
405
+ return data;
406
+ }
407
+ static parseTokenUnpause(body) {
408
+ if (!body) return void 0;
409
+ const data = {};
410
+ if (body.token) {
411
+ data.tokenId = new TokenId(
412
+ body.token.shardNum ?? 0,
413
+ body.token.realmNum ?? 0,
414
+ body.token.tokenNum ?? 0
415
+ ).toString();
416
+ }
417
+ return data;
418
+ }
419
+ static parseTokenWipeAccount(body) {
420
+ if (!body) return void 0;
421
+ const data = {};
422
+ if (body.token) {
423
+ data.tokenId = new TokenId(
424
+ body.token.shardNum ?? 0,
425
+ body.token.realmNum ?? 0,
426
+ body.token.tokenNum ?? 0
427
+ ).toString();
428
+ }
429
+ if (body.account) {
430
+ data.accountId = new AccountId(
431
+ body.account.shardNum ?? 0,
432
+ body.account.realmNum ?? 0,
433
+ body.account.accountNum ?? 0
434
+ ).toString();
435
+ }
436
+ if (body.serialNumbers && body.serialNumbers.length > 0) {
437
+ data.serialNumbers = body.serialNumbers.map(
438
+ (sn) => Long.fromValue(sn).toString()
439
+ );
440
+ }
441
+ if (body.amount) {
442
+ data.amount = Long.fromValue(body.amount).toString();
443
+ }
444
+ return data;
445
+ }
446
+ static parseTokenDelete(body) {
447
+ if (!body) return void 0;
448
+ const data = {};
449
+ if (body.token) {
450
+ data.tokenId = new TokenId(
451
+ body.token.shardNum ?? 0,
452
+ body.token.realmNum ?? 0,
453
+ body.token.tokenNum ?? 0
454
+ ).toString();
455
+ }
456
+ return data;
457
+ }
458
+ static parseTokenAssociate(body) {
459
+ if (!body) return void 0;
460
+ const data = {};
461
+ if (body.account) {
462
+ data.accountId = new AccountId(
463
+ body.account.shardNum ?? 0,
464
+ body.account.realmNum ?? 0,
465
+ body.account.accountNum ?? 0
466
+ ).toString();
467
+ }
468
+ if (body.tokens && body.tokens.length > 0) {
469
+ data.tokenIds = body.tokens.map(
470
+ (t) => new TokenId(
471
+ t.shardNum ?? 0,
472
+ t.realmNum ?? 0,
473
+ t.tokenNum ?? 0
474
+ ).toString()
475
+ );
476
+ }
477
+ return data;
478
+ }
479
+ static parseTokenDissociate(body) {
480
+ if (!body) return void 0;
481
+ const data = {};
482
+ if (body.account) {
483
+ data.accountId = new AccountId(
484
+ body.account.shardNum ?? 0,
485
+ body.account.realmNum ?? 0,
486
+ body.account.accountNum ?? 0
487
+ ).toString();
488
+ }
489
+ if (body.tokens && body.tokens.length > 0) {
490
+ data.tokenIds = body.tokens.map(
491
+ (t) => new TokenId(
492
+ t.shardNum ?? 0,
493
+ t.realmNum ?? 0,
494
+ t.tokenNum ?? 0
495
+ ).toString()
496
+ );
62
497
  }
63
498
  return data;
64
499
  }
65
500
  }
66
501
  export {
67
- FileParser
502
+ HTSParser
68
503
  };
69
504
  //# sourceMappingURL=standards-sdk.es26.js.map