feat: store metadata in IPLD CBOR format #50
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a
storeMetadata
method that allows for storing NFT metadata encoded using IPLD CBOR.It takes an
Object
- the metadata to persist. It recursively inspects the object to see if there are anyFile
s orBlob
s and when it find them it callsstoreBlob
/storeDirectory
and replaces them with a CID.The result is an object that we can pass to
js-dag-cbor
for encoding.I need to figure out how to store the encoded data. I've just passed it to
storeBlob
, which gives us back a CID with the RAW codec (since it's small enough and we specify v1 CIDs, giving us raw leaves). In the code I'm taking this RAW CID and re-encoding it to be CBOR. I thought this would work but it looks like the blockstore is still keyed on CID not multihash...The plan was to then be able to view this on the gateway: ipfs/kubo#8037
I'm using this code to test (runnable in Node.js):