-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add treasuries pallet * add cli for treasuries rpc * tested successfully * lift patches and bump crate versions * comment fix
- Loading branch information
Showing
15 changed files
with
240 additions
and
23 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name = "encointer-client-notee" | |
authors = ["encointer.org <[email protected]>"] | ||
edition = "2021" | ||
#keep with node version. major, minor and patch | ||
version = "1.14.0" | ||
version = "1.14.1" | ||
|
||
[dependencies] | ||
# todo migrate to clap >=3 https://github.com/encointer/encointer-node/issues/107 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::Api; | ||
use encointer_node_notee_runtime::AccountId; | ||
use encointer_primitives::communities::CommunityIdentifier; | ||
|
||
use substrate_api_client::{ac_compose_macros::rpc_params, rpc::Request}; | ||
|
||
#[maybe_async::maybe_async(?Send)] | ||
pub trait TreasuriesApi { | ||
async fn get_community_treasury_account_unchecked( | ||
&self, | ||
maybecid: Option<CommunityIdentifier>, | ||
) -> Option<AccountId>; | ||
} | ||
|
||
#[maybe_async::maybe_async(?Send)] | ||
impl TreasuriesApi for Api { | ||
async fn get_community_treasury_account_unchecked( | ||
&self, | ||
maybecid: Option<CommunityIdentifier>, | ||
) -> Option<AccountId> { | ||
self.client() | ||
.request("encointer_getCommunityTreasuryAccountUnchecked", rpc_params![maybecid]) | ||
.await | ||
.expect("Could not get treasury address...") | ||
} | ||
} |
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,20 @@ | ||
use crate::{cli_args::EncointerArgsExtractor, utils::get_chain_api}; | ||
use clap::ArgMatches; | ||
use encointer_api_client_extension::{CommunitiesApi, TreasuriesApi}; | ||
|
||
pub fn get_treasury_account(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap::Error> { | ||
let rt = tokio::runtime::Runtime::new().unwrap(); | ||
rt.block_on(async { | ||
let api = get_chain_api(matches).await; | ||
|
||
let maybecid = if let Some(cid) = matches.cid_arg() { | ||
Some(api.verify_cid(cid, None).await) | ||
} else { | ||
None | ||
}; | ||
let treasury = api.get_community_treasury_account_unchecked(maybecid).await.unwrap(); | ||
println!("{treasury}"); | ||
Ok(()) | ||
}) | ||
.into() | ||
} |
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.