-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement initial StarknetBuilder and StarknetBuildComponents * taplo fmt * Add query client state CLI * Implement BuilderLoader for StarknetAppComponents * Add query client state CLI for Starknet to Cosmos * Fix query client-state CLI name * clippy fix * Use Starknet chain config from Starknet relayer config instead of creating a new one
- Loading branch information
Showing
13 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
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
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 @@ | ||
pub mod query; |
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 @@ | ||
pub mod subcommand; |
23 changes: 23 additions & 0 deletions
23
relayer/crates/starknet-cli/src/commands/query/subcommand.rs
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,23 @@ | ||
use hermes_cli_components::impls::commands::queries::client_state::QueryClientStateArgs; | ||
use hermes_cli_components::traits::command::{CanRunCommand, CommandRunner}; | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
pub enum QuerySubCommand { | ||
ClientState(QueryClientStateArgs), | ||
} | ||
|
||
pub struct RunQuerySubCommand; | ||
|
||
impl<App> CommandRunner<App, QuerySubCommand> for RunQuerySubCommand | ||
where | ||
App: CanRunCommand<QueryClientStateArgs>, | ||
{ | ||
async fn run_command( | ||
app: &App, | ||
subcommand: &QuerySubCommand, | ||
) -> Result<App::Output, App::Error> { | ||
match subcommand { | ||
QuerySubCommand::ClientState(args) => app.run_command(args).await, | ||
} | ||
} | ||
} |
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,45 @@ | ||
use cgp::prelude::CanRaiseError; | ||
use hermes_cli_components::traits::build::{BuilderLoader, HasBuilderType}; | ||
use hermes_cli_components::traits::config::load_config::CanLoadConfig; | ||
use hermes_cli_components::traits::types::config::HasConfigType; | ||
use hermes_cosmos_relayer::contexts::build::CosmosBuilder; | ||
use hermes_runtime::types::runtime::HermesRuntime; | ||
use hermes_runtime_components::traits::runtime::HasRuntime; | ||
use hermes_starknet_chain_components::impls::types::config::StarknetRelayerConfig; | ||
use hermes_starknet_relayer::contexts::builder::StarknetBuilder; | ||
|
||
pub struct LoadStarknetBuilder; | ||
|
||
impl<App> BuilderLoader<App> for LoadStarknetBuilder | ||
where | ||
App: HasBuilderType<Builder = StarknetBuilder> | ||
+ HasConfigType<Config = StarknetRelayerConfig> | ||
+ HasRuntime<Runtime = HermesRuntime> | ||
+ CanLoadConfig | ||
+ CanRaiseError<&'static str>, | ||
{ | ||
async fn load_builder(app: &App) -> Result<App::Builder, App::Error> { | ||
let runtime = app.runtime().clone(); | ||
let config = app.load_config().await?; | ||
let cosmos_chain_config = config.cosmos_chain_config.ok_or_else(|| { | ||
App::raise_error("missing Cosmos chain config in Starknet relayer config") | ||
})?; | ||
|
||
let cosmos_builder = CosmosBuilder::new( | ||
vec![cosmos_chain_config], | ||
runtime.clone(), | ||
Default::default(), | ||
Default::default(), | ||
Default::default(), | ||
Default::default(), | ||
); | ||
|
||
let starknet_chain_config = config.starknet_chain_config.ok_or_else(|| { | ||
App::raise_error("missing Starknet chain config in Starknet relayer config") | ||
})?; | ||
|
||
let builder = StarknetBuilder::new(cosmos_builder, runtime, starknet_chain_config); | ||
|
||
Ok(builder) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod bootstrap; | ||
pub mod build; | ||
pub mod error; | ||
pub mod subcommand; |
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 |
---|---|---|
@@ -1,25 +1,29 @@ | ||
use hermes_cli_components::traits::command::{CanRunCommand, CommandRunner}; | ||
|
||
use crate::commands::query::subcommand::QuerySubCommand; | ||
use crate::impls::bootstrap::subcommand::BootstrapSubCommand; | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
pub enum AllSubCommands { | ||
#[clap(subcommand)] | ||
Bootstrap(BootstrapSubCommand), | ||
#[clap(subcommand)] | ||
Query(QuerySubCommand), | ||
} | ||
|
||
pub struct RunAllSubCommand; | ||
|
||
impl<App> CommandRunner<App, AllSubCommands> for RunAllSubCommand | ||
where | ||
App: CanRunCommand<BootstrapSubCommand>, | ||
App: CanRunCommand<BootstrapSubCommand> + CanRunCommand<QuerySubCommand>, | ||
{ | ||
async fn run_command( | ||
app: &App, | ||
subcommand: &AllSubCommands, | ||
) -> Result<App::Output, App::Error> { | ||
match subcommand { | ||
AllSubCommands::Bootstrap(args) => app.run_command(args).await, | ||
AllSubCommands::Query(args) => app.run_command(args).await, | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
extern crate alloc; | ||
|
||
pub mod commands; | ||
pub mod contexts; | ||
pub mod impls; |