-
Notifications
You must be signed in to change notification settings - Fork 118
Upgrade guide from Helia 3.0.0 to Helia 4.0.0
Please see the release notes for the full run-down of all the new features and bug fixes in helia@4.x.x.
### HTTP
Helia@4.0.0 aims to increase the viability of IPFS in web browsers by leaning heavily on Trustless Gateways for block retrieval and Delegated HTTP Routers for other operations such as resolving block providers and IPNS.
A new @helia/http
module is available that implements the Helia API defined in @helia/interface
meaning it is compatible with the full @helia/*
ecosystem of helper modules.
import { createHeliaHTTP } from '@helia/http'
import { unixfs } from '@helia/unixfs'
import { CID } from 'multiformats/cid'
const cid = CID.parse('QmFoo')
const node = await createHeliaHTTP()
const fs = unixfs(node)
// do UnixFS things
for await (const buf of fs.cat(cid)) {
// ...do something with buf
}
@helia/http
concentrates on using HTTP exclusively, helia
takes a more varied approach and uses libp2p for a fully P2P application.
The .libp2p
property has been removed from the Helia API but it is still present on the return type of the createHelia
function exported from the helia
module.
If you are using the return types of this function there is nothing to do, otherwise you will have to update your code to use the types from helia
instead of @helia/interface
, if you depend on accessing the .libp2p
property in your code.
### Routing
Because the .libp2p
property has been removed from the Helia API a new .routing
property has been added to enable use of Delegated HTTP Routers to perform what were previously content and peer routing operations in a libp2p-agnostic way.
Before
const peerId = peerIdFromString('123Foo...')
const peerInfo = await helia.libp2p.peerRouting.findPeer(peerId)
After
const peerId = peerIdFromString('123Foo...')
const peerInfo = await helia.routing.findPeer(peerId)
@helia/ipns
has been updated to use the new .routing
property on the Helia API by default so there's no need to configure a separate libp2p router any more, instead it will use whatever has been configured on the passed Helia node.
Before
const { createHelia } from 'helia'
const { ipns } from '@helia/ipns'
const { libp2p } from '@helia/ipns/routers'
const node = await createHelia()
const name = ipns(helia, {
routers: [
libp2p(helia)
]
})
const peerId = peerIdFromString('123Foo...')
const cid = await name.resolve(peerId)
After
const { createHelia } from 'helia'
const { ipns } from '@helia/ipns'
const node = await createHelia()
const name = ipns(helia)
const peerId = peerIdFromString('123Foo...')
const cid = await name.resolve(peerId)