@hashgraphonline/standards-sdk 0.1.175 → 0.1.176
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/README.md +23 -0
- package/dist/browser/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/browser/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/browser/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/browser/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/types.d.ts +36 -1
- package/dist/browser/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser/standards-sdk.browser.js +155 -1
- package/dist/browser/standards-sdk.browser.js.map +1 -1
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/browser-root/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/browser-root/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/types.d.ts +36 -1
- package/dist/browser-root/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser-root/standards-sdk.root-browser.js +308 -1
- package/dist/browser-root/standards-sdk.root-browser.js.map +1 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/cjs/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +36 -1
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts +9 -5
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/skills.d.ts +9 -5
- package/dist/es/services/registry-broker/client/skills.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +2870 -8
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +36 -1
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es116.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es127.js +1 -1
- package/dist/es/standards-sdk.es128.js +5 -5
- package/dist/es/standards-sdk.es138.js +1 -1
- package/dist/es/standards-sdk.es139.js +1 -1
- package/dist/es/standards-sdk.es140.js +5 -5
- package/dist/es/standards-sdk.es142.js +3 -3
- package/dist/es/standards-sdk.es143.js +1 -1
- package/dist/es/standards-sdk.es145.js +24 -3
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +1 -1
- package/dist/es/standards-sdk.es148.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es160.js +1778 -12461
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +12461 -1608
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +51 -167
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +88 -306
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +71 -336
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +186 -439
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +695 -314
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +63 -66
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +158 -90
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +314 -65
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +345 -55
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +443 -71
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +315 -184
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +68 -565
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +1 -1
- package/dist/es/standards-sdk.es176.js +1 -1
- package/dist/es/standards-sdk.es178.js +2 -2
- package/dist/es/standards-sdk.es179.js +1 -1
- package/dist/es/standards-sdk.es18.js +2 -2
- package/dist/es/standards-sdk.es180.js +1 -1
- package/dist/es/standards-sdk.es181.js +2 -2
- package/dist/es/standards-sdk.es182.js +1 -1
- package/dist/es/standards-sdk.es183.js +1 -1
- package/dist/es/standards-sdk.es19.js +2 -2
- package/dist/es/standards-sdk.es27.js +2 -2
- package/dist/es/standards-sdk.es30.js +1 -1
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es35.js +2 -2
- package/dist/es/standards-sdk.es36.js +1 -1
- package/dist/es/standards-sdk.es37.js +1 -1
- package/dist/es/standards-sdk.es56.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.es62.js +1 -1
- package/dist/es/standards-sdk.es63.js +2 -2
- package/dist/es/standards-sdk.es64.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es67.js +1 -1
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es75.js +1 -1
- package/dist/es/standards-sdk.es84.js +1 -1
- package/package.json +2 -1
|
@@ -1,456 +1,203 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
static parseSCSTransaction(transaction, originalBytes) {
|
|
11
|
-
try {
|
|
12
|
-
if (originalBytes || transaction.toBytes) {
|
|
13
|
-
try {
|
|
14
|
-
const bytesToParse = originalBytes || transaction.toBytes();
|
|
15
|
-
const decoded = proto.TransactionList.decode(bytesToParse);
|
|
16
|
-
if (decoded.transactionList && decoded.transactionList.length > 0) {
|
|
17
|
-
const tx = decoded.transactionList[0];
|
|
18
|
-
let txBody = null;
|
|
19
|
-
if (tx.bodyBytes && tx.bodyBytes.length > 0) {
|
|
20
|
-
txBody = proto.TransactionBody.decode(tx.bodyBytes);
|
|
21
|
-
} else if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {
|
|
22
|
-
const signedTx = proto.SignedTransaction.decode(
|
|
23
|
-
tx.signedTransactionBytes
|
|
24
|
-
);
|
|
25
|
-
if (signedTx.bodyBytes) {
|
|
26
|
-
txBody = proto.TransactionBody.decode(signedTx.bodyBytes);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (txBody) {
|
|
30
|
-
const protoResult = this.parseFromProtobufTxBody(txBody);
|
|
31
|
-
if (protoResult.type && protoResult.type !== "UNKNOWN") {
|
|
32
|
-
return protoResult;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} catch (protoError) {
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return this.parseFromTransactionInternals(transaction);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return {
|
|
42
|
-
type: "UNKNOWN",
|
|
43
|
-
humanReadableType: "Unknown Contract Transaction"
|
|
44
|
-
};
|
|
45
|
-
}
|
|
1
|
+
import { parseSemicolonFields } from "./standards-sdk.es165.js";
|
|
2
|
+
const ANS_HCS27_REGISTRY = "ans";
|
|
3
|
+
function isObjectRecord(value) {
|
|
4
|
+
return typeof value === "object" && value !== null;
|
|
5
|
+
}
|
|
6
|
+
function asString(value) {
|
|
7
|
+
if (typeof value !== "string") {
|
|
8
|
+
return null;
|
|
46
9
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*/
|
|
51
|
-
static parseFromProtobufTxBody(txBody) {
|
|
52
|
-
if (txBody.contractCall) {
|
|
53
|
-
const contractCall = this.parseContractCall(txBody.contractCall);
|
|
54
|
-
if (contractCall) {
|
|
55
|
-
return {
|
|
56
|
-
type: "CONTRACTCALL",
|
|
57
|
-
humanReadableType: "Contract Call",
|
|
58
|
-
contractCall
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (txBody.contractCreateInstance) {
|
|
63
|
-
const contractCreate = this.parseContractCreate(
|
|
64
|
-
txBody.contractCreateInstance
|
|
65
|
-
);
|
|
66
|
-
if (contractCreate) {
|
|
67
|
-
return {
|
|
68
|
-
type: "CONTRACTCREATE",
|
|
69
|
-
humanReadableType: "Contract Create",
|
|
70
|
-
contractCreate
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (txBody.contractUpdateInstance) {
|
|
75
|
-
const contractUpdate = this.parseContractUpdate(
|
|
76
|
-
txBody.contractUpdateInstance
|
|
77
|
-
);
|
|
78
|
-
if (contractUpdate) {
|
|
79
|
-
return {
|
|
80
|
-
type: "CONTRACTUPDATE",
|
|
81
|
-
humanReadableType: "Contract Update",
|
|
82
|
-
contractUpdate
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (txBody.contractDeleteInstance) {
|
|
87
|
-
const contractDelete = this.parseContractDelete(
|
|
88
|
-
txBody.contractDeleteInstance
|
|
89
|
-
);
|
|
90
|
-
if (contractDelete) {
|
|
91
|
-
return {
|
|
92
|
-
type: "CONTRACTDELETE",
|
|
93
|
-
humanReadableType: "Contract Delete",
|
|
94
|
-
contractDelete
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (txBody.ethereumTransaction) {
|
|
99
|
-
const ethereumCall = this.parseEthereumTransaction(
|
|
100
|
-
txBody.ethereumTransaction
|
|
101
|
-
);
|
|
102
|
-
if (ethereumCall) {
|
|
103
|
-
return {
|
|
104
|
-
type: "ETHEREUMTRANSACTION",
|
|
105
|
-
humanReadableType: "Ethereum Transaction",
|
|
106
|
-
ethereumTransaction: ethereumCall
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return {};
|
|
10
|
+
const trimmed = value.trim();
|
|
11
|
+
if (!trimmed) {
|
|
12
|
+
return null;
|
|
111
13
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
amount: tx._amount ? parseFloat(tx._amount.toString()) : 0
|
|
124
|
-
};
|
|
125
|
-
if (tx._functionParameters) {
|
|
126
|
-
const funcParams = Buffer.from(tx._functionParameters).toString(
|
|
127
|
-
"hex"
|
|
128
|
-
);
|
|
129
|
-
contractCall.functionParameters = funcParams;
|
|
130
|
-
contractCall.functionName = this.extractFunctionName(funcParams);
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
type: "CONTRACTCALL",
|
|
134
|
-
humanReadableType: "Contract Call",
|
|
135
|
-
contractCall
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
if (hasTransactionType(transaction, "contractCreateInstance")) {
|
|
139
|
-
const contractCreate = {
|
|
140
|
-
gas: tx._gas.toString(),
|
|
141
|
-
initialBalance: tx._initialBalance?.toString() || "0"
|
|
142
|
-
};
|
|
143
|
-
if (tx._fileId) {
|
|
144
|
-
contractCreate.initcodeSource = "fileID";
|
|
145
|
-
contractCreate.initcode = tx._fileId.toString();
|
|
146
|
-
} else if (tx._bytecode) {
|
|
147
|
-
contractCreate.initcodeSource = "bytes";
|
|
148
|
-
contractCreate.initcode = Buffer.from(tx._bytecode).toString("hex");
|
|
149
|
-
}
|
|
150
|
-
if (tx._constructorParameters) {
|
|
151
|
-
contractCreate.constructorParameters = Buffer.from(
|
|
152
|
-
tx._constructorParameters
|
|
153
|
-
).toString("hex");
|
|
154
|
-
}
|
|
155
|
-
if (tx._memo) contractCreate.memo = tx._memo;
|
|
156
|
-
if (tx._adminKey) contractCreate.adminKey = parseKey(tx._adminKey);
|
|
157
|
-
if (tx._maxAutomaticTokenAssociations !== void 0) {
|
|
158
|
-
contractCreate.maxAutomaticTokenAssociations = tx._maxAutomaticTokenAssociations;
|
|
159
|
-
}
|
|
160
|
-
if (tx._stakedAccountId) {
|
|
161
|
-
contractCreate.stakedAccountId = tx._stakedAccountId.toString();
|
|
162
|
-
} else if (tx._stakedNodeId !== null && tx._stakedNodeId !== void 0) {
|
|
163
|
-
contractCreate.stakedNodeId = Long.fromValue(
|
|
164
|
-
tx._stakedNodeId
|
|
165
|
-
).toString();
|
|
166
|
-
}
|
|
167
|
-
if (tx._declineReward !== void 0)
|
|
168
|
-
contractCreate.declineReward = tx._declineReward;
|
|
169
|
-
if (tx._autoRenewPeriod)
|
|
170
|
-
contractCreate.autoRenewPeriod = tx._autoRenewPeriod.toString();
|
|
171
|
-
return {
|
|
172
|
-
type: "CONTRACTCREATE",
|
|
173
|
-
humanReadableType: "Contract Create",
|
|
174
|
-
contractCreate
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
if (hasTransactionType(transaction, "contractUpdateInstance")) {
|
|
178
|
-
const contractUpdate = {
|
|
179
|
-
contractIdToUpdate: tx._contractId.toString()
|
|
180
|
-
};
|
|
181
|
-
if (tx._memo) contractUpdate.memo = tx._memo;
|
|
182
|
-
if (tx._adminKey) contractUpdate.adminKey = parseKey(tx._adminKey);
|
|
183
|
-
if (tx._maxAutomaticTokenAssociations !== void 0) {
|
|
184
|
-
contractUpdate.maxAutomaticTokenAssociations = tx._maxAutomaticTokenAssociations;
|
|
185
|
-
}
|
|
186
|
-
if (tx._stakedAccountId) {
|
|
187
|
-
contractUpdate.stakedAccountId = tx._stakedAccountId.toString();
|
|
188
|
-
} else if (tx._stakedNodeId !== null && tx._stakedNodeId !== void 0) {
|
|
189
|
-
contractUpdate.stakedNodeId = Long.fromValue(
|
|
190
|
-
tx._stakedNodeId
|
|
191
|
-
).toString();
|
|
192
|
-
}
|
|
193
|
-
if (tx._declineReward !== void 0)
|
|
194
|
-
contractUpdate.declineReward = tx._declineReward;
|
|
195
|
-
if (tx._autoRenewPeriod)
|
|
196
|
-
contractUpdate.autoRenewPeriod = tx._autoRenewPeriod.toString();
|
|
197
|
-
return {
|
|
198
|
-
type: "CONTRACTUPDATE",
|
|
199
|
-
humanReadableType: "Contract Update",
|
|
200
|
-
contractUpdate
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
if (hasTransactionType(transaction, "contractDeleteInstance")) {
|
|
204
|
-
const contractDelete = {
|
|
205
|
-
contractIdToDelete: tx._contractId.toString()
|
|
206
|
-
};
|
|
207
|
-
if (tx._transferAccountId) {
|
|
208
|
-
contractDelete.transferAccountId = tx._transferAccountId.toString();
|
|
209
|
-
} else if (tx._transferContractId) {
|
|
210
|
-
contractDelete.transferContractId = tx._transferContractId.toString();
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
type: "CONTRACTDELETE",
|
|
214
|
-
humanReadableType: "Contract Delete",
|
|
215
|
-
contractDelete
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
return {};
|
|
219
|
-
} catch (error) {
|
|
220
|
-
return {};
|
|
221
|
-
}
|
|
14
|
+
return trimmed;
|
|
15
|
+
}
|
|
16
|
+
function isSemver(value) {
|
|
17
|
+
return /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(
|
|
18
|
+
value
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function normalizeAnsVersion(value) {
|
|
22
|
+
const trimmed = value.trim();
|
|
23
|
+
if (!trimmed) {
|
|
24
|
+
return null;
|
|
222
25
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
*/
|
|
227
|
-
static extractFunctionName(functionParameters) {
|
|
228
|
-
if (functionParameters.length < 8) return "unknown";
|
|
229
|
-
const selector = functionParameters.substring(0, 8);
|
|
230
|
-
const commonSelectors = {
|
|
231
|
-
a9059cbb: "transfer",
|
|
232
|
-
"095ea7b3": "approve",
|
|
233
|
-
"23b872dd": "transferFrom",
|
|
234
|
-
"70a08231": "balanceOf",
|
|
235
|
-
dd62ed3e: "allowance",
|
|
236
|
-
"18160ddd": "totalSupply",
|
|
237
|
-
"06fdde03": "name",
|
|
238
|
-
"95d89b41": "symbol",
|
|
239
|
-
"313ce567": "decimals",
|
|
240
|
-
"42842e0e": "safeTransferFrom",
|
|
241
|
-
b88d4fde: "safeTransferFrom",
|
|
242
|
-
e985e9c5: "isApprovedForAll",
|
|
243
|
-
a22cb465: "setApprovalForAll",
|
|
244
|
-
"6352211e": "ownerOf",
|
|
245
|
-
c87b56dd: "tokenURI",
|
|
246
|
-
"01ffc9a7": "supportsInterface",
|
|
247
|
-
"40c10f19": "mint",
|
|
248
|
-
"42966c68": "burn",
|
|
249
|
-
f2fde38b: "transferOwnership",
|
|
250
|
-
"715018a6": "renounceOwnership",
|
|
251
|
-
"8da5cb5b": "owner"
|
|
252
|
-
};
|
|
253
|
-
return commonSelectors[selector] || selector;
|
|
26
|
+
const withoutPrefix = trimmed.startsWith("v") || trimmed.startsWith("V") ? trimmed.slice(1) : trimmed;
|
|
27
|
+
if (!isSemver(withoutPrefix)) {
|
|
28
|
+
return null;
|
|
254
29
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
amount: 0
|
|
264
|
-
};
|
|
265
|
-
if (body.ethereumData && body.ethereumData.length > 0) {
|
|
266
|
-
const ethData = Buffer.from(body.ethereumData).toString("hex");
|
|
267
|
-
data.functionParameters = ethData;
|
|
268
|
-
if (ethData.length >= 8) {
|
|
269
|
-
data.functionName = this.extractFunctionName(ethData);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return data;
|
|
30
|
+
return withoutPrefix;
|
|
31
|
+
}
|
|
32
|
+
function parseAnsDnsTxtRecord(rawRecord) {
|
|
33
|
+
const fields = parseSemicolonFields(rawRecord);
|
|
34
|
+
const version = fields["v"];
|
|
35
|
+
const urlValue = fields["url"];
|
|
36
|
+
if (!version || !urlValue || version.toLowerCase() !== "ans1") {
|
|
37
|
+
return null;
|
|
273
38
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
body.contractID.shardNum ?? 0,
|
|
280
|
-
body.contractID.realmNum ?? 0,
|
|
281
|
-
body.contractID.contractNum ?? 0
|
|
282
|
-
).toString(),
|
|
283
|
-
gas: Long.fromValue(body.gas ?? 0).toNumber(),
|
|
284
|
-
amount: parseFloat(hbarAmount.toString(HbarUnit.Hbar))
|
|
285
|
-
};
|
|
286
|
-
if (body.functionParameters) {
|
|
287
|
-
data.functionParameters = Buffer.from(body.functionParameters).toString(
|
|
288
|
-
"hex"
|
|
289
|
-
);
|
|
290
|
-
if (data.functionParameters.length >= 8) {
|
|
291
|
-
data.functionName = this.extractFunctionName(data.functionParameters);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return data;
|
|
39
|
+
let parsedUrl;
|
|
40
|
+
try {
|
|
41
|
+
parsedUrl = new URL(urlValue);
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
295
44
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const data = {};
|
|
299
|
-
if (body.initialBalance) {
|
|
300
|
-
data.initialBalance = Hbar.fromTinybars(
|
|
301
|
-
Long.fromValue(body.initialBalance)
|
|
302
|
-
).toString(HbarUnit.Hbar);
|
|
303
|
-
}
|
|
304
|
-
if (body.gas) {
|
|
305
|
-
data.gas = Long.fromValue(body.gas).toString();
|
|
306
|
-
}
|
|
307
|
-
if (body.adminKey) {
|
|
308
|
-
data.adminKey = parseKey(body.adminKey);
|
|
309
|
-
}
|
|
310
|
-
if (body.constructorParameters) {
|
|
311
|
-
data.constructorParameters = Buffer.from(
|
|
312
|
-
body.constructorParameters
|
|
313
|
-
).toString("hex");
|
|
314
|
-
}
|
|
315
|
-
if (body.memo) {
|
|
316
|
-
data.memo = body.memo;
|
|
317
|
-
}
|
|
318
|
-
if (body.autoRenewPeriod?.seconds) {
|
|
319
|
-
data.autoRenewPeriod = Long.fromValue(
|
|
320
|
-
body.autoRenewPeriod.seconds
|
|
321
|
-
).toString();
|
|
322
|
-
}
|
|
323
|
-
if (body.stakedAccountId) {
|
|
324
|
-
data.stakedAccountId = new AccountId(
|
|
325
|
-
body.stakedAccountId.shardNum ?? 0,
|
|
326
|
-
body.stakedAccountId.realmNum ?? 0,
|
|
327
|
-
body.stakedAccountId.accountNum ?? 0
|
|
328
|
-
).toString();
|
|
329
|
-
} else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0) {
|
|
330
|
-
data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
|
|
331
|
-
}
|
|
332
|
-
if (body.declineReward !== void 0) {
|
|
333
|
-
data.declineReward = body.declineReward;
|
|
334
|
-
}
|
|
335
|
-
if (body.maxAutomaticTokenAssociations !== void 0) {
|
|
336
|
-
data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations;
|
|
337
|
-
}
|
|
338
|
-
if (body.fileID) {
|
|
339
|
-
data.initcodeSource = "fileID";
|
|
340
|
-
data.initcode = new FileId(
|
|
341
|
-
body.fileID.shardNum ?? 0,
|
|
342
|
-
body.fileID.realmNum ?? 0,
|
|
343
|
-
body.fileID.fileNum ?? 0
|
|
344
|
-
).toString();
|
|
345
|
-
} else if (body.initcode && body.initcode.length > 0) {
|
|
346
|
-
data.initcodeSource = "bytes";
|
|
347
|
-
data.initcode = Buffer.from(body.initcode).toString("hex");
|
|
348
|
-
}
|
|
349
|
-
return data;
|
|
45
|
+
if (parsedUrl.protocol.toLowerCase() !== "https:") {
|
|
46
|
+
return null;
|
|
350
47
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const value = memoUnion.value;
|
|
378
|
-
if (value === null || value === void 0) {
|
|
379
|
-
data.memo = void 0;
|
|
380
|
-
} else {
|
|
381
|
-
data.memo = String(value);
|
|
382
|
-
}
|
|
383
|
-
} else if (typeof memoUnion === "string") {
|
|
384
|
-
data.memo = memoUnion;
|
|
385
|
-
} else {
|
|
386
|
-
data.memo = void 0;
|
|
387
|
-
}
|
|
388
|
-
} else {
|
|
389
|
-
data.memo = void 0;
|
|
390
|
-
}
|
|
391
|
-
if (body.stakedAccountId) {
|
|
392
|
-
data.stakedAccountId = new AccountId(
|
|
393
|
-
body.stakedAccountId.shardNum ?? 0,
|
|
394
|
-
body.stakedAccountId.realmNum ?? 0,
|
|
395
|
-
body.stakedAccountId.accountNum ?? 0
|
|
396
|
-
).toString();
|
|
397
|
-
data.stakedNodeId = void 0;
|
|
398
|
-
} else if (body.stakedNodeId !== null && body.stakedNodeId !== void 0 && Long.fromValue(body.stakedNodeId).notEquals(-1)) {
|
|
399
|
-
data.stakedNodeId = Long.fromValue(body.stakedNodeId).toString();
|
|
400
|
-
data.stakedAccountId = void 0;
|
|
401
|
-
} else {
|
|
402
|
-
data.stakedNodeId = void 0;
|
|
403
|
-
data.stakedAccountId = void 0;
|
|
404
|
-
}
|
|
405
|
-
if (body.declineReward?.value !== void 0) {
|
|
406
|
-
data.declineReward = body.declineReward.value;
|
|
407
|
-
}
|
|
408
|
-
if (body.maxAutomaticTokenAssociations?.value !== void 0) {
|
|
409
|
-
data.maxAutomaticTokenAssociations = body.maxAutomaticTokenAssociations.value;
|
|
410
|
-
}
|
|
411
|
-
if (body.autoRenewAccountId) {
|
|
412
|
-
data.autoRenewAccountId = new AccountId(
|
|
413
|
-
body.autoRenewAccountId.shardNum ?? 0,
|
|
414
|
-
body.autoRenewAccountId.realmNum ?? 0,
|
|
415
|
-
body.autoRenewAccountId.accountNum ?? 0
|
|
416
|
-
).toString();
|
|
48
|
+
const rawAnsVersion = fields["version"];
|
|
49
|
+
let normalizedAnsVersion;
|
|
50
|
+
if (rawAnsVersion !== void 0) {
|
|
51
|
+
const parsedVersion = normalizeAnsVersion(rawAnsVersion);
|
|
52
|
+
if (!parsedVersion) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
normalizedAnsVersion = parsedVersion;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
version: normalizedAnsVersion,
|
|
59
|
+
url: parsedUrl.toString()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function isValidAnsProfileVersion(value) {
|
|
63
|
+
return !!value && normalizeAnsVersion(value) !== null;
|
|
64
|
+
}
|
|
65
|
+
function hasProtocolPathSegment(pathname, protocol) {
|
|
66
|
+
const normalizedProtocol = protocol.trim().toLowerCase();
|
|
67
|
+
if (!normalizedProtocol) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const pathSegments = pathname.split("/").map((segment) => segment.trim()).filter((segment) => segment.length > 0);
|
|
71
|
+
for (const segment of pathSegments) {
|
|
72
|
+
if (segment.toLowerCase() === normalizedProtocol) {
|
|
73
|
+
return true;
|
|
417
74
|
}
|
|
418
|
-
return data;
|
|
419
75
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
body.contractID.contractNum ?? 0
|
|
428
|
-
).toString();
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
function extractEndpointCandidates(endpoints, supportedSchemes) {
|
|
79
|
+
const candidates = [];
|
|
80
|
+
for (const [key, value] of Object.entries(endpoints)) {
|
|
81
|
+
if (!isObjectRecord(value)) {
|
|
82
|
+
continue;
|
|
429
83
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
body.transferAccountID.realmNum ?? 0,
|
|
434
|
-
body.transferAccountID.accountNum ?? 0
|
|
435
|
-
).toString();
|
|
436
|
-
} else if (body.transferContractID) {
|
|
437
|
-
data.transferContractId = new ContractId(
|
|
438
|
-
body.transferContractID.shardNum ?? 0,
|
|
439
|
-
body.transferContractID.realmNum ?? 0,
|
|
440
|
-
body.transferContractID.contractNum ?? 0
|
|
441
|
-
).toString();
|
|
84
|
+
const endpoint = asString(value["url"]);
|
|
85
|
+
if (!endpoint) {
|
|
86
|
+
continue;
|
|
442
87
|
}
|
|
443
|
-
|
|
88
|
+
let parsedUrl;
|
|
89
|
+
try {
|
|
90
|
+
parsedUrl = new URL(endpoint);
|
|
91
|
+
} catch {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const scheme = parsedUrl.protocol.replace(/:$/, "").toLowerCase();
|
|
95
|
+
if (!supportedSchemes.has(scheme)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
candidates.push({
|
|
99
|
+
key,
|
|
100
|
+
endpointUrl: parsedUrl.toString(),
|
|
101
|
+
parsedUrl
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return candidates;
|
|
105
|
+
}
|
|
106
|
+
function validateAnsHcs27Hints(input) {
|
|
107
|
+
if (!isObjectRecord(input)) {
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
const checkpointTopicId = asString(input["checkpoint_topic_id"]);
|
|
111
|
+
const registry = asString(input["registry"]);
|
|
112
|
+
const logId = asString(input["log_id"]);
|
|
113
|
+
if (!checkpointTopicId || !registry || !logId || registry !== ANS_HCS27_REGISTRY) {
|
|
114
|
+
return void 0;
|
|
444
115
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
116
|
+
const checkpointUri = asString(input["checkpoint_uri"]) ?? void 0;
|
|
117
|
+
const viewerUri = asString(input["viewer_uri"]) ?? void 0;
|
|
118
|
+
return {
|
|
119
|
+
checkpointTopicId,
|
|
120
|
+
registry,
|
|
121
|
+
logId,
|
|
122
|
+
checkpointUri,
|
|
123
|
+
viewerUri
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function validateHcs28Hints(input) {
|
|
127
|
+
if (!isObjectRecord(input)) {
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
const directoryTopicId = asString(input["directory_topic_id"]);
|
|
131
|
+
const tId = asString(input["t_id"]);
|
|
132
|
+
const agentId = asString(input["agent_id"]);
|
|
133
|
+
if (!directoryTopicId || !tId || !agentId) {
|
|
134
|
+
return void 0;
|
|
135
|
+
}
|
|
136
|
+
const proofProfile = asString(input["proof_profile"]) ?? void 0;
|
|
137
|
+
return {
|
|
138
|
+
directoryTopicId,
|
|
139
|
+
tId,
|
|
140
|
+
agentId,
|
|
141
|
+
proofProfile
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function parseTransparencyHints(input) {
|
|
145
|
+
if (!isObjectRecord(input)) {
|
|
146
|
+
return void 0;
|
|
147
|
+
}
|
|
148
|
+
const hcs27 = validateAnsHcs27Hints(input["hcs27"]);
|
|
149
|
+
const hcs28 = validateHcs28Hints(input["hcs28"]);
|
|
150
|
+
if (!hcs27 && !hcs28) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
hcs27,
|
|
155
|
+
hcs28
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function parseAnsAgentCard(input) {
|
|
159
|
+
if (!isObjectRecord(input)) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const ansName = asString(input["ansName"]);
|
|
163
|
+
const endpoints = input["endpoints"];
|
|
164
|
+
if (!ansName || !isObjectRecord(endpoints)) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
ansName,
|
|
169
|
+
endpoints,
|
|
170
|
+
transparencyHints: parseTransparencyHints(input["transparency"])
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function selectPreferredEndpoint(candidates, protocol) {
|
|
174
|
+
if (candidates.length === 0) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const sortedCandidates = [...candidates].sort(
|
|
178
|
+
(a, b) => a.key.localeCompare(b.key)
|
|
179
|
+
);
|
|
180
|
+
const protocolMatches = sortedCandidates.filter(
|
|
181
|
+
(candidate) => hasProtocolPathSegment(candidate.parsedUrl.pathname, protocol)
|
|
182
|
+
);
|
|
183
|
+
if (protocolMatches.length > 0) {
|
|
184
|
+
return protocolMatches[0];
|
|
185
|
+
}
|
|
186
|
+
return sortedCandidates[0];
|
|
187
|
+
}
|
|
188
|
+
function toErrorMessage(error) {
|
|
189
|
+
if (error instanceof Error && error.message) {
|
|
190
|
+
return error.message;
|
|
451
191
|
}
|
|
192
|
+
return null;
|
|
452
193
|
}
|
|
453
194
|
export {
|
|
454
|
-
|
|
195
|
+
extractEndpointCandidates,
|
|
196
|
+
isValidAnsProfileVersion,
|
|
197
|
+
normalizeAnsVersion,
|
|
198
|
+
parseAnsAgentCard,
|
|
199
|
+
parseAnsDnsTxtRecord,
|
|
200
|
+
selectPreferredEndpoint,
|
|
201
|
+
toErrorMessage
|
|
455
202
|
};
|
|
456
203
|
//# sourceMappingURL=standards-sdk.es166.js.map
|