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

use anyhow::Result;
use futures::join;
use sp_core::{sr25519::Pair, Encode, Pair as _};

pub async fn gen_revoc_doc(api: &Client, pair: &Pair) -> Result<()> {
	let account_id: sp_core::crypto::AccountId32 = pair.public().into();
Hugo Trentesaux's avatar
Hugo Trentesaux committed
	let addr_idty_index = runtime::storage().identity().identity_index_of(&account_id);
	let addr_block_hash = runtime::storage().system().block_hash(0);
	let (idty_index, genesis_hash) = join!(
		api.storage().fetch(&addr_idty_index, None,),
		api.storage().fetch(&addr_block_hash, None)
	);
	let idty_index = idty_index?.unwrap();
	let genesis_hash = genesis_hash?.unwrap();
	let payload = (b"revo", genesis_hash, idty_index).encode();
	let signature = pair.sign(&payload);
	println!("0x{}", hex::encode(signature));
	Ok(())