Skip to content

Commit e70f3fe

Browse files
committedMar 25, 2022
Added IPNS support for ENS contenthash.

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎packages/providers/src.ts/base-provider.ts

+9
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,15 @@ export class Resolver implements EnsResolver {
640640
}
641641
}
642642

643+
// IPNS (CID: 1, Type: libp2p-key)
644+
const ipns = hexBytes.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);
645+
if (ipns) {
646+
const length = parseInt(ipns[3], 16);
647+
if (ipns[4].length === length * 2) {
648+
return "ipns:/\/" + Base58.encode("0x" + ipns[1]);
649+
}
650+
}
651+
643652
// Swarm (CID: 1, Type: swarm-manifest; hash/length hard-coded to keccak256/32)
644653
const swarm = hexBytes.match(/^0xe40101fa011b20([0-9a-f]*)$/)
645654
if (swarm) {

1 commit comments

Comments
 (1)

briansoule commented on Mar 27, 2022

@briansoule

🥳

Please sign in to comment.