From 4180e921ea0c65e503483d59ec10bc77c9fd6a82 Mon Sep 17 00:00:00 2001 From: master_jedy Date: Sat, 5 Jul 2025 01:26:27 +0200 Subject: [PATCH] fix bounce msg processing issue Signed-off-by: master_jedy --- target_chains/ton/contracts/contracts/Main.fc | 10 +++++----- .../ton/contracts/contracts/tests/PythTest.fc | 13 ++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/target_chains/ton/contracts/contracts/Main.fc b/target_chains/ton/contracts/contracts/Main.fc index edb3123062..af05e89cca 100644 --- a/target_chains/ton/contracts/contracts/Main.fc +++ b/target_chains/ton/contracts/contracts/Main.fc @@ -29,11 +29,6 @@ return (); } - ;; * A 32-bit (big-endian) unsigned integer `op`, identifying the `operation` to be performed, or the `method` of the smart contract to be invoked. - int op = in_msg_body~load_uint(32); - cell data = in_msg_body~load_ref(); - slice data_slice = data.begin_parse(); - ;; Get sender address from message slice cs = in_msg_full.begin_parse(); int flags = cs~load_uint(4); @@ -42,6 +37,11 @@ } slice sender_address = cs~load_msg_addr(); ;; load sender address + ;; * A 32-bit (big-endian) unsigned integer `op`, identifying the `operation` to be performed, or the `method` of the smart contract to be invoked. + int op = in_msg_body~load_uint(32); + cell data = in_msg_body~load_ref(); + slice data_slice = data.begin_parse(); + ;; * The remainder of the message body is specific for each supported value of `op`. if (op == OP_UPDATE_GUARDIAN_SET) { ;; @notice Updates the guardian set based on a Wormhole VAA diff --git a/target_chains/ton/contracts/contracts/tests/PythTest.fc b/target_chains/ton/contracts/contracts/tests/PythTest.fc index b1d3db169a..328767c070 100644 --- a/target_chains/ton/contracts/contracts/tests/PythTest.fc +++ b/target_chains/ton/contracts/contracts/tests/PythTest.fc @@ -18,15 +18,18 @@ return (); } - int op = in_msg_body~load_uint(32); - cell data = in_msg_body~load_ref(); - slice data_slice = data.begin_parse(); - ;; Get sender address from message slice cs = in_msg_full.begin_parse(); - cs~skip_bits(4); ;; skip flags + int flags = cs~load_uint(4); ;; load flags + if (flags & 1) { + return (); + } slice sender_address = cs~load_msg_addr(); ;; load sender address + int op = in_msg_body~load_uint(32); + cell data = in_msg_body~load_ref(); + slice data_slice = data.begin_parse(); + if (op == OP_UPDATE_GUARDIAN_SET) { update_guardian_set(data_slice); } elseif (op == OP_UPDATE_PRICE_FEEDS) {