Newer
Older
use crate::{gdev, Client};
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();
let addr_idty_index = gdev::storage().identity().identity_index_of(&account_id);
let addr_block_hash = gdev::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(())
}