Skip to content

Commit

Permalink
Use kairos-crypto in CLI parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
koxu1996 committed Mar 17, 2024
1 parent 80aace0 commit 81bc25b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kairos-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ casper-types = { version = "4.0.1", features = ["std"] } # TODO: Change `std` ->
clap = { version = "4.4.18", features = ["derive"] }
hex = "0.4.3"
thiserror = "1.0.56"
kairos-crypto = { path = "../kairos-crypto" }

[dev-dependencies]
assert_cmd = "2.0.13"
Expand Down
8 changes: 5 additions & 3 deletions kairos-cli/src/commands/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::common::args::{AmountArg, PrivateKeyPathArg};
use crate::crypto::error::CryptoError;
use crate::crypto::signer::CasperSigner;
use crate::error::CliError;

use kairos_crypto::error::CryptoError;
use kairos_crypto::implementations::Signer;
use kairos_crypto::CryptoSigner;

use clap::Parser;

#[derive(Parser, Debug)]
Expand All @@ -16,7 +18,7 @@ pub struct Args {
pub fn run(args: Args) -> Result<String, CliError> {
let _amount: u64 = args.amount.field;
let _signer =
CasperSigner::from_file(args.private_key_path.field).map_err(CryptoError::from)?;
Signer::from_private_key_file(args.private_key_path.field).map_err(CryptoError::from)?;

// TODO: Create transaction and sign it with `signer`.

Expand Down
11 changes: 6 additions & 5 deletions kairos-cli/src/commands/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::common::args::{AmountArg, PrivateKeyPathArg};
use crate::crypto::error::CryptoError;
use crate::crypto::public_key::CasperPublicKey;
use crate::crypto::signer::CasperSigner;
use crate::error::CliError;
use crate::utils::parse_hex_string;

use kairos_crypto::error::CryptoError;
use kairos_crypto::implementations::Signer;
use kairos_crypto::CryptoSigner;

use clap::Parser;

#[derive(Parser)]
Expand All @@ -18,10 +19,10 @@ pub struct Args {
}

pub fn run(args: Args) -> Result<String, CliError> {
let _recipient = CasperPublicKey::from_bytes(args.recipient.as_ref())?;
let _recipient = Signer::from_public_key(args.recipient.as_ref())?.to_public_key()?;
let _amount: u64 = args.amount.field;
let _signer =
CasperSigner::from_file(args.private_key_path.field).map_err(CryptoError::from)?;
Signer::from_private_key_file(args.private_key_path.field).map_err(CryptoError::from)?;

// TODO: Create transaction and sign it with `signer`.

Expand Down
8 changes: 5 additions & 3 deletions kairos-cli/src/commands/withdraw.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::common::args::{AmountArg, PrivateKeyPathArg};
use crate::crypto::error::CryptoError;
use crate::crypto::signer::CasperSigner;
use crate::error::CliError;

use kairos_crypto::error::CryptoError;
use kairos_crypto::implementations::Signer;
use kairos_crypto::CryptoSigner;

use clap::Parser;

#[derive(Parser)]
Expand All @@ -16,7 +18,7 @@ pub struct Args {
pub fn run(args: Args) -> Result<String, CliError> {
let _amount: u64 = args.amount.field;
let _signer =
CasperSigner::from_file(args.private_key_path.field).map_err(CryptoError::from)?;
Signer::from_private_key_file(args.private_key_path.field).map_err(CryptoError::from)?;

// TODO: Create transaction and sign it with `signer`.

Expand Down
2 changes: 1 addition & 1 deletion kairos-cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use hex::FromHexError;
use thiserror::Error;

use crate::crypto::error::CryptoError;
use kairos_crypto::error::CryptoError;

#[derive(Error, Debug)]
pub enum CliError {
Expand Down

0 comments on commit 81bc25b

Please sign in to comment.