-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XCM builder pattern improvement - Accept
impl Into<T>
instead of ju…
…st `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>
- Loading branch information
1 parent
bcb4d13
commit c130ea9
Showing
5 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
||
title: XCM builder pattern automatically converts instruction parameters. | ||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
Small quality of life improvement. | ||
Previously, an XCM could be built like this: | ||
```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(); | ||
``` | ||
Now, it can be built like this: | ||
```rust | ||
let xcm = Xcm::builder() | ||
.withdraw_asset((Parent, 100u128)) | ||
.buy_execution((Parent, 1u128)) | ||
.deposit_asset(All, [0u8; 32]) | ||
.build(); | ||
``` | ||
|
||
crates: | ||
- name: "xcm-procedural" | ||
bump: minor | ||
- name: "staging-xcm" | ||
bump: minor |