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

[question] How to handle contract grc20 treasury ? #634

Open
albttx opened this issue Mar 22, 2023 · 3 comments
Open

[question] How to handle contract grc20 treasury ? #634

albttx opened this issue Mar 22, 2023 · 3 comments
Labels
❓ question Questions about Gno

Comments

@albttx
Copy link
Member

albttx commented Mar 22, 2023

Hey, i'm currently working on a Merkle Airdrop realm, and i'm facing an implementation decision, and i'd love to have your inputs

context: i developed:

  • p/demo/airdrop package to create easily merkle airdrops
  • r/demo/foo20airdrop airdrop realm for r/demo/foo20

In my first implementation, the struct MerkleAirdrop contained a token *grc.AdminToken, but i believe it's a security issue, and i have updated to a grc20.IGRC

So when i call p/demo/airdrop.MerkleAirdrop.Claim() i need to call the GRC20 Transfer or TransferFrom function, but the issue is that the spender is std.GetOrigCaller(), which lead to an allowance error.

i would need the spender to be the contract address (std.GetOrigPkgAddr())

I see multiple solutions to that (not always good)

  1. Set an foo20.Approve to all airdroped users, IMHO: non-sense
  2. Add a getter like foo20.GetAdmin with a whitelist of address to access the *AdminToken IMHO: not good for security reasons
  3. Update std.GetOrigCaller() to a new system like std.GetCallers() and have an array of callers (when a contract call a contract that call a contract ...) to be able to check all allowance, or just std.GetLastCaller?
  4. Have a solution to change the Caller from the contract as the contractAddr, like the test function std.TestSetOrigCaller(std.GetOrigPkgAddr())
  5. Use a Banker system for ERC20? Banker are for coins only, not tokens right ?

Or do you have another idea ? Am i missing something ?

@albttx albttx added the ❓ question Questions about Gno label Mar 22, 2023
@wwqiu
Copy link
Contributor

wwqiu commented Mar 23, 2023

Maybe this will help you. #473 #335

@moul
Copy link
Member

moul commented Apr 19, 2023

Related with #757, #683

@jaekwon
Copy link
Contributor

jaekwon commented Apr 20, 2023

Can you show some code links so I know what to look at?

We will be implementing a "GetRealmCaller" which gets the last realm that ultimately called the current function. This function should generally be used, (instead of "GetOrigCaller" which is only the tx signer).

Banker could be used, but we would have to figure out coin issuance management at the SDK banker level. So I guess, not at first. First we can implement a pure Gno one to get the interfaces right.

Have a solution to change the Caller from the contract as the contractAddr, like the test function std.TestSetOrigCaller(std.GetOrigPkgAddr())

Only for testing, we can't support that in production without opening a can of worms we prob don't want.

Use a Banker system for ERC20? Banker are for coins only, not tokens right ?

What's the difference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Questions about Gno
Projects
Status: 🌟 Wanted for Launch
Development

No branches or pull requests

5 participants