Skip to content

Commit

Permalink
fix: handle async digests in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
tabcat committed Jun 12, 2023
1 parent 3a5e27e commit 1495f6a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/dcid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CID> {
const digest = await sha256.digest(routingKey(cid))

const dcid = CID.create(1, raw.code, digest)

Expand Down

0 comments on commit 1495f6a

Please # to comment.