-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support parsing base32 and base36 libp2p-key CIDs in peerIdFromString #3042
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the utility functions exported by this module, if I have a string and I want a PeerId it would not be obvious to me whether to call peerIdFromString
or this new getPeerId
function.
Given that the spec mentions base32 (not base36 as in the comment here) encoded libp2p-key
CIDs as a canonical string encoding, let's check form that prefix in peerIdFromString
instead.
Do you mean checking the multibase prefix in the string for Regarding base36 cids, I realise it's not in the peerIDs spec, but it's the standard string form for ipns names. Do you feel strongly about not including it here? |
Yes, but with few more characters to include the
Groan. The usual reason not to include lots of different base encoder/decoders is because they bloat bundle sizes but I suppose here we have a dependency on the CID class so base36 is in there anyway. |
This turned out to be rather confusing. I took a look at the string encoding of cids and I'm not sure I got the right prefix characters for base36/base32 CID encoded public keys. |
Title
Given the prevalence of both CID encoded PeerIDs and base58mh encoded ones, I found myself defining this function in multiple places.
This PR introduces this as a helper (as was supported in an earlier version of js-libp2p)
Notes & open questions
Change checklist