Эх сурвалжийг харах

fix bounce msg processing issue (#2833)

* fix bounce msg processing issue

Signed-off-by: master_jedy <yura.zarudny@gmail.com>

* trigger ci

---------

Signed-off-by: master_jedy <yura.zarudny@gmail.com>
Co-authored-by: Ali Behjati <bahjatia@gmail.com>
Yura Zarudniy 3 сар өмнө
parent
commit
c98d6e59fb

+ 5 - 5
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

+ 8 - 5
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) {