From 1495f6abda16311365f4a81af5c3df1dc17a3e2f Mon Sep 17 00:00:00 2001 From: tabcat Date: Mon, 12 Jun 2023 09:28:00 -0500 Subject: [PATCH] fix: handle async digests in browser --- src/dcid.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/dcid.ts b/src/dcid.ts index 03cd5ef..f9ce9e4 100644 --- a/src/dcid.ts +++ b/src/dcid.ts @@ -11,12 +11,8 @@ const DCOI_KEY = fromString('/dcoi/') const routingKey = (cid: CID): Uint8Array => concat([DCOI_KEY, cid.multihash.bytes]) // Use CID as Routing Key to make APIs easier to work with -export function toDcid (cid: CID): CID { - const digest = sha256.digest(routingKey(cid)) - - if (digest instanceof Promise) { - throw new Error('unexpected asynchronous digest') - } +export async function toDcid (cid: CID): Promise { + const digest = await sha256.digest(routingKey(cid)) const dcid = CID.create(1, raw.code, digest)