-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add jcli option to generate and sign EVM mapping certificates.
- Loading branch information
1 parent
4ff6beb
commit 2d85f84
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} |