-
Notifications
You must be signed in to change notification settings - Fork 1.2k
allow treasury to do reserve asset transfers #1447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
f97b8b4
0cb9bd8
6950232
6edfe8c
1c39018
cd1a317
92c19e4
bc47444
b0a32df
fd36d62
8967478
0900cf6
97919f2
a20fcf6
d692513
c43e583
b0bb2b5
3ed9509
b666a1c
25da765
6410078
4ae6087
920b3ea
cc1fbc5
7ce71d1
20abdf0
558e585
8d478b9
4de166a
5a42734
aee64f5
28b4f9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,13 +84,28 @@ impl DescribeLocation for DescribeAccountKey20Terminal { | |
| } | ||
| } | ||
|
|
||
| /// Create a description of the remote treasury `location` if possible. No two locations should have | ||
| /// the same descriptor. | ||
| pub struct DescribeTreasuryVoiceTerminal; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very cute name. |
||
|
|
||
| impl DescribeLocation for DescribeTreasuryVoiceTerminal { | ||
| fn describe_location(l: &MultiLocation) -> Option<Vec<u8>> { | ||
| match (l.parents, &l.interior) { | ||
| (0, X1(Plurality { id: BodyId::Treasury, part: BodyPart::Voice })) => | ||
| Some(("Treasury").encode()), | ||
|
samelamin marked this conversation as resolved.
Outdated
|
||
| _ => return None, | ||
|
samelamin marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| pub type DescribeAccountIdTerminal = (DescribeAccountId32Terminal, DescribeAccountKey20Terminal); | ||
|
|
||
| pub type DescribeAllTerminal = ( | ||
| DescribeTerminus, | ||
| DescribePalletTerminal, | ||
| DescribeAccountId32Terminal, | ||
| DescribeAccountKey20Terminal, | ||
| DescribeTreasuryVoiceTerminal, | ||
| ); | ||
|
|
||
| pub struct DescribeFamily<DescribeInterior>(PhantomData<DescribeInterior>); | ||
|
|
@@ -317,6 +332,25 @@ impl<Network: Get<Option<NetworkId>>, AccountId: From<[u8; 32]> + Into<[u8; 32]> | |
| } | ||
| } | ||
|
|
||
| /// Extracts the `AccountId32` from the passed Treasury plurality if the network matches. | ||
|
samelamin marked this conversation as resolved.
Outdated
|
||
| pub struct LocalTreasuryVoiceConvertsVia<TreasuryAccount, AccountId>( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be nice to add here simple test for this converter |
||
| PhantomData<(TreasuryAccount, AccountId)>, | ||
| ); | ||
| impl<TreasuryAccount: Get<AccountId>, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> | ||
| ConvertLocation<AccountId> for LocalTreasuryVoiceConvertsVia<TreasuryAccount, AccountId> | ||
| { | ||
| fn convert_location(location: &MultiLocation) -> Option<AccountId> { | ||
| let id: [u8; 32] = match *location { | ||
|
samelamin marked this conversation as resolved.
Outdated
|
||
| MultiLocation { | ||
|
samelamin marked this conversation as resolved.
Outdated
|
||
| parents: 0, | ||
| interior: X1(Plurality { id: BodyId::Treasury, part: BodyPart::Voice }), | ||
| } => TreasuryAccount::get().into(), | ||
| _ => return None, | ||
| }; | ||
| Some(id.into()) | ||
| } | ||
| } | ||
|
|
||
| /// Conversion implementation which converts from a `[u8; 32]`-based `AccountId` into a | ||
| /// `MultiLocation` consisting solely of a `AccountId32` junction with a fixed value for its | ||
| /// network (provided by `Network`) and the `AccountId`'s `[u8; 32]` datum for the `id`. | ||
|
|
@@ -435,6 +469,9 @@ mod tests { | |
| pub type ForeignChainAliasAccount<AccountId> = | ||
| HashedDescription<AccountId, LegacyDescribeForeignChainAccount>; | ||
|
|
||
| pub type ForeignChainAliasTreasuryAccount<AccountId> = | ||
| HashedDescription<AccountId, DescribeFamily<DescribeTreasuryVoiceTerminal>>; | ||
|
|
||
| use frame_support::parameter_types; | ||
| use xcm::latest::Junction; | ||
|
|
||
|
|
@@ -925,4 +962,22 @@ mod tests { | |
| }; | ||
| assert!(ForeignChainAliasAccount::<[u8; 32]>::convert_location(&mul).is_none()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn remote_account_convert_on_para_sending_relay_treasury() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably I am missing some context here, I can understand
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its a badly named test i think, but its meant to be remote treasury on a parachain to another parachain
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, because from the parachain's point of view this: represents Plurality-Treasury-Voice location on relay chain (because From the parachain's point-of-view a relay chain plurality looks like: From the parachain's point-of-view an other parachain plurality looks like: So I would suggest to cover at least these two case in this test, to be sure that it works as expected. (but as I said, I dont have full context here)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @bkontur thanks for this, I've renamed the tests and added another test to cover the para to para treasury conversion I think the |
||
| let mul = MultiLocation { | ||
|
samelamin marked this conversation as resolved.
Outdated
|
||
| parents: 1, | ||
| interior: X1(Plurality { id: BodyId::Treasury, part: BodyPart::Voice }), | ||
| }; | ||
| let actual_description = | ||
| ForeignChainAliasTreasuryAccount::<[u8; 32]>::convert_location(&mul).unwrap(); | ||
|
|
||
| assert_eq!( | ||
| [ | ||
| 103, 157, 82, 57, 235, 216, 82, 162, 31, 148, 162, 21, 44, 34, 218, 173, 202, 123, | ||
| 235, 14, 186, 214, 16, 211, 10, 13, 72, 194, 254, 71, 87, 96 | ||
| ], | ||
| actual_description | ||
| ); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.