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

chore(zkgm): virtualize tokenfactory #3631

Merged
merged 19 commits into from
Jan 31, 2025
Merged

chore(zkgm): virtualize tokenfactory #3631

merged 19 commits into from
Jan 31, 2025

Conversation

aeryz
Copy link
Contributor

@aeryz aeryz commented Jan 24, 2025

Intended behaviour:

  1. transfer:
    a. Minter is TF, sent wrapped token: Call TokenFactoryMsg::BurnFrom -> tf minter checks whether the funds are provided and burns.
    b. Minter is CW20, sent wrapped token: Call TokenFactoryMsg::BurnFrom -> cw20 minter just burns the tokens.
    c. Minter is TF, sent native token: Call LocalTokenMsg::TakeFunds -> tf minter checks whether the funds are provided and noops.
    d. Minter is CW20, sent CW20: Call LocalTokenMsg::TakeFunds -> cw20 minter calls CW20::TransferFrom
    e. Minter is CW20, sent native token: Call LocalTokenMsg::TakeFunds -> cw20 minter sees funds are provided, saves the given denom as native and noops.

  2. recv_transfer:
    a. Minter is TF: Nothing fancy, just delegate the messages to TF.
    b. Minter is CW20, need to create a wrapped token:
    1. Call TokenFactoryMsg::CreateDenom: Since CW20 doesn't have the token info yet, it just noops.
    2. Call TokenFactoryMsg::SetDenomMetadata: CW20 now has the token info, so it instantiates a contract. To save the denom to the denom to addr mapping, it saves the denom to DENOM_TO_BE_STORED. NOTE THAT THIS IS A SINGLE VALUE STORAGE.
    3. Step 2 results in reply if success, in the reply, read DENOM_TO_BE_STORED and save denom and addr to DENOM_TO_ADDR mapping.
    4. Call TokenFactoryMsg::MintTokens: Read from DENOM_TO_ADDR mapping and mint the tokens.

    c. Minter is CW20, need to unescrow local token: CW20 just calls CW20::Transfer
    d. Minter is CW20, need to unescrow native token: CW20 sees that the given denom previously been saved as a native token. So it calls BankMsg::Send.

Copy link

vercel bot commented Jan 24, 2025

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
site ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2025 4:07pm

@aeryz aeryz force-pushed the virtualize-tokenfactory branch 2 times, most recently from a628f13 to d9567de Compare January 29, 2025 06:20
@aeryz aeryz marked this pull request as ready for review January 29, 2025 06:23
cosmwasm/cw20-token-minter/src/contract.rs Outdated Show resolved Hide resolved
cosmwasm/cw20-token-minter/src/state.rs Outdated Show resolved Hide resolved
cosmwasm/cw20-token-minter/src/error.rs Outdated Show resolved Hide resolved
Copy link

Docs 🤌

✨ Deployment complete! Take a peek over at https://0c5d5696.docs-ajn.pages.dev
✨ Deployment alias URL: https://head.docs-ajn.pages.dev


aeryz and others added 17 commits January 31, 2025 18:53
Signed-off-by: aeryz <[email protected]>
@aeryz aeryz force-pushed the virtualize-tokenfactory branch from bd2983a to 77f9910 Compare January 31, 2025 15:53
Copy link
Contributor

@benluelo benluelo left a comment

Choose a reason for hiding this comment

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

cool

@aeryz aeryz merged commit 90601ec into main Jan 31, 2025
104 checks passed
@aeryz aeryz deleted the virtualize-tokenfactory branch January 31, 2025 16:27
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