-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: ETCM-9063 add update-governance offchain and command (#329)
- Loading branch information
1 parent
850e268
commit 3632997
Showing
19 changed files
with
690 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use crate::read_private_key_from_file; | ||
use jsonrpsee::http_client::HttpClient; | ||
use partner_chains_cardano_offchain::{ | ||
await_tx::FixedDelayRetries, init_governance::run_init_governance, | ||
update_governance::run_update_governance, | ||
}; | ||
use sidechain_domain::{MainchainAddressHash, UtxoId}; | ||
|
||
#[derive(Clone, Debug, clap::Subcommand)] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum GovernanceCmd { | ||
/// Initialize Partner Chain governance | ||
Init(InitGovernanceCmd), | ||
/// Update Partner Chain governance | ||
Update(UpdateGovernanceCmd), | ||
} | ||
|
||
impl GovernanceCmd { | ||
pub async fn execute(self) -> crate::CmdResult<()> { | ||
match self { | ||
Self::Init(cmd) => cmd.execute().await, | ||
Self::Update(cmd) => cmd.execute().await, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, clap::Parser)] | ||
pub struct InitGovernanceCmd { | ||
#[clap(flatten)] | ||
common_arguments: crate::CommonArguments, | ||
/// Governance authority hash to be set. | ||
#[arg(long, short = 'g')] | ||
governance_authority: MainchainAddressHash, | ||
/// Path to the Cardano Payment Key file. | ||
#[arg(long, short = 'k')] | ||
payment_key_file: String, | ||
/// Genesis UTXO of the new chain, it will be spent durning initialization. If not set, then one will be selected from UTXOs of the payment key. | ||
#[arg(long, short = 'c')] | ||
genesis_utxo: Option<UtxoId>, | ||
} | ||
|
||
impl InitGovernanceCmd { | ||
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_url)?; | ||
|
||
run_init_governance( | ||
self.governance_authority, | ||
payment_key, | ||
self.genesis_utxo, | ||
&client, | ||
FixedDelayRetries::two_minutes(), | ||
) | ||
.await?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, clap::Parser)] | ||
pub struct UpdateGovernanceCmd { | ||
#[clap(flatten)] | ||
common_arguments: crate::CommonArguments, | ||
/// Governance authority hash to be set. | ||
#[arg(long, short = 'g')] | ||
new_governance_authority: MainchainAddressHash, | ||
/// Path to the Cardano Payment Key file. | ||
#[arg(long, short = 'k')] | ||
payment_key_file: String, | ||
/// Genesis UTXO of the chain | ||
#[arg(long, short = 'c')] | ||
genesis_utxo: UtxoId, | ||
} | ||
|
||
impl UpdateGovernanceCmd { | ||
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_url)?; | ||
|
||
run_update_governance( | ||
self.new_governance_authority, | ||
payment_key, | ||
self.genesis_utxo, | ||
&client, | ||
FixedDelayRetries::two_minutes(), | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
toolkit/cli/smart-contracts-commands/src/init_governance.rs
This file was deleted.
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
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
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
Oops, something went wrong.