-
Notifications
You must be signed in to change notification settings - Fork 126
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
Improve ipfs util #440
Improve ipfs util #440
Conversation
- Use `is-ipfs` library to validate IPFS CID in provided uri/url - Handle IPFS URIs with folder/directory path structure - Handle http urls (many contracts use direct gateway urls in their contracts). And convert them to provided gateway - Use provided gateway on all required fields (previously metadata fetching was not using gateway) - Add more default gateway options, as ipfs.io fails often, so it is easier to test/develop before getting dedicated gateway
}, | ||
{ | ||
protocol: 'https', | ||
hostname: 'nftstorage.link', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's dope. Teach me a bit, how do they work together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly telling nextjs to allow to load images from these domains in nextjs NextImage component
@@ -1,18 +1,128 @@ | |||
import { cid } from 'is-ipfs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General thinking, I like a lot what's going on here.
Why some of these utility don't live in is-ipfs
or, do we see other libraries have some of those?
Or should any of those live inside OnchainKit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yuripetusko thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is-ipfs
is great, but it mostly just checks if url has ipfs, it doesn't have utils to replace gateway or add gateway and preserve the path etc. But regarding onchainkit I agree, I can create a similar PR there if this makes sense.
I actually have all of this code in a library already. Just need to add docs. Perhaps instead of having is-ipfs and all this code explicitly, our library will work? Otherwise I can just duplicate some of it in Onchainkit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's probably move part of it inside OnchainKit.
We can proabably create a new section called IPFS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok will do tomorrow. I'll close this PR then and later will create a new one where onchainkit utils are used
Hey @Yuripetusko 👋 |
The idea was to create a new one, more generic without any specific code that I had there that I copied over from our ipfs-utils https://github.com/rmrk-team/rmrk-js/tree/main/packages/ipfs-utils unfortunately life and work happened and I couldn't find a time to do it since. |
What changed? Why?
is-ipfs
library to validate IPFS CID in provided uri/urlNotes to reviewers
How has it been tested?
yarn test
Fixes #441