-
Notifications
You must be signed in to change notification settings - Fork 41
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
Conversation
pages/cookbook/jettons.mdx
Outdated
|
||
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. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
Hey, should i move all my requests to tact-lang/tact repository? |
@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 :) |
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! |
Closes #399