XCM builder pattern (#2107)

Added a proc macro to be able to write XCMs using the builder pattern.
This means we go from having to do this:

```rust
let message: Xcm<()> = Xcm(vec![
  WithdrawAsset(assets),
  BuyExecution { fees: asset, weight_limit: Unlimited },
  DepositAsset { assets, beneficiary },
]);
```

to this:

```rust
let message: Xcm<()> = Xcm::builder()
  .withdraw_asset(assets)
  .buy_execution(asset, Unlimited),
  .deposit_asset(assets, beneficiary)
  .build();
```

---------

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: command-bot <>
This commit is contained in:
Francisco Aguirre
2023-11-08 06:39:40 +01:00
committed by GitHub
parent 8ebb5c3319
commit 0524aa51d3
10 changed files with 247 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
# Schema: Parity PR Documentation Schema (prdoc)
# See doc at https://github.com/paritytech/prdoc
title: Add a builder pattern to create XCM programs
doc:
- audience: Core Dev
description: |
XCMs can now be built using a builder pattern like so:
Xcm::builder()
.withdraw_asset(assets)
.buy_execution(fees, weight_limit)
.deposit_asset(assets, beneficiary)
.build();
migrations:
db: []
runtime: []
crates:
- name: xcm
host_functions: []