Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit ea5a7f2

Browse files
lidelvmx
authored andcommitted
feat: support Base36
Context: multiformats/cid-utils-website#23 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
1 parent a61d15d commit ea5a7f2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"dependencies": {
3838
"buffer": "^5.5.0",
3939
"class-is": "^1.1.0",
40-
"multibase": "~0.7.0",
40+
"multibase": "^1.0.0",
4141
"multicodec": "^1.0.1",
4242
"multihashes": "~0.4.17"
4343
},

test/index.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ describe('CID', () => {
133133
expect(cid.toBaseEncodedString()).to.be.eql(cidStr)
134134
})
135135

136+
it('handles ED25519 PeerID as CID in Base36', () => {
137+
const peerIdStr = 'k51qzi5uqu5dj16qyiq0tajolkojyl9qdkr254920wxv7ghtuwcz593tp69z9m'
138+
139+
const cid = new CID(peerIdStr)
140+
141+
expect(cid).to.have.property('codec', 'libp2p-key')
142+
expect(cid).to.have.property('version', 1)
143+
expect(cid).to.have.property('multihash')
144+
expect(cid).to.have.property('multibaseName', 'base36')
145+
146+
expect(cid.toBaseEncodedString()).to.be.eql(peerIdStr)
147+
})
148+
136149
it('create by parts', () => {
137150
const cid = new CID(1, 'dag-cbor', hash)
138151

0 commit comments

Comments
 (0)