Skip to content

Commit 3291af9

Browse files
committed
mdBook generated from gitorial
1 parent a92db28 commit 3291af9

File tree

17 files changed

+245
-213534
lines changed

17 files changed

+245
-213534
lines changed

src/0/source/changes.diff

-213,521
Large diffs are not rendered by default.

src/10/README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616

1717
<div id="Template" class="maintab tabcontent active">
1818

19-
No files edited in this step.
19+
<div class="tab">
20+
<button class="subtab tablinks file-template file-modified active" onclick="switchSubTab(event, 'fundamentals/src/xcm_executor.rs')" data-id="fundamentals/src/xcm_executor.rs">fundamentals/src/xcm_executor.rs</button>
21+
</div>
22+
<div id="template/fundamentals/src/xcm_executor.rs" class="subtab tabcontent active" data-id="fundamentals/src/xcm_executor.rs">
23+
24+
```rust
25+
{{#include ./template/fundamentals/src/xcm_executor.rs}}
26+
```
27+
28+
</div>
29+
30+
2031

2132
</div>
2233

src/10/solution/solution.diff

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2-
index d50d85a..f03d79b 100644
2+
index 540086f..f03d79b 100644
33
--- a/fundamentals/src/xcm_executor.rs
44
+++ b/fundamentals/src/xcm_executor.rs
5-
@@ -132,14 +132,50 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
5+
@@ -132,32 +132,50 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
66
// - `assets`: The asset(s) to remove from holding.
77
// - `beneficiary`: The new owner for the assets.
88
DepositAsset { assets, beneficiary } => {
9+
- /* TODO:
10+
- - Make a clone of `self.holding` into a variable `old_holding`.
11+
- - Start a new `TransactionalProcessor`, storing the `result`.
12+
- - `saturating_take` the `assets` into a variable `deposited.
13+
- - For `asset` in `deposited`
14+
- - Use `AssetTransactor` to `deposit_asset` to the `beneficiary`.
15+
- - If anything goes wrong, we should reset `self.holding` to `old_holding`.
16+
- - Return the `result`
17+
- */
918
- todo!("{:?} {:?}", assets, beneficiary)
1019
+ let old_holding = self.holding.clone();
1120
+ let result = Config::TransactionalProcessor::process(|| {
@@ -33,6 +42,15 @@ index d50d85a..f03d79b 100644
3342
//
3443
// - `assets`: The asset(s) that are minted into the Holding Register.
3544
ReceiveTeleportedAsset(assets) => {
45+
- /* TODO:
46+
- - Process everything inside `TransactionalProcessor`.
47+
- - Get the `origin` or return `XcmError::BadOrigin`.
48+
- - For `asset` in `assets`:
49+
- - Use `AssetTransactor` to see if we `can_check_in`.
50+
- - Then actually `check_in` those assets.
51+
- - `and_then`, if everything goes okay...
52+
- - `subsume_assets` into the `self.holding`.
53+
- */
3654
- todo!("{:?}", assets)
3755
+ Config::TransactionalProcessor::process(|| {
3856
+ let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?;

src/10/template/fundamentals/src/xcm_executor.rs

+18
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,31 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
132132
// - `assets`: The asset(s) to remove from holding.
133133
// - `beneficiary`: The new owner for the assets.
134134
DepositAsset { assets, beneficiary } => {
135+
/* TODO:
136+
- Make a clone of `self.holding` into a variable `old_holding`.
137+
- Start a new `TransactionalProcessor`, storing the `result`.
138+
- `saturating_take` the `assets` into a variable `deposited.
139+
- For `asset` in `deposited`
140+
- Use `AssetTransactor` to `deposit_asset` to the `beneficiary`.
141+
- If anything goes wrong, we should reset `self.holding` to `old_holding`.
142+
- Return the `result`
143+
*/
135144
todo!("{:?} {:?}", assets, beneficiary)
136145
},
137146
// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets
138147
// should be created and placed into the Holding Register.
139148
//
140149
// - `assets`: The asset(s) that are minted into the Holding Register.
141150
ReceiveTeleportedAsset(assets) => {
151+
/* TODO:
152+
- Process everything inside `TransactionalProcessor`.
153+
- Get the `origin` or return `XcmError::BadOrigin`.
154+
- For `asset` in `assets`:
155+
- Use `AssetTransactor` to see if we `can_check_in`.
156+
- Then actually `check_in` those assets.
157+
- `and_then`, if everything goes okay...
158+
- `subsume_assets` into the `self.holding`.
159+
*/
142160
todo!("{:?}", assets)
143161
},
144162
// In this workshop, we won't be implementing every instruction, just the ones above...

src/10/template/template.diff

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2+
index d50d85a..540086f 100644
3+
--- a/fundamentals/src/xcm_executor.rs
4+
+++ b/fundamentals/src/xcm_executor.rs
5+
@@ -132,6 +132,15 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
6+
// - `assets`: The asset(s) to remove from holding.
7+
// - `beneficiary`: The new owner for the assets.
8+
DepositAsset { assets, beneficiary } => {
9+
+ /* TODO:
10+
+ - Make a clone of `self.holding` into a variable `old_holding`.
11+
+ - Start a new `TransactionalProcessor`, storing the `result`.
12+
+ - `saturating_take` the `assets` into a variable `deposited.
13+
+ - For `asset` in `deposited`
14+
+ - Use `AssetTransactor` to `deposit_asset` to the `beneficiary`.
15+
+ - If anything goes wrong, we should reset `self.holding` to `old_holding`.
16+
+ - Return the `result`
17+
+ */
18+
todo!("{:?} {:?}", assets, beneficiary)
19+
},
20+
// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets
21+
@@ -139,6 +148,15 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
22+
//
23+
// - `assets`: The asset(s) that are minted into the Holding Register.
24+
ReceiveTeleportedAsset(assets) => {
25+
+ /* TODO:
26+
+ - Process everything inside `TransactionalProcessor`.
27+
+ - Get the `origin` or return `XcmError::BadOrigin`.
28+
+ - For `asset` in `assets`:
29+
+ - Use `AssetTransactor` to see if we `can_check_in`.
30+
+ - Then actually `check_in` those assets.
31+
+ - `and_then`, if everything goes okay...
32+
+ - `subsume_assets` into the `self.holding`.
33+
+ */
34+
todo!("{:?}", assets)
35+
},
36+
// In this workshop, we won't be implementing every instruction, just the ones above...

src/7/README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616

1717
<div id="Template" class="maintab tabcontent active">
1818

19-
No files edited in this step.
19+
<div class="tab">
20+
<button class="subtab tablinks file-template file-modified active" onclick="switchSubTab(event, 'fundamentals/src/xcm_executor.rs')" data-id="fundamentals/src/xcm_executor.rs">fundamentals/src/xcm_executor.rs</button>
21+
</div>
22+
<div id="template/fundamentals/src/xcm_executor.rs" class="subtab tabcontent active" data-id="fundamentals/src/xcm_executor.rs">
23+
24+
```rust
25+
{{#include ./template/fundamentals/src/xcm_executor.rs}}
26+
```
27+
28+
</div>
29+
30+
2031

2132
</div>
2233

src/7/solution/solution.diff

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2-
index 9e0647a..57e1bd4 100644
2+
index 08884c9..57e1bd4 100644
33
--- a/fundamentals/src/xcm_executor.rs
44
+++ b/fundamentals/src/xcm_executor.rs
5-
@@ -62,12 +62,17 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
5+
@@ -62,20 +62,17 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
66
// the authority of the origin (e.g. if they are being relayed from an untrusted
77
// source, as often the case with `ReserveAssetDeposited`).
88
ClearOrigin => {
9+
- /* TODO: Simply set `self.context.origin` to `None` */
910
- todo!()
1011
+ self.context.origin = None;
1112
+ Ok(())
1213
},
1314
// Appends `who` to the current XCM Executor `origin` location.
1415
- DescendOrigin(who) => {
16+
- /* TODO:
17+
- - Get the `self.context.origin`.
18+
- - Access it `as_mut()`.
19+
- - If `origin` is `None`, return `XcmError::BadOrigin`.
20+
- - Then `append_with` `who`
21+
- - If the append fails, return `XcmError::LocationFull`.
22+
- */
1523
- todo!("{:?}", who)
1624
- }
1725
+ DescendOrigin(who) => self

src/7/template/fundamentals/src/xcm_executor.rs

+8
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
6262
// the authority of the origin (e.g. if they are being relayed from an untrusted
6363
// source, as often the case with `ReserveAssetDeposited`).
6464
ClearOrigin => {
65+
/* TODO: Simply set `self.context.origin` to `None` */
6566
todo!()
6667
},
6768
// Appends `who` to the current XCM Executor `origin` location.
6869
DescendOrigin(who) => {
70+
/* TODO:
71+
- Get the `self.context.origin`.
72+
- Access it `as_mut()`.
73+
- If `origin` is `None`, return `XcmError::BadOrigin`.
74+
- Then `append_with` `who`
75+
- If the append fails, return `XcmError::LocationFull`.
76+
*/
6977
todo!("{:?}", who)
7078
}
7179
// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent

src/7/template/template.diff

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2+
index 9e0647a..08884c9 100644
3+
--- a/fundamentals/src/xcm_executor.rs
4+
+++ b/fundamentals/src/xcm_executor.rs
5+
@@ -62,10 +62,18 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
6+
// the authority of the origin (e.g. if they are being relayed from an untrusted
7+
// source, as often the case with `ReserveAssetDeposited`).
8+
ClearOrigin => {
9+
+ /* TODO: Simply set `self.context.origin` to `None` */
10+
todo!()
11+
},
12+
// Appends `who` to the current XCM Executor `origin` location.
13+
DescendOrigin(who) => {
14+
+ /* TODO:
15+
+ - Get the `self.context.origin`.
16+
+ - Access it `as_mut()`.
17+
+ - If `origin` is `None`, return `XcmError::BadOrigin`.
18+
+ - Then `append_with` `who`
19+
+ - If the append fails, return `XcmError::LocationFull`.
20+
+ */
21+
todo!("{:?}", who)
22+
}
23+
// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent

src/8/README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616

1717
<div id="Template" class="maintab tabcontent active">
1818

19-
No files edited in this step.
19+
<div class="tab">
20+
<button class="subtab tablinks file-template file-modified active" onclick="switchSubTab(event, 'fundamentals/src/xcm_executor.rs')" data-id="fundamentals/src/xcm_executor.rs">fundamentals/src/xcm_executor.rs</button>
21+
</div>
22+
<div id="template/fundamentals/src/xcm_executor.rs" class="subtab tabcontent active" data-id="fundamentals/src/xcm_executor.rs">
23+
24+
```rust
25+
{{#include ./template/fundamentals/src/xcm_executor.rs}}
26+
```
27+
28+
</div>
29+
30+
2031

2132
</div>
2233

src/8/solution/solution.diff

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2-
index 57e1bd4..f84c243 100644
2+
index 97ba170..f84c243 100644
33
--- a/fundamentals/src/xcm_executor.rs
44
+++ b/fundamentals/src/xcm_executor.rs
5-
@@ -79,7 +79,20 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
5+
@@ -79,14 +79,20 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
66
// - `assets`: The asset(s) to be withdrawn.
77
// - `beneficiary`: The new owner for the assets.
88
TransferAsset { assets, beneficiary } => {
9+
- /* TODO:
10+
- - Process everything inside a `TransactionalProcessor`.
11+
- - Get the `origin` from `self.origin_ref()`.
12+
- - For each `asset` in `assets`
13+
- - Use `AssetTransactor` and `transfer_asset` to the `beneficiary`.
14+
- - If everything works well, return `Ok(())`
15+
- */
916
- todo!("{:?} {:?}", assets, beneficiary)
1017
+ Config::TransactionalProcessor::process(|| {
1118
+ // Take `assets` from the origin account (on-chain) and place into dest account.

src/8/template/fundamentals/src/xcm_executor.rs

+7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
7979
// - `assets`: The asset(s) to be withdrawn.
8080
// - `beneficiary`: The new owner for the assets.
8181
TransferAsset { assets, beneficiary } => {
82+
/* TODO:
83+
- Process everything inside a `TransactionalProcessor`.
84+
- Get the `origin` from `self.origin_ref()`.
85+
- For each `asset` in `assets`
86+
- Use `AssetTransactor` and `transfer_asset` to the `beneficiary`.
87+
- If everything works well, return `Ok(())`
88+
*/
8289
todo!("{:?} {:?}", assets, beneficiary)
8390
},
8491
// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the

src/8/template/template.diff

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2+
index 57e1bd4..97ba170 100644
3+
--- a/fundamentals/src/xcm_executor.rs
4+
+++ b/fundamentals/src/xcm_executor.rs
5+
@@ -79,6 +79,13 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
6+
// - `assets`: The asset(s) to be withdrawn.
7+
// - `beneficiary`: The new owner for the assets.
8+
TransferAsset { assets, beneficiary } => {
9+
+ /* TODO:
10+
+ - Process everything inside a `TransactionalProcessor`.
11+
+ - Get the `origin` from `self.origin_ref()`.
12+
+ - For each `asset` in `assets`
13+
+ - Use `AssetTransactor` and `transfer_asset` to the `beneficiary`.
14+
+ - If everything works well, return `Ok(())`
15+
+ */
16+
todo!("{:?} {:?}", assets, beneficiary)
17+
},
18+
// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the

src/9/README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616

1717
<div id="Template" class="maintab tabcontent active">
1818

19-
No files edited in this step.
19+
<div class="tab">
20+
<button class="subtab tablinks file-template file-modified active" onclick="switchSubTab(event, 'fundamentals/src/xcm_executor.rs')" data-id="fundamentals/src/xcm_executor.rs">fundamentals/src/xcm_executor.rs</button>
21+
</div>
22+
<div id="template/fundamentals/src/xcm_executor.rs" class="subtab tabcontent active" data-id="fundamentals/src/xcm_executor.rs">
23+
24+
```rust
25+
{{#include ./template/fundamentals/src/xcm_executor.rs}}
26+
```
27+
28+
</div>
29+
30+
2031

2132
</div>
2233

src/9/solution/solution.diff

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2-
index f84c243..d50d85a 100644
2+
index f97757d..d50d85a 100644
33
--- a/fundamentals/src/xcm_executor.rs
44
+++ b/fundamentals/src/xcm_executor.rs
5-
@@ -99,7 +99,23 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
5+
@@ -99,15 +99,23 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
66
//
77
// - `assets`: The asset(s) to be withdrawn into holding.
88
WithdrawAsset(assets) => {
9+
- /* TODO:
10+
- - Process everything inside a `TransactionalProcessor`.
11+
- - Get the `origin` or return `XcmError::BadOrigin`.
12+
- - For each `asset` in `assets`
13+
- - Use the `AssetTransactor` to `withdraw_asset`.
14+
- - `and_then`, if everything goes okay...
15+
- - `subsume_assets` into the `self.holding`
16+
- */
917
- todo!("{:?}", assets)
1018
+ Config::TransactionalProcessor::process(|| {
1119
+ let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?;
@@ -27,10 +35,11 @@ index f84c243..d50d85a 100644
2735
},
2836
// Reduce Holding by up to the given assets.
2937
//
30-
@@ -107,7 +123,8 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
38+
@@ -115,8 +123,8 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
3139
// not an error if the Holding does not contain the assets (to make this an error, use
3240
// `ExpectAsset` prior).
3341
BurnAsset(assets) => {
42+
- /* TODO: Simply `saturating_take` `assets` from the `self.holding`. */
3443
- todo!("{:?}", assets)
3544
+ self.holding.saturating_take(assets.into());
3645
+ Ok(())

src/9/template/fundamentals/src/xcm_executor.rs

+9
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
9999
//
100100
// - `assets`: The asset(s) to be withdrawn into holding.
101101
WithdrawAsset(assets) => {
102+
/* TODO:
103+
- Process everything inside a `TransactionalProcessor`.
104+
- Get the `origin` or return `XcmError::BadOrigin`.
105+
- For each `asset` in `assets`
106+
- Use the `AssetTransactor` to `withdraw_asset`.
107+
- `and_then`, if everything goes okay...
108+
- `subsume_assets` into the `self.holding`
109+
*/
102110
todo!("{:?}", assets)
103111
},
104112
// Reduce Holding by up to the given assets.
@@ -107,6 +115,7 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
107115
// not an error if the Holding does not contain the assets (to make this an error, use
108116
// `ExpectAsset` prior).
109117
BurnAsset(assets) => {
118+
/* TODO: Simply `saturating_take` `assets` from the `self.holding`. */
110119
todo!("{:?}", assets)
111120
},
112121
// Remove the asset(s) (`assets`) from the Holding Register and place equivalent assets

src/9/template/template.diff

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
diff --git a/fundamentals/src/xcm_executor.rs b/fundamentals/src/xcm_executor.rs
2+
index f84c243..f97757d 100644
3+
--- a/fundamentals/src/xcm_executor.rs
4+
+++ b/fundamentals/src/xcm_executor.rs
5+
@@ -99,6 +99,14 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
6+
//
7+
// - `assets`: The asset(s) to be withdrawn into holding.
8+
WithdrawAsset(assets) => {
9+
+ /* TODO:
10+
+ - Process everything inside a `TransactionalProcessor`.
11+
+ - Get the `origin` or return `XcmError::BadOrigin`.
12+
+ - For each `asset` in `assets`
13+
+ - Use the `AssetTransactor` to `withdraw_asset`.
14+
+ - `and_then`, if everything goes okay...
15+
+ - `subsume_assets` into the `self.holding`
16+
+ */
17+
todo!("{:?}", assets)
18+
},
19+
// Reduce Holding by up to the given assets.
20+
@@ -107,6 +115,7 @@ impl<Config: XcmConfig> XcmExecutor<Config> {
21+
// not an error if the Holding does not contain the assets (to make this an error, use
22+
// `ExpectAsset` prior).
23+
BurnAsset(assets) => {
24+
+ /* TODO: Simply `saturating_take` `assets` from the `self.holding`. */
25+
todo!("{:?}", assets)
26+
},
27+
// Remove the asset(s) (`assets`) from the Holding Register and place equivalent assets

0 commit comments

Comments
 (0)