-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-4099: New pallets API in aleph-client (#1629)
# Description Recently we added the feature control and vk storage pallet - in order to test them in e2e tests, we need its API covered by aleph-client. ## Type of change - New feature (non-breaking change which adds functionality) # Checklist: - I have created new documentation - I have bumped aleph-client version if relevant
- Loading branch information
1 parent
f7b05cf
commit 06bf402
Showing
7 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
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
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,41 @@ | ||
use crate::{ | ||
api, pallet_feature_control::Feature, BlockHash, ConnectionApi, RootConnection, | ||
SignedConnectionApi, TxInfo, TxStatus, | ||
}; | ||
|
||
/// Read only pallet feature control API. | ||
#[async_trait::async_trait] | ||
pub trait FeatureControlApi { | ||
/// Check if a feature is active. | ||
async fn is_feature_active(&self, feature: Feature, at: Option<BlockHash>) -> bool; | ||
} | ||
|
||
/// Pallet feature control API that requires sudo. | ||
#[async_trait::async_trait] | ||
pub trait FeatureControlSudoApi { | ||
/// Enable a feature. | ||
async fn enable_feature(&self, feature: Feature, status: TxStatus) -> anyhow::Result<TxInfo>; | ||
/// Disable a feature. | ||
async fn disable_feature(&self, feature: Feature, status: TxStatus) -> anyhow::Result<TxInfo>; | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl<C: ConnectionApi> FeatureControlApi for C { | ||
async fn is_feature_active(&self, feature: Feature, at: Option<BlockHash>) -> bool { | ||
let addrs = api::storage().feature_control().active_features(feature); | ||
self.get_storage_entry_maybe(&addrs, at).await.is_some() | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl FeatureControlSudoApi for RootConnection { | ||
async fn enable_feature(&self, feature: Feature, status: TxStatus) -> anyhow::Result<TxInfo> { | ||
let tx = api::tx().feature_control().enable(feature); | ||
self.send_tx(tx, status).await | ||
} | ||
|
||
async fn disable_feature(&self, feature: Feature, status: TxStatus) -> anyhow::Result<TxInfo> { | ||
let tx = api::tx().feature_control().disable(feature); | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.