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

Add options to configure IPFS gateway to use to fetch data #11

Merged
merged 13 commits into from
Nov 19, 2024

Conversation

mderriey
Copy link
Member

@mderriey mderriey commented Nov 18, 2024

Description of change

This adds options to CacheOnlyIPFS, PinataStorageWithCache, and PinataStorage to specify which IPFS gateway to use when fetching data.

Options include the base URL of the gateway (assuming the content can always be fetched at /ipfs/<cid>).

Pull-Request Checklist

  • Code is up-to-date with the main branch
  • npm run lint passes with this change
  • npm test passes with this change
  • npm run commitlint passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change

Please note that this repository uses conventional commits in combination with semantic-release to automate package publication. Therefore, your commit messages are critical, and the build process will lint them. If the build fails at the commitlint stage, please refer to this handy guide on how to update the commit messages

@mderriey mderriey marked this pull request as ready for review November 18, 2024 13:36

constructor(cache: ObjectCache, getFromIpfs?: boolean) {
constructor(cache: ObjectCache, ipfsGatewayOptions?: IPFSGatewayOptions) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a breaking change, so we should release as such.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed.

I'm not well-versed with the tooling around that, but saw after a quick look that the commit title feat!: <bla> (note the bang) should be recognised as one and trigger a major version bump.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately feat!: doesn't actually trigger a breaking change bump in the npm semantic release plugin.
You need to add a commit footer with the text "Breaking Change:", it's a pain!

Here's an example commit algorandfoundation/algokit-client-generator-ts@dd9d157

You may find it easy to squash the GitHub UI and add the breaking change info.

src/ipfs.ts Outdated

export function getCIDUrl(ipfsGatewayBaseUrl: URL, cid: string) {
const copy = new URL(ipfsGatewayBaseUrl.toString())
copy.pathname = `/ipfs/${cid}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not all gateways use this format, for example cloudflare used a subdomain.

I think it's probably ok to assume it's path based (not what cloudflare does), however I'd be inclined to require the full url minus the cid, so in the default value that'd be https://ipfs.algonode.dev/ipfs

Copy link
Member Author

Choose a reason for hiding this comment

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

Understood, thanks for the feedback, let me change that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 68bcaaa.

Copy link
Member

Choose a reason for hiding this comment

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

Cloudflare actually still worked with this format

@mderriey mderriey merged commit ce3051b into main Nov 19, 2024
1 check passed
@mderriey mderriey deleted the mderriey/add-options-to-configure-ipfs-gateway branch November 19, 2024 08:57
mderriey added a commit that referenced this pull request Nov 19, 2024
BREAKING CHANGE:
The `CacheOnlyIPFS` constructor allows specifying which IPFS gateway to use to fetch assets.
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.

3 participants