@hashgraphonline/standards-sdk 0.0.157-canary.2 → 0.0.157-canary.4
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-10/base-client.d.ts +1 -1
- package/dist/cjs/hcs-10/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-10/sdk.d.ts +1 -1
- package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-11/agent-builder.d.ts +2 -0
- package/dist/cjs/hcs-11/agent-builder.d.ts.map +1 -1
- package/dist/cjs/hcs-11/client.d.ts +2 -0
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/types.d.ts +4 -2
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/hcs-15/index.d.ts +3 -0
- package/dist/cjs/hcs-15/index.d.ts.map +1 -0
- package/dist/cjs/hcs-15/petal-manager.d.ts +27 -0
- package/dist/cjs/hcs-15/petal-manager.d.ts.map +1 -0
- package/dist/cjs/hcs-15/types.d.ts +41 -0
- package/dist/cjs/hcs-15/types.d.ts.map +1 -0
- package/dist/cjs/hcs-16/flora-account-manager.d.ts.map +1 -1
- package/dist/cjs/hcs-16/types.d.ts +3 -5
- package/dist/cjs/hcs-16/types.d.ts.map +1 -1
- package/dist/cjs/hcs-18/discovery.d.ts +1 -0
- package/dist/cjs/hcs-18/discovery.d.ts.map +1 -1
- package/dist/cjs/hcs-18/types.d.ts +1 -0
- package/dist/cjs/hcs-18/types.d.ts.map +1 -1
- package/dist/cjs/hcs-20/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-7/evm-bridge.d.ts.map +1 -1
- package/dist/cjs/hcs-7/redis-cache.d.ts.map +1 -1
- package/dist/cjs/hcs-7/wasm-bridge.d.ts.map +1 -1
- package/dist/cjs/{index-xZmk-HBD.cjs → index-CJsmyij2.cjs} +12 -12
- package/dist/cjs/index-CJsmyij2.cjs.map +1 -0
- package/dist/cjs/{index-CyAbgH2f-Cv8mxAhS.cjs → index-CyAbgH2f-Dn5WQtPx.cjs} +2 -2
- package/dist/cjs/{index-CyAbgH2f-Cv8mxAhS.cjs.map → index-CyAbgH2f-Dn5WQtPx.cjs.map} +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/services/types.d.ts +1 -1
- package/dist/cjs/services/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/{standards-sdk.es45-BxAtDqsy-ELd4REyl.cjs → standards-sdk.es45-BxAtDqsy-CiMtsDbD.cjs} +2 -2
- package/dist/cjs/{standards-sdk.es45-BxAtDqsy-ELd4REyl.cjs.map → standards-sdk.es45-BxAtDqsy-CiMtsDbD.cjs.map} +1 -1
- package/dist/cjs/{standards-sdk.es46-BI8ACeLM-DRmcgoN0.cjs → standards-sdk.es46-BI8ACeLM-DFYgO-fP.cjs} +2 -2
- package/dist/cjs/{standards-sdk.es46-BI8ACeLM-DRmcgoN0.cjs.map → standards-sdk.es46-BI8ACeLM-DFYgO-fP.cjs.map} +1 -1
- package/dist/cjs/{standards-sdk.es47-DbkY3FlD-DfMpZygD.cjs → standards-sdk.es47-DbkY3FlD-2qTWs2BD.cjs} +2 -2
- package/dist/cjs/{standards-sdk.es47-DbkY3FlD-DfMpZygD.cjs.map → standards-sdk.es47-DbkY3FlD-2qTWs2BD.cjs.map} +1 -1
- package/dist/cjs/{standards-sdk.es48-DzT9Qc3F-CmCkJl3x.cjs → standards-sdk.es48-DzT9Qc3F-Byz0fQnW.cjs} +2 -2
- package/dist/cjs/{standards-sdk.es48-DzT9Qc3F-CmCkJl3x.cjs.map → standards-sdk.es48-DzT9Qc3F-Byz0fQnW.cjs.map} +1 -1
- package/dist/cjs/utils/logger.d.ts.map +1 -1
- package/dist/es/hcs-10/base-client.d.ts +1 -1
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts +1 -1
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-11/agent-builder.d.ts +2 -0
- package/dist/es/hcs-11/agent-builder.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts +2 -0
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/types.d.ts +4 -2
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/hcs-15/index.d.ts +3 -0
- package/dist/es/hcs-15/index.d.ts.map +1 -0
- package/dist/es/hcs-15/petal-manager.d.ts +27 -0
- package/dist/es/hcs-15/petal-manager.d.ts.map +1 -0
- package/dist/es/hcs-15/types.d.ts +41 -0
- package/dist/es/hcs-15/types.d.ts.map +1 -0
- package/dist/es/hcs-16/flora-account-manager.d.ts.map +1 -1
- package/dist/es/hcs-16/types.d.ts +3 -5
- package/dist/es/hcs-16/types.d.ts.map +1 -1
- package/dist/es/hcs-18/discovery.d.ts +1 -0
- package/dist/es/hcs-18/discovery.d.ts.map +1 -1
- package/dist/es/hcs-18/types.d.ts +1 -0
- package/dist/es/hcs-18/types.d.ts.map +1 -1
- package/dist/es/hcs-20/sdk.d.ts.map +1 -1
- package/dist/es/hcs-7/evm-bridge.d.ts.map +1 -1
- package/dist/es/hcs-7/redis-cache.d.ts.map +1 -1
- package/dist/es/hcs-7/wasm-bridge.d.ts.map +1 -1
- package/dist/es/index.d.ts +1 -1
- package/dist/es/services/types.d.ts +1 -1
- package/dist/es/services/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +19 -22
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es10.js +1 -1
- package/dist/es/standards-sdk.es11.js +10 -2
- package/dist/es/standards-sdk.es11.js.map +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es13.js.map +1 -1
- package/dist/es/standards-sdk.es14.js +1 -1
- package/dist/es/standards-sdk.es15.js +39 -9
- package/dist/es/standards-sdk.es15.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +1 -0
- package/dist/es/standards-sdk.es16.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +1 -1
- package/dist/es/standards-sdk.es19.js +1 -1
- package/dist/es/standards-sdk.es2.js +1 -1
- package/dist/es/standards-sdk.es20.js +2 -2
- package/dist/es/standards-sdk.es23.js +2 -2
- package/dist/es/standards-sdk.es25.js +4 -2
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +2 -2
- package/dist/es/standards-sdk.es27.js +152 -6
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +26 -189
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +446 -26
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es3.js +1 -1
- package/dist/es/standards-sdk.es3.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +6 -342
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +202 -6
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +34 -202
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +529 -34
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +87 -501
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +19 -98
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +156 -18
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +146 -150
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +561 -134
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +562 -543
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +6 -4
- package/dist/es/standards-sdk.es4.js.map +1 -1
- package/dist/es/standards-sdk.es40.js +4 -601
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +415 -4
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +1536 -389
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +133 -1541
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +7 -155
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +2 -7
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +5 -5
- package/dist/es/standards-sdk.es48.js +1 -1
- package/dist/es/standards-sdk.es49.js +1 -1
- package/dist/es/standards-sdk.es5.js +4 -6
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +1 -1
- package/dist/es/standards-sdk.es51.js +1 -1
- package/dist/es/standards-sdk.es52.js +1 -1
- package/dist/es/standards-sdk.es54.js +7135 -2
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +7134 -41
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +37 -37
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +37 -37
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +78 -72
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +41 -7134
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es6.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +28 -22
- package/dist/es/standards-sdk.es7.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +5 -5
- package/dist/es/utils/logger.d.ts.map +1 -1
- package/package.json +37 -35
- package/dist/cjs/hcs-21/index.d.ts +0 -4
- package/dist/cjs/hcs-21/index.d.ts.map +0 -1
- package/dist/cjs/hcs-21/petal-account-manager.d.ts +0 -52
- package/dist/cjs/hcs-21/petal-account-manager.d.ts.map +0 -1
- package/dist/cjs/hcs-21/types.d.ts +0 -44
- package/dist/cjs/hcs-21/types.d.ts.map +0 -1
- package/dist/cjs/index-xZmk-HBD.cjs.map +0 -1
- package/dist/es/hcs-21/index.d.ts +0 -4
- package/dist/es/hcs-21/index.d.ts.map +0 -1
- package/dist/es/hcs-21/petal-account-manager.d.ts +0 -52
- package/dist/es/hcs-21/petal-account-manager.d.ts.map +0 -1
- package/dist/es/hcs-21/types.d.ts +0 -44
- package/dist/es/hcs-21/types.d.ts.map +0 -1
- package/dist/es/standards-sdk.es60.js +0 -7144
- package/dist/es/standards-sdk.es60.js.map +0 -1
|
@@ -1,159 +1,586 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { proto } from "@hashgraph/proto";
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { Hbar, Long, HbarUnit } from "@hashgraph/sdk";
|
|
4
|
+
import { ethers } from "ethers";
|
|
5
|
+
import { HTSParser } from "./standards-sdk.es48.js";
|
|
6
|
+
import { HCSParser } from "./standards-sdk.es49.js";
|
|
7
|
+
import { FileParser } from "./standards-sdk.es50.js";
|
|
8
|
+
import { CryptoParser } from "./standards-sdk.es51.js";
|
|
9
|
+
import { SCSParser } from "./standards-sdk.es52.js";
|
|
10
|
+
import { UtilParser } from "./standards-sdk.es53.js";
|
|
11
|
+
class TransactionParser {
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Parse a base64 encoded transaction body and return structured data
|
|
14
|
+
* @param transactionBodyBase64 - The base64 encoded transaction body
|
|
15
|
+
* @returns The parsed transaction
|
|
13
16
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
static parseTransactionBody(transactionBodyBase64) {
|
|
18
|
+
try {
|
|
19
|
+
const buffer = ethers.decodeBase64(transactionBodyBase64);
|
|
20
|
+
const txBody = proto.SchedulableTransactionBody.decode(buffer);
|
|
21
|
+
const transactionType = this.getTransactionType(txBody);
|
|
22
|
+
const result = {
|
|
23
|
+
type: transactionType,
|
|
24
|
+
humanReadableType: this.getHumanReadableType(transactionType),
|
|
25
|
+
transfers: [],
|
|
26
|
+
tokenTransfers: [],
|
|
27
|
+
raw: txBody
|
|
28
|
+
};
|
|
29
|
+
if (txBody.memo) {
|
|
30
|
+
result.memo = txBody.memo;
|
|
31
|
+
}
|
|
32
|
+
if (txBody.transactionFee) {
|
|
33
|
+
const hbarAmount = Hbar.fromTinybars(
|
|
34
|
+
Long.fromValue(txBody.transactionFee)
|
|
35
|
+
);
|
|
36
|
+
result.transactionFee = hbarAmount.toString(HbarUnit.Hbar);
|
|
37
|
+
}
|
|
38
|
+
if (txBody.cryptoTransfer) {
|
|
39
|
+
CryptoParser.parseCryptoTransfers(txBody.cryptoTransfer, result);
|
|
40
|
+
}
|
|
41
|
+
if (txBody.cryptoDelete) {
|
|
42
|
+
result.cryptoDelete = CryptoParser.parseCryptoDelete(
|
|
43
|
+
txBody.cryptoDelete
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (txBody.cryptoCreateAccount) {
|
|
47
|
+
result.cryptoCreateAccount = CryptoParser.parseCryptoCreateAccount(
|
|
48
|
+
txBody.cryptoCreateAccount
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (txBody.cryptoUpdateAccount) {
|
|
52
|
+
result.cryptoUpdateAccount = CryptoParser.parseCryptoUpdateAccount(
|
|
53
|
+
txBody.cryptoUpdateAccount
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (txBody.cryptoApproveAllowance) {
|
|
57
|
+
result.cryptoApproveAllowance = CryptoParser.parseCryptoApproveAllowance(
|
|
58
|
+
txBody.cryptoApproveAllowance
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (txBody.cryptoDeleteAllowance) {
|
|
62
|
+
result.cryptoDeleteAllowance = CryptoParser.parseCryptoDeleteAllowance(
|
|
63
|
+
txBody.cryptoDeleteAllowance
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (txBody.contractCall) {
|
|
67
|
+
result.contractCall = SCSParser.parseContractCall(txBody.contractCall);
|
|
68
|
+
}
|
|
69
|
+
if (txBody.contractCreateInstance) {
|
|
70
|
+
result.contractCreate = SCSParser.parseContractCreate(
|
|
71
|
+
txBody.contractCreateInstance
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
if (txBody.contractUpdateInstance) {
|
|
75
|
+
result.contractUpdate = SCSParser.parseContractUpdate(
|
|
76
|
+
txBody.contractUpdateInstance
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (txBody.contractDeleteInstance) {
|
|
80
|
+
result.contractDelete = SCSParser.parseContractDelete(
|
|
81
|
+
txBody.contractDeleteInstance
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
if (txBody.tokenCreation) {
|
|
85
|
+
result.tokenCreation = HTSParser.parseTokenCreate(txBody.tokenCreation);
|
|
86
|
+
}
|
|
87
|
+
if (txBody.tokenMint) {
|
|
88
|
+
result.tokenMint = HTSParser.parseTokenMint(txBody.tokenMint);
|
|
89
|
+
}
|
|
90
|
+
if (txBody.tokenBurn) {
|
|
91
|
+
result.tokenBurn = HTSParser.parseTokenBurn(txBody.tokenBurn);
|
|
92
|
+
}
|
|
93
|
+
if (txBody.tokenUpdate) {
|
|
94
|
+
result.tokenUpdate = HTSParser.parseTokenUpdate(txBody.tokenUpdate);
|
|
95
|
+
}
|
|
96
|
+
if (txBody.tokenFeeScheduleUpdate) {
|
|
97
|
+
result.tokenFeeScheduleUpdate = HTSParser.parseTokenFeeScheduleUpdate(
|
|
98
|
+
txBody.tokenFeeScheduleUpdate
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (txBody.tokenFreeze) {
|
|
102
|
+
result.tokenFreeze = HTSParser.parseTokenFreeze(txBody.tokenFreeze);
|
|
103
|
+
}
|
|
104
|
+
if (txBody.tokenUnfreeze) {
|
|
105
|
+
result.tokenUnfreeze = HTSParser.parseTokenUnfreeze(
|
|
106
|
+
txBody.tokenUnfreeze
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
if (txBody.tokenGrantKyc) {
|
|
110
|
+
result.tokenGrantKyc = HTSParser.parseTokenGrantKyc(
|
|
111
|
+
txBody.tokenGrantKyc
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
if (txBody.tokenRevokeKyc) {
|
|
115
|
+
result.tokenRevokeKyc = HTSParser.parseTokenRevokeKyc(
|
|
116
|
+
txBody.tokenRevokeKyc
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
if (txBody.tokenPause) {
|
|
120
|
+
result.tokenPause = HTSParser.parseTokenPause(txBody.tokenPause);
|
|
121
|
+
}
|
|
122
|
+
if (txBody.tokenUnpause) {
|
|
123
|
+
result.tokenUnpause = HTSParser.parseTokenUnpause(txBody.tokenUnpause);
|
|
124
|
+
}
|
|
125
|
+
if (txBody.tokenWipe) {
|
|
126
|
+
result.tokenWipeAccount = HTSParser.parseTokenWipeAccount(
|
|
127
|
+
txBody.tokenWipe
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (txBody.tokenDeletion) {
|
|
131
|
+
result.tokenDelete = HTSParser.parseTokenDelete(txBody.tokenDeletion);
|
|
132
|
+
}
|
|
133
|
+
if (txBody.tokenAssociate) {
|
|
134
|
+
result.tokenAssociate = HTSParser.parseTokenAssociate(
|
|
135
|
+
txBody.tokenAssociate
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
if (txBody.tokenDissociate) {
|
|
139
|
+
result.tokenDissociate = HTSParser.parseTokenDissociate(
|
|
140
|
+
txBody.tokenDissociate
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
if (txBody.consensusCreateTopic) {
|
|
144
|
+
result.consensusCreateTopic = HCSParser.parseConsensusCreateTopic(
|
|
145
|
+
txBody.consensusCreateTopic
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (txBody.consensusSubmitMessage) {
|
|
149
|
+
result.consensusSubmitMessage = HCSParser.parseConsensusSubmitMessage(
|
|
150
|
+
txBody.consensusSubmitMessage
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (txBody.consensusUpdateTopic) {
|
|
154
|
+
result.consensusUpdateTopic = HCSParser.parseConsensusUpdateTopic(
|
|
155
|
+
txBody.consensusUpdateTopic
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
if (txBody.consensusDeleteTopic) {
|
|
159
|
+
result.consensusDeleteTopic = HCSParser.parseConsensusDeleteTopic(
|
|
160
|
+
txBody.consensusDeleteTopic
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
if (txBody.fileCreate) {
|
|
164
|
+
result.fileCreate = FileParser.parseFileCreate(txBody.fileCreate);
|
|
165
|
+
}
|
|
166
|
+
if (txBody.fileAppend) {
|
|
167
|
+
result.fileAppend = FileParser.parseFileAppend(txBody.fileAppend);
|
|
168
|
+
}
|
|
169
|
+
if (txBody.fileUpdate) {
|
|
170
|
+
result.fileUpdate = FileParser.parseFileUpdate(txBody.fileUpdate);
|
|
171
|
+
}
|
|
172
|
+
if (txBody.fileDelete) {
|
|
173
|
+
result.fileDelete = FileParser.parseFileDelete(txBody.fileDelete);
|
|
174
|
+
}
|
|
175
|
+
if (txBody.utilPrng) {
|
|
176
|
+
result.utilPrng = UtilParser.parseUtilPrng(txBody.utilPrng);
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
`Failed to parse transaction body: ${error instanceof Error ? error.message : String(error)}`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
31
184
|
}
|
|
32
185
|
/**
|
|
33
|
-
*
|
|
186
|
+
* Parse details from a complete schedule response
|
|
187
|
+
* @param scheduleResponse - The schedule response to parse
|
|
188
|
+
* @returns The parsed transaction
|
|
34
189
|
*/
|
|
35
|
-
|
|
36
|
-
if (!
|
|
37
|
-
|
|
190
|
+
static parseScheduleResponse(scheduleResponse) {
|
|
191
|
+
if (!scheduleResponse.transaction_body) {
|
|
192
|
+
throw new Error("Schedule response missing transaction_body");
|
|
38
193
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return null;
|
|
194
|
+
const parsed = this.parseTransactionBody(scheduleResponse.transaction_body);
|
|
195
|
+
if (scheduleResponse.memo) {
|
|
196
|
+
parsed.memo = scheduleResponse.memo;
|
|
43
197
|
}
|
|
44
|
-
return
|
|
45
|
-
standard: match[1],
|
|
46
|
-
topicId: match[2]
|
|
47
|
-
};
|
|
198
|
+
return parsed;
|
|
48
199
|
}
|
|
49
200
|
/**
|
|
50
|
-
*
|
|
201
|
+
* Determine the transaction type
|
|
202
|
+
* @param txBody - The transaction body to determine the type of
|
|
203
|
+
* @returns The type of the transaction
|
|
51
204
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
205
|
+
static getTransactionType(txBody) {
|
|
206
|
+
let transactionType = "unknown";
|
|
207
|
+
if (txBody.cryptoTransfer) {
|
|
208
|
+
transactionType = "cryptoTransfer";
|
|
209
|
+
} else if (txBody.cryptoCreateAccount) {
|
|
210
|
+
transactionType = "cryptoCreateAccount";
|
|
211
|
+
} else if (txBody.cryptoUpdateAccount) {
|
|
212
|
+
transactionType = "cryptoUpdateAccount";
|
|
213
|
+
} else if (txBody.cryptoApproveAllowance) {
|
|
214
|
+
transactionType = "cryptoApproveAllowance";
|
|
215
|
+
} else if (txBody.cryptoDeleteAllowance) {
|
|
216
|
+
transactionType = "cryptoDeleteAllowance";
|
|
217
|
+
} else if (txBody.cryptoDelete) {
|
|
218
|
+
transactionType = "cryptoDelete";
|
|
219
|
+
} else if (txBody.consensusCreateTopic) {
|
|
220
|
+
transactionType = "consensusCreateTopic";
|
|
221
|
+
} else if (txBody.consensusUpdateTopic) {
|
|
222
|
+
transactionType = "consensusUpdateTopic";
|
|
223
|
+
} else if (txBody.consensusSubmitMessage) {
|
|
224
|
+
transactionType = "consensusSubmitMessage";
|
|
225
|
+
} else if (txBody.consensusDeleteTopic) {
|
|
226
|
+
transactionType = "consensusDeleteTopic";
|
|
227
|
+
} else if (txBody.fileCreate) {
|
|
228
|
+
transactionType = "fileCreate";
|
|
229
|
+
} else if (txBody.fileAppend) {
|
|
230
|
+
transactionType = "fileAppend";
|
|
231
|
+
} else if (txBody.fileUpdate) {
|
|
232
|
+
transactionType = "fileUpdate";
|
|
233
|
+
} else if (txBody.fileDelete) {
|
|
234
|
+
transactionType = "fileDelete";
|
|
235
|
+
} else if (txBody.contractCall) {
|
|
236
|
+
transactionType = "contractCall";
|
|
237
|
+
} else if (txBody.contractCreateInstance) {
|
|
238
|
+
transactionType = "contractCreate";
|
|
239
|
+
} else if (txBody.contractUpdateInstance) {
|
|
240
|
+
transactionType = "contractUpdate";
|
|
241
|
+
} else if (txBody.contractDeleteInstance) {
|
|
242
|
+
transactionType = "contractDelete";
|
|
243
|
+
} else if (txBody.tokenCreation) {
|
|
244
|
+
transactionType = "tokenCreate";
|
|
245
|
+
} else if (txBody.tokenUpdate) {
|
|
246
|
+
transactionType = "tokenUpdate";
|
|
247
|
+
} else if (txBody.tokenDeletion) {
|
|
248
|
+
transactionType = "tokenDelete";
|
|
249
|
+
} else if (txBody.tokenAssociate) {
|
|
250
|
+
transactionType = "tokenAssociate";
|
|
251
|
+
} else if (txBody.tokenDissociate) {
|
|
252
|
+
transactionType = "tokenDissociate";
|
|
253
|
+
} else if (txBody.tokenMint) {
|
|
254
|
+
transactionType = "tokenMint";
|
|
255
|
+
} else if (txBody.tokenBurn) {
|
|
256
|
+
transactionType = "tokenBurn";
|
|
257
|
+
} else if (txBody.tokenFeeScheduleUpdate) {
|
|
258
|
+
transactionType = "tokenFeeScheduleUpdate";
|
|
259
|
+
} else if (txBody.tokenFreeze) {
|
|
260
|
+
transactionType = "tokenFreeze";
|
|
261
|
+
} else if (txBody.tokenUnfreeze) {
|
|
262
|
+
transactionType = "tokenUnfreeze";
|
|
263
|
+
} else if (txBody.tokenGrantKyc) {
|
|
264
|
+
transactionType = "tokenGrantKyc";
|
|
265
|
+
} else if (txBody.tokenRevokeKyc) {
|
|
266
|
+
transactionType = "tokenRevokeKyc";
|
|
267
|
+
} else if (txBody.tokenPause) {
|
|
268
|
+
transactionType = "tokenPause";
|
|
269
|
+
} else if (txBody.tokenUnpause) {
|
|
270
|
+
transactionType = "tokenUnpause";
|
|
271
|
+
} else if (txBody.tokenWipe) {
|
|
272
|
+
transactionType = "tokenWipe";
|
|
273
|
+
} else if (txBody.utilPrng) {
|
|
274
|
+
transactionType = "utilPrng";
|
|
59
275
|
}
|
|
60
|
-
|
|
61
|
-
if (!topicIdPattern.test(parsed.topicId)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
276
|
+
return transactionType;
|
|
65
277
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Convert technical transaction type to human-readable format
|
|
280
|
+
* @param type - The technical transaction type
|
|
281
|
+
* @returns The human-readable transaction type
|
|
282
|
+
*/
|
|
283
|
+
static getHumanReadableType(type) {
|
|
284
|
+
const typeMap = {
|
|
285
|
+
cryptoTransfer: "HBAR Transfer",
|
|
286
|
+
cryptoCreateAccount: "Create Account",
|
|
287
|
+
cryptoUpdateAccount: "Update Account",
|
|
288
|
+
cryptoDeleteAccount: "Delete Account",
|
|
289
|
+
cryptoApproveAllowance: "Approve Allowance",
|
|
290
|
+
cryptoDeleteAllowance: "Delete Allowance",
|
|
291
|
+
cryptoDelete: "Delete Account",
|
|
292
|
+
consensusCreateTopic: "Create Topic",
|
|
293
|
+
consensusUpdateTopic: "Update Topic",
|
|
294
|
+
consensusSubmitMessage: "Submit Message",
|
|
295
|
+
consensusDeleteTopic: "Delete Topic",
|
|
296
|
+
fileCreate: "Create File",
|
|
297
|
+
fileAppend: "Append File",
|
|
298
|
+
fileUpdate: "Update File",
|
|
299
|
+
fileDelete: "Delete File",
|
|
300
|
+
contractCall: "Contract Call",
|
|
301
|
+
contractCreate: "Create Contract",
|
|
302
|
+
contractUpdate: "Update Contract",
|
|
303
|
+
contractDelete: "Delete Contract",
|
|
304
|
+
ethereumTransaction: "Ethereum Transaction",
|
|
305
|
+
tokenCreate: "Create Token",
|
|
306
|
+
tokenUpdate: "Update Token",
|
|
307
|
+
tokenDelete: "Delete Token",
|
|
308
|
+
tokenAssociate: "Associate Token",
|
|
309
|
+
tokenDissociate: "Dissociate Token",
|
|
310
|
+
tokenMint: "Mint Token",
|
|
311
|
+
tokenBurn: "Burn Token",
|
|
312
|
+
tokenFeeScheduleUpdate: "Update Token Fee Schedule",
|
|
313
|
+
tokenFreeze: "Freeze Token",
|
|
314
|
+
tokenUnfreeze: "Unfreeze Token",
|
|
315
|
+
tokenGrantKyc: "Grant KYC",
|
|
316
|
+
tokenRevokeKyc: "Revoke KYC",
|
|
317
|
+
tokenPause: "Pause Token",
|
|
318
|
+
tokenUnpause: "Unpause Token",
|
|
319
|
+
tokenWipe: "Wipe Token",
|
|
320
|
+
scheduleCreate: "Create Schedule",
|
|
321
|
+
scheduleSign: "Sign Schedule",
|
|
322
|
+
utilPrng: "Generate Random Number",
|
|
323
|
+
unknown: "Unknown Transaction"
|
|
324
|
+
};
|
|
325
|
+
let result;
|
|
326
|
+
if (typeMap[type]) {
|
|
327
|
+
result = typeMap[type];
|
|
328
|
+
} else {
|
|
329
|
+
result = "Unknown Transaction";
|
|
86
330
|
}
|
|
331
|
+
return result;
|
|
87
332
|
}
|
|
88
333
|
/**
|
|
89
|
-
*
|
|
334
|
+
* Get a human-readable summary of the transaction
|
|
335
|
+
* @param parsedTx - The parsed transaction
|
|
336
|
+
* @returns The human-readable summary of the transaction
|
|
90
337
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const isBinary = this.isBinaryContentType(contentType);
|
|
107
|
-
if (isBinary || options.returnRaw) {
|
|
108
|
-
const response2 = await axios.get(cdnUrl, {
|
|
109
|
-
responseType: "arraybuffer"
|
|
110
|
-
});
|
|
111
|
-
return {
|
|
112
|
-
content: response2.data,
|
|
113
|
-
contentType,
|
|
114
|
-
topicId,
|
|
115
|
-
isBinary: true
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
if (contentType === "application/json") {
|
|
119
|
-
const response2 = await axios.get(cdnUrl, {
|
|
120
|
-
responseType: "json"
|
|
121
|
-
});
|
|
122
|
-
if (!response2.data) {
|
|
123
|
-
throw new Error(`Failed to fetch content from topic: ${topicId}`);
|
|
338
|
+
static getTransactionSummary(parsedTx) {
|
|
339
|
+
if (parsedTx.type === "cryptoTransfer") {
|
|
340
|
+
const senders = [];
|
|
341
|
+
const receivers = [];
|
|
342
|
+
for (const transfer of parsedTx.transfers) {
|
|
343
|
+
const originalAmountFloat = parseFloat(transfer.amount);
|
|
344
|
+
let displayStr = transfer.amount;
|
|
345
|
+
if (displayStr.startsWith("-")) {
|
|
346
|
+
displayStr = displayStr.substring(1);
|
|
347
|
+
}
|
|
348
|
+
displayStr = displayStr.replace(/\s*ℏ$/, "");
|
|
349
|
+
if (originalAmountFloat < 0) {
|
|
350
|
+
senders.push(`${transfer.accountId} (${displayStr} ℏ)`);
|
|
351
|
+
} else if (originalAmountFloat > 0) {
|
|
352
|
+
receivers.push(`${transfer.accountId} (${displayStr} ℏ)`);
|
|
124
353
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
const response = await axios.get(cdnUrl);
|
|
133
|
-
if (!response.data) {
|
|
134
|
-
throw new Error(`Failed to fetch content from topic: ${topicId}`);
|
|
135
|
-
}
|
|
136
|
-
let content;
|
|
137
|
-
if (typeof response.data === "object") {
|
|
138
|
-
content = response.data.content || response.data.text || JSON.stringify(response.data);
|
|
354
|
+
}
|
|
355
|
+
if (senders.length > 0 && receivers.length > 0) {
|
|
356
|
+
return `Transfer of HBAR from ${senders.join(", ")} to ${receivers.join(
|
|
357
|
+
", "
|
|
358
|
+
)}`;
|
|
139
359
|
} else {
|
|
140
|
-
|
|
360
|
+
return parsedTx.humanReadableType;
|
|
141
361
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
362
|
+
} else if (parsedTx.contractCall) {
|
|
363
|
+
let contractCallSummary = `Contract call to ${parsedTx.contractCall.contractId} with ${parsedTx.contractCall.gas} gas`;
|
|
364
|
+
if (parsedTx.contractCall.amount > 0) {
|
|
365
|
+
contractCallSummary += ` and ${parsedTx.contractCall.amount} HBAR`;
|
|
366
|
+
}
|
|
367
|
+
if (parsedTx.contractCall.functionName) {
|
|
368
|
+
contractCallSummary += ` calling function ${parsedTx.contractCall.functionName}`;
|
|
369
|
+
}
|
|
370
|
+
return contractCallSummary;
|
|
371
|
+
} else if (parsedTx.tokenMint) {
|
|
372
|
+
return `Mint ${parsedTx.tokenMint.amount} tokens for token ${parsedTx.tokenMint.tokenId}`;
|
|
373
|
+
} else if (parsedTx.tokenBurn) {
|
|
374
|
+
return `Burn ${parsedTx.tokenBurn.amount} tokens for token ${parsedTx.tokenBurn.tokenId}`;
|
|
375
|
+
} else if (parsedTx.tokenCreation) {
|
|
376
|
+
let summary = `Create token ${parsedTx.tokenCreation.tokenName || "(No Name)"} (${parsedTx.tokenCreation.tokenSymbol || "(No Symbol)"})`;
|
|
377
|
+
if (parsedTx.tokenCreation.initialSupply) {
|
|
378
|
+
summary += ` with initial supply ${parsedTx.tokenCreation.initialSupply}`;
|
|
379
|
+
}
|
|
380
|
+
if (parsedTx.tokenCreation.customFees?.length) {
|
|
381
|
+
summary += ` including ${parsedTx.tokenCreation.customFees.length} custom fee(s)`;
|
|
382
|
+
}
|
|
383
|
+
return summary;
|
|
384
|
+
} else if (parsedTx.tokenTransfers.length > 0) {
|
|
385
|
+
const tokenGroups = {};
|
|
386
|
+
for (const transfer of parsedTx.tokenTransfers) {
|
|
387
|
+
if (!tokenGroups[transfer.tokenId]) {
|
|
388
|
+
tokenGroups[transfer.tokenId] = [];
|
|
389
|
+
}
|
|
390
|
+
tokenGroups[transfer.tokenId].push(transfer);
|
|
391
|
+
}
|
|
392
|
+
const tokenSummaries = [];
|
|
393
|
+
for (const [tokenId, transfers] of Object.entries(tokenGroups)) {
|
|
394
|
+
const tokenSenders = [];
|
|
395
|
+
const tokenReceivers = [];
|
|
396
|
+
for (const transfer of transfers) {
|
|
397
|
+
const transferAmountValue = parseFloat(transfer.amount.toString());
|
|
398
|
+
if (transferAmountValue < 0) {
|
|
399
|
+
tokenSenders.push(
|
|
400
|
+
`${transfer.accountId} (${Math.abs(transferAmountValue)})`
|
|
401
|
+
);
|
|
402
|
+
} else if (transferAmountValue > 0) {
|
|
403
|
+
tokenReceivers.push(
|
|
404
|
+
`${transfer.accountId} (${transferAmountValue})`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (tokenSenders.length > 0 && tokenReceivers.length > 0) {
|
|
409
|
+
tokenSummaries.push(
|
|
410
|
+
`Transfer of token ${tokenId} from ${tokenSenders.join(
|
|
411
|
+
", "
|
|
412
|
+
)} to ${tokenReceivers.join(", ")}`
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (tokenSummaries.length > 0) {
|
|
417
|
+
return tokenSummaries.join("; ");
|
|
418
|
+
} else {
|
|
419
|
+
return parsedTx.humanReadableType;
|
|
420
|
+
}
|
|
421
|
+
} else if (parsedTx.consensusCreateTopic) {
|
|
422
|
+
let summary = `Create new topic`;
|
|
423
|
+
if (parsedTx.consensusCreateTopic.memo) {
|
|
424
|
+
summary += ` with memo "${parsedTx.consensusCreateTopic.memo}"`;
|
|
425
|
+
}
|
|
426
|
+
if (parsedTx.consensusCreateTopic.autoRenewAccountId) {
|
|
427
|
+
summary += `, auto-renew by ${parsedTx.consensusCreateTopic.autoRenewAccountId}`;
|
|
428
|
+
}
|
|
429
|
+
return summary;
|
|
430
|
+
} else if (parsedTx.consensusSubmitMessage) {
|
|
431
|
+
let summary = `Submit message`;
|
|
432
|
+
if (parsedTx.consensusSubmitMessage.topicId) {
|
|
433
|
+
summary += ` to topic ${parsedTx.consensusSubmitMessage.topicId}`;
|
|
434
|
+
}
|
|
435
|
+
if (parsedTx.consensusSubmitMessage.message) {
|
|
436
|
+
if (parsedTx.consensusSubmitMessage.messageEncoding === "utf8") {
|
|
437
|
+
const messagePreview = parsedTx.consensusSubmitMessage.message.substring(0, 70);
|
|
438
|
+
summary += `: "${messagePreview}${parsedTx.consensusSubmitMessage.message.length > 70 ? "..." : ""}"`;
|
|
439
|
+
} else {
|
|
440
|
+
summary += ` (binary message data, length: ${Buffer.from(parsedTx.consensusSubmitMessage.message, "base64").length} bytes)`;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (parsedTx.consensusSubmitMessage.chunkInfoNumber && parsedTx.consensusSubmitMessage.chunkInfoTotal) {
|
|
444
|
+
summary += ` (chunk ${parsedTx.consensusSubmitMessage.chunkInfoNumber}/${parsedTx.consensusSubmitMessage.chunkInfoTotal})`;
|
|
445
|
+
}
|
|
446
|
+
return summary;
|
|
447
|
+
} else if (parsedTx.fileCreate) {
|
|
448
|
+
let summary = "Create File";
|
|
449
|
+
if (parsedTx.fileCreate.memo) {
|
|
450
|
+
summary += ` with memo "${parsedTx.fileCreate.memo}"`;
|
|
451
|
+
}
|
|
452
|
+
if (parsedTx.fileCreate.contents) {
|
|
453
|
+
summary += ` (includes content)`;
|
|
454
|
+
}
|
|
455
|
+
return summary;
|
|
456
|
+
} else if (parsedTx.fileAppend) {
|
|
457
|
+
return `Append to File ${parsedTx.fileAppend.fileId || "(Unknown ID)"}`;
|
|
458
|
+
} else if (parsedTx.fileUpdate) {
|
|
459
|
+
return `Update File ${parsedTx.fileUpdate.fileId || "(Unknown ID)"}`;
|
|
460
|
+
} else if (parsedTx.fileDelete) {
|
|
461
|
+
return `Delete File ${parsedTx.fileDelete.fileId || "(Unknown ID)"}`;
|
|
462
|
+
} else if (parsedTx.consensusUpdateTopic) {
|
|
463
|
+
return `Update Topic ${parsedTx.consensusUpdateTopic.topicId || "(Unknown ID)"}`;
|
|
464
|
+
} else if (parsedTx.consensusDeleteTopic) {
|
|
465
|
+
return `Delete Topic ${parsedTx.consensusDeleteTopic.topicId || "(Unknown ID)"}`;
|
|
466
|
+
} else if (parsedTx.tokenUpdate) {
|
|
467
|
+
return `Update Token ${parsedTx.tokenUpdate.tokenId || "(Unknown ID)"}`;
|
|
468
|
+
} else if (parsedTx.tokenFeeScheduleUpdate) {
|
|
469
|
+
return `Update Fee Schedule for Token ${parsedTx.tokenFeeScheduleUpdate.tokenId || "(Unknown ID)"}`;
|
|
470
|
+
} else if (parsedTx.utilPrng) {
|
|
471
|
+
let summary = "Generate Random Number";
|
|
472
|
+
if (parsedTx.utilPrng.range && parsedTx.utilPrng.range > 0) {
|
|
473
|
+
summary += ` (range up to ${parsedTx.utilPrng.range - 1})`;
|
|
474
|
+
}
|
|
475
|
+
return summary;
|
|
476
|
+
} else if (parsedTx.tokenFreeze) {
|
|
477
|
+
return `Freeze Token ${parsedTx.tokenFreeze.tokenId} for Account ${parsedTx.tokenFreeze.accountId}`;
|
|
478
|
+
} else if (parsedTx.tokenUnfreeze) {
|
|
479
|
+
return `Unfreeze Token ${parsedTx.tokenUnfreeze.tokenId} for Account ${parsedTx.tokenUnfreeze.accountId}`;
|
|
480
|
+
} else if (parsedTx.tokenGrantKyc) {
|
|
481
|
+
return `Grant KYC for Token ${parsedTx.tokenGrantKyc.tokenId} to Account ${parsedTx.tokenGrantKyc.accountId}`;
|
|
482
|
+
} else if (parsedTx.tokenRevokeKyc) {
|
|
483
|
+
return `Revoke KYC for Token ${parsedTx.tokenRevokeKyc.tokenId} from Account ${parsedTx.tokenRevokeKyc.accountId}`;
|
|
484
|
+
} else if (parsedTx.tokenPause) {
|
|
485
|
+
return `Pause Token ${parsedTx.tokenPause.tokenId}`;
|
|
486
|
+
} else if (parsedTx.tokenUnpause) {
|
|
487
|
+
return `Unpause Token ${parsedTx.tokenUnpause.tokenId}`;
|
|
488
|
+
} else if (parsedTx.tokenWipeAccount) {
|
|
489
|
+
let summary = `Wipe Token ${parsedTx.tokenWipeAccount.tokenId} from Account ${parsedTx.tokenWipeAccount.accountId}`;
|
|
490
|
+
if (parsedTx.tokenWipeAccount.serialNumbers?.length) {
|
|
491
|
+
summary += ` (Serials: ${parsedTx.tokenWipeAccount.serialNumbers.join(
|
|
492
|
+
", "
|
|
493
|
+
)})`;
|
|
494
|
+
}
|
|
495
|
+
if (parsedTx.tokenWipeAccount.amount) {
|
|
496
|
+
summary += ` (Amount: ${parsedTx.tokenWipeAccount.amount})`;
|
|
497
|
+
}
|
|
498
|
+
return summary;
|
|
499
|
+
} else if (parsedTx.tokenDelete) {
|
|
500
|
+
return `Delete Token ${parsedTx.tokenDelete.tokenId}`;
|
|
501
|
+
} else if (parsedTx.tokenAssociate) {
|
|
502
|
+
return `Associate Account ${parsedTx.tokenAssociate.accountId} with Tokens: ${parsedTx.tokenAssociate.tokenIds?.join(", ")}`;
|
|
503
|
+
} else if (parsedTx.tokenDissociate) {
|
|
504
|
+
return `Dissociate Account ${parsedTx.tokenDissociate.accountId} from Tokens: ${parsedTx.tokenDissociate.tokenIds?.join(", ")}`;
|
|
505
|
+
} else if (parsedTx.cryptoDelete) {
|
|
506
|
+
return `Delete Account ${parsedTx.cryptoDelete.deleteAccountId}`;
|
|
507
|
+
}
|
|
508
|
+
if (parsedTx.cryptoCreateAccount) {
|
|
509
|
+
let summary = "Create Account";
|
|
510
|
+
if (parsedTx.cryptoCreateAccount.initialBalance && parsedTx.cryptoCreateAccount.initialBalance !== "0") {
|
|
511
|
+
summary += ` with balance ${parsedTx.cryptoCreateAccount.initialBalance}`;
|
|
512
|
+
}
|
|
513
|
+
if (parsedTx.cryptoCreateAccount.alias) {
|
|
514
|
+
summary += ` (Alias: ${parsedTx.cryptoCreateAccount.alias})`;
|
|
515
|
+
}
|
|
516
|
+
return summary;
|
|
517
|
+
}
|
|
518
|
+
if (parsedTx.cryptoUpdateAccount) {
|
|
519
|
+
return `Update Account ${parsedTx.cryptoUpdateAccount.accountIdToUpdate || "(Unknown ID)"}`;
|
|
520
|
+
}
|
|
521
|
+
if (parsedTx.cryptoApproveAllowance) {
|
|
522
|
+
let count = (parsedTx.cryptoApproveAllowance.hbarAllowances?.length || 0) + (parsedTx.cryptoApproveAllowance.tokenAllowances?.length || 0) + (parsedTx.cryptoApproveAllowance.nftAllowances?.length || 0);
|
|
523
|
+
return `Approve ${count} Crypto Allowance(s)`;
|
|
524
|
+
}
|
|
525
|
+
if (parsedTx.cryptoDeleteAllowance) {
|
|
526
|
+
return `Delete ${parsedTx.cryptoDeleteAllowance.nftAllowancesToRemove?.length || 0} NFT Crypto Allowance(s)`;
|
|
527
|
+
}
|
|
528
|
+
if (parsedTx.contractCreate) {
|
|
529
|
+
let summary = "Create Contract";
|
|
530
|
+
if (parsedTx.contractCreate.memo) {
|
|
531
|
+
summary += ` (Memo: ${parsedTx.contractCreate.memo})`;
|
|
532
|
+
}
|
|
533
|
+
return summary;
|
|
534
|
+
}
|
|
535
|
+
if (parsedTx.contractUpdate) {
|
|
536
|
+
return `Update Contract ${parsedTx.contractUpdate.contractIdToUpdate || "(Unknown ID)"}`;
|
|
537
|
+
}
|
|
538
|
+
if (parsedTx.contractDelete) {
|
|
539
|
+
let summary = `Delete Contract ${parsedTx.contractDelete.contractIdToDelete || "(Unknown ID)"}`;
|
|
540
|
+
if (parsedTx.contractDelete.transferAccountId) {
|
|
541
|
+
summary += ` (Transfer to Account: ${parsedTx.contractDelete.transferAccountId})`;
|
|
542
|
+
} else if (parsedTx.contractDelete.transferContractId) {
|
|
543
|
+
summary += ` (Transfer to Contract: ${parsedTx.contractDelete.transferContractId})`;
|
|
544
|
+
}
|
|
545
|
+
return summary;
|
|
546
|
+
}
|
|
547
|
+
if (parsedTx.humanReadableType && parsedTx.humanReadableType !== "Unknown Transaction") {
|
|
548
|
+
return parsedTx.humanReadableType;
|
|
549
|
+
}
|
|
550
|
+
if (parsedTx.tokenTransfers.length > 0) {
|
|
551
|
+
const tokenGroups = {};
|
|
552
|
+
for (const transfer of parsedTx.tokenTransfers) {
|
|
553
|
+
if (!tokenGroups[transfer.tokenId]) {
|
|
554
|
+
tokenGroups[transfer.tokenId] = [];
|
|
555
|
+
}
|
|
556
|
+
tokenGroups[transfer.tokenId].push(transfer);
|
|
557
|
+
}
|
|
558
|
+
const tokenSummaries = [];
|
|
559
|
+
for (const [tokenId, transfers] of Object.entries(tokenGroups)) {
|
|
560
|
+
const tokenSenders = transfers.filter((t) => t.amount < 0).map((t) => `${t.accountId} (${Math.abs(t.amount)})`);
|
|
561
|
+
const tokenReceivers = transfers.filter((t) => t.amount > 0).map((t) => `${t.accountId} (${t.amount})`);
|
|
562
|
+
if (tokenSenders.length > 0 && tokenReceivers.length > 0) {
|
|
563
|
+
tokenSummaries.push(
|
|
564
|
+
`Transfer of token ${tokenId} from ${tokenSenders.join(
|
|
565
|
+
", "
|
|
566
|
+
)} to ${tokenReceivers.join(", ")}`
|
|
567
|
+
);
|
|
568
|
+
} else if (tokenReceivers.length > 0) {
|
|
569
|
+
tokenSummaries.push(
|
|
570
|
+
`Token ${tokenId} received by ${tokenReceivers.join(", ")}`
|
|
571
|
+
);
|
|
572
|
+
} else if (tokenSenders.length > 0) {
|
|
573
|
+
tokenSummaries.push(
|
|
574
|
+
`Token ${tokenId} sent from ${tokenSenders.join(", ")}`
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (tokenSummaries.length > 0) return tokenSummaries.join("; ");
|
|
153
579
|
}
|
|
580
|
+
return "Unknown Transaction";
|
|
154
581
|
}
|
|
155
582
|
}
|
|
156
583
|
export {
|
|
157
|
-
|
|
584
|
+
TransactionParser
|
|
158
585
|
};
|
|
159
586
|
//# sourceMappingURL=standards-sdk.es38.js.map
|