@hashgraphonline/standards-sdk 0.1.143-feat-solana-register.canary.1870c8f.71 → 0.1.143-feat-solana-register.canary.b9faba1.72
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/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-11/client.d.ts +2 -2
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/person-builder.d.ts +1 -0
- package/dist/cjs/hcs-11/person-builder.d.ts.map +1 -1
- package/dist/cjs/hcs-11/types.d.ts +1 -0
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/hcs-15/sdk.d.ts +4 -1
- package/dist/cjs/hcs-15/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-15/types.d.ts +16 -1
- package/dist/cjs/hcs-15/types.d.ts.map +1 -1
- package/dist/cjs/hcs-16/sdk.d.ts +22 -1
- package/dist/cjs/hcs-16/sdk.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/private-key-signer.d.ts +1 -0
- package/dist/cjs/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +12 -12
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts +2 -2
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/person-builder.d.ts +1 -0
- package/dist/es/hcs-11/person-builder.d.ts.map +1 -1
- package/dist/es/hcs-11/types.d.ts +1 -0
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/hcs-15/sdk.d.ts +4 -1
- package/dist/es/hcs-15/sdk.d.ts.map +1 -1
- package/dist/es/hcs-15/types.d.ts +16 -1
- package/dist/es/hcs-15/types.d.ts.map +1 -1
- package/dist/es/hcs-16/sdk.d.ts +22 -1
- package/dist/es/hcs-16/sdk.d.ts.map +1 -1
- package/dist/es/services/registry-broker/private-key-signer.d.ts +1 -0
- package/dist/es/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +12 -12
- package/dist/es/standards-sdk.es.js +2 -1
- package/dist/es/standards-sdk.es100.js +1 -1
- package/dist/es/standards-sdk.es102.js +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es111.js +5 -5
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es122.js +1 -1
- package/dist/es/standards-sdk.es123.js +5 -5
- package/dist/es/standards-sdk.es125.js +1 -1
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es128.js +2 -2
- package/dist/es/standards-sdk.es129.js +2 -2
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es130.js +2 -2
- package/dist/es/standards-sdk.es131.js +3 -3
- package/dist/es/standards-sdk.es132.js +2 -2
- package/dist/es/standards-sdk.es133.js +3 -3
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +1 -1
- package/dist/es/standards-sdk.es135.js +3 -3
- package/dist/es/standards-sdk.es136.js +1 -1
- package/dist/es/standards-sdk.es138.js +31 -17
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +30 -28
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +34 -138
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +28 -42
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +105 -12256
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +36 -50
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +12264 -57
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es150.js +54 -15
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +71 -161
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +13 -318
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +120 -294
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +191 -322
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +294 -279
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +440 -63
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +331 -871
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +68 -231
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +871 -244
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es160.js +242 -0
- package/dist/es/standards-sdk.es160.js.map +1 -0
- package/dist/es/standards-sdk.es161.js +247 -0
- package/dist/es/standards-sdk.es161.js.map +1 -0
- package/dist/es/standards-sdk.es19.js +7 -5
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es25.js +5 -0
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +23 -4
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es36.js +1 -1
- package/dist/es/standards-sdk.es37.js +3 -3
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es5.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es57.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es61.js +1 -1
- package/dist/es/standards-sdk.es63.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +2 -2
- package/dist/es/standards-sdk.es69.js +2 -2
- package/dist/es/standards-sdk.es70.js +1 -1
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es77.js +1 -1
- package/dist/es/standards-sdk.es79.js +1 -1
- package/dist/es/standards-sdk.es8.js +1 -1
- package/dist/es/standards-sdk.es82.js +1 -1
- package/dist/es/standards-sdk.es84.js +1 -1
- package/dist/es/standards-sdk.es88.js +65 -2
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/dist/es/standards-sdk.es93.js +58 -1
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +1 -1
- package/package.json +1 -1
|
@@ -1,334 +1,349 @@
|
|
|
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
|
-
|
|
1
|
+
import { AccountId, Hbar, Long, HbarUnit, TokenId } from "@hashgraph/sdk";
|
|
2
|
+
import { parseKey } from "./standards-sdk.es158.js";
|
|
3
|
+
class CryptoParser {
|
|
4
|
+
static parseCryptoTransfers(cryptoTransfer, result) {
|
|
5
|
+
if (cryptoTransfer.transfers?.accountAmounts) {
|
|
6
|
+
result.transfers = cryptoTransfer.transfers.accountAmounts.map((aa) => {
|
|
7
|
+
const accountId = new AccountId(
|
|
8
|
+
aa.accountID.shardNum ?? 0,
|
|
9
|
+
aa.accountID.realmNum ?? 0,
|
|
10
|
+
aa.accountID.accountNum ?? 0
|
|
11
|
+
);
|
|
12
|
+
const hbarAmount = Hbar.fromTinybars(Long.fromValue(aa.amount));
|
|
13
|
+
return {
|
|
14
|
+
accountId: accountId.toString(),
|
|
15
|
+
amount: hbarAmount.toString(HbarUnit.Hbar),
|
|
16
|
+
isDecimal: true
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (cryptoTransfer.tokenTransfers) {
|
|
21
|
+
for (const tokenTransferList of cryptoTransfer.tokenTransfers) {
|
|
22
|
+
const tokenId = new TokenId(
|
|
23
|
+
tokenTransferList.token.shardNum ?? 0,
|
|
24
|
+
tokenTransferList.token.realmNum ?? 0,
|
|
25
|
+
tokenTransferList.token.tokenNum ?? 0
|
|
26
|
+
);
|
|
27
|
+
if (tokenTransferList.transfers) {
|
|
28
|
+
for (const transfer of tokenTransferList.transfers) {
|
|
29
|
+
const accountId = new AccountId(
|
|
30
|
+
transfer.accountID.shardNum ?? 0,
|
|
31
|
+
transfer.accountID.realmNum ?? 0,
|
|
32
|
+
transfer.accountID.accountNum ?? 0
|
|
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
|
+
});
|
|
34
40
|
}
|
|
35
|
-
} catch (protoError) {
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
|
-
return this.parseFromTransactionInternals(transaction);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
return {
|
|
41
|
-
type: "UNKNOWN",
|
|
42
|
-
humanReadableType: "Unknown Utility Transaction"
|
|
43
|
-
};
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
type: "PRNG",
|
|
56
|
-
humanReadableType: "Pseudo Random Number",
|
|
57
|
-
utilPrng
|
|
58
|
-
};
|
|
59
|
-
}
|
|
45
|
+
static parseCryptoDelete(body) {
|
|
46
|
+
if (!body) return void 0;
|
|
47
|
+
const data = {};
|
|
48
|
+
if (body.deleteAccountID) {
|
|
49
|
+
data.deleteAccountId = new AccountId(
|
|
50
|
+
body.deleteAccountID.shardNum ?? 0,
|
|
51
|
+
body.deleteAccountID.realmNum ?? 0,
|
|
52
|
+
body.deleteAccountID.accountNum ?? 0
|
|
53
|
+
).toString();
|
|
60
54
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
freeze: networkFreeze
|
|
68
|
-
};
|
|
69
|
-
}
|
|
55
|
+
if (body.transferAccountID) {
|
|
56
|
+
data.transferAccountId = new AccountId(
|
|
57
|
+
body.transferAccountID.shardNum ?? 0,
|
|
58
|
+
body.transferAccountID.realmNum ?? 0,
|
|
59
|
+
body.transferAccountID.accountNum ?? 0
|
|
60
|
+
).toString();
|
|
70
61
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
static parseCryptoCreateAccount(body) {
|
|
65
|
+
if (!body) return void 0;
|
|
66
|
+
const data = {};
|
|
67
|
+
if (body.initialBalance) {
|
|
68
|
+
data.initialBalance = Hbar.fromTinybars(
|
|
69
|
+
Long.fromValue(body.initialBalance)
|
|
70
|
+
).toString(HbarUnit.Hbar);
|
|
80
71
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
txBody.systemUndelete
|
|
84
|
-
);
|
|
85
|
-
if (systemUndelete) {
|
|
86
|
-
return {
|
|
87
|
-
type: "SYSTEMUNDELETE",
|
|
88
|
-
humanReadableType: "System Undelete",
|
|
89
|
-
systemUndelete
|
|
90
|
-
};
|
|
91
|
-
}
|
|
72
|
+
if (body.key) {
|
|
73
|
+
data.key = parseKey(body.key);
|
|
92
74
|
}
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
if (nodeCreate) {
|
|
96
|
-
return {
|
|
97
|
-
type: "NODECREATE",
|
|
98
|
-
humanReadableType: "Node Create",
|
|
99
|
-
nodeCreate
|
|
100
|
-
};
|
|
101
|
-
}
|
|
75
|
+
if (body.receiverSigRequired !== void 0) {
|
|
76
|
+
data.receiverSigRequired = body.receiverSigRequired;
|
|
102
77
|
}
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
type: "NODEUPDATE",
|
|
108
|
-
humanReadableType: "Node Update",
|
|
109
|
-
nodeUpdate
|
|
110
|
-
};
|
|
111
|
-
}
|
|
78
|
+
if (body.autoRenewPeriod?.seconds) {
|
|
79
|
+
data.autoRenewPeriod = Long.fromValue(
|
|
80
|
+
body.autoRenewPeriod.seconds
|
|
81
|
+
).toString();
|
|
112
82
|
}
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
if (nodeDelete) {
|
|
116
|
-
return {
|
|
117
|
-
type: "NODEDELETE",
|
|
118
|
-
humanReadableType: "Node Delete",
|
|
119
|
-
nodeDelete
|
|
120
|
-
};
|
|
121
|
-
}
|
|
83
|
+
if (body.memo) {
|
|
84
|
+
data.memo = body.memo;
|
|
122
85
|
}
|
|
123
|
-
|
|
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 {};
|
|
86
|
+
if (body.maxAutomaticTokenAssociations !== void 0) {
|
|
87
|
+
data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations;
|
|
198
88
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
|
89
|
+
if (body.stakedAccountId) {
|
|
90
|
+
data.stakedAccountId = new AccountId(
|
|
91
|
+
body.stakedAccountId.shardNum ?? 0,
|
|
92
|
+
body.stakedAccountId.realmNum ?? 0,
|
|
93
|
+
body.stakedAccountId.accountNum ?? 0
|
|
216
94
|
).toString();
|
|
95
|
+
} else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0) {
|
|
96
|
+
data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
|
|
217
97
|
}
|
|
218
|
-
if (body.
|
|
219
|
-
data.
|
|
98
|
+
if (body.declineReward !== void 0) {
|
|
99
|
+
data.declineReward = body.declineReward;
|
|
220
100
|
}
|
|
221
|
-
if (body.
|
|
222
|
-
|
|
223
|
-
"FREEZE_ONLY",
|
|
224
|
-
"PREPARE_UPGRADE",
|
|
225
|
-
"FREEZE_UPGRADE",
|
|
226
|
-
"FREEZE_ABORT"
|
|
227
|
-
];
|
|
228
|
-
data.freezeType = freezeTypes[body.freezeType] || "FREEZE_ONLY";
|
|
101
|
+
if (body.alias && body.alias.length > 0) {
|
|
102
|
+
data.alias = Buffer.from(body.alias).toString("hex");
|
|
229
103
|
}
|
|
230
104
|
return data;
|
|
231
105
|
}
|
|
232
|
-
|
|
233
|
-
* Parse System Delete from protobuf data
|
|
234
|
-
*/
|
|
235
|
-
static parseSystemDeleteFromProto(body) {
|
|
106
|
+
static parseCryptoUpdateAccount(body) {
|
|
236
107
|
if (!body) return void 0;
|
|
237
108
|
const data = {};
|
|
238
|
-
if (body.
|
|
239
|
-
data.
|
|
240
|
-
body.
|
|
241
|
-
body.
|
|
242
|
-
body.
|
|
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
|
|
109
|
+
if (body.accountIDToUpdate) {
|
|
110
|
+
data.accountIdToUpdate = new AccountId(
|
|
111
|
+
body.accountIDToUpdate.shardNum ?? 0,
|
|
112
|
+
body.accountIDToUpdate.realmNum ?? 0,
|
|
113
|
+
body.accountIDToUpdate.accountNum ?? 0
|
|
249
114
|
).toString();
|
|
250
115
|
}
|
|
116
|
+
if (body.key) {
|
|
117
|
+
data.key = parseKey(body.key);
|
|
118
|
+
}
|
|
251
119
|
if (body.expirationTime?.seconds) {
|
|
252
|
-
data.expirationTime = Long.fromValue(
|
|
120
|
+
data.expirationTime = `${Long.fromValue(
|
|
253
121
|
body.expirationTime.seconds
|
|
254
|
-
).toString()
|
|
122
|
+
).toString()}.${body.expirationTime.nanos}`;
|
|
255
123
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (!body) return void 0;
|
|
263
|
-
const data = {};
|
|
264
|
-
if (body.fileID) {
|
|
265
|
-
data.fileId = new FileId(
|
|
266
|
-
body.fileID.shardNum ?? 0,
|
|
267
|
-
body.fileID.realmNum ?? 0,
|
|
268
|
-
body.fileID.fileNum ?? 0
|
|
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
|
|
269
130
|
).toString();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
|
275
143
|
).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);
|
|
276
154
|
}
|
|
277
155
|
return data;
|
|
278
156
|
}
|
|
279
|
-
|
|
280
|
-
* Parse Node Create from protobuf data
|
|
281
|
-
*/
|
|
282
|
-
static parseNodeCreateFromProto(body) {
|
|
157
|
+
static parseCryptoApproveAllowance(body) {
|
|
283
158
|
if (!body) return void 0;
|
|
284
159
|
const data = {};
|
|
285
|
-
if (body.
|
|
286
|
-
data.
|
|
160
|
+
if (body.cryptoAllowances && body.cryptoAllowances.length > 0) {
|
|
161
|
+
data.hbarAllowances = body.cryptoAllowances.map((a) => ({
|
|
162
|
+
ownerAccountId: new AccountId(
|
|
163
|
+
a.owner.shardNum ?? 0,
|
|
164
|
+
a.owner.realmNum ?? 0,
|
|
165
|
+
a.owner.accountNum ?? 0
|
|
166
|
+
).toString(),
|
|
167
|
+
spenderAccountId: new AccountId(
|
|
168
|
+
a.spender.shardNum ?? 0,
|
|
169
|
+
a.spender.realmNum ?? 0,
|
|
170
|
+
a.spender.accountNum ?? 0
|
|
171
|
+
).toString(),
|
|
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
|
+
});
|
|
287
232
|
}
|
|
288
233
|
return data;
|
|
289
234
|
}
|
|
290
|
-
|
|
291
|
-
* Parse Node Update from protobuf data
|
|
292
|
-
*/
|
|
293
|
-
static parseNodeUpdateFromProto(body) {
|
|
235
|
+
static parseCryptoDeleteAllowance(body) {
|
|
294
236
|
if (!body) return void 0;
|
|
295
237
|
const data = {};
|
|
296
|
-
if (body.
|
|
297
|
-
data.
|
|
238
|
+
if (body.nftAllowances && body.nftAllowances.length > 0) {
|
|
239
|
+
data.nftAllowancesToRemove = body.nftAllowances.map((a) => ({
|
|
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
|
+
}));
|
|
298
252
|
}
|
|
299
253
|
return data;
|
|
300
254
|
}
|
|
301
255
|
/**
|
|
302
|
-
*
|
|
256
|
+
* Extract HBAR transfers from Transaction object
|
|
303
257
|
*/
|
|
304
|
-
static
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
258
|
+
static extractHbarTransfersFromTransaction(transaction) {
|
|
259
|
+
const transfers = [];
|
|
260
|
+
try {
|
|
261
|
+
const hbarTransfers = transaction._hbarTransfers;
|
|
262
|
+
if (Array.isArray(hbarTransfers)) {
|
|
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) {
|
|
309
275
|
}
|
|
310
|
-
return
|
|
276
|
+
return transfers;
|
|
311
277
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Extract token transfers from Transaction object
|
|
280
|
+
*/
|
|
281
|
+
static extractTokenTransfersFromTransaction(transaction) {
|
|
282
|
+
const tokenTransfers = [];
|
|
283
|
+
try {
|
|
284
|
+
const tokenTransfersList = transaction._tokenTransfers;
|
|
285
|
+
if (Array.isArray(tokenTransfersList)) {
|
|
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) {
|
|
317
300
|
}
|
|
318
|
-
return
|
|
319
|
-
}
|
|
320
|
-
static parseFreeze(body) {
|
|
321
|
-
return this.parseNetworkFreezeFromProto(body);
|
|
301
|
+
return tokenTransfers;
|
|
322
302
|
}
|
|
323
303
|
/**
|
|
324
|
-
* Parse
|
|
325
|
-
* This is the unified entry point that
|
|
304
|
+
* Parse crypto transaction from Transaction object with comprehensive extraction
|
|
305
|
+
* This is the unified entry point that handles both protobuf and internal field extraction
|
|
326
306
|
*/
|
|
327
307
|
static parseFromTransactionObject(transaction) {
|
|
328
|
-
|
|
308
|
+
try {
|
|
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
|
+
}
|
|
329
344
|
}
|
|
330
345
|
}
|
|
331
346
|
export {
|
|
332
|
-
|
|
347
|
+
CryptoParser
|
|
333
348
|
};
|
|
334
349
|
//# sourceMappingURL=standards-sdk.es155.js.map
|