@hashgraphonline/standards-sdk 0.0.98 → 0.0.100
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/es/hcs-10/base-client.d.ts +12 -4
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-10/connections-manager.d.ts +51 -0
- package/dist/es/hcs-10/connections-manager.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts +37 -1
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-10/types.d.ts +9 -3
- package/dist/es/hcs-10/types.d.ts.map +1 -1
- package/dist/es/inscribe/inscriber.d.ts +2 -0
- package/dist/es/inscribe/inscriber.d.ts.map +1 -1
- package/dist/es/services/index.d.ts +1 -0
- package/dist/es/services/index.d.ts.map +1 -1
- package/dist/es/services/mirror-node.d.ts +17 -1
- package/dist/es/services/mirror-node.d.ts.map +1 -1
- package/dist/es/services/types.d.ts +24 -0
- package/dist/es/services/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +8 -5
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es10.js +66 -0
- package/dist/es/standards-sdk.es10.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +16 -13
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +5 -13
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +37 -30
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +40 -15
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +37 -4
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +78 -4
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +3 -16
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +2 -5
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +2 -39
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +18 -37
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +26 -36
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +25 -77
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +38 -3
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +34 -2
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +33 -2
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +9 -34
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +32 -31
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +101 -9
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +2 -34
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +19 -0
- package/dist/es/standards-sdk.es119.js.map +1 -0
- package/dist/es/standards-sdk.es120.js +412 -0
- package/dist/es/standards-sdk.es120.js.map +1 -0
- package/dist/es/standards-sdk.es121.js +2285 -0
- package/dist/es/standards-sdk.es121.js.map +1 -0
- package/dist/es/standards-sdk.es122.js +13 -0
- package/dist/es/standards-sdk.es122.js.map +1 -0
- package/dist/es/standards-sdk.es123.js +14 -0
- package/dist/es/standards-sdk.es123.js.map +1 -0
- package/dist/es/standards-sdk.es124.js +21 -0
- package/dist/es/standards-sdk.es124.js.map +1 -0
- package/dist/es/standards-sdk.es125.js +9 -0
- package/dist/es/standards-sdk.es125.js.map +1 -0
- package/dist/es/standards-sdk.es126.js +12 -0
- package/dist/es/standards-sdk.es126.js.map +1 -0
- package/dist/es/standards-sdk.es13.js +5 -5
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es18.js +2 -2
- package/dist/es/standards-sdk.es19.js +397 -386
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +386 -315
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +357 -128
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +155 -7
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +7 -1041
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +966 -1692
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +5 -3
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +36 -4167
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +21 -7163
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +1769 -2
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +10 -36
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +7163 -21
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +3 -5
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +8 -100
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +2 -2
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +4167 -15
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +397 -387
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +2 -2
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +120 -2282
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +343 -143
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +4 -193
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es40.js +158 -417
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +75 -19
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +103 -128
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +48 -14
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +9 -28
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +91 -23
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +3 -20
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +2 -44
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +108 -13
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +71 -58
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +33 -9
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +4 -1287
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +4 -147
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +208 -78
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +55 -81
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +69 -32
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +2 -6
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +3 -159
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +160 -19
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +29 -790
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +55 -166
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +43 -136
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +9 -20
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +63 -25
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +6 -26
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +14 -37
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +7 -3
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +45 -4
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +2 -7136
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +120 -403
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +172 -2
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +111 -5
- package/dist/es/standards-sdk.es7.js.map +1 -1
- package/dist/es/standards-sdk.es70.js +3 -119
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +12 -363
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +13 -6
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +7114 -157
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +188 -74
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +423 -99
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +20 -47
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +138 -9
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +13 -92
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +28 -3
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +4 -4
- package/dist/es/standards-sdk.es80.js +29 -2
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +15 -107
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +41 -71
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +17 -5
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +60 -4
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +1259 -191
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +142 -52
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +91 -69
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +80 -28
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +27 -58
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es90.js +5 -49
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +157 -8
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +19 -61
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +792 -5
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +171 -12
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +143 -7
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +30 -43
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +15 -2
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +4 -136
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +4 -172
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/index.d.ts +1 -0
- package/dist/es/utils/index.d.ts.map +1 -1
- package/dist/es/utils/transaction-parser.d.ts +103 -0
- package/dist/es/utils/transaction-parser.d.ts.map +1 -0
- package/dist/umd/hcs-10/base-client.d.ts +12 -4
- package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
- package/dist/umd/hcs-10/connections-manager.d.ts +51 -0
- package/dist/umd/hcs-10/connections-manager.d.ts.map +1 -1
- package/dist/umd/hcs-10/sdk.d.ts +37 -1
- package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
- package/dist/umd/hcs-10/types.d.ts +9 -3
- package/dist/umd/hcs-10/types.d.ts.map +1 -1
- package/dist/umd/inscribe/inscriber.d.ts +2 -0
- package/dist/umd/inscribe/inscriber.d.ts.map +1 -1
- package/dist/umd/services/index.d.ts +1 -0
- package/dist/umd/services/index.d.ts.map +1 -1
- package/dist/umd/services/mirror-node.d.ts +17 -1
- package/dist/umd/services/mirror-node.d.ts.map +1 -1
- package/dist/umd/services/types.d.ts +24 -0
- package/dist/umd/services/types.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +12 -12
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/dist/umd/utils/index.d.ts +1 -0
- package/dist/umd/utils/index.d.ts.map +1 -1
- package/dist/umd/utils/transaction-parser.d.ts +103 -0
- package/dist/umd/utils/transaction-parser.d.ts.map +1 -0
- package/package.json +12 -6
|
@@ -1,410 +1,421 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
tags: options.tags || [],
|
|
44
|
-
mode: options.mode || "file",
|
|
45
|
-
chunkSize: options.chunkSize
|
|
46
|
-
};
|
|
47
|
-
let request;
|
|
48
|
-
switch (input.type) {
|
|
49
|
-
case "url":
|
|
50
|
-
request = {
|
|
51
|
-
...baseRequest,
|
|
52
|
-
file: {
|
|
53
|
-
type: "url",
|
|
54
|
-
url: input.url
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
break;
|
|
58
|
-
case "file":
|
|
59
|
-
request = {
|
|
60
|
-
...baseRequest,
|
|
61
|
-
file: {
|
|
62
|
-
type: "path",
|
|
63
|
-
path: input.path
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
break;
|
|
67
|
-
case "buffer":
|
|
68
|
-
request = {
|
|
69
|
-
...baseRequest,
|
|
70
|
-
file: {
|
|
71
|
-
type: "base64",
|
|
72
|
-
base64: Buffer.from(input.buffer).toString("base64"),
|
|
73
|
-
fileName: input.fileName,
|
|
74
|
-
mimeType: input.mimeType
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
if (options.mode === "hashinal") {
|
|
80
|
-
request.metadataObject = options.metadata;
|
|
81
|
-
request.creator = options.metadata?.creator || clientConfig.accountId;
|
|
82
|
-
request.description = options.metadata?.description;
|
|
83
|
-
if (options.jsonFileURL) {
|
|
84
|
-
request.jsonFileURL = options.jsonFileURL;
|
|
1
|
+
import { proto } from "@hashgraph/proto";
|
|
2
|
+
import { Buffer as Buffer$1 } from "./standards-sdk.es28.js";
|
|
3
|
+
import { Hbar, Long, HbarUnit, AccountId, TokenId, ContractId } from "@hashgraph/sdk";
|
|
4
|
+
import { decodeBase64 } from "./standards-sdk.es29.js";
|
|
5
|
+
class TransactionParser {
|
|
6
|
+
/**
|
|
7
|
+
* Parse a base64 encoded transaction body and return structured data
|
|
8
|
+
* @param transactionBodyBase64 - The base64 encoded transaction body
|
|
9
|
+
* @returns The parsed transaction
|
|
10
|
+
*/
|
|
11
|
+
static parseTransactionBody(transactionBodyBase64) {
|
|
12
|
+
try {
|
|
13
|
+
const buffer = decodeBase64(transactionBodyBase64);
|
|
14
|
+
const txBody = proto.SchedulableTransactionBody.decode(buffer);
|
|
15
|
+
const transactionType = this.getTransactionType(txBody);
|
|
16
|
+
const result = {
|
|
17
|
+
type: transactionType,
|
|
18
|
+
humanReadableType: this.getHumanReadableType(transactionType),
|
|
19
|
+
transfers: [],
|
|
20
|
+
tokenTransfers: [],
|
|
21
|
+
raw: txBody
|
|
22
|
+
};
|
|
23
|
+
if (txBody.memo) {
|
|
24
|
+
result.memo = txBody.memo;
|
|
25
|
+
}
|
|
26
|
+
if (txBody.transactionFee) {
|
|
27
|
+
const hbarAmount = Hbar.fromTinybars(
|
|
28
|
+
Long.fromValue(txBody.transactionFee)
|
|
29
|
+
);
|
|
30
|
+
result.transactionFee = hbarAmount.toString(HbarUnit.Hbar);
|
|
31
|
+
}
|
|
32
|
+
if (txBody.cryptoTransfer) {
|
|
33
|
+
this.parseCryptoTransfers(txBody.cryptoTransfer, result);
|
|
34
|
+
}
|
|
35
|
+
if (txBody.contractCall) {
|
|
36
|
+
this.parseContractCall(txBody.contractCall, result);
|
|
37
|
+
}
|
|
38
|
+
if (txBody.tokenMint) {
|
|
39
|
+
this.parseTokenMint(txBody.tokenMint, result);
|
|
40
|
+
}
|
|
41
|
+
if (txBody.tokenBurn) {
|
|
42
|
+
this.parseTokenBurn(txBody.tokenBurn, result);
|
|
85
43
|
}
|
|
44
|
+
return result;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new Error(`Failed to parse transaction body: ${error}`);
|
|
86
47
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
transactionId: result.jobId
|
|
97
|
-
});
|
|
98
|
-
if (options.waitForConfirmation) {
|
|
99
|
-
logger.debug("Waiting for inscription confirmation", {
|
|
100
|
-
transactionId: result.jobId,
|
|
101
|
-
maxAttempts: options.waitMaxAttempts,
|
|
102
|
-
intervalMs: options.waitIntervalMs
|
|
103
|
-
});
|
|
104
|
-
const inscription = await waitForInscriptionConfirmation(
|
|
105
|
-
sdk,
|
|
106
|
-
result.jobId,
|
|
107
|
-
options.waitMaxAttempts,
|
|
108
|
-
options.waitIntervalMs,
|
|
109
|
-
options.progressCallback
|
|
110
|
-
);
|
|
111
|
-
logger.info("Inscription confirmation received", {
|
|
112
|
-
transactionId: result.jobId
|
|
113
|
-
});
|
|
114
|
-
return {
|
|
115
|
-
confirmed: true,
|
|
116
|
-
result,
|
|
117
|
-
inscription,
|
|
118
|
-
sdk
|
|
119
|
-
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parse details from a complete schedule response
|
|
51
|
+
* @param scheduleResponse - The schedule response to parse
|
|
52
|
+
* @returns The parsed transaction
|
|
53
|
+
*/
|
|
54
|
+
static parseScheduleResponse(scheduleResponse) {
|
|
55
|
+
if (!scheduleResponse.transaction_body) {
|
|
56
|
+
throw new Error("Schedule response missing transaction_body");
|
|
120
57
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
} catch (error) {
|
|
127
|
-
logger.error("Error during inscription process", error);
|
|
128
|
-
throw error;
|
|
58
|
+
const parsed = this.parseTransactionBody(scheduleResponse.transaction_body);
|
|
59
|
+
if (scheduleResponse.memo) {
|
|
60
|
+
parsed.memo = scheduleResponse.memo;
|
|
61
|
+
}
|
|
62
|
+
return parsed;
|
|
129
63
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Determine the transaction type
|
|
66
|
+
* @param txBody - The transaction body to determine the type of
|
|
67
|
+
* @returns The type of the transaction
|
|
68
|
+
*/
|
|
69
|
+
static getTransactionType(txBody) {
|
|
70
|
+
let transactionType = "unknown";
|
|
71
|
+
if (txBody.cryptoTransfer) {
|
|
72
|
+
transactionType = "cryptoTransfer";
|
|
73
|
+
} else if (txBody.cryptoCreateAccount) {
|
|
74
|
+
transactionType = "cryptoCreateAccount";
|
|
75
|
+
} else if (txBody.cryptoUpdateAccount) {
|
|
76
|
+
transactionType = "cryptoUpdateAccount";
|
|
77
|
+
} else if (txBody.cryptoApproveAllowance) {
|
|
78
|
+
transactionType = "cryptoApproveAllowance";
|
|
79
|
+
} else if (txBody.cryptoDeleteAllowance) {
|
|
80
|
+
transactionType = "cryptoDeleteAllowance";
|
|
81
|
+
} else if (txBody.consensusCreateTopic) {
|
|
82
|
+
transactionType = "consensusCreateTopic";
|
|
83
|
+
} else if (txBody.consensusUpdateTopic) {
|
|
84
|
+
transactionType = "consensusUpdateTopic";
|
|
85
|
+
} else if (txBody.consensusSubmitMessage) {
|
|
86
|
+
transactionType = "consensusSubmitMessage";
|
|
87
|
+
} else if (txBody.consensusDeleteTopic) {
|
|
88
|
+
transactionType = "consensusDeleteTopic";
|
|
89
|
+
} else if (txBody.fileCreate) {
|
|
90
|
+
transactionType = "fileCreate";
|
|
91
|
+
} else if (txBody.fileAppend) {
|
|
92
|
+
transactionType = "fileAppend";
|
|
93
|
+
} else if (txBody.fileUpdate) {
|
|
94
|
+
transactionType = "fileUpdate";
|
|
95
|
+
} else if (txBody.fileDelete) {
|
|
96
|
+
transactionType = "fileDelete";
|
|
97
|
+
} else if (txBody.contractCall) {
|
|
98
|
+
transactionType = "contractCall";
|
|
99
|
+
} else if (txBody.contractCreateInstance) {
|
|
100
|
+
transactionType = "contractCreate";
|
|
101
|
+
} else if (txBody.contractUpdateInstance) {
|
|
102
|
+
transactionType = "contractUpdate";
|
|
103
|
+
} else if (txBody.contractDeleteInstance) {
|
|
104
|
+
transactionType = "contractDelete";
|
|
105
|
+
} else if (txBody.tokenCreation) {
|
|
106
|
+
transactionType = "tokenCreate";
|
|
107
|
+
} else if (txBody.tokenUpdate) {
|
|
108
|
+
transactionType = "tokenUpdate";
|
|
109
|
+
} else if (txBody.tokenDeletion) {
|
|
110
|
+
transactionType = "tokenDelete";
|
|
111
|
+
} else if (txBody.tokenAssociate) {
|
|
112
|
+
transactionType = "tokenAssociate";
|
|
113
|
+
} else if (txBody.tokenDissociate) {
|
|
114
|
+
transactionType = "tokenDissociate";
|
|
115
|
+
} else if (txBody.tokenMint) {
|
|
116
|
+
transactionType = "tokenMint";
|
|
117
|
+
} else if (txBody.tokenBurn) {
|
|
118
|
+
transactionType = "tokenBurn";
|
|
119
|
+
} else if (txBody.tokenFeeScheduleUpdate) {
|
|
120
|
+
transactionType = "tokenFeeScheduleUpdate";
|
|
121
|
+
} else if (txBody.tokenFreeze) {
|
|
122
|
+
transactionType = "tokenFreeze";
|
|
123
|
+
} else if (txBody.tokenUnfreeze) {
|
|
124
|
+
transactionType = "tokenUnfreeze";
|
|
125
|
+
} else if (txBody.tokenGrantKyc) {
|
|
126
|
+
transactionType = "tokenGrantKyc";
|
|
127
|
+
} else if (txBody.tokenRevokeKyc) {
|
|
128
|
+
transactionType = "tokenRevokeKyc";
|
|
129
|
+
} else if (txBody.tokenPause) {
|
|
130
|
+
transactionType = "tokenPause";
|
|
131
|
+
} else if (txBody.tokenUnpause) {
|
|
132
|
+
transactionType = "tokenUnpause";
|
|
133
|
+
} else if (txBody.tokenWipe) {
|
|
134
|
+
transactionType = "tokenWipe";
|
|
135
|
+
} else if (txBody.scheduleDelete) {
|
|
136
|
+
transactionType = "scheduleDelete";
|
|
146
137
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
138
|
+
return transactionType;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Convert technical transaction type to human-readable format
|
|
142
|
+
* @param type - The technical transaction type
|
|
143
|
+
* @returns The human-readable transaction type
|
|
144
|
+
*/
|
|
145
|
+
static getHumanReadableType(type) {
|
|
146
|
+
const typeMap = {
|
|
147
|
+
cryptoTransfer: "HBAR Transfer",
|
|
148
|
+
cryptoCreateAccount: "Create Account",
|
|
149
|
+
cryptoUpdateAccount: "Update Account",
|
|
150
|
+
cryptoDeleteAccount: "Delete Account",
|
|
151
|
+
cryptoApproveAllowance: "Approve Allowance",
|
|
152
|
+
cryptoDeleteAllowance: "Delete Allowance",
|
|
153
|
+
consensusCreateTopic: "Create Topic",
|
|
154
|
+
consensusUpdateTopic: "Update Topic",
|
|
155
|
+
consensusSubmitMessage: "Submit Message",
|
|
156
|
+
consensusDeleteTopic: "Delete Topic",
|
|
157
|
+
fileCreate: "Create File",
|
|
158
|
+
fileAppend: "Append File",
|
|
159
|
+
fileUpdate: "Update File",
|
|
160
|
+
fileDelete: "Delete File",
|
|
161
|
+
contractCall: "Contract Call",
|
|
162
|
+
contractCreate: "Create Contract",
|
|
163
|
+
contractUpdate: "Update Contract",
|
|
164
|
+
contractDelete: "Delete Contract",
|
|
165
|
+
ethereumTransaction: "Ethereum Transaction",
|
|
166
|
+
tokenCreate: "Create Token",
|
|
167
|
+
tokenUpdate: "Update Token",
|
|
168
|
+
tokenDelete: "Delete Token",
|
|
169
|
+
tokenAssociate: "Associate Token",
|
|
170
|
+
tokenDissociate: "Dissociate Token",
|
|
171
|
+
tokenMint: "Mint Token",
|
|
172
|
+
tokenBurn: "Burn Token",
|
|
173
|
+
tokenFeeScheduleUpdate: "Update Token Fee Schedule",
|
|
174
|
+
tokenFreeze: "Freeze Token",
|
|
175
|
+
tokenUnfreeze: "Unfreeze Token",
|
|
176
|
+
tokenGrantKyc: "Grant KYC",
|
|
177
|
+
tokenRevokeKyc: "Revoke KYC",
|
|
178
|
+
tokenPause: "Pause Token",
|
|
179
|
+
tokenUnpause: "Unpause Token",
|
|
180
|
+
tokenWipe: "Wipe Token",
|
|
181
|
+
scheduleCreate: "Create Schedule",
|
|
182
|
+
scheduleDelete: "Delete Schedule",
|
|
183
|
+
scheduleSign: "Sign Schedule",
|
|
184
|
+
systemDelete: "System Delete",
|
|
185
|
+
systemUndelete: "System Undelete",
|
|
186
|
+
unknown: "Unknown Transaction"
|
|
187
|
+
};
|
|
188
|
+
let result;
|
|
189
|
+
if (typeMap[type]) {
|
|
190
|
+
result = typeMap[type];
|
|
159
191
|
} else {
|
|
160
|
-
|
|
161
|
-
sdk = await InscriptionSDK.createWithAuth({
|
|
162
|
-
type: "client",
|
|
163
|
-
accountId,
|
|
164
|
-
signer,
|
|
165
|
-
network: options.network || "mainnet"
|
|
166
|
-
});
|
|
192
|
+
result = "Unknown Transaction";
|
|
167
193
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
};
|
|
194
|
-
break;
|
|
195
|
-
case "buffer":
|
|
196
|
-
request = {
|
|
197
|
-
...baseRequest,
|
|
198
|
-
file: {
|
|
199
|
-
type: "base64",
|
|
200
|
-
base64: Buffer.from(input.buffer).toString("base64"),
|
|
201
|
-
fileName: input.fileName,
|
|
202
|
-
mimeType: input.mimeType
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Parse crypto transfers from the transaction
|
|
198
|
+
* @param cryptoTransfer - The crypto transfer transaction body
|
|
199
|
+
* @param result - The parsed transaction
|
|
200
|
+
*/
|
|
201
|
+
static parseCryptoTransfers(cryptoTransfer, result) {
|
|
202
|
+
if (cryptoTransfer.transfers) {
|
|
203
|
+
if (cryptoTransfer.transfers.accountAmounts) {
|
|
204
|
+
result.transfers = cryptoTransfer.transfers.accountAmounts.map(
|
|
205
|
+
(amount) => {
|
|
206
|
+
const shard = amount.accountID?.shardNum ? Long.fromValue(amount.accountID.shardNum).toNumber() : 0;
|
|
207
|
+
const realm = amount.accountID?.realmNum ? Long.fromValue(amount.accountID.realmNum).toNumber() : 0;
|
|
208
|
+
const accountNum = amount.accountID?.accountNum ? Long.fromValue(amount.accountID.accountNum).toNumber() : 0;
|
|
209
|
+
const accountId = AccountId.fromString(
|
|
210
|
+
`${shard}.${realm}.${accountNum}`
|
|
211
|
+
);
|
|
212
|
+
const hbarValue = amount.amount ? Long.fromValue(amount.amount) : Long.ZERO;
|
|
213
|
+
const hbarAmount = Hbar.fromTinybars(hbarValue);
|
|
214
|
+
return {
|
|
215
|
+
accountId: accountId.toString(),
|
|
216
|
+
amount: hbarAmount.toString(HbarUnit.Hbar),
|
|
217
|
+
isDecimal: true
|
|
218
|
+
};
|
|
203
219
|
}
|
|
204
|
-
|
|
205
|
-
|
|
220
|
+
);
|
|
221
|
+
}
|
|
206
222
|
}
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
223
|
+
if (cryptoTransfer.tokenTransfers) {
|
|
224
|
+
for (const tokenTransfer of cryptoTransfer.tokenTransfers) {
|
|
225
|
+
const shard = tokenTransfer.token?.shardNum ? Long.fromValue(tokenTransfer.token.shardNum).toNumber() : 0;
|
|
226
|
+
const realm = tokenTransfer.token?.realmNum ? Long.fromValue(tokenTransfer.token.realmNum).toNumber() : 0;
|
|
227
|
+
const tokenNum = tokenTransfer.token?.tokenNum ? Long.fromValue(tokenTransfer.token.tokenNum).toNumber() : 0;
|
|
228
|
+
const tokenId = TokenId.fromString(`${shard}.${realm}.${tokenNum}`);
|
|
229
|
+
if (tokenTransfer.transfers) {
|
|
230
|
+
for (const transfer of tokenTransfer.transfers) {
|
|
231
|
+
const accShard = transfer.accountID?.shardNum ? Long.fromValue(transfer.accountID.shardNum).toNumber() : 0;
|
|
232
|
+
const accRealm = transfer.accountID?.realmNum ? Long.fromValue(transfer.accountID.realmNum).toNumber() : 0;
|
|
233
|
+
const accNum = transfer.accountID?.accountNum ? Long.fromValue(transfer.accountID.accountNum).toNumber() : 0;
|
|
234
|
+
const accountId = AccountId.fromString(
|
|
235
|
+
`${accShard}.${accRealm}.${accNum}`
|
|
236
|
+
);
|
|
237
|
+
const tokenAmount = transfer.amount ? Long.fromValue(transfer.amount).toNumber() : 0;
|
|
238
|
+
result.tokenTransfers.push({
|
|
239
|
+
tokenId: tokenId.toString(),
|
|
240
|
+
accountId: accountId.toString(),
|
|
241
|
+
amount: tokenAmount
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
213
245
|
}
|
|
214
246
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
type: input.type,
|
|
229
|
-
mode: options.mode || "file",
|
|
230
|
-
transactionId: result.jobId
|
|
231
|
-
});
|
|
232
|
-
if (options.waitForConfirmation) {
|
|
233
|
-
logger.debug("Waiting for inscription confirmation", {
|
|
234
|
-
transactionId: result.jobId,
|
|
235
|
-
maxAttempts: options.waitMaxAttempts,
|
|
236
|
-
intervalMs: options.waitIntervalMs
|
|
237
|
-
});
|
|
238
|
-
const inscription = await waitForInscriptionConfirmation(
|
|
239
|
-
sdk,
|
|
240
|
-
result.jobId,
|
|
241
|
-
options.waitMaxAttempts,
|
|
242
|
-
options.waitIntervalMs,
|
|
243
|
-
options.progressCallback
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Parse contract call transaction data
|
|
250
|
+
* @param contractCall - The contract call transaction body
|
|
251
|
+
* @param result - The parsed transaction
|
|
252
|
+
*/
|
|
253
|
+
static parseContractCall(contractCall, result) {
|
|
254
|
+
if (contractCall) {
|
|
255
|
+
const shard = contractCall.contractID?.shardNum ? Long.fromValue(contractCall.contractID.shardNum).toNumber() : 0;
|
|
256
|
+
const realm = contractCall.contractID?.realmNum ? Long.fromValue(contractCall.contractID.realmNum).toNumber() : 0;
|
|
257
|
+
const contractNum = contractCall.contractID?.contractNum ? Long.fromValue(contractCall.contractID.contractNum).toNumber() : 0;
|
|
258
|
+
const contractId = ContractId.fromString(
|
|
259
|
+
`${shard}.${realm}.${contractNum}`
|
|
244
260
|
);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
261
|
+
const gasLimit = contractCall.gas ? Long.fromValue(contractCall.gas).toNumber() : 0;
|
|
262
|
+
let amount = 0;
|
|
263
|
+
if (contractCall.amount) {
|
|
264
|
+
const hbar = Hbar.fromTinybars(Long.fromValue(contractCall.amount));
|
|
265
|
+
amount = parseFloat(hbar.toString(HbarUnit.Hbar));
|
|
266
|
+
}
|
|
267
|
+
const functionParameters = contractCall.functionParameters ? Buffer$1.from(contractCall.functionParameters).toString("hex") : void 0;
|
|
268
|
+
let functionName;
|
|
269
|
+
if (functionParameters && functionParameters.length >= 8) {
|
|
270
|
+
functionName = functionParameters.substring(0, 8);
|
|
271
|
+
}
|
|
272
|
+
result.contractCall = {
|
|
273
|
+
contractId: contractId.toString(),
|
|
274
|
+
gas: gasLimit,
|
|
275
|
+
amount,
|
|
276
|
+
functionParameters,
|
|
277
|
+
functionName
|
|
253
278
|
};
|
|
254
279
|
}
|
|
255
|
-
return {
|
|
256
|
-
confirmed: false,
|
|
257
|
-
result,
|
|
258
|
-
sdk
|
|
259
|
-
};
|
|
260
|
-
} catch (error) {
|
|
261
|
-
logger.error("Error during inscription process", error);
|
|
262
|
-
throw error;
|
|
263
280
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
network: options.network || "mainnet"
|
|
290
|
-
});
|
|
291
|
-
} else {
|
|
292
|
-
const error = new Error(
|
|
293
|
-
"Either API key or account ID and private key are required for retrieving inscriptions"
|
|
294
|
-
);
|
|
295
|
-
logger.error("Missing authentication credentials", {
|
|
296
|
-
hasApiKey: Boolean(options?.apiKey),
|
|
297
|
-
hasAccountId: Boolean(options?.accountId),
|
|
298
|
-
hasPrivateKey: Boolean(options?.privateKey)
|
|
299
|
-
});
|
|
300
|
-
throw error;
|
|
281
|
+
/**
|
|
282
|
+
* Parse token mint transaction data
|
|
283
|
+
* @param tokenMint - The token mint transaction body
|
|
284
|
+
* @param result - The parsed transaction
|
|
285
|
+
*/
|
|
286
|
+
static parseTokenMint(tokenMint, result) {
|
|
287
|
+
if (tokenMint) {
|
|
288
|
+
const shard = tokenMint.token?.shardNum ? Long.fromValue(tokenMint.token.shardNum).toNumber() : 0;
|
|
289
|
+
const realm = tokenMint.token?.realmNum ? Long.fromValue(tokenMint.token.realmNum).toNumber() : 0;
|
|
290
|
+
const tokenNum = tokenMint.token?.tokenNum ? Long.fromValue(tokenMint.token.tokenNum).toNumber() : 0;
|
|
291
|
+
const tokenId = TokenId.fromString(`${shard}.${realm}.${tokenNum}`);
|
|
292
|
+
const amount = tokenMint.amount ? Long.fromValue(tokenMint.amount).toNumber() : 0;
|
|
293
|
+
const metadata = [];
|
|
294
|
+
if (tokenMint.metadata) {
|
|
295
|
+
for (const meta of tokenMint.metadata) {
|
|
296
|
+
if (meta) {
|
|
297
|
+
metadata.push(Buffer$1.from(meta).toString("base64"));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
result.tokenMint = {
|
|
302
|
+
tokenId: tokenId.toString(),
|
|
303
|
+
amount,
|
|
304
|
+
metadata: metadata.length > 0 ? metadata : void 0
|
|
305
|
+
};
|
|
301
306
|
}
|
|
302
|
-
logger.debug("Initialized SDK for inscription retrieval", {
|
|
303
|
-
formattedTransactionId,
|
|
304
|
-
network: options.network || "mainnet"
|
|
305
|
-
});
|
|
306
|
-
const result = await sdk.retrieveInscription(formattedTransactionId);
|
|
307
|
-
logger.info("Successfully retrieved inscription", {
|
|
308
|
-
formattedTransactionId
|
|
309
|
-
});
|
|
310
|
-
return result;
|
|
311
|
-
} catch (error) {
|
|
312
|
-
logger.error("Error retrieving inscription", {
|
|
313
|
-
formattedTransactionId,
|
|
314
|
-
error
|
|
315
|
-
});
|
|
316
|
-
throw error;
|
|
317
307
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
logger,
|
|
343
|
-
callback: progressCallback
|
|
344
|
-
});
|
|
345
|
-
try {
|
|
346
|
-
logger.debug("Waiting for inscription confirmation", {
|
|
347
|
-
transactionId,
|
|
348
|
-
maxAttempts,
|
|
349
|
-
intervalMs
|
|
350
|
-
});
|
|
351
|
-
progressReporter.preparing("Preparing for inscription confirmation", 5, {
|
|
352
|
-
transactionId,
|
|
353
|
-
maxAttempts,
|
|
354
|
-
intervalMs
|
|
355
|
-
});
|
|
356
|
-
try {
|
|
357
|
-
const waitMethod = sdk.waitForInscription.bind(sdk);
|
|
358
|
-
const wrappedCallback = (data) => {
|
|
359
|
-
const stage = data.stage || "confirming";
|
|
360
|
-
const message = data.message || "Processing inscription";
|
|
361
|
-
const percent = data.progressPercent || 50;
|
|
362
|
-
progressReporter.report({
|
|
363
|
-
stage,
|
|
364
|
-
message,
|
|
365
|
-
progressPercent: percent,
|
|
366
|
-
details: {}
|
|
367
|
-
});
|
|
308
|
+
/**
|
|
309
|
+
* Parse token burn transaction data
|
|
310
|
+
* @param tokenBurn - The token burn transaction body
|
|
311
|
+
* @param result - The parsed transaction
|
|
312
|
+
*/
|
|
313
|
+
static parseTokenBurn(tokenBurn, result) {
|
|
314
|
+
if (tokenBurn) {
|
|
315
|
+
const shard = tokenBurn.token?.shardNum ? Long.fromValue(tokenBurn.token.shardNum).toNumber() : 0;
|
|
316
|
+
const realm = tokenBurn.token?.realmNum ? Long.fromValue(tokenBurn.token.realmNum).toNumber() : 0;
|
|
317
|
+
const tokenNum = tokenBurn.token?.tokenNum ? Long.fromValue(tokenBurn.token.tokenNum).toNumber() : 0;
|
|
318
|
+
const tokenId = TokenId.fromString(`${shard}.${realm}.${tokenNum}`);
|
|
319
|
+
const amount = tokenBurn.amount ? Long.fromValue(tokenBurn.amount).toNumber() : 0;
|
|
320
|
+
const serialNumbers = [];
|
|
321
|
+
if (tokenBurn.serialNumbers) {
|
|
322
|
+
for (const serial of tokenBurn.serialNumbers) {
|
|
323
|
+
if (serial) {
|
|
324
|
+
serialNumbers.push(Long.fromValue(serial).toNumber());
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
result.tokenBurn = {
|
|
329
|
+
tokenId: tokenId.toString(),
|
|
330
|
+
amount,
|
|
331
|
+
serialNumbers: serialNumbers.length > 0 ? serialNumbers : void 0
|
|
368
332
|
};
|
|
369
|
-
return await waitMethod(
|
|
370
|
-
transactionId,
|
|
371
|
-
maxAttempts,
|
|
372
|
-
intervalMs,
|
|
373
|
-
true,
|
|
374
|
-
wrappedCallback
|
|
375
|
-
);
|
|
376
|
-
} catch (e) {
|
|
377
|
-
console.log(e);
|
|
378
|
-
logger.debug("Falling back to standard waitForInscription method", {
|
|
379
|
-
error: e
|
|
380
|
-
});
|
|
381
|
-
progressReporter.verifying("Verifying inscription status", 50, {
|
|
382
|
-
error: e
|
|
383
|
-
});
|
|
384
|
-
return await sdk.waitForInscription(
|
|
385
|
-
transactionId,
|
|
386
|
-
maxAttempts,
|
|
387
|
-
intervalMs,
|
|
388
|
-
true
|
|
389
|
-
);
|
|
390
333
|
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get a human-readable summary of the transaction
|
|
337
|
+
* @param parsedTx - The parsed transaction
|
|
338
|
+
* @returns The human-readable summary of the transaction
|
|
339
|
+
*/
|
|
340
|
+
static getTransactionSummary(parsedTx) {
|
|
341
|
+
let summary;
|
|
342
|
+
if (parsedTx.type === "cryptoTransfer") {
|
|
343
|
+
const senders = [];
|
|
344
|
+
const receivers = [];
|
|
345
|
+
for (const transfer of parsedTx.transfers) {
|
|
346
|
+
const transferAmount = parseFloat(transfer.amount);
|
|
347
|
+
if (transferAmount < 0) {
|
|
348
|
+
senders.push(
|
|
349
|
+
`${transfer.accountId} (${transfer.amount.startsWith("-") ? transfer.amount.substring(1) : transfer.amount} ℏ)`
|
|
350
|
+
);
|
|
351
|
+
} else if (transferAmount > 0) {
|
|
352
|
+
receivers.push(
|
|
353
|
+
`${transfer.accountId} (${transfer.amount} ℏ)`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (senders.length > 0 && receivers.length > 0) {
|
|
358
|
+
summary = `Transfer of HBAR from ${senders.join(
|
|
359
|
+
", "
|
|
360
|
+
)} to ${receivers.join(", ")}`;
|
|
361
|
+
} else {
|
|
362
|
+
summary = parsedTx.humanReadableType;
|
|
363
|
+
}
|
|
364
|
+
} else if (parsedTx.contractCall) {
|
|
365
|
+
let contractCallSummary = `Contract call to ${parsedTx.contractCall.contractId} with ${parsedTx.contractCall.gas} gas`;
|
|
366
|
+
if (parsedTx.contractCall.amount > 0) {
|
|
367
|
+
contractCallSummary += ` and ${parsedTx.contractCall.amount} HBAR`;
|
|
368
|
+
}
|
|
369
|
+
if (parsedTx.contractCall.functionName) {
|
|
370
|
+
contractCallSummary += ` calling function ${parsedTx.contractCall.functionName}`;
|
|
371
|
+
}
|
|
372
|
+
summary = contractCallSummary;
|
|
373
|
+
} else if (parsedTx.tokenMint) {
|
|
374
|
+
summary = `Mint ${parsedTx.tokenMint.amount} tokens for token ${parsedTx.tokenMint.tokenId}`;
|
|
375
|
+
} else if (parsedTx.tokenBurn) {
|
|
376
|
+
summary = `Burn ${parsedTx.tokenBurn.amount} tokens for token ${parsedTx.tokenBurn.tokenId}`;
|
|
377
|
+
} else if (parsedTx.tokenTransfers.length > 0) {
|
|
378
|
+
const tokenGroups = {};
|
|
379
|
+
for (const transfer of parsedTx.tokenTransfers) {
|
|
380
|
+
if (!tokenGroups[transfer.tokenId]) {
|
|
381
|
+
tokenGroups[transfer.tokenId] = [];
|
|
382
|
+
}
|
|
383
|
+
tokenGroups[transfer.tokenId].push(transfer);
|
|
384
|
+
}
|
|
385
|
+
const tokenSummaries = [];
|
|
386
|
+
for (const [tokenId, transfers] of Object.entries(tokenGroups)) {
|
|
387
|
+
const senders = [];
|
|
388
|
+
const receivers = [];
|
|
389
|
+
for (const transfer of transfers) {
|
|
390
|
+
const transferAmount = parseFloat(transfer.amount.toString());
|
|
391
|
+
if (transferAmount < 0) {
|
|
392
|
+
senders.push(
|
|
393
|
+
`${transfer.accountId} (${Math.abs(transferAmount)})`
|
|
394
|
+
);
|
|
395
|
+
} else if (transferAmount > 0) {
|
|
396
|
+
receivers.push(`${transfer.accountId} (${transferAmount})`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (senders.length > 0 && receivers.length > 0) {
|
|
400
|
+
tokenSummaries.push(
|
|
401
|
+
`Transfer of token ${tokenId} from ${senders.join(
|
|
402
|
+
", "
|
|
403
|
+
)} to ${receivers.join(", ")}`
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (tokenSummaries.length > 0) {
|
|
408
|
+
summary = tokenSummaries.join("; ");
|
|
409
|
+
} else {
|
|
410
|
+
summary = parsedTx.humanReadableType;
|
|
411
|
+
}
|
|
412
|
+
} else {
|
|
413
|
+
summary = parsedTx.humanReadableType;
|
|
414
|
+
}
|
|
415
|
+
return summary;
|
|
403
416
|
}
|
|
404
417
|
}
|
|
405
418
|
export {
|
|
406
|
-
|
|
407
|
-
inscribeWithSigner,
|
|
408
|
-
retrieveInscription
|
|
419
|
+
TransactionParser
|
|
409
420
|
};
|
|
410
421
|
//# sourceMappingURL=standards-sdk.es19.js.map
|