@hashgraphonline/standards-sdk 0.1.141-canary.30 → 0.1.141-canary.31
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-21/sdk.d.ts +17 -0
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-21/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts +17 -0
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-21/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es100.js +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es111.js +5 -5
- 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.es128.js +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es138.js +766 -42
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +42 -766
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es140.js +12 -12269
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +168 -13
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +321 -55
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +294 -120
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +322 -191
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +279 -294
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +63 -440
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +12210 -267
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +49 -69
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +1 -1
- package/dist/es/standards-sdk.es19.js +3 -3
- package/dist/es/standards-sdk.es20.js +2 -2
- 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 +2 -2
- package/dist/es/standards-sdk.es37.js +2 -2
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es57.js +1 -1
- package/dist/es/standards-sdk.es59.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 +1 -1
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es70.js +1 -1
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es78.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.es80.js +2 -2
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +1 -1
- package/dist/es/standards-sdk.es84.js +55 -0
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/package.json +61 -63
|
@@ -1,349 +1,334 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const tokenAmount = Long.fromValue(transfer.amount).toNumber();
|
|
35
|
-
result.tokenTransfers.push({
|
|
36
|
-
tokenId: tokenId.toString(),
|
|
37
|
-
accountId: accountId.toString(),
|
|
38
|
-
amount: tokenAmount
|
|
39
|
-
});
|
|
1
|
+
import { proto } from "@hashgraph/proto";
|
|
2
|
+
import { Long, FileId, ContractId } from "@hashgraph/sdk";
|
|
3
|
+
import { hasTransactionType } from "./standards-sdk.es146.js";
|
|
4
|
+
class UtilParser {
|
|
5
|
+
/**
|
|
6
|
+
* Parse Utility/System Service transaction using unified dual-branch approach
|
|
7
|
+
* This handles both regular transactions and signed transaction variants
|
|
8
|
+
*/
|
|
9
|
+
static parseUtilTransaction(transaction, originalBytes) {
|
|
10
|
+
try {
|
|
11
|
+
if (originalBytes || transaction.toBytes) {
|
|
12
|
+
try {
|
|
13
|
+
const bytesToParse = originalBytes || transaction.toBytes();
|
|
14
|
+
const decoded = proto.TransactionList.decode(bytesToParse);
|
|
15
|
+
if (decoded.transactionList && decoded.transactionList.length > 0) {
|
|
16
|
+
const tx = decoded.transactionList[0];
|
|
17
|
+
let txBody = null;
|
|
18
|
+
if (tx.bodyBytes && tx.bodyBytes.length > 0) {
|
|
19
|
+
txBody = proto.TransactionBody.decode(tx.bodyBytes);
|
|
20
|
+
} else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
|
|
21
|
+
const signedTx = proto.SignedTransaction.decode(
|
|
22
|
+
tx.signedTransactionBytes
|
|
23
|
+
);
|
|
24
|
+
if (signedTx.bodyBytes) {
|
|
25
|
+
txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (txBody) {
|
|
29
|
+
const protoResult = this.parseFromProtobufTxBody(txBody);
|
|
30
|
+
if (protoResult.type && protoResult.type !== "UNKNOWN") {
|
|
31
|
+
return protoResult;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
40
34
|
}
|
|
35
|
+
} catch (protoError) {
|
|
41
36
|
}
|
|
42
37
|
}
|
|
38
|
+
return this.parseFromTransactionInternals(transaction);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return {
|
|
41
|
+
type: "UNKNOWN",
|
|
42
|
+
humanReadableType: "Unknown Utility Transaction"
|
|
43
|
+
};
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Parse utility transaction from protobuf TransactionBody
|
|
48
|
+
* Handles all utility operations from decoded protobuf data
|
|
49
|
+
*/
|
|
50
|
+
static parseFromProtobufTxBody(txBody) {
|
|
51
|
+
if (txBody.utilPrng) {
|
|
52
|
+
const utilPrng = this.parseUtilPrng(txBody.utilPrng);
|
|
53
|
+
if (utilPrng) {
|
|
54
|
+
return {
|
|
55
|
+
type: "PRNG",
|
|
56
|
+
humanReadableType: "Pseudo Random Number",
|
|
57
|
+
utilPrng
|
|
58
|
+
};
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
if (txBody.freeze) {
|
|
62
|
+
const networkFreeze = this.parseNetworkFreezeFromProto(txBody.freeze);
|
|
63
|
+
if (networkFreeze) {
|
|
64
|
+
return {
|
|
65
|
+
type: "FREEZE",
|
|
66
|
+
humanReadableType: "Network Freeze",
|
|
67
|
+
freeze: networkFreeze
|
|
68
|
+
};
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
if (txBody.systemDelete) {
|
|
72
|
+
const systemDelete = this.parseSystemDeleteFromProto(txBody.systemDelete);
|
|
73
|
+
if (systemDelete) {
|
|
74
|
+
return {
|
|
75
|
+
type: "SYSTEMDELETE",
|
|
76
|
+
humanReadableType: "System Delete",
|
|
77
|
+
systemDelete
|
|
78
|
+
};
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
|
-
if (
|
|
73
|
-
|
|
81
|
+
if (txBody.systemUndelete) {
|
|
82
|
+
const systemUndelete = this.parseSystemUndeleteFromProto(
|
|
83
|
+
txBody.systemUndelete
|
|
84
|
+
);
|
|
85
|
+
if (systemUndelete) {
|
|
86
|
+
return {
|
|
87
|
+
type: "SYSTEMUNDELETE",
|
|
88
|
+
humanReadableType: "System Undelete",
|
|
89
|
+
systemUndelete
|
|
90
|
+
};
|
|
91
|
+
}
|
|
74
92
|
}
|
|
75
|
-
if (
|
|
76
|
-
|
|
93
|
+
if (txBody.nodeCreate) {
|
|
94
|
+
const nodeCreate = this.parseNodeCreateFromProto(txBody.nodeCreate);
|
|
95
|
+
if (nodeCreate) {
|
|
96
|
+
return {
|
|
97
|
+
type: "NODECREATE",
|
|
98
|
+
humanReadableType: "Node Create",
|
|
99
|
+
nodeCreate
|
|
100
|
+
};
|
|
101
|
+
}
|
|
77
102
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
103
|
+
if (txBody.nodeUpdate) {
|
|
104
|
+
const nodeUpdate = this.parseNodeUpdateFromProto(txBody.nodeUpdate);
|
|
105
|
+
if (nodeUpdate) {
|
|
106
|
+
return {
|
|
107
|
+
type: "NODEUPDATE",
|
|
108
|
+
humanReadableType: "Node Update",
|
|
109
|
+
nodeUpdate
|
|
110
|
+
};
|
|
111
|
+
}
|
|
82
112
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
113
|
+
if (txBody.nodeDelete) {
|
|
114
|
+
const nodeDelete = this.parseNodeDeleteFromProto(txBody.nodeDelete);
|
|
115
|
+
if (nodeDelete) {
|
|
116
|
+
return {
|
|
117
|
+
type: "NODEDELETE",
|
|
118
|
+
humanReadableType: "Node Delete",
|
|
119
|
+
nodeDelete
|
|
120
|
+
};
|
|
121
|
+
}
|
|
85
122
|
}
|
|
86
|
-
|
|
87
|
-
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extract utility data from Transaction internal fields
|
|
127
|
+
* This handles cases where data is stored in Transaction object internals
|
|
128
|
+
*/
|
|
129
|
+
static parseFromTransactionInternals(transaction) {
|
|
130
|
+
try {
|
|
131
|
+
const tx = transaction;
|
|
132
|
+
if (hasTransactionType(transaction, "utilPrng")) {
|
|
133
|
+
const utilPrng = {};
|
|
134
|
+
if (tx._range && tx._range !== 0) {
|
|
135
|
+
utilPrng.range = tx._range;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
type: "PRNG",
|
|
139
|
+
humanReadableType: "Pseudo Random Number",
|
|
140
|
+
utilPrng
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (hasTransactionType(transaction, "freeze")) {
|
|
144
|
+
const networkFreeze = {};
|
|
145
|
+
if (tx._startTime) {
|
|
146
|
+
networkFreeze.startTime = tx._startTime.toString();
|
|
147
|
+
}
|
|
148
|
+
if (tx._endTime) {
|
|
149
|
+
networkFreeze.endTime = tx._endTime.toString();
|
|
150
|
+
}
|
|
151
|
+
if (tx._updateFile) {
|
|
152
|
+
networkFreeze.updateFile = tx._updateFile.toString();
|
|
153
|
+
}
|
|
154
|
+
if (tx._fileHash) {
|
|
155
|
+
networkFreeze.fileHash = Buffer.from(tx._fileHash).toString("hex");
|
|
156
|
+
}
|
|
157
|
+
if (tx._freezeType) {
|
|
158
|
+
networkFreeze.freezeType = tx._freezeType;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
type: "FREEZE",
|
|
162
|
+
humanReadableType: "Network Freeze",
|
|
163
|
+
freeze: networkFreeze
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (hasTransactionType(transaction, "systemDelete")) {
|
|
167
|
+
const systemDelete = {};
|
|
168
|
+
if (tx._fileId) {
|
|
169
|
+
systemDelete.fileId = tx._fileId.toString();
|
|
170
|
+
} else if (tx._contractId) {
|
|
171
|
+
systemDelete.contractId = tx._contractId.toString();
|
|
172
|
+
}
|
|
173
|
+
if (tx._expirationTime) {
|
|
174
|
+
systemDelete.expirationTime = tx._expirationTime.toString();
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
type: "SYSTEMDELETE",
|
|
178
|
+
humanReadableType: "System Delete",
|
|
179
|
+
systemDelete
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (hasTransactionType(transaction, "systemUndelete")) {
|
|
183
|
+
const systemUndelete = {};
|
|
184
|
+
if (tx._fileId) {
|
|
185
|
+
systemUndelete.fileId = tx._fileId.toString();
|
|
186
|
+
} else if (tx._contractId) {
|
|
187
|
+
systemUndelete.contractId = tx._contractId.toString();
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
type: "SYSTEMUNDELETE",
|
|
191
|
+
humanReadableType: "System Undelete",
|
|
192
|
+
systemUndelete
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {};
|
|
196
|
+
} catch (error) {
|
|
197
|
+
return {};
|
|
88
198
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Parse Network Freeze from protobuf data
|
|
202
|
+
*/
|
|
203
|
+
static parseNetworkFreezeFromProto(body) {
|
|
204
|
+
if (!body) return void 0;
|
|
205
|
+
const data = {};
|
|
206
|
+
if (body.startTime?.seconds) {
|
|
207
|
+
data.startTime = `${Long.fromValue(
|
|
208
|
+
body.startTime.seconds
|
|
209
|
+
).toString()}.${body.startTime.nanos ?? 0}`;
|
|
210
|
+
}
|
|
211
|
+
if (body.updateFile) {
|
|
212
|
+
data.updateFile = new FileId(
|
|
213
|
+
body.updateFile.shardNum ?? 0,
|
|
214
|
+
body.updateFile.realmNum ?? 0,
|
|
215
|
+
body.updateFile.fileNum ?? 0
|
|
94
216
|
).toString();
|
|
95
|
-
} else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0) {
|
|
96
|
-
data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
|
|
97
217
|
}
|
|
98
|
-
if (body.
|
|
99
|
-
data.
|
|
218
|
+
if (body.fileHash && body.fileHash.length > 0) {
|
|
219
|
+
data.fileHash = Buffer.from(body.fileHash).toString("hex");
|
|
100
220
|
}
|
|
101
|
-
if (body.
|
|
102
|
-
|
|
221
|
+
if (body.freezeType !== void 0) {
|
|
222
|
+
const freezeTypes = [
|
|
223
|
+
"FREEZE_ONLY",
|
|
224
|
+
"PREPARE_UPGRADE",
|
|
225
|
+
"FREEZE_UPGRADE",
|
|
226
|
+
"FREEZE_ABORT"
|
|
227
|
+
];
|
|
228
|
+
data.freezeType = freezeTypes[body.freezeType] || "FREEZE_ONLY";
|
|
103
229
|
}
|
|
104
230
|
return data;
|
|
105
231
|
}
|
|
106
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Parse System Delete from protobuf data
|
|
234
|
+
*/
|
|
235
|
+
static parseSystemDeleteFromProto(body) {
|
|
107
236
|
if (!body) return void 0;
|
|
108
237
|
const data = {};
|
|
109
|
-
if (body.
|
|
110
|
-
data.
|
|
111
|
-
body.
|
|
112
|
-
body.
|
|
113
|
-
body.
|
|
238
|
+
if (body.fileID) {
|
|
239
|
+
data.fileId = new FileId(
|
|
240
|
+
body.fileID.shardNum ?? 0,
|
|
241
|
+
body.fileID.realmNum ?? 0,
|
|
242
|
+
body.fileID.fileNum ?? 0
|
|
243
|
+
).toString();
|
|
244
|
+
} else if (body.contractID) {
|
|
245
|
+
data.contractId = new ContractId(
|
|
246
|
+
body.contractID.shardNum ?? 0,
|
|
247
|
+
body.contractID.realmNum ?? 0,
|
|
248
|
+
body.contractID.contractNum ?? 0
|
|
114
249
|
).toString();
|
|
115
|
-
}
|
|
116
|
-
if (body.key) {
|
|
117
|
-
data.key = parseKey(body.key);
|
|
118
250
|
}
|
|
119
251
|
if (body.expirationTime?.seconds) {
|
|
120
|
-
data.expirationTime =
|
|
252
|
+
data.expirationTime = Long.fromValue(
|
|
121
253
|
body.expirationTime.seconds
|
|
122
|
-
).toString()}.${body.expirationTime.nanos}`;
|
|
123
|
-
}
|
|
124
|
-
if (body.receiverSigRequired !== null && body.receiverSigRequired !== void 0) {
|
|
125
|
-
data.receiverSigRequired = Boolean(body.receiverSigRequired);
|
|
126
|
-
}
|
|
127
|
-
if (body.autoRenewPeriod?.seconds) {
|
|
128
|
-
data.autoRenewPeriod = Long.fromValue(
|
|
129
|
-
body.autoRenewPeriod.seconds
|
|
130
|
-
).toString();
|
|
131
|
-
}
|
|
132
|
-
if (body.memo?.value !== void 0) {
|
|
133
|
-
data.memo = body.memo.value;
|
|
134
|
-
}
|
|
135
|
-
if (body.maxAutomaticTokenAssociations?.value !== void 0) {
|
|
136
|
-
data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations.value;
|
|
137
|
-
}
|
|
138
|
-
if (body.stakedAccountId) {
|
|
139
|
-
data.stakedAccountId = new AccountId(
|
|
140
|
-
body.stakedAccountId.shardNum ?? 0,
|
|
141
|
-
body.stakedAccountId.realmNum ?? 0,
|
|
142
|
-
body.stakedAccountId.accountNum ?? 0
|
|
143
254
|
).toString();
|
|
144
|
-
data.stakedNodeId = void 0;
|
|
145
|
-
} else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0) {
|
|
146
|
-
data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
|
|
147
|
-
data.stakedAccountId = void 0;
|
|
148
|
-
} else {
|
|
149
|
-
data.stakedAccountId = void 0;
|
|
150
|
-
data.stakedNodeId = void 0;
|
|
151
|
-
}
|
|
152
|
-
if (body.declineReward !== null && body.declineReward !== void 0) {
|
|
153
|
-
data.declineReward = Boolean(body.declineReward);
|
|
154
255
|
}
|
|
155
256
|
return data;
|
|
156
257
|
}
|
|
157
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Parse System Undelete from protobuf data
|
|
260
|
+
*/
|
|
261
|
+
static parseSystemUndeleteFromProto(body) {
|
|
158
262
|
if (!body) return void 0;
|
|
159
263
|
const data = {};
|
|
160
|
-
if (body.
|
|
161
|
-
data.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
amount: Hbar.fromTinybars(Long.fromValue(a.amount)).toString(
|
|
173
|
-
HbarUnit.Hbar
|
|
174
|
-
)
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
if (body.tokenAllowances && body.tokenAllowances.length > 0) {
|
|
178
|
-
data.tokenAllowances = body.tokenAllowances.map((a) => ({
|
|
179
|
-
tokenId: new TokenId(
|
|
180
|
-
a.tokenId.shardNum ?? 0,
|
|
181
|
-
a.tokenId.realmNum ?? 0,
|
|
182
|
-
a.tokenId.tokenNum ?? 0
|
|
183
|
-
).toString(),
|
|
184
|
-
ownerAccountId: new AccountId(
|
|
185
|
-
a.owner.shardNum ?? 0,
|
|
186
|
-
a.owner.realmNum ?? 0,
|
|
187
|
-
a.owner.accountNum ?? 0
|
|
188
|
-
).toString(),
|
|
189
|
-
spenderAccountId: new AccountId(
|
|
190
|
-
a.spender.shardNum ?? 0,
|
|
191
|
-
a.spender.realmNum ?? 0,
|
|
192
|
-
a.spender.accountNum ?? 0
|
|
193
|
-
).toString(),
|
|
194
|
-
amount: Long.fromValue(a.amount).toString()
|
|
195
|
-
}));
|
|
196
|
-
}
|
|
197
|
-
if (body.nftAllowances && body.nftAllowances.length > 0) {
|
|
198
|
-
data.nftAllowances = body.nftAllowances.map((a) => {
|
|
199
|
-
const allowance = {};
|
|
200
|
-
if (a.tokenId)
|
|
201
|
-
allowance.tokenId = new TokenId(
|
|
202
|
-
a.tokenId.shardNum ?? 0,
|
|
203
|
-
a.tokenId.realmNum ?? 0,
|
|
204
|
-
a.tokenId.tokenNum ?? 0
|
|
205
|
-
).toString();
|
|
206
|
-
if (a.owner)
|
|
207
|
-
allowance.ownerAccountId = new AccountId(
|
|
208
|
-
a.owner.shardNum ?? 0,
|
|
209
|
-
a.owner.realmNum ?? 0,
|
|
210
|
-
a.owner.accountNum ?? 0
|
|
211
|
-
).toString();
|
|
212
|
-
if (a.spender)
|
|
213
|
-
allowance.spenderAccountId = new AccountId(
|
|
214
|
-
a.spender.shardNum ?? 0,
|
|
215
|
-
a.spender.realmNum ?? 0,
|
|
216
|
-
a.spender.accountNum ?? 0
|
|
217
|
-
).toString();
|
|
218
|
-
if (a.serialNumbers && a.serialNumbers.length > 0)
|
|
219
|
-
allowance.serialNumbers = a.serialNumbers.map(
|
|
220
|
-
(sn) => Long.fromValue(sn).toString()
|
|
221
|
-
);
|
|
222
|
-
if (a.approvedForAll?.value !== void 0)
|
|
223
|
-
allowance.approvedForAll = a.approvedForAll.value;
|
|
224
|
-
if (a.delegatingSpender)
|
|
225
|
-
allowance.delegatingSpender = new AccountId(
|
|
226
|
-
a.delegatingSpender.shardNum ?? 0,
|
|
227
|
-
a.delegatingSpender.realmNum ?? 0,
|
|
228
|
-
a.delegatingSpender.accountNum ?? 0
|
|
229
|
-
).toString();
|
|
230
|
-
return allowance;
|
|
231
|
-
});
|
|
264
|
+
if (body.fileID) {
|
|
265
|
+
data.fileId = new FileId(
|
|
266
|
+
body.fileID.shardNum ?? 0,
|
|
267
|
+
body.fileID.realmNum ?? 0,
|
|
268
|
+
body.fileID.fileNum ?? 0
|
|
269
|
+
).toString();
|
|
270
|
+
} else if (body.contractID) {
|
|
271
|
+
data.contractId = new ContractId(
|
|
272
|
+
body.contractID.shardNum ?? 0,
|
|
273
|
+
body.contractID.realmNum ?? 0,
|
|
274
|
+
body.contractID.contractNum ?? 0
|
|
275
|
+
).toString();
|
|
232
276
|
}
|
|
233
277
|
return data;
|
|
234
278
|
}
|
|
235
|
-
|
|
279
|
+
/**
|
|
280
|
+
* Parse Node Create from protobuf data
|
|
281
|
+
*/
|
|
282
|
+
static parseNodeCreateFromProto(body) {
|
|
236
283
|
if (!body) return void 0;
|
|
237
284
|
const data = {};
|
|
238
|
-
if (body.
|
|
239
|
-
data.
|
|
240
|
-
ownerAccountId: new AccountId(
|
|
241
|
-
a.owner.shardNum ?? 0,
|
|
242
|
-
a.owner.realmNum ?? 0,
|
|
243
|
-
a.owner.accountNum ?? 0
|
|
244
|
-
).toString(),
|
|
245
|
-
tokenId: new TokenId(
|
|
246
|
-
a.tokenId.shardNum ?? 0,
|
|
247
|
-
a.tokenId.realmNum ?? 0,
|
|
248
|
-
a.tokenId.tokenNum ?? 0
|
|
249
|
-
).toString(),
|
|
250
|
-
serialNumbers: a.serialNumbers ? a.serialNumbers.map((sn) => Long.fromValue(sn).toString()) : []
|
|
251
|
-
}));
|
|
285
|
+
if (body.nodeId !== void 0) {
|
|
286
|
+
data.nodeId = Long.fromValue(body.nodeId).toNumber();
|
|
252
287
|
}
|
|
253
288
|
return data;
|
|
254
289
|
}
|
|
255
290
|
/**
|
|
256
|
-
*
|
|
291
|
+
* Parse Node Update from protobuf data
|
|
257
292
|
*/
|
|
258
|
-
static
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
hbarTransfers.forEach((transfer) => {
|
|
264
|
-
if (transfer.accountId && transfer.amount) {
|
|
265
|
-
const amountInTinybars = transfer.amount.toTinybars();
|
|
266
|
-
const amountInHbar = Number(amountInTinybars) / 1e8;
|
|
267
|
-
transfers.push({
|
|
268
|
-
accountId: transfer.accountId.toString(),
|
|
269
|
-
amount: amountInHbar
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
} catch (error) {
|
|
293
|
+
static parseNodeUpdateFromProto(body) {
|
|
294
|
+
if (!body) return void 0;
|
|
295
|
+
const data = {};
|
|
296
|
+
if (body.nodeId !== void 0) {
|
|
297
|
+
data.nodeId = Long.fromValue(body.nodeId).toNumber();
|
|
275
298
|
}
|
|
276
|
-
return
|
|
299
|
+
return data;
|
|
277
300
|
}
|
|
278
301
|
/**
|
|
279
|
-
*
|
|
302
|
+
* Parse Node Delete from protobuf data
|
|
280
303
|
*/
|
|
281
|
-
static
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
tokenTransfersList.forEach((tokenTransfer) => {
|
|
287
|
-
if (tokenTransfer.tokenId && Array.isArray(tokenTransfer.transfers)) {
|
|
288
|
-
const transfers = tokenTransfer.transfers.map((transfer) => ({
|
|
289
|
-
accountId: transfer.accountId?.toString() || "Unknown",
|
|
290
|
-
amount: Number(transfer.amount || 0)
|
|
291
|
-
}));
|
|
292
|
-
tokenTransfers.push({
|
|
293
|
-
tokenId: tokenTransfer.tokenId.toString(),
|
|
294
|
-
transfers
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
} catch (error) {
|
|
304
|
+
static parseNodeDeleteFromProto(body) {
|
|
305
|
+
if (!body) return void 0;
|
|
306
|
+
const data = {};
|
|
307
|
+
if (body.nodeId !== void 0) {
|
|
308
|
+
data.nodeId = Long.fromValue(body.nodeId).toNumber();
|
|
300
309
|
}
|
|
301
|
-
return
|
|
310
|
+
return data;
|
|
311
|
+
}
|
|
312
|
+
static parseUtilPrng(body) {
|
|
313
|
+
if (!body) return void 0;
|
|
314
|
+
const data = {};
|
|
315
|
+
if (body.range && body.range !== 0) {
|
|
316
|
+
data.range = body.range;
|
|
317
|
+
}
|
|
318
|
+
return data;
|
|
319
|
+
}
|
|
320
|
+
static parseFreeze(body) {
|
|
321
|
+
return this.parseNetworkFreezeFromProto(body);
|
|
302
322
|
}
|
|
303
323
|
/**
|
|
304
|
-
* Parse
|
|
305
|
-
* This is the unified entry point that
|
|
324
|
+
* Parse Utility/System Service transaction from Transaction object
|
|
325
|
+
* This is the unified entry point that delegates to the comprehensive parsing logic
|
|
306
326
|
*/
|
|
307
327
|
static parseFromTransactionObject(transaction) {
|
|
308
|
-
|
|
309
|
-
const hbarTransfers = this.extractHbarTransfersFromTransaction(transaction);
|
|
310
|
-
const tokenTransfers = this.extractTokenTransfersFromTransaction(transaction);
|
|
311
|
-
if (hbarTransfers.length > 0 || tokenTransfers.length > 0) {
|
|
312
|
-
const convertedTransfers = hbarTransfers.map((transfer) => ({
|
|
313
|
-
accountId: transfer.accountId,
|
|
314
|
-
amount: transfer.amount.toString() + " ℏ",
|
|
315
|
-
isDecimal: true
|
|
316
|
-
}));
|
|
317
|
-
const convertedTokenTransfers = tokenTransfers.flatMap(
|
|
318
|
-
(tokenGroup) => tokenGroup.transfers.map((transfer) => ({
|
|
319
|
-
tokenId: tokenGroup.tokenId,
|
|
320
|
-
accountId: transfer.accountId,
|
|
321
|
-
amount: transfer.amount
|
|
322
|
-
}))
|
|
323
|
-
);
|
|
324
|
-
if (hbarTransfers.length > 0) {
|
|
325
|
-
return {
|
|
326
|
-
type: "CRYPTOTRANSFER",
|
|
327
|
-
humanReadableType: "Crypto Transfer",
|
|
328
|
-
transfers: convertedTransfers,
|
|
329
|
-
tokenTransfers: convertedTokenTransfers
|
|
330
|
-
};
|
|
331
|
-
} else if (tokenTransfers.length > 0) {
|
|
332
|
-
return {
|
|
333
|
-
type: "TOKENTRANSFER",
|
|
334
|
-
humanReadableType: "Token Transfer",
|
|
335
|
-
transfers: convertedTransfers,
|
|
336
|
-
tokenTransfers: convertedTokenTransfers
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return {};
|
|
341
|
-
} catch (error) {
|
|
342
|
-
return {};
|
|
343
|
-
}
|
|
328
|
+
return this.parseUtilTransaction(transaction);
|
|
344
329
|
}
|
|
345
330
|
}
|
|
346
331
|
export {
|
|
347
|
-
|
|
332
|
+
UtilParser
|
|
348
333
|
};
|
|
349
334
|
//# sourceMappingURL=standards-sdk.es145.js.map
|