-
Notifications
You must be signed in to change notification settings - Fork 282
TEP-137: Jetton Wallet Balance Query #137
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: 0kenx <km@nxfi.app>
Signed-off-by: 0kenx <km@nxfi.app>
Signed-off-by: 0kenx <km@nxfi.app>
It will never be accepted.
In this case contract should block processing all over messages which can change balance until it receives get_balance_response. In can require up to few minutes. Very easy to make mistake for developers without big experience in async networks. |
This is simply not true. In my example where the contract just wants to make sure its balance is greater than
As I have stated multiple times in the document, it should up to the dapp developer to correctly use this feature. You can't cripple experienced async developers for the reason that the feature can "potentially be misused by inexperienced developers". We can mitigate the misuse risk by providing clear explanations in the documentation (which I have already done in the standard). |
Bumping this since we've again run into issues related to this design flaw. Saying "you can't query the balance since the balance might change" is equivalent to your bank or credit card company refusing to give you an account statement because "someone might have charged your card in the meantime". |
I feel this should be accompanied with a good programming language with marker structs which would allow to track assumptions. struct ValidOnce;
struct ValidThisTx;
struct ValidForever;
trait ValidityTicket {}
impl ValidityTicket for ValidOnce {}
impl ValidityTicket for ValidThisTx {}
impl ValidityTicket for ValidForever {}
async fn send_jettons_or_refund(jettons: usize) {
let my_jetton_wallet = todo!();
let my_balance: (usize, ValidOnce) = my_jetton_wallet.request_balance().await; // <-- TRANSACTION BOUNDARY
// SAFETY: all jetton send requests are routed through balance request
// thus they are processed in order (by lt), and our balance is at least what we received
let my_balance: (usize, ValidThisTx) = unsafe {my_balance.fiat_extend()};
(if my_balance.0 < jettons {
send_refund()
} else {
my_jetton_wallet.transfer(todo!(), jettons, my_balance)
}).await; // <-- TRANSACTION BOUNDARY
} |
this expression is not feasible on TON since call context is not preserved. |
If destination contract can be trusted to return a cell as-is, then continuation with needed temporary variables may be passed. |
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.
J****A(CEO) |
No description provided.