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

Implement Tokens to mint init parameter #27

Closed
ya7on opened this issue Jan 5, 2025 · 8 comments · Fixed by #30
Closed

Implement Tokens to mint init parameter #27

ya7on opened this issue Jan 5, 2025 · 8 comments · Fixed by #30
Assignees

Comments

@ya7on
Copy link
Member

ya7on commented Jan 5, 2025

Some other jetton implementations have initial "Tokens to mint" parameter. It allows mint tokens on jetton deploy phase.
I think we should implement that parameter and add it to JettonInit and if it's present, specified amount of tokens will be minted and transfered to owner account

@iamIcarus iamIcarus self-assigned this Jan 11, 2025
@iamIcarus
Copy link
Collaborator

i'm working on this at feature/mint-tokens-on-init , possible to have a quick look (if you have some free time) on why it fails to mint at JettonInit?

i have a test you can run npm run test tests/JettonInit and at the first test case it should try to init and mint 10 jettons. It looks like a gas issue , cant quite pinpoint why.

@ya7on
Copy link
Member Author

ya7on commented Jan 12, 2025

Hello @iamIcarus I looked at your code. My guess the issue is in multiple sends with SendRemainingValue mode. At first contract send toncoins at self.notify() and after that it trying to send more toncoins in self.mint()
I tried to comment notify line and tests passed.

Recently read Tact docs and find out about storageReserve parameter in BaseTrait. Maybe it could help with that. Tomorrow i can take a closer look.

@iamIcarus
Copy link
Collaborator

thank you for taking a look and for the pointers , much appreciated! I’ll look into storageReserve

@iamIcarus
Copy link
Collaborator

iamIcarus commented Jan 13, 2025

@ya7on what's your thoughts on this commit and the way gas is calculated?

@ya7on
Copy link
Member Author

ya7on commented Jan 14, 2025

Looks complicated. But i can't imagine how to simplify it.
Do we really need JettonInitOk notification? 🤔 What role does it play? If it's about sending toncoins change, JettonInternalTransfer will handle it and send Excess message. If it's about onchain trigger for emitting finish jetton initialization, JettonInternalTransfer also will handle it and send JettonNotification message.
What do you think about send JettoninitOk only if mint_amount is not provided?

@iamIcarus
Copy link
Collaborator

iamIcarus commented Jan 14, 2025

i was thinking about it as well, my thoughts are that JettonInitOk will give us a simple solution to only have to monitor one notification to confirm that init was success for all cases within init (and in the case that init gets more logic added in the future).

It does look overcomplicated, wanted to check with you if you have any suggestions or improvements 😃

The general idea of this implementation is:

  1. Keep JettonInitOk as a single source for init confirmation
  2. Preserve the mint message receive logic with SendRemainingValue
  3. JettonInit will need to calculate gas for the mint, so if something goes wrong, we can revert to simple init and mint in a new message

@ya7on
Copy link
Member Author

ya7on commented Jan 14, 2025

Ok, I agree with the idea of JettonInitOk as single notification. It looks useful.

Also i think we should send this message after jetton transfering and put remaining toncoins to it, not to mint message. Because if user hasn't set mint_amount, change won't be returned.

@iamIcarus
Copy link
Collaborator

iamIcarus commented Jan 14, 2025

Also i think we should send this message after jetton transfering and put remaining toncoins to it, not to mint message. Because if user hasn't set mint_amount, change won't be returned.

good catch , i'll rework that part

@iamIcarus iamIcarus linked a pull request Jan 14, 2025 that will close this issue
@ya7on ya7on closed this as completed in #30 Jan 15, 2025
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 a pull request may close this issue.

2 participants