Skip to content

Commit

Permalink
Jcli evm mapping args (#3896)
Browse files Browse the repository at this point in the history
* Add jcli option to generate and sign EVM mapping certificates.
  • Loading branch information
saibatizoku authored May 5, 2022
1 parent 4ff6beb commit 2d85f84
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Bump time from 0.3.7 to 0.3.9
- Bump libc from 0.2.117 to 0.2.124
- Bump rand from 0.8.4 to 0.8.5
- Add jcli option to generate and sign EVM mapping certificates.

## Release 0.13.0

Expand Down
7 changes: 7 additions & 0 deletions jcli/src/jcli_lib/certificate/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "evm")]
mod new_evm_mapping;
mod new_owner_stake_delegation;
mod new_stake_delegation;
mod new_stake_pool_registration;
Expand Down Expand Up @@ -174,6 +176,9 @@ pub enum NewArgs {
UpdateProposal(new_update_proposal::UpdateProposal),
/// create a vote cast certificate
VoteCast(new_vote_cast::VoteCastCmd),
#[cfg(feature = "evm")]
/// create an EVM address mapping certificate
EvmMapping(new_evm_mapping::EvmMapCmd),
}

#[derive(StructOpt)]
Expand Down Expand Up @@ -206,6 +211,8 @@ impl NewArgs {
NewArgs::VoteCast(args) => args.exec()?,
NewArgs::UpdateVote(args) => args.exec()?,
NewArgs::UpdateProposal(args) => args.exec()?,
#[cfg(feature = "evm")]
NewArgs::EvmMapping(args) => args.exec()?,
}
Ok(())
}
Expand Down
36 changes: 36 additions & 0 deletions jcli/src/jcli_lib/certificate/new_evm_mapping.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use crate::jcli_lib::{
certificate::{write_cert, Error},
utils::key_parser::parse_pub_key,
};
use chain_crypto::{Ed25519, PublicKey};
use chain_impl_mockchain::{
certificate::{Certificate, EvmMapping},
evm::Address,
};
use jormungandr_lib::interfaces::Certificate as CertificateType;
use std::path::PathBuf;
use structopt::StructOpt;

#[derive(StructOpt, Debug)]
#[structopt(rename_all = "kebab-case")]
pub struct EvmMapCmd {
/// jormungandr account id
#[structopt(name = "ACCOUNT_KEY", parse(try_from_str = parse_pub_key))]
account_id: PublicKey<Ed25519>,
/// hex encoded H160 address
evm_address: Address,
/// write the output to the given file or print it to the standard output if not defined
#[structopt(short = "o", long = "output")]
output: Option<PathBuf>,
}

impl EvmMapCmd {
pub fn exec(self) -> Result<(), Error> {
let content = EvmMapping {
account_id: self.account_id.into(),
evm_address: self.evm_address,
};
let cert = Certificate::EvmMapping(content);
write_cert(self.output.as_deref(), CertificateType(cert))
}
}

0 comments on commit 2d85f84

Please sign in to comment.