-
Notifications
You must be signed in to change notification settings - Fork 159
Upgrade guide from Helia 6.0.0 to Helia 7.0.0
Please see the release notes for the full run-down of all the new features and bug fixes in helia@7.x.x.
The createHelia function used to return a promise of a running node, now it returns the node in a stopped state and the user must await the result of the .start() method.
This gives greater control of the node's lifecycle.
Before
import { createHelia } from 'helia'
const helia = await createHelia()
// do Helia thingsAfter
import { createHelia } from 'helia'
const helia = await createHelia().start()
// do Helia thingssecp256k1 is a style of PeerId used by the Ethereum network. It is not used by IPFS so it has been removed from the default config.
If you require secp256k1 it can be loaded at run time by specifying a cryptoLoader function:
import { createHelia } from 'helia'
import type { Crypto } from '@helia/interface'
import secp256k1Impl from 'my-secp256k1-module'
const node = await createHelia({
loadCrypto: (codeOrName: number | string, options?: AbortOptions): Crypto {
if (codeOrName === 'secp256k1' || codeOrName === 2) {
return secp256k1Impl
}
throw new Error(`Unknown crypto scheme ${codeOrName}`)
}
})The @helia/http module used to export a factory function that could be used to create a Helia node that used HTTP routers/block brokers.
Now it exports a function that can configure an existing node with the same functionality.
Before
import { createHeliaHTTP } from '@helia/http'
const helia = await createHeliaHTTP()
// do Helia thingsAfter
import { createHelia } from 'helia'
import { withHTTP } from '@helia/http'
const helia = await withHTTP(createHelia()).start()
// do Helia thingsIt's now possible to configure a Helia node that does not use libp2p at all, instead using HTTP routers/block brokers exclusively.
Previously a minimal libp2p node would still be present to satisfy the API requirements and provide a keychain for use with IPNS, etc, but these have now been removed.
A Helia-specific keychain is now present that works with WebCrypto based RSA/Ed25519 keys, but heavyweight libp2p dependencies are no longer used for this.
Before
import { libp2pDefaults } from 'helia'
import type { DefaultLibp2pServices } from 'helia'After
import { libp2pDefaults } from '@helia/libp2p'
import type { DefaultLibp2pServices } from '@helia/libp2p'Instead pass it to the withLibp2p function:
Before
import { createHelia } from 'helia'
const node = await createHelia({
libp2p: {
// ...libp2p args
}
})After
Note that we switch to createHeliaLight to pass libp2p args, createHelia will supply the default libp2p config.
import { createHeliaLight } from 'helia'
import { withLibp2p } from '@helia/libp2p'
const node = await withLibp2p(createHeliaLight(), {
// ...libp2p args
}).start()Instead of using PeerId instances, use CIDs with the libp2p-key codec instead.