mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
XCM builder pattern improvement - Accept impl Into<T> instead of just T (#3708)
The XCM builder pattern lets you build xcms like so:
```rust
let xcm = Xcm::builder()
.withdraw_asset((Parent, 100u128).into())
.buy_execution((Parent, 1u128).into())
.deposit_asset(All.into(), AccountId32 { id: [0u8; 32], network: None }.into())
.build();
```
All the `.into()` become quite annoying to have to write.
I accepted `impl Into<T>` instead of `T` in the generated methods from
the macro.
Now the previous example can be simplified as follows:
```rust
let xcm = Xcm::builder()
.withdraw_asset((Parent, 100u128))
.buy_execution((Parent, 1u128))
.deposit_asset(All, [0u8; 32])
.build();
```
---------
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: command-bot <>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
committed by
GitHub
parent
bcb4d137c9
commit
c130ea9939
@@ -486,9 +486,8 @@ fn claim_assets_works() {
|
||||
let balances = vec![(ALICE, INITIAL_BALANCE)];
|
||||
new_test_ext_with_balances(balances).execute_with(|| {
|
||||
// First trap some assets.
|
||||
let trapping_program = Xcm::<RuntimeCall>::builder_unsafe()
|
||||
.withdraw_asset((Here, SEND_AMOUNT).into())
|
||||
.build();
|
||||
let trapping_program =
|
||||
Xcm::<RuntimeCall>::builder_unsafe().withdraw_asset((Here, SEND_AMOUNT)).build();
|
||||
// Even though assets are trapped, the extrinsic returns success.
|
||||
assert_ok!(XcmPallet::execute_blob(
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
|
||||
Reference in New Issue
Block a user