@@ -9,7 +9,7 @@ use codec::{Decode, Encode};
99use core:: marker:: PhantomData ;
1010use frame_support:: { traits:: tokens:: Balance as BalanceT , weights:: Weight , PalletError } ;
1111use scale_info:: TypeInfo ;
12- use sp_core:: { Get , RuntimeDebug , H160 } ;
12+ use sp_core:: { Get , RuntimeDebug , H160 , H256 } ;
1313use sp_io:: hashing:: blake2_256;
1414use sp_runtime:: MultiAddress ;
1515use sp_std:: prelude:: * ;
@@ -115,7 +115,10 @@ pub trait ConvertMessage {
115115 type Balance : BalanceT + From < u128 > ;
116116 type AccountId ;
117117 /// Converts a versioned message into an XCM message and an optional topicID
118- fn convert ( message : VersionedMessage ) -> Result < ( Xcm < ( ) > , Self :: Balance ) , ConvertMessageError > ;
118+ fn convert (
119+ message_id : H256 ,
120+ message : VersionedMessage ,
121+ ) -> Result < ( Xcm < ( ) > , Self :: Balance ) , ConvertMessageError > ;
119122}
120123
121124pub type CallIndex = [ u8 ; 2 ] ;
@@ -138,14 +141,17 @@ impl<CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, AccountId,
138141 type Balance = Balance ;
139142 type AccountId = AccountId ;
140143
141- fn convert ( message : VersionedMessage ) -> Result < ( Xcm < ( ) > , Self :: Balance ) , ConvertMessageError > {
144+ fn convert (
145+ message_id : H256 ,
146+ message : VersionedMessage ,
147+ ) -> Result < ( Xcm < ( ) > , Self :: Balance ) , ConvertMessageError > {
142148 use Command :: * ;
143149 use VersionedMessage :: * ;
144150 match message {
145151 V1 ( MessageV1 { chain_id, command : RegisterToken { token, fee } } ) =>
146- Ok ( Self :: convert_register_token ( chain_id, token, fee) ) ,
152+ Ok ( Self :: convert_register_token ( message_id , chain_id, token, fee) ) ,
147153 V1 ( MessageV1 { chain_id, command : SendToken { token, destination, amount, fee } } ) =>
148- Ok ( Self :: convert_send_token ( chain_id, token, destination, amount, fee) ) ,
154+ Ok ( Self :: convert_send_token ( message_id , chain_id, token, destination, amount, fee) ) ,
149155 }
150156 }
151157}
@@ -159,7 +165,12 @@ where
159165 Balance : BalanceT + From < u128 > ,
160166 AccountId : Into < [ u8 ; 32 ] > ,
161167{
162- fn convert_register_token ( chain_id : u64 , token : H160 , fee : u128 ) -> ( Xcm < ( ) > , Balance ) {
168+ fn convert_register_token (
169+ message_id : H256 ,
170+ chain_id : u64 ,
171+ token : H160 ,
172+ fee : u128 ,
173+ ) -> ( Xcm < ( ) > , Balance ) {
163174 let network = Ethereum { chain_id } ;
164175 let xcm_fee: Asset = ( Location :: parent ( ) , fee) . into ( ) ;
165176 let deposit: Asset = ( Location :: parent ( ) , CreateAssetDeposit :: get ( ) ) . into ( ) ;
@@ -202,13 +213,16 @@ where
202213 // Clear the origin so that remaining assets in holding
203214 // are claimable by the physical origin (BridgeHub)
204215 ClearOrigin ,
216+ // Forward message id to Asset Hub
217+ SetTopic ( message_id. into( ) ) ,
205218 ]
206219 . into ( ) ;
207220
208221 ( xcm, total_amount. into ( ) )
209222 }
210223
211224 fn convert_send_token (
225+ message_id : H256 ,
212226 chain_id : u64 ,
213227 token : H160 ,
214228 destination : Destination ,
@@ -266,6 +280,8 @@ where
266280 BuyExecution { fees: dest_para_fee_asset, weight_limit: Unlimited } ,
267281 // Deposit asset to beneficiary.
268282 DepositAsset { assets: Definite ( asset. into( ) ) , beneficiary } ,
283+ // Forward message id to destination parachain.
284+ SetTopic ( message_id. into( ) ) ,
269285 ]
270286 . into( ) ,
271287 } ,
@@ -279,6 +295,9 @@ where
279295 } ,
280296 }
281297
298+ // Forward message id to Asset Hub.
299+ instructions. push ( SetTopic ( message_id. into ( ) ) ) ;
300+
282301 ( instructions. into ( ) , total_fees. into ( ) )
283302 }
284303
0 commit comments