Skip to content

Commit

Permalink
AccountKind helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Nov 2, 2023
1 parent 8c65f48 commit ca0e580
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/src/wizards/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub async fn ask(term: &Arc<Terminal>) -> Result<Vec<String>> {
pub(crate) async fn import_with_mnemonic(ctx: &Arc<KaspaCli>, account_kind: AccountKind, additional_xpubs: &[String]) -> Result<()> {
let wallet = ctx.wallet();

let is_legacy = matches!(account_kind, AccountKind::Legacy);
let is_legacy = account_kind.is_legacy();

if !wallet.is_open() {
return Err(Error::WalletIsNotOpen);
Expand Down
26 changes: 26 additions & 0 deletions wallet/core/src/runtime/account/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ u8_try_from! {
}
}

impl AccountKind {
pub fn is_legacy(&self) -> bool {
matches!(self, AccountKind::Legacy)
}

pub fn is_bip32(&self) -> bool {
matches!(self, AccountKind::Bip32)
}

pub fn is_multisig(&self) -> bool {
matches!(self, AccountKind::MultiSig)
}

pub fn is_keypair(&self) -> bool {
matches!(self, AccountKind::Keypair)
}

pub fn is_hardware(&self) -> bool {
matches!(self, AccountKind::Hardware)
}

pub fn is_resident(&self) -> bool {
matches!(self, AccountKind::Resident)
}
}

impl std::fmt::Display for AccountKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down

0 comments on commit ca0e580

Please sign in to comment.