-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ETCM-8754: implement register tx submit (#299)
- Loading branch information
1 parent
0f1286f
commit 95736ba
Showing
11 changed files
with
332 additions
and
57 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,63 @@ | ||
use jsonrpsee::http_client::HttpClient; | ||
use partner_chains_cardano_offchain::{await_tx::FixedDelayRetries, register::run_register}; | ||
use sidechain_domain::{ | ||
AdaBasedStaking, CandidateRegistration, MainchainPublicKey, MainchainSignature, | ||
PermissionedCandidateData, SidechainSignature, UtxoId, | ||
}; | ||
|
||
use crate::{parse_partnerchain_public_keys, read_private_key_from_file}; | ||
|
||
#[derive(Clone, Debug, clap::Parser)] | ||
pub struct RegisterCmd { | ||
#[clap(flatten)] | ||
common_arguments: crate::CommonArguments, | ||
#[arg(long)] | ||
genesis_utxo: UtxoId, | ||
#[arg(long)] | ||
registration_utxo: UtxoId, | ||
#[arg(long)] | ||
payment_key_file: String, | ||
#[arg( | ||
long, | ||
value_name = "PARTNERCHAIN_KEY:AURA_KEY:GRANDPA_KEY", | ||
alias = "sidechain-public-keys", | ||
value_parser=parse_partnerchain_public_keys | ||
)] | ||
partnerchain_public_keys: PermissionedCandidateData, | ||
#[arg(long, alias = "sidechain-signature")] | ||
partnerchain_signature: SidechainSignature, | ||
#[arg(long)] | ||
spo_public_key: MainchainPublicKey, | ||
#[arg(long)] | ||
spo_signature: MainchainSignature, | ||
} | ||
|
||
impl RegisterCmd { | ||
pub async fn execute(self) -> crate::CmdResult<()> { | ||
let payment_key = read_private_key_from_file(&self.payment_key_file)?; | ||
let client = HttpClient::builder().build(self.common_arguments.ogmios_host)?; | ||
let candidate_registration = CandidateRegistration { | ||
stake_ownership: AdaBasedStaking { | ||
pub_key: self.spo_public_key, | ||
signature: self.spo_signature, | ||
}, | ||
partnerchain_pub_key: self.partnerchain_public_keys.sidechain_public_key, | ||
partnerchain_signature: self.partnerchain_signature, | ||
own_pkh: crate::payment_signing_key_to_mainchain_address_hash(payment_key.clone())?, | ||
registration_utxo: self.registration_utxo, | ||
aura_pub_key: self.partnerchain_public_keys.aura_public_key, | ||
grandpa_pub_key: self.partnerchain_public_keys.grandpa_public_key, | ||
}; | ||
|
||
run_register( | ||
self.genesis_utxo, | ||
&candidate_registration, | ||
payment_key, | ||
&client, | ||
FixedDelayRetries::two_minutes(), | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |
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
Oops, something went wrong.