Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • clients/rust/gcli-v2s
  • d0p1/gcli-v2s
  • flebon/gcli-v2s
  • zicmama/gcli-v2s
  • Nicolas80/gcli-v2s
5 results
Show changes
use crate::*;
/// define sudo subcommands
#[derive(Clone, Default, Debug, clap::Parser)]
pub enum Subcommand {
/// Nothing
#[default]
#[clap(hide = true)]
Nothing,
/// set sudo keys
SetKey { new_key: AccountId },
/// force valid distance status
SetDistanceOk { identity: IdtyId },
}
/// handle smith commands
pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError> {
let data = data.build_client().await?;
match command {
Subcommand::Nothing => todo!(),
Subcommand::SetKey { new_key } => {
set_key(&data, new_key).await?;
}
Subcommand::SetDistanceOk { identity } => {
set_distance_ok(&data, identity).await?;
}
};
Ok(())
}
/// set sudo key
pub async fn set_key(data: &Data, new_key: AccountId) -> Result<(), subxt::Error> {
submit_call_and_look_event::<
runtime::sudo::events::KeyChanged,
StaticPayload<runtime::sudo::calls::types::SetKey>,
>(data, &runtime::tx().sudo().set_key(new_key.into()))
.await
}
/// set distance ok
pub async fn set_distance_ok(data: &Data, identity: IdtyId) -> Result<(), subxt::Error> {
let inner = runtime::distance::Call::force_valid_distance_status { identity };
let inner = runtime::Call::Distance(inner);
submit_call_and_look_event::<
runtime::sudo::events::Sudid,
StaticPayload<runtime::sudo::calls::types::Sudo>,
>(data, &runtime::tx().sudo().sudo(inner))
.await
}
use crate::*;
#[cfg(feature = "gdev")] // find how to get runtime calls
type Call = runtime::runtime_types::gdev_runtime::RuntimeCall;
type BalancesCall = runtime::runtime_types::pallet_balances::pallet::Call;
/// transfer balance to target
pub async fn transfer(
data: &Data,
balance: u64,
dest: AccountId,
keep_alive: bool,
is_ud: bool,
) -> Result<(), subxt::Error> {
match (keep_alive, is_ud) {
(true, false) => {
submit_call_and_look_event::<
runtime::balances::events::Transfer,
StaticPayload<runtime::balances::calls::types::TransferKeepAlive>,
>(
data,
&runtime::tx()
.balances()
.transfer_keep_alive(dest.into(), balance),
)
.await
}
(false, false) => {
submit_call_and_look_event::<
runtime::balances::events::Transfer,
StaticPayload<runtime::balances::calls::types::TransferAllowDeath>,
>(
data,
&runtime::tx()
.balances()
.transfer_allow_death(dest.into(), balance),
)
.await
}
(true, true) => {
submit_call_and_look_event::<
runtime::balances::events::Transfer,
StaticPayload<runtime::universal_dividend::calls::types::TransferUdKeepAlive>,
>(
data,
&runtime::tx()
.universal_dividend()
.transfer_ud_keep_alive(dest.into(), balance),
)
.await
}
(false, true) => {
submit_call_and_look_event::<
runtime::balances::events::Transfer,
StaticPayload<runtime::universal_dividend::calls::types::TransferUd>,
>(
data,
&runtime::tx()
.universal_dividend()
.transfer_ud(dest.into(), balance),
)
.await
}
}
}
/// transfer balance to multiple target
pub async fn transfer_multiple(
data: &Data,
amount: u64,
dests: Vec<AccountId>,
) -> Result<(), subxt::Error> {
// build the list of transactions from the destination accounts
let transactions: Vec<Call> = dests
.into_iter()
.map(|dest| {
Call::Balances(BalancesCall::transfer_keep_alive {
dest: dest.into(),
value: amount,
})
})
.collect();
// wrap these calls in a batch call
submit_call_and_look_event::<
runtime::utility::events::BatchCompleted,
StaticPayload<runtime::utility::calls::types::Batch>,
>(data, &runtime::tx().utility().batch(transactions))
.await
}
use crate::*;
/// define universal dividends subcommands
#[derive(Clone, Default, Debug, clap::Parser)]
pub enum Subcommand {
#[default]
/// Claim uds
Claim,
}
/// handle ud commands
pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError> {
// build indexer because it is needed for all subcommands
let data = data.build_client().await?.fetch_system_properties().await?;
// match subcommand
match command {
Subcommand::Claim => {
claim_ud(&data).await?;
}
};
Ok(())
}
/// claim universal dividend
pub async fn claim_ud(data: &Data) -> Result<(), subxt::Error> {
submit_call_and_look_event::<
runtime::universal_dividend::events::UdsClaimed,
StaticPayload<runtime::universal_dividend::calls::types::ClaimUds>,
>(data, &runtime::tx().universal_dividend().claim_uds())
.await
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
pub mod vault_account;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.