ceramicnetwork / ceramicnetwork/js-ceramic
In sample core code : Ceramic.create is not a function ?
- Dominant language
- TypeScript
- Stars
- 423
- Forks
- 126
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The code described here leads to several errors :
https://developers.ceramic.network/build/installation/
https://github.com/ceramicnetwork/js-ceramic/tree/develop/packages/core
**To Reproduce**
With the code given, after packages are installed :
````
// package.json
{
"name": "ceramic-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@ceramicnetwork/core": "^0.19.7",
"dag-jose": "^0.3.0",
"ipfs-core": "^0.5.4",
"multiformats": "^4.6.2"
}
}
````
````
// index.js
import Ceramic from '@ceramicnetwork/core'
import IPFS from 'ipfs'
import dagJose from 'dag-jose'
import basicsImport from 'multiformats/cjs/src/basics-import.js'
import legacy from 'multiformats/cjs/src/legacy.js'
basicsImport.multicodec.add(dagJose)
const format = legacy(basicsImport, dagJose.name)
const ipfs = Ipfs.create({
ipld: { formats: [format] },
})
const ceramic = await Ceramic.create(ipfs, config)
````
Several errors with this code occur after `node index.js` (v15.9.0) :
- the multiformat import return : `'./cjs/src/basics-import.js' is not defined`, same for `legacy`
- the ipfs import is not found (should be ipfs-core)
- the ceramiq config is not defined (not a big deal)
I've therefore modified ìndex.js` (according this [comment](https://github.com/ipfs/js-ipfs/issues/3586#issuecomment-796178453) dealing with multiformat ) :
````
import Ceramic from '@ceramicnetwork/core'
import IPFS from 'ipfs-core'
import dagJose from 'dag-jose'
import { sha256 } from 'multiformats/hashes/sha2'
import legacy from 'multiformats/legacy'
const hasher = {}
hasher[sha256.code] = sha256
const format = legacy(dagJose, {hashes: hasher})
const ipfs = IPFS.create({
ipld: { formats: [format] },
})
Ceramic.create(ipfs, {}).then((c) => {
console.info(c);
})
````
Which returns a `TypeError: Ceramic.create is not a function`
May be the example code should be modified/improved to help newcomers start with ceramiq, with a step by step sample.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.