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: enhance jetton page #403

Closed
wants to merge 4 commits into from

Conversation

a-bahdanau
Copy link
Contributor

@a-bahdanau a-bahdanau commented Sep 30, 2024

Closes #399

pages/cookbook/jettons.mdx Outdated Show resolved Hide resolved
pages/cookbook/jettons.mdx Outdated Show resolved Hide resolved
pages/cookbook/jettons.mdx Show resolved Hide resolved
pages/cookbook/jettons.mdx Outdated Show resolved Hide resolved
pages/cookbook/jettons.mdx Outdated Show resolved Hide resolved

Calculation of contract's jetton wallet is done via function.
To obtain jetton wallet state init we need jetton wallets data and code. Common initial data layout is shown below but in may differ in some case, like in .
Since notifications come from your contract's jetton wallet as shown in diagram, the function should be used in state init the owner address field.
Copy link
Member

Choose a reason for hiding this comment

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

function should - extra space


init(jettonWalletCode: Cell, jettonMasterAddress: Address) {
self.jettonWalletCode = jettonWalletCode;
self.jettonMasterAddress = jettonMasterAddress;
self.myJettonWalletAddress = calculateJettonWalletAddress(myAddress(), jettonMasterAddress, jettonWalletCode);
Copy link
Member

Choose a reason for hiding this comment

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

as I already said before in previous reviews, in most cases the solution for verification is to calculate that address offchain and then just add it into the stateinit of the contract itself.

calculating the address on-chain will only work if you're 100% sure in the jetton code and data structure, or if you take them as variable parameters in the stateinit

require(sender() == myJettonWalletAddress, "Notification not from your jetton wallet!");
require(sender() == self.myJettonWalletAddress, "Notification not from your jetton wallet!");

self.myJettonAmount += msg.amount;
Copy link
Member

Choose a reason for hiding this comment

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

We should also highlight that these notifications are not guaranteed to be sent. The default implementation doesn't send notification if forwardAmount is zero, so in such cases you can't really rely on them.

@a-bahdanau
Copy link
Contributor Author

Hey, should i move all my requests to tact-lang/tact repository?

@novusnota
Copy link
Member

@a-bahdanau if that's convenient to you. If not, it's ok to continue working on existing ones here. Once they're done, I'll simply port them to the main docs :)

@novusnota
Copy link
Member

This PR is transferred to tact-lang/tact#944

Massive thanks to @pixelplex and @a-bahdanau for opening and working on this and subsequent PRs in Tact compiler repo, and thanks to @Gusarich for the review!

@novusnota novusnota closed this Oct 25, 2024
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.

More context and better snippets for cookbook/jettons
3 participants