-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): bridge sudo change command #1612
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use astria_core::primitive::v1::Address; | ||
use astria_sequencer_client::{ | ||
HttpClient, | ||
SequencerClientExt, | ||
}; | ||
use color_eyre::eyre::{ | ||
self, | ||
WrapErr as _, | ||
}; | ||
|
||
#[derive(Debug, clap::Args)] | ||
pub(super) struct Command { | ||
#[command(subcommand)] | ||
command: SubCommand, | ||
} | ||
|
||
impl Command { | ||
pub(super) async fn run(self) -> eyre::Result<()> { | ||
let SubCommand::Get(get) = self.command; | ||
get.run().await | ||
} | ||
} | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
enum SubCommand { | ||
/// Command for getting bridge account information | ||
Get(Get), | ||
} | ||
|
||
#[derive(Debug, clap::Args)] | ||
struct Get { | ||
/// The url of the Sequencer node | ||
#[arg( | ||
long, | ||
env = "SEQUENCER_URL", | ||
default_value = crate::DEFAULT_SEQUENCER_RPC | ||
)] | ||
pub(crate) sequencer_url: String, | ||
/// The bridge account address on the Sequencer | ||
pub(crate) address: Address, | ||
} | ||
|
||
impl Get { | ||
async fn run(self) -> eyre::Result<()> { | ||
let sequencer_client = HttpClient::new(self.sequencer_url.as_str()) | ||
.wrap_err("failed constructing http sequencer client")?; | ||
|
||
let res = sequencer_client | ||
.get_bridge_account_info(self.address) | ||
.await | ||
.wrap_err("failed getting bridge account")?; | ||
let Some(info) = res.info else { | ||
return Err(eyre::eyre!("bridge account information not found")); | ||
}; | ||
println!("Bridge Account Information for address: {}", self.address); | ||
println!(" Rollup Id: {}", info.rollup_id); | ||
println!(" Asset: {}", info.asset); | ||
println!(" Sudo Address: {}", info.sudo_address); | ||
println!(" Withdrawer Address {}", info.withdrawer_address); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use astria_core::{ | ||
primitive::v1::{ | ||
asset, | ||
Address, | ||
}, | ||
protocol::transaction::v1::{ | ||
action::BridgeSudoChange, | ||
Action, | ||
}, | ||
}; | ||
use color_eyre::eyre::{ | ||
self, | ||
WrapErr as _, | ||
}; | ||
|
||
use crate::utils::submit_transaction; | ||
|
||
#[derive(clap::Args, Debug)] | ||
#[command(group(clap::ArgGroup::new("new_address") | ||
.required(true) | ||
.multiple(true) | ||
.args(&["new_sudo_address", "new_withdrawer_address"])))] | ||
pub(crate) struct Command { | ||
/// The bridge account whose privileges will be modified. | ||
pub(crate) bridge_address: Address, | ||
/// The new address to receive sudo privileges. | ||
#[arg(long, default_value = None)] | ||
pub(crate) new_sudo_address: Option<Address>, | ||
/// The new address to receive withdrawer privileges. | ||
#[arg(long, default_value = None)] | ||
pub(crate) new_withdrawer_address: Option<Address>, | ||
/// The prefix to construct a bech32m address given the private key. | ||
#[arg(long, default_value = "astria")] | ||
pub(crate) prefix: String, | ||
// TODO: https://github.com/astriaorg/astria/issues/594 | ||
// Don't use a plain text private, prefer wrapper like from | ||
// the secrecy crate with specialized `Debug` and `Drop` implementations | ||
// that overwrite the key on drop and don't reveal it when printing. | ||
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")] | ||
pub(crate) private_key: String, | ||
/// The url of the Sequencer node | ||
#[arg( | ||
long, | ||
env = "SEQUENCER_URL", | ||
default_value = crate::DEFAULT_SEQUENCER_RPC | ||
)] | ||
pub(crate) sequencer_url: String, | ||
/// The chain id of the sequencing chain being used | ||
#[arg( | ||
long = "sequencer.chain-id", | ||
env = "ROLLUP_SEQUENCER_CHAIN_ID", | ||
default_value = crate::DEFAULT_SEQUENCER_CHAIN_ID | ||
)] | ||
pub(crate) sequencer_chain_id: String, | ||
/// The asset to pay the transfer fees with. | ||
#[arg(long, default_value = "nria")] | ||
pub(crate) fee_asset: asset::Denom, | ||
} | ||
|
||
impl Command { | ||
pub(super) async fn run(self) -> eyre::Result<()> { | ||
let res = submit_transaction( | ||
self.sequencer_url.as_str(), | ||
self.sequencer_chain_id.clone(), | ||
&self.prefix, | ||
self.private_key.as_str(), | ||
Action::BridgeSudoChange(BridgeSudoChange { | ||
bridge_address: self.bridge_address, | ||
new_sudo_address: self.new_sudo_address, | ||
new_withdrawer_address: self.new_withdrawer_address, | ||
fee_asset: self.fee_asset.clone(), | ||
}), | ||
) | ||
.await | ||
.wrap_err("failed to submit BridgeSudoChange transaction")?; | ||
|
||
println!("BridgeSudoChange completed!"); | ||
println!("Included in block: {}", res.height); | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.