Skip to content

feat: add erc20 sponsorship card #1631

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

blakecduncan
Copy link
Collaborator

@blakecduncan blakecduncan commented May 20, 2025

Pull Request Checklist


PR-Codex overview

This PR focuses on enhancing the Erc20 modal functionality, including new ERC20 minting features and improved UI components across the application.

Detailed summary

  • Added Erc20Modal export in examples/ui-demo/src/components/modals/Erc20/index.ts.
  • Updated exports in examples/ui-demo/src/components/modals/index.ts.
  • Introduced constants for demo addresses in examples/ui-demo/src/utils/constants.ts.
  • Enhanced MintCard and Badge components with additional properties.
  • Modified the Viewport styling in examples/ui-demo/src/app/page.tsx.
  • Upgraded dependencies in examples/ui-demo/package.json.
  • Created a new BagIcon component in examples/ui-demo/src/components/modals/Erc20/BagIcon.tsx.
  • Implemented ERC20 minting logic in examples/ui-demo/src/hooks/useMintErc20.ts.
  • Added utility functions for NFT minting in examples/ui-demo/src/components/modals/Erc20/utils.ts.
  • Expanded Erc20SponsorshipCard to include NFT minting features.
  • Updated modal behavior and network fee estimation in examples/ui-demo/src/components/modals/Erc20/Erc20Modal.tsx.

The following files were skipped due to too many changes: yarn.lock, examples/ui-demo/contracts/broadcast/DeployNFTUSDCMintable.s.sol/421614/run-1747861796.json, examples/ui-demo/contracts/broadcast/DeployNFTUSDCMintable.s.sol/84532/run-1747861828.json

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented May 20, 2025

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

Name Status Preview Comments Updated (UTC)
aa-sdk-ui-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 1:55pm

Copy link

graphite-app bot commented May 20, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@blakecduncan blakecduncan changed the title Blake/erc20 sponsorship card feat: add erc20 sponsorship card May 20, 2025
Copy link

github-actions bot commented May 20, 2025

🌿 Documentation Preview

Name Status Preview Updated (UTC)
Alchemy Docs ✅ Ready 🔗 Visit Preview May 21, 2025, 9:20 PM

@github-actions github-actions bot temporarily deployed to docs-preview May 20, 2025 15:41 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 20, 2025 16:45 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 20, 2025 16:55 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 21, 2025 14:37 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 21, 2025 20:54 Inactive

const queryKey = useMemo(
() => ["erc20Balance", tokenAddress, accountAddress, chain?.id, rpcUrl],
[tokenAddress, accountAddress, chain, rpcUrl, params.accountMode]
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ [eslint] <react-hooks/exhaustive-deps> reported by reviewdog 🐶
React Hook useMemo has an unnecessary dependency: 'params.accountMode'. Either exclude it or remove the dependency array.

@github-actions github-actions bot temporarily deployed to docs-preview May 21, 2025 21:00 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 21, 2025 21:19 Inactive
constructor(string memory name, string memory symbol)
ERC20(name, symbol)
{
_decimals = 6;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added this because I need an erc20 token that has 6 decimals so that our policy can accurately price the token with the priceReferenceTokenAddress set to usdc on mainnet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, I didn't just edit the other erc20 contract we have to accept a decimal parameter because I didn't want to mess up the deployment address of that contract. Not sure if that matters but did that just in case

}

function mintTo(address recipient) public returns (uint256) {
if (!usdcToken.transferFrom(msg.sender, address(this), mintPrice)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

charging 1 of our test token to mint the nft

@@ -45,7 +45,7 @@ export default function Home() {
<PreviewNav showCode={showCode} setShowCode={setShowCode} />
<PreviewWrapper showCode={showCode} />
{/* Toast viewport */}
<Viewport className="absolute lg:bottom-10 lg:right-10 bottom-10 right-1/2 translate-x-1/2 lg:translate-x-0 z-50 outline-none" />
<Viewport className="fixed lg:bottom-10 lg:right-10 bottom-10 right-1/2 translate-x-1/2 lg:translate-x-0 z-[1000000] outline-none" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like the high z index but I needed to do this so the toast shows up above the modal overlay

{/* 1) Warning */}
<div className="flex flex-col gap-4 pb-2">
<div className="h-12">
<Transition
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added Transtion from headless ui to help with the animation. Let me know if we don't want to use this but it definitely cleaned up some of the code

},
});

const estimateFee = async (userOperations: UserOperationCall[]) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we would like to have a function like this in the sdk. I'd like to get some feedback on this. The gas estimates are pretty accurate but I kinda figured this out from looking through other code and chatgpt. So would like another set of eyes

Here is the asana ticket

Fun fact: 7702 mode is significantly cheaper for the nft mint

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, this reverts if the account isn't funded with enough erc20 tokens for the txn. I'm not sure if there is a way around that

>({
queryKey: ["ethUsdPrice", ETH_USD_PRICE_FEED_ADDRESS, mainnet.id],
queryFn: async () => {
const [roundData, feedDecimals] = await Promise.all([
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getting the price from chainlink so that I can show an accurate fee in usd terms

@@ -52,6 +65,11 @@ export const useModularAccountV2Client = ({
// Must destructure the inner fields to use as dependencies in the useEffect hook, otherwise the object reference will be compared and cause an infinite render loop
const { key, entityId, accountAddress } = localKeyOverride ?? {};

useEffect(() => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I needed this because when I switched between modes from 7702 to default, the client wouldn't update when trying to use the erc20 modal

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.

2 participants