@@ -11,6 +11,7 @@ A migration guide for refactoring your application code from libp2p `v1.0.0` to
11
11
- [ The ` createLibp2p ` function accepts a ` PrivateKey ` instead of a ` PeerId ` ] ( #the-createlibp2p-function-accepts-a-privatekey-instead-of-a-peerid )
12
12
- [ The ` @libp2p/keychain ` module operates on ` PrivateKey ` s instead of ` PeerId ` s] ( #the-libp2pkeychain-module-operates-on-privatekeys-instead-of-peerids )
13
13
- [ The ` @libp2p/peer-id-factory ` module has been removed] ( #the-libp2ppeer-id-factory-module-has-been-removed )
14
+ - [ ` peerIdFromString ` no longer accepts CID encoded PeerIDs] ( #peeridfromstring-no-longer-accepts-cid-encoded-peerids )
14
15
- [ The autodialer has been removed] ( #the-autodialer-has-been-removed )
15
16
- [ "Transient" connections have been renamed "limited"] ( #transient-connections-have-been-renamed-limited )
16
17
- [ The CustomEvent polyfill has been removed from ` @libp2p/interface ` ] ( #the-customevent-polyfill-has-been-removed-from-libp2pinterface )
@@ -251,6 +252,36 @@ const privateKey = await generateKeyPair('Ed25519')
251
252
const peerId = peerIdFromPrivateKey (privateKey )
252
253
```
253
254
255
+ ## ` peerIdFromString ` no longer accepts CID encoded PeerIDs
256
+
257
+ The ` peerIdFromString ` function used to be quite flexible in that it would attempt
258
+ to interpret multibase strings as either a multihash encoded PeerID or a CID.
259
+
260
+ As of
` @libp2p/[email protected] ` the method has been simplified to only accept
261
+ multibase strings containing a multihash encoded PeerID.
262
+
263
+ To read a PeerId from a string containing a CID, first parse the CID from the
264
+ string, then use the ` peerIdFromCID ` method.
265
+
266
+ ** Before**
267
+
268
+ ``` ts
269
+ import { peerIdFromString } from ' @libp2p/peer-id'
270
+
271
+ const peer = peerIdFromString (' k51qzi5uqu5dkwkqm42v9j9kqcam2jiuvloi16g72i4i4amoo2m8u3ol3mqu6s' )
272
+ ```
273
+
274
+ ** After**
275
+
276
+ ``` ts
277
+ import { peerIdFromCID } from ' @libp2p/peer-id'
278
+ import { CID } from ' multiformats/cid'
279
+
280
+ // CID encoded PeerID in base36
281
+ const cid = CID .parse (' k51qzi5uqu5dkwkqm42v9j9kqcam2jiuvloi16g72i4i4amoo2m8u3ol3mqu6s' )
282
+ const peer = peerIdFromCID (cid )
283
+ ```
284
+
254
285
## The autodialer has been removed
255
286
256
287
The libp2p autodialer was a component that attempted to ensure a minimum number
0 commit comments