@@ -8,6 +8,10 @@ native mulDiv(a: Int, b: Int, c: Int): Int;
88@name (fill_zeros)
99native fillZerosCheckLen (jetton_wallets : map <Address , Address >, want_len : Int ): map <Address , Int >;
1010
11+ @name (load_msg_addr)
12+ extends mutates native fun loadAddress (self : Slice ): Address ;
13+ // SAFETY: doesn't check if address is std-type
14+
1115
1216
1317message DexDeploy {
@@ -41,10 +45,9 @@ struct SystemInfo {
4145 owner_address : Address ;
4246}
4347
44- struct Swap {
45- otherJettonMaster : Address ;
46- // TODO (see below): otherJettonMinExpected: Int as coins;
47- }
48+ // swap#4a2663c4 otherJettonMaster:MsgAddressInt = Swap;
49+ // TODO (see below): add also otherJettonMinExpected:(VarUInteger 16)
50+ // the problem is that Tact doesn't support parsing slices as arbitrary structs
4851
4952
5053
@@ -103,8 +106,16 @@ contract MultitokenDex {
103106 return ;
104107 }
105108
106- let swap : Swap = msg .forward_payload % Swap ;
107- let other_jw : Address = self .jetton_wallets .get (swap .otherJettonMaster )!! ;
109+ // let swap: Swap = msg.forward_payload % Swap;
110+ let /* mut*/ swap : Slice = msg .forward_payload ;
111+ if (swap .loadUint (32 ) != 0x4a2663c4 ) {
112+ self .transferJettonTo (ctx .sender , msg .sender , received ,
113+ msg .query_id , " Unknown operation" );
114+ }
115+ let otherJettonMaster : Address = swap .loadAddress ();
116+
117+
118+ let other_jw : Address = self .jetton_wallets .get (otherJettonMaster )!! ;
108119 let old_balance_dst : Int = self .assets .get (other_jw )!! ;
109120
110121 let swap_value : Int = self .calc_swap (old_balance_src !! , old_balance_dst , received );
0 commit comments