dcgtc / dgrants

Decentralized Grant platform that implements quadratic funding.
GNU Affero General Public License v3.0
84 stars 39 forks source link

Decouple MetaPtr logic from IPFS Utils #558

Open apbendi opened 2 years ago

apbendi commented 2 years ago

The functions in the ipfs file should not be aware of MetaPtr's at all. By the time a function related to IPFS is called, we should have already confirmed that the protocol used is IPFS, and should be dealing only with CIDs at this point.

This implies a new utility file is warranted, perhaps utils/data/metaPtrs.ts or similar. Functions in this file should allow uploading and fetching MetaPtr's. Inside these utility functions, we should detect the protocol, then curry the pointer off to the appropriate method to fetch/upload the data for the protocol in question. Currently, the only supported protocols should be 0 (return null on fetch, no-op on upload) or 1 for IPFS, which should pull out the CID and pass it to the aforementioned IPFS utils. Any other protocol ID should throw.

Up a level from this function, in the UI logic inside the app, we should catch if the metaPtr fetch util function throws and gracefully degrade by showing the placeholder image.

jjwoz commented 2 years ago

@apbendi because I was bored πŸ˜† !

apbendi commented 2 years ago

Sorry @jjwoz not sure I follow?

mds1 commented 2 years ago

@apbendi During standup you said if someone is bored they can take this issue since it's not urgent haha 😜

jjwoz commented 2 years ago

@apbendi what @mds1 said!

thelostone-mc commented 2 years ago

LOL this is my fav issue thread till date on dgrants <3

apbendi commented 2 years ago

lol got itβ€” I am smort