mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 02:51:01 +00:00
CLI: Derive Account (#860)
* Move derive account. * Fix account derivation.
This commit is contained in:
committed by
Bastian Köcher
parent
da3f94d99f
commit
0d7291d729
@@ -29,7 +29,7 @@ pub type MillauClient = relay_substrate_client::Client<Millau>;
|
||||
pub type RialtoClient = relay_substrate_client::Client<Rialto>;
|
||||
|
||||
use crate::cli::{
|
||||
AccountId, CliChain, ExplicitOrMaximal, HexBytes, Origins, SourceConnectionParams, SourceSigningParams,
|
||||
CliChain, ExplicitOrMaximal, HexBytes, Origins, SourceConnectionParams, SourceSigningParams,
|
||||
TargetConnectionParams, TargetSigningParams,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
@@ -337,43 +337,6 @@ async fn run_estimate_fee(cmd: cli::EstimateFee) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_derive_account(cmd: cli::DeriveAccount) -> Result<(), String> {
|
||||
match cmd {
|
||||
cli::DeriveAccount::RialtoToMillau { mut account } => {
|
||||
type Source = Rialto;
|
||||
type Target = Millau;
|
||||
|
||||
account.enforce_chain::<Source>();
|
||||
let acc = bp_runtime::SourceAccount::Account(account.raw_id());
|
||||
let id = bp_millau::derive_account_from_rialto_id(acc);
|
||||
let derived_account = AccountId::from_raw::<Target>(id);
|
||||
println!("Source address:\n{} ({})", account, Source::NAME);
|
||||
println!(
|
||||
"->Corresponding (derived) address:\n{} ({})",
|
||||
derived_account,
|
||||
Target::NAME,
|
||||
);
|
||||
}
|
||||
cli::DeriveAccount::MillauToRialto { mut account } => {
|
||||
type Source = Millau;
|
||||
type Target = Rialto;
|
||||
|
||||
account.enforce_chain::<Source>();
|
||||
let acc = bp_runtime::SourceAccount::Account(account.raw_id());
|
||||
let id = bp_rialto::derive_account_from_millau_id(acc);
|
||||
let derived_account = AccountId::from_raw::<Target>(id);
|
||||
println!("Source address:\n{} ({})", account, Source::NAME);
|
||||
println!(
|
||||
"->Corresponding (derived) address:\n{} ({})",
|
||||
derived_account,
|
||||
Target::NAME,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn estimate_message_delivery_and_dispatch_fee<Fee: Decode, C: Chain, P: Encode>(
|
||||
client: &relay_substrate_client::Client<C>,
|
||||
estimate_fee_method: &str,
|
||||
@@ -864,25 +827,4 @@ mod tests {
|
||||
extra_bytes_in_transaction,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_reformat_addresses() {
|
||||
// given
|
||||
let mut rialto1: AccountId = "5sauUXUfPjmwxSgmb3tZ5d6yx24eZX4wWJ2JtVUBaQqFbvEU".parse().unwrap();
|
||||
let mut millau1: AccountId = "752paRyW1EGfq9YLTSSqcSJ5hqnBDidBmaftGhBo8fy6ypW9".parse().unwrap();
|
||||
|
||||
// when
|
||||
rialto1.enforce_chain::<Millau>();
|
||||
millau1.enforce_chain::<Rialto>();
|
||||
|
||||
// then
|
||||
assert_eq!(
|
||||
&format!("{}", rialto1),
|
||||
"752paRyW1EGfq9YLTSSqcSJ5hqnBDidBmaftGhBo8fy6ypW9"
|
||||
);
|
||||
assert_eq!(
|
||||
&format!("{}", millau1),
|
||||
"5sauUXUfPjmwxSgmb3tZ5d6yx24eZX4wWJ2JtVUBaQqFbvEU"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user