Add Wrapped TON (wTON)#746
Conversation
|
👋 krebernisak, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
There was a problem hiding this comment.
Pull request overview
Adds initial Wrapped TON (wTON) Jetton-style contracts plus supporting Jetton library utilities/types.
Changes:
- Introduces wTON
JettonMinterandJettonWalletcontracts and a short README. - Refactors/extends Jetton shared code (errors, fees management, wallet address derivation) and updates message/storage types.
- Updates the Jetton onramp mock example to import the new jetton-utils module.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/contracts/wton/README.md | Adds brief documentation for the new wTON module. |
| contracts/contracts/wton/JettonWallet.tolk | Implements the wTON Jetton wallet contract (transfers, burns, bounce handling, getters). |
| contracts/contracts/wton/JettonMinter.tolk | Implements the wTON Jetton minter contract (mint/burn handling, wallet address queries, metadata getter). |
| contracts/contracts/lib/jetton/utils.tolk | Removes the previous Jetton utility module. |
| contracts/contracts/lib/jetton/storage.tolk | Updates Jetton storage types (admin fields optional, metadataUri now string). |
| contracts/contracts/lib/jetton/messages.tolk | Updates Jetton message schemas (several fields now optional; metadata update payload type adjusted). |
| contracts/contracts/lib/jetton/jetton-utils.tolk | Adds new wallet address/state-init derivation helpers. |
| contracts/contracts/lib/jetton/fees-management.tolk | Adds shared fee/gas/storage calculations and “enough gas” checks. |
| contracts/contracts/lib/jetton/errors.tolk | Adds shared Jetton error constants. |
| contracts/contracts/examples/jetton/onramp_mock.tolk | Updates imports and local constants to align with the Jetton refactor. |
Comments suppressed due to low confidence (1)
contracts/contracts/lib/jetton/fees-management.tolk:58
- Spelling typo in comment: "iternal_transfer" should be "internal_transfer".
// but last one is optional (it is ok if it fails)
fwdCount * fwdFee +
forwardInitStateOverhead() + // additional fwd fees related to initstate in iternal_transfer
calculateGasFee(MY_WORKCHAIN, sendTransferGasConsumption) +
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| in.bouncedBody.skipBouncedPrefix(); | ||
|
|
||
| val msg = lazy BounceOpToHandle.fromSlice(in.bouncedBody); |
| fun onBouncedMessage(in: InMessageBounced) { | ||
| in.bouncedBody.skipBouncedPrefix(); | ||
| // process only mint bounces; on other messages, an exception will be thrown, it's okay | ||
| val msg = lazy InternalTransferStep.fromSlice(in.bouncedBody); | ||
|
|
||
| var storage = lazy MinterStorage.load(); | ||
| storage.totalSupply -= msg.jettonAmount; | ||
| storage.save(); |
| @@ -0,0 +1,73 @@ | |||
| // SPDX-License-Identifier: MIT | |||
| // Imported from https://github.com/ton-blockchain/tolk-bench/blob/0f416ca611fbfa25e736973d01e5fb70af485468/contracts_Tolk/03_notcoin/messages.tolk | |||
| } | ||
|
|
||
| fun checkAmountIsEnoughToTransfer(msgValue: int, forwardTonAmount: int, fwdFee: int) { | ||
| var fwdCount = forwardTonAmount != 0 ? 2 : 1; // second sending (forward) will be cheaper that first |
patricios-space
left a comment
There was a problem hiding this comment.
Looks good! I would remove ERROR_WRONG_OP and ERROR_INVALID_MESSAGE from errors.tolk. Although they are also defined in the notcoin implementation, these variables are unused.
|
|
||
| fun calcDeployedJettonWallet(ownerAddress: address, minterAddress: address, jettonWalletCode: cell): AutoDeployAddress { | ||
| val emptyWalletStorage: WalletStorage = { | ||
| status: 0, |
There was a problem hiding this comment.
What is this status for?
There was a problem hiding this comment.
It is also defined in notcoin but not mentioned in docs
There was a problem hiding this comment.
It's used to lock outgoing and incoming transfers in the original notcoin impl here: https://github.com/OpenBuilders/notcoin-contract/blob/c9992514b71f1775cec5df49fbea31a85ddd87f9/contracts/jetton-wallet.fc#L44C5-L44C62
;; int outgoing_transfers_unlocked = ((status & 1) == 0);
...
;; int incoming_transfers_locked = ((status & 2) == 2);
We keep it in ther ref implementation for consistent addr derivation and get_status getter which here just returns 0 for wTON, no transfer limits
No description provided.