Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small updates to README to get demo to work #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DougAnderson444
Copy link

Cool library, just need some readme tweaks for those trying to follow along:

Chg blockcodec-to-ipld-format to ipld-format-to-blockcodec to get it to work properly
Chg formats to codecs as per docs

Cool library, just need some readme tweaks for those trying to follow along:

Chg `blockcodec-to-ipld-format` to `ipld-format-to-blockcodec`
Chg `formats` to `codecs`
@rvagg
Copy link
Contributor

rvagg commented Oct 19, 2021

I'm pretty sure this is not correct, you're converting it the wrong way. But I think what you're encountering is that the lastest js-ipfs now uses the new BlockCodec style of codecs natively so I don't believe you need the adapter now. Try getting rid of the conversion code entirely and pass [dagJose] in to the codecs option and see if that works for you. If so, maybe update the PR to remove references to the legacy conversion entirely.

@DougAnderson444
Copy link
Author

Thanks Rod! Yep, what you suggested totally works. Don't even need to load the codecs, looks like Multicodecs auto loads that for us?

import * as dagJose from 'dag-jose';

let ipfs = await createIpfs();

const cid = await this.ipfs.dag.put(jwe, {
		format: dagJose.codec,
		hashAlg: 'sha2-256'
	});

I'll modify the PR to just remove that config code that doesn't work anymore.

Changes based on Rod's conversation
@rvagg
Copy link
Contributor

rvagg commented Oct 20, 2021

Yeah, blockcodec-to-ipld-format and ipld-format-to-blockcodec were for bridging old and new codec formats, but we've since entirely deprecated the old codec formats, even in js-ipfs, and just use the new ones now which follow the js-multiformats BlockCodec pattern. So 🥳 .

@@ -114,7 +114,7 @@ _A plain IPLD (without IPFS, for cases where you are managing the block store) v
```js
// IPLD & IPFS
import { create as createIpfs } from 'ipfs'
import { convert as toLegacyIpld } from 'blockcodec-to-ipld-format'
import { convert } from 'ipld-format-to-blockcodec';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { convert } from 'ipld-format-to-blockcodec';

Comment on lines +108 to 109
When using DAG-JOSE (for JWE or JWS) with js-IPFS, you will need to convert it from a raw multiformats style codec to a legacy IPLD codec using [ipld-format-to-blockcodec](https://github.com/ipld/js-ipld-format-to-blockcodec).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When using DAG-JOSE (for JWE or JWS) with js-IPFS, you will need to convert it from a raw multiformats style codec to a legacy IPLD codec using [ipld-format-to-blockcodec](https://github.com/ipld/js-ipld-format-to-blockcodec).

@rvagg
Copy link
Contributor

rvagg commented Oct 20, 2021

Also note that even this change is going to be breaking soon thanks to a change in the DAG API in go-ipfs v0.10 where format is no longer accepted as an argument, you can't run this code against a go-ipfs v0.10 backend with the JS ipfs http client. That should get fixed via ipfs/js-ipfs#3917. Although this current pattern could be addressed by using the BLOCK API instead of the DAG and just feeding it the raw block data, maybe I should have written the example that way instead..

@DougAnderson444
Copy link
Author

Perhaps it should wait until #3917 is merged then? My whole point with this note was to bring the README up to speed for anyone else looking at this so they can understand what's going on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants