UNPKG

@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.

70 lines (69 loc) 2 kB
import { Long } from "@hashgraph/sdk"; import { parseKey } from "./standards-sdk.es44.js"; import { Buffer } from "buffer"; class FileParser { static parseFileCreate(body) { if (!body) return void 0; const data = {}; if (body.expirationTime?.seconds) { data.expirationTime = `${Long.fromValue( body.expirationTime.seconds ).toString()}.${body.expirationTime.nanos}`; } if (body.keys) { data.keys = parseKey({ keyList: body.keys }); } if (body.contents) { data.contents = Buffer.from(body.contents).toString("base64"); } if (body.memo) { data.memo = body.memo; } return data; } static parseFileAppend(body) { if (!body) return void 0; const data = {}; if (body.fileID) { data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`; } if (body.contents) { data.contents = Buffer.from(body.contents).toString("base64"); } return data; } static parseFileUpdate(body) { if (!body) return void 0; const data = {}; if (body.fileID) { data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`; } if (body.expirationTime?.seconds) { data.expirationTime = `${Long.fromValue( body.expirationTime.seconds ).toString()}.${body.expirationTime.nanos}`; } if (body.keys) { data.keys = parseKey({ keyList: body.keys }); } if (body.contents) { data.contents = Buffer.from(body.contents).toString("base64"); } if (body.memo?.value !== void 0) { data.memo = body.memo.value; } return data; } static parseFileDelete(body) { if (!body) return void 0; const data = {}; if (body.fileID) { data.fileId = `${body.fileID.shardNum ?? 0}.${body.fileID.realmNum ?? 0}.${body.fileID.fileNum ?? 0}`; } return data; } } export { FileParser }; //# sourceMappingURL=standards-sdk.es36.js.map