diff --git a/src/components/object-info/ObjectInfo.stories.tsx b/src/components/object-info/ObjectInfo.stories.tsx
index 85a27dc..2eb2829 100644
--- a/src/components/object-info/ObjectInfo.stories.tsx
+++ b/src/components/object-info/ObjectInfo.stories.tsx
@@ -75,3 +75,23 @@ export const CidV0DagPb1240Links = () => (
CidV0DagPb1240Links.story = {
name: 'cid v0 dag-pb 1240 links...'
}
+
+export const identityCID = () => (
+
+)
+identityCID.story = {
+ name: 'identity CID'
+}
+
diff --git a/src/lib/hash-importer.ts b/src/lib/hash-importer.ts
index 1b11d08..b7cace0 100644
--- a/src/lib/hash-importer.ts
+++ b/src/lib/hash-importer.ts
@@ -1,11 +1,13 @@
/* global globalThis */
import { sha3512, keccak256 } from '@multiformats/sha3'
import { type Hasher, from } from 'multiformats/hashes/hasher'
+import { identity } from 'multiformats/hashes/identity'
import * as sha2 from 'multiformats/hashes/sha2'
// #WhenAddingNewHasher
export type SupportedHashers = typeof sha2.sha256 |
typeof sha2.sha512 |
+ Hasher<'identity', 0x0> |
Hasher<'keccak-256', 27> |
Hasher<'sha1', 17> |
Hasher<'blake2b-256', 0xb220> |
@@ -39,6 +41,11 @@ function getBoundHasher (hasher: T): T {
export async function getHasherForCode (code: number): Promise {
// #WhenAddingNewHasher
switch (code) {
+ case identity.code:
+ return getBoundHasher({
+ ...identity,
+ name: 'identity' // multiformats/hashes/identity doesn't export a proper Hasher type. See https://github.com/multiformats/js-multiformats/issues/313
+ })
case sha2.sha256.code:
return getBoundHasher(sha2.sha256)
case sha2.sha512.code:
diff --git a/test/e2e/edge-cases.test.ts b/test/e2e/edge-cases.test.ts
index 3c6974c..695d35f 100644
--- a/test/e2e/edge-cases.test.ts
+++ b/test/e2e/edge-cases.test.ts
@@ -36,4 +36,19 @@ test.describe('edge-cases', () => {
type: 'dag-pb'
})
})
+
+ test('identity CIDs render object info properly', async ({ page }) => {
+ // Test for https://github.com/ipfs/ipld-explorer-components/issues/464
+ const cid = 'bafkqaddjnzzxazldoqwxizltoq'
+
+ await page.goto('/#/explore/bafkqaddjnzzxazldoqwxizltoq')
+
+ await testExploredCid({
+ fillOutForm: false,
+ page,
+ cid,
+ humanReadableCID: 'base32 - cidv1 - raw - identity~96~696E73706563742D74657374',
+ type: 'raw'
+ })
+ })
})