@hashgraphonline/standards-sdk
Version:
The Hashgraph Online Standards SDK provides a complete implementation of the Hashgraph Consensus Standards (HCS), giving developers all the tools needed to build applications on Hedera.
46 lines (45 loc) • 1.42 kB
JavaScript
import { ContractId } from "@hashgraph/sdk";
import { Buffer } from "buffer";
function parseKey(key) {
if (!key) {
return void 0;
}
if (key.contractID) {
return `ContractID: ${new ContractId(
key.contractID.shardNum ?? 0,
key.contractID.realmNum ?? 0,
key.contractID.contractNum ?? 0
).toString()}`;
}
if (key.ed25519) {
return `ED25519: ${Buffer.from(key.ed25519).toString("hex")}`;
}
if (key.ECDSASecp256k1) {
return `ECDSA_secp256k1: ${Buffer.from(key.ECDSASecp256k1).toString(
"hex"
)}`;
}
if (key?.keyList?.keys?.length > 0) {
const keys = key.keyList.keys.map((k) => parseKey(k)).filter(Boolean);
return `KeyList (${keys.length} keys): [${keys.join(", ")}]`;
}
if (key?.thresholdKey?.keys?.keys?.length > 0) {
const keys = key.thresholdKey.keys.keys.map((k) => parseKey(k)).filter(Boolean);
return `ThresholdKey (${key.thresholdKey.threshold} of ${keys.length}): [${keys.join(", ")}]`;
}
if (key.delegatableContractId) {
return `DelegatableContractID: ${new ContractId(
key.delegatableContractId.shardNum ?? 0,
key.delegatableContractId.realmNum ?? 0,
key.delegatableContractId.contractNum ?? 0
).toString()}`;
}
if (Object.keys(key).length === 0) {
return "Empty Key Structure";
}
return "Unknown or Unset Key Type";
}
export {
parseKey
};
//# sourceMappingURL=standards-sdk.es44.js.map