Hello, I try to write a new IPLD structure with js-ipfs (compiling code for in the browser) . First I make a new node with ipfs.object.new and the template ‘unixfs-dir’. Than I try to add something to the dag by using ipfs.object.patch.addLink
But it seems to get stuck in this patch step.
My code is:
const cleannode = await ipfs.object.new({template: 'unixfs-dir'}) //(een leeg object.put wordt gezien als group en kan niet worden gebruikt daarom object.new)
const hashcleannode = (cleannode.toString())
const hashcleannodep = CID.parse(hashcleannode)
log('hash of clean node: '+hashcleannode)
log('hash of clean node after parse: '+hashcleannodep)
//logs:
//hash of clean node after parse: QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
const encoder = new TextEncoder()
const decoder = new TextDecoder()
const addOptions = { pin: true }
var { cid } = await ipfs.add(encoder.encode('hello ipld'), addOptions)
for await (const chunk of ipfs.cat(cid)) {
const addnode = (decoder.decode(chunk))
const hashaddnode = (cid.toString())
console.log ('what is in the node to be patched: '+addnode)
console.log ('the hash: '+hashaddnode)
//logs:
//what is in the node to be patched: hello ipld
//the hash: Qmb6ECa7a72waFreKRxGk3S6dsm6XHaoWdTpKoxYqba24o
const hey = {
name: hashaddnode,
size: 37,
cid: CID.parse(hashaddnode)
}
const patchednode = await ipfs.object.patch.addLink(hashcleannodep, hey)
const hashpatchednode = (patchednode.toString())
console.log ('new patched node: '+hashpatchednode)
}
//logs:
//Uncaught (in promise) TypeError: Invalid DAG-PB form (extraneous properties on link object)
I hope anyone can help,