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

[feat] Wire up create font project submit button to the backend and smart contract apis #11

Merged
merged 5 commits into from
Jan 6, 2023

Conversation

jsanchez034
Copy link
Contributor

This change wires up the create font project submit button to the backend and smart contract apis so that the create font project wizard works end to end. The following changes where made as part of this work...

  • Create a generic /api/upload-metadata endpoint for uploading smart contract entity metadata to IPFS using Infura IPFS node
  • Create the createIPFontProject client api util function which takes care of making backend calls to upload font files and font project metadata json to IPFS along with making the createFontProject in our smart contract

After this change all metadata json uploads will be done through our Infura IPFS node and actual font files will be uploaded to IPFS using web3.storage. web3.storage does not pin our metadata files quick enough for our graph subgraph to pick up the files during indexing leading to null data in our subgraph queries. Thanks @hyperalchemy for the heads up on this 🙌 😃

@vercel
Copy link

vercel bot commented Jan 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
app-interplanetaryfonts ✅ Ready (Inspect) Visit Preview Jan 6, 2023 at 4:07AM (UTC)

@jsanchez034 jsanchez034 requested review from miglconts, eduairet, hyperalchemy and bomanaps and removed request for miglconts and eduairet January 5, 2023 18:30
Copy link
Member

@eduairet eduairet left a comment

Choose a reason for hiding this comment

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

Awesome as always JP, reading your code is like going to school, a lot of learning, you really are a master of your craft!

} catch(err) {
console.log(err);
}
}
Copy link
Member

@eduairet eduairet Jan 6, 2023

Choose a reason for hiding this comment

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

I'll take this as example for the user :) Does make sense to have these files:

  • createIPFontsUser.js
  • editIPFontsUser.js
  • createLensUser.js (just in testnet)
  • editLensUser.js
    And condition them according to how the user has been authenticated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice yeah makes sense 😃

functionName: 'addressToUser',
args: [lensAddress]
});
const { createdAt } = await getIPFontsUser(address);

const isRegistered = !ethers.BigNumber.from(createdAt).isZero;

Copy link
Member

Choose a reason for hiding this comment

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

This file is related to the part I'm testing, didn't modify it (but I used parts of it) to avoid merging stashing, but my plan is to refactor some of the logic I'm using in the form here, does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool yeah makes sense to me 👍


export default function Submit() {
const { activeStepIndex, setActiveStepIndex, formData, setFormData } =
useContext(FormContext);
const { address, isConnected } = useAccount();
Copy link
Member

Choose a reason for hiding this comment

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

Haven't seen this before, looks smart!

perCharacterMintPrice: formData.setPrice,
mintLimit: formData.minLimit
});
}
Copy link
Member

Choose a reason for hiding this comment

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

This file really got cleaned 💯 sweet!

return res.status(401).json({ message: 'You have to sign-in first' });
}

return await storeFontMetadata(req, res);
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about making a generic storeMetadata method instead storeFontMetadata and using it for both, lens and user, maybe add a string parameter that makes custom messages "Error uploading ${type} metadata"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yeah good call 👍 Let me update in a follow up PR. The type variable could be a param passed in the request body

});

return result.cid.toString();
}
Copy link
Member

Choose a reason for hiding this comment

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

Already used this file for the user :) thanks a lot JP

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.

None yet

2 participants