@@ -8,11 +8,12 @@ use futures::StreamExt;
8
8
use polkadot_sdk:: {
9
9
sp_core:: { bytes:: from_hex, sr25519, Pair , H256 } ,
10
10
sp_runtime:: Weight ,
11
- staging_xcm:: v4 :: { Asset , AssetId , Fungibility } ,
11
+ staging_xcm:: v5 :: { Asset , AssetId , Fungibility } ,
12
12
* ,
13
13
} ;
14
+ use polkadot_sdk:: staging_xcm:: v5:: Parent ;
14
15
use staging_xcm:: {
15
- v4 :: { Junction , Junctions , Location , NetworkId , WeightLimit } ,
16
+ v5 :: { Junction , Junctions , Location , NetworkId , WeightLimit } ,
16
17
VersionedLocation ,
17
18
} ;
18
19
use subxt:: {
@@ -45,17 +46,27 @@ async fn should_dispatch_ismp_request_when_xcm_is_received() -> anyhow::Result<(
45
46
let url = std:: env:: var ( "ROCOCO_LOCAL_URL" )
46
47
. ok ( )
47
48
. unwrap_or ( "ws://127.0.0.1:9922" . to_string ( ) ) ;
48
- let client = OnlineClient :: < BlakeSubstrateChain > :: from_url ( & url) . await ?;
49
+ let relay_client = OnlineClient :: < BlakeSubstrateChain > :: from_url ( & url) . await ?;
49
50
let rpc_client = RpcClient :: from_url ( & url) . await ?;
50
51
let _rpc = LegacyRpcMethods :: < BlakeSubstrateChain > :: new ( rpc_client. clone ( ) ) ;
51
52
53
+ let assethub_url = std:: env:: var ( "ASSET_HUB_LOCAL_URL" )
54
+ . ok ( )
55
+ . unwrap_or ( "ws://127.0.0.1:9910" . to_string ( ) ) ;
56
+ let assethub_client = OnlineClient :: < BlakeSubstrateChain > :: from_url ( & assethub_url) . await ?;
57
+ let _assethub_rpc_client = RpcClient :: from_url ( & assethub_url) . await ?;
58
+ let _assethub_rpc = LegacyRpcMethods :: < BlakeSubstrateChain > :: new ( rpc_client. clone ( ) ) ;
59
+
52
60
let para_url = std:: env:: var ( "PARA_LOCAL_URL" )
53
61
. ok ( )
54
62
. unwrap_or ( "ws://127.0.0.1:9990" . to_string ( ) ) ;
55
63
let _para_client = OnlineClient :: < Hyperbridge > :: from_url ( & para_url) . await ?;
56
64
let para_rpc_client = RpcClient :: from_url ( & para_url) . await ?;
57
65
let para_rpc = LegacyRpcMethods :: < BlakeSubstrateChain > :: new ( para_rpc_client. clone ( ) ) ;
58
66
67
+ force_open_hrmp_channel ( & relay_client, & signer, 1000 , 2000 ) . await ?;
68
+ force_open_hrmp_channel ( & relay_client, & signer, 2000 , 1000 ) . await ?;
69
+
59
70
// Wait for parachain block production
60
71
61
72
let sub = para_rpc. chain_subscribe_finalized_heads ( ) . await ?;
@@ -76,37 +87,23 @@ async fn should_dispatch_ismp_request_when_xcm_is_received() -> anyhow::Result<(
76
87
. into_location ( ) ;
77
88
let weight_limit = WeightLimit :: Unlimited ;
78
89
79
- let dest: VersionedLocation = VersionedLocation :: V4 ( Junction :: Parachain ( 2000 ) . into ( ) ) ;
90
+ let dest: VersionedLocation = VersionedLocation :: V5 ( Location :: new ( 1 , [ Junction :: Parachain ( 2000 ) ] ) ) ;
80
91
81
- let beneficiary_as_versioned = VersionedLocation :: V4 ( beneficiary) ;
82
- let assets_vec = vec ! [ ( Junctions :: Here , SEND_AMOUNT ) . into( ) ] ;
92
+ let beneficiary_as_versioned = VersionedLocation :: V5 ( beneficiary) ;
93
+ let dot_location: Location = Parent . into ( ) ;
94
+ let assets_vec = vec ! [ Asset {
95
+ id: dot_location. into( ) ,
96
+ fun: Fungibility :: Fungible ( SEND_AMOUNT ) ,
97
+ } ] ;
83
98
84
99
let dest_value = versioned_location_to_value ( & dest) ;
85
100
let beneficiary_value = versioned_location_to_value ( & beneficiary_as_versioned) ;
86
101
let assets_value = versioned_assets_to_value ( & assets_vec) ;
87
102
let fee_asset_index_value = Value :: u128 ( 0 ) ;
88
103
let weight_limit_value = weight_limit_to_value ( & weight_limit) ;
89
104
90
- {
91
- let signer = InMemorySigner :: < BlakeSubstrateChain > :: new ( pair. clone ( ) ) ;
92
- let para_absolute_location: Location = Junction :: Parachain ( 2000 ) . into ( ) ;
93
- let version = 4u32 ;
94
-
95
- let location_as_value = location_to_value ( & para_absolute_location) ;
96
- let version_as_value = Value :: u128 ( version. into ( ) ) ;
97
-
98
- // Force set the xcm version to our supported version
99
- let call = subxt:: dynamic:: tx (
100
- "XcmPallet" ,
101
- "force_xcm_version" ,
102
- vec ! [ location_as_value, version_as_value] ,
103
- ) ;
104
- let tx = subxt:: dynamic:: tx ( "Sudo" , "sudo" , vec ! [ call. into_value( ) ] ) ;
105
- send_extrinsic ( & client, & signer, & tx, None ) . await ?;
106
- }
107
-
108
105
let ext = subxt:: dynamic:: tx (
109
- "XcmPallet " ,
106
+ "PolkadotXcm " ,
110
107
"limited_reserve_transfer_assets" ,
111
108
vec ! [
112
109
dest_value,
@@ -123,8 +120,10 @@ async fn should_dispatch_ismp_request_when_xcm_is_received() -> anyhow::Result<(
123
120
. ok_or_else ( || anyhow ! ( "Failed to fetch latest header" ) ) ?
124
121
. number ( ) ;
125
122
126
- send_extrinsic ( & client, & signer, & ext, None ) . await ?;
123
+ send_extrinsic ( & assethub_client, & signer, & ext, None ) . await ?;
124
+
127
125
126
+ println ! ( "done performing limited reserve asset transfer" ) ;
128
127
let mut sub = para_rpc. chain_subscribe_finalized_heads ( ) . await ?;
129
128
130
129
while let Some ( res) = sub. next ( ) . await {
@@ -171,6 +170,28 @@ async fn should_dispatch_ismp_request_when_xcm_is_received() -> anyhow::Result<(
171
170
Err ( anyhow ! ( "XCM Integration test failed" ) )
172
171
}
173
172
173
+ async fn force_open_hrmp_channel (
174
+ relay_client : & OnlineClient < BlakeSubstrateChain > ,
175
+ signer : & InMemorySigner < BlakeSubstrateChain > ,
176
+ sender : u128 ,
177
+ recipient : u128 ,
178
+ ) -> anyhow:: Result < ( ) > {
179
+ let force_call = subxt:: dynamic:: tx (
180
+ "Hrmp" ,
181
+ "force_open_hrmp_channel" ,
182
+ vec ! [
183
+ Value :: u128 ( sender) ,
184
+ Value :: u128 ( recipient) ,
185
+ Value :: u128 ( 8 ) ,
186
+ Value :: u128 ( 1024 * 1024 ) ,
187
+ ] ,
188
+ ) ;
189
+ let sudo_call = subxt:: dynamic:: tx ( "Sudo" , "sudo" , vec ! [ force_call. into_value( ) ] ) ;
190
+ send_extrinsic ( relay_client, signer, & sudo_call, None ) . await ?;
191
+
192
+ Ok ( ( ) )
193
+ }
194
+
174
195
fn junction_to_value ( junction : & Junction ) -> Value < ( ) > {
175
196
match junction {
176
197
Junction :: Parachain ( id) =>
@@ -253,11 +274,11 @@ pub fn force_xcm_version_value() -> Value<()> {
253
274
254
275
fn versioned_location_to_value ( loc : & VersionedLocation ) -> Value < ( ) > {
255
276
match loc {
256
- VersionedLocation :: V4 ( location) => {
277
+ VersionedLocation :: V5 ( location) => {
257
278
let location_value = location_to_value ( location) ;
258
- Value :: variant ( "V4 " , Composite :: unnamed ( vec ! [ location_value] ) )
279
+ Value :: variant ( "V5 " , Composite :: unnamed ( vec ! [ location_value] ) )
259
280
} ,
260
- _ => unimplemented ! ( "This helper only supports V4 VersionedLocation" ) ,
281
+ _ => unimplemented ! ( "This helper only supports V5 VersionedLocation" ) ,
261
282
}
262
283
}
263
284
@@ -285,7 +306,7 @@ fn versioned_assets_to_value(assets_vec: &Vec<Asset>) -> Value<()> {
285
306
let inner_assets_value = Value :: unnamed_composite ( asset_values) ;
286
307
287
308
let assets_struct_value = Value :: unnamed_composite ( vec ! [ inner_assets_value] ) ;
288
- Value :: variant ( "V4 " , Composite :: unnamed ( vec ! [ assets_struct_value] ) )
309
+ Value :: variant ( "V5 " , Composite :: unnamed ( vec ! [ assets_struct_value] ) )
289
310
}
290
311
291
312
fn weight_to_value ( weight : & Weight ) -> Value < ( ) > {
0 commit comments