From 8e963d4b0449dfcbeb55eae61c202cbfea5ffc9e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 2 Sep 2023 07:29:26 -0400 Subject: [PATCH] fix: re-encode cid to be a webapp --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 36504c2..f1fc1a3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { encodeCid } from "@lumeweb/libportal"; +import { decodeCid, encodeCid } from "@lumeweb/libportal"; import { BOOTSTRAP_NODES, CID_HASH_TYPES, @@ -18,6 +18,7 @@ import fromAsync from "array-from-async"; import * as util from "util"; import { + CID, concatBytes, hexToBytes, loginActivePortals, @@ -124,12 +125,15 @@ processedFiles const serializedMetadata = pack(metadata); -const [cid, err] = await uploadObject(serializedMetadata); +let [cid, err] = await uploadObject(serializedMetadata); if (err) { console.error("Failed to publish: ", err); process.exit(1); } +cid = decodeCid(cid) as CID; +cid = encodeCid(cid.hash, cid.size, CID_TYPES.METADATA_WEBAPP); + console.log( util.format("%s: %s", chalk.green("Web App successfully published"), cid), );