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

Allow IPFS URLs to Contain Path Elements #12

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

dysbulic
Copy link

@dan13ram, @Innkeeping & @dysbulic are in the process of developing dAcademy (source) which is an extension & revamping of the Quest Chains architecture.

For storage, we are using Storacha which is the successor to Web3.Storage. (It uses UCAN delegation to permission clients to directly upload to the service.)

The issue is that the artifacts it produces aren't simple CIDs. They include a file name, even for single resource uploads. So, the strings we are submitting when creating Chains & whatnot look like: ipfs://bafybeibydxuwx57bkertjywkshcikwodskt33pjc4rumnzhu4moirnjj5a/frontmatter.2024-12-04T20:33:13.156Z.json.

As it stands, Quest Chains URL parser assumes that the last element in the URL split by /s is the CID. This PR changes that behavior to instead strip off the protocol part of the URL and send the rest of it to ipfs.cat.

If the programmatic version of the command works the same as the CLI tool, ipfs.cat should correctly resolve the resource and download the correct file.

AssemblyScript is truly a horror to work with. 😹 I tried running the yarn deploy-local script, but I am getting a couple errors like:

ERROR AS100: Not implemented: Iterators

   for (let questerId of questChain.questers) {
    let hasCompleted = questChainCompletedByUser(
      questChain.id,
      questChain.totalQuestCount,
      questerId,
    );

    completed.set(questerId, hasCompleted);
  }
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 in src/mappings/helpers/status.ts(40,3)

That's not my code, and if iterators aren't allowed, I don't understand how this ever compiled.

Because of those errors we weren't able to verify that the code actually performs as desired. I'm about 90% sure it's fine, since I only changed what needed to be changed to fix the issue, but you never know. 🐞

@@ -1,5 +1,5 @@
export * from './constants';
export * from './ipfs';
export { Metadata } from './ipfs';
Copy link
Author

Choose a reason for hiding this comment

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

Barrel files that don't use named exports will break tree-shaking in bundlers.

};

return networkMap[network] || 'unknown';
if (network === 'mainnet') return '0x1';
Copy link
Author

Choose a reason for hiding this comment

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

It bitched alot about the eight different ways I tried to type the object literal & the AIs said they don't exist in AssemblyScript.

fetchMetadata,
getUser,
} from '../helpers';
import { ADDRESS_ZERO, removeFromArray, Metadata, getUser } from '../helpers';
Copy link
Author

Choose a reason for hiding this comment

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

Prettier squished this line.

Comment on lines +6 to +7
"@graphprotocol/graph-cli": "^0.91.1",
"@graphprotocol/graph-ts": "^0.36.0",
Copy link
Author

Choose a reason for hiding this comment

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

I updated these trying to get the yarn deploy-local task to run.

Copy link
Member

Choose a reason for hiding this comment

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

This repo is using really old versions of graphprotocol as you can see, so lot of things might break as you upgrade since they often introduce some breaking changes

Copy link
Author

Choose a reason for hiding this comment

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

If AssemblyScript doesn't support iterators, it seems like it never would have supported itertators. It'd be weird to remove support for something like that…

In any case, I replaced the iterators with a for loop & the AssemblyScript will now compile to WASM. I deployed the code to the Subgraph Studio & everything seems to work, if you'd like use it.

We're about to redeploy the contracts so the spurious entries will stop showing up in questchains.xyz.

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