-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-3393: add proxy to runtime (#1484)
# Description Add pallet proxy to runtime with 3 proxy type available: * Any - proxy can make any call * Staking - proxy can make calls related to staking (bond, nominate etc) * Nontrasfer - calls that do not make any transfer of funds ## Type of change Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) # Checklist: <!-- delete when not applicable to your PR --> - I have added tests
- Loading branch information
Showing
11 changed files
with
3,420 additions
and
609 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,79 @@ | ||
use subxt::utils::MultiAddress; | ||
|
||
use crate::{ | ||
aleph_runtime::{ProxyType, RuntimeCall}, | ||
api, AccountId, SignedConnectionApi, TxInfo, TxStatus, | ||
}; | ||
|
||
/// any object that implements pallet proxy api | ||
#[async_trait::async_trait] | ||
pub trait ProxyUserApi { | ||
/// API for [`proxy`](https://paritytech.github.io/polkadot-sdk/master/pallet_proxy/pallet/struct.Pallet.html#method.proxy) call. | ||
async fn proxy( | ||
&self, | ||
real: AccountId, | ||
call: RuntimeCall, | ||
status: TxStatus, | ||
) -> anyhow::Result<TxInfo>; | ||
|
||
/// API for [`add_proxy`](https://paritytech.github.io/polkadot-sdk/master/pallet_proxy/pallet/struct.Pallet.html#method.add_proxy) call. | ||
async fn add_proxy( | ||
&self, | ||
delegate: AccountId, | ||
proxy_type: ProxyType, | ||
delay: u32, | ||
status: TxStatus, | ||
) -> anyhow::Result<TxInfo>; | ||
|
||
/// API for [`remove_proxy`](https://paritytech.github.io/polkadot-sdk/master/pallet_proxy/pallet/struct.Pallet.html#method.remove_proxy) call. | ||
async fn remove_proxy( | ||
&self, | ||
delegate: AccountId, | ||
proxy_type: ProxyType, | ||
delay: u32, | ||
status: TxStatus, | ||
) -> anyhow::Result<TxInfo>; | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl<S: SignedConnectionApi> ProxyUserApi for S { | ||
async fn proxy( | ||
&self, | ||
real: AccountId, | ||
call: RuntimeCall, | ||
status: TxStatus, | ||
) -> anyhow::Result<TxInfo> { | ||
let tx = api::tx() | ||
.proxy() | ||
.proxy(MultiAddress::Id(real.into()), None, call); | ||
|
||
self.send_tx(tx, status).await | ||
} | ||
async fn add_proxy( | ||
&self, | ||
delegate: AccountId, | ||
proxy_type: ProxyType, | ||
delay: u32, | ||
status: TxStatus, | ||
) -> anyhow::Result<TxInfo> { | ||
let tx = api::tx() | ||
.proxy() | ||
.add_proxy(MultiAddress::Id(delegate.into()), proxy_type, delay); | ||
|
||
self.send_tx(tx, status).await | ||
} | ||
async fn remove_proxy( | ||
&self, | ||
delegate: AccountId, | ||
proxy_type: ProxyType, | ||
delay: u32, | ||
status: TxStatus, | ||
) -> anyhow::Result<TxInfo> { | ||
let tx = | ||
api::tx() | ||
.proxy() | ||
.remove_proxy(MultiAddress::Id(delegate.into()), proxy_type, delay); | ||
|
||
self.send_tx(tx, status).await | ||
} | ||
} |
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
Oops, something went wrong.