Skip to content
Snippets Groups Projects
sudo.rs 420 B
Newer Older
Hugo Trentesaux's avatar
Hugo Trentesaux committed
use crate::*;

use anyhow::Result;
use sp_core::{crypto::AccountId32, sr25519::Pair};
use subxt::tx::{BaseExtrinsicParamsBuilder, PairSigner};

Hugo Trentesaux's avatar
Hugo Trentesaux committed
pub async fn set_key(pair: Pair, client: &Client, new_key: AccountId32) -> Result<()> {
	client
		.tx()
		.sign_and_submit_then_watch(
Hugo Trentesaux's avatar
Hugo Trentesaux committed
			&runtime::tx().sudo().set_key(new_key.into()),
			&PairSigner::new(pair),
			BaseExtrinsicParamsBuilder::new(),
		)
		.await?;
	Ok(())