Skip to content

Commit

Permalink
Add EnvironmentArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
tkporter committed Oct 23, 2023
1 parent 51e2711 commit d7e84ea
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 51 deletions.
3 changes: 2 additions & 1 deletion rust/sealevel/client/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use hyperlane_sealevel_igp::accounts::{SOL_DECIMALS, TOKEN_EXCHANGE_RATE_SCALE};
pub(crate) fn process_core_cmd(mut ctx: Context, cmd: CoreCmd) {
match cmd.cmd {
CoreSubCmd::Deploy(core) => {
let environments_dir = create_new_directory(&core.environments_dir, &core.environment);
let environments_dir =
create_new_directory(&core.env_args.environments_dir, &core.env_args.environment);
let chain_dir = create_new_directory(&environments_dir, &core.chain);
let core_dir = create_new_directory(&chain_dir, "core");
let key_dir = create_new_directory(&core_dir, "keys");
Expand Down
4 changes: 2 additions & 2 deletions rust/sealevel/client/src/helloworld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ fn deploy_helloworld(ctx: &mut Context, deploy: HelloWorldDeploy) {
&deploy.context,
deploy.config_file,
deploy.chain_config_file,
deploy.environments_dir,
&deploy.environment,
deploy.env_args.environments_dir,
&deploy.env_args.environment,
deploy.built_so_dir,
)
}
26 changes: 18 additions & 8 deletions rust/sealevel/client/src/igp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ fn get_context_dir_name(context: Option<&String>) -> &str {
pub(crate) fn process_igp_cmd(mut ctx: Context, cmd: IgpCmd) {
match cmd.cmd {
IgpSubCmd::DeployProgram(deploy) => {
let environments_dir =
create_new_directory(&deploy.environments_dir, &deploy.environment);
let environments_dir = create_new_directory(
&deploy.env_args.environments_dir,
&deploy.env_args.environment,
);
let ism_dir = create_new_directory(&environments_dir, "igp");
let chain_dir = create_new_directory(&ism_dir, &deploy.chain);
let key_dir = create_new_directory(&chain_dir, "keys");
Expand All @@ -75,7 +77,8 @@ pub(crate) fn process_igp_cmd(mut ctx: Context, cmd: IgpCmd) {
);
}
IgpSubCmd::InitIgpAccount(init) => {
let environments_dir = create_new_directory(&init.environments_dir, &init.environment);
let environments_dir =
create_new_directory(&init.env_args.environments_dir, &init.env_args.environment);
let ism_dir = create_new_directory(&environments_dir, "igp");
let chain_dir = create_new_directory(&ism_dir, &init.chain);
let context_dir =
Expand Down Expand Up @@ -107,7 +110,8 @@ pub(crate) fn process_igp_cmd(mut ctx: Context, cmd: IgpCmd) {
write_json(&artifacts_path, artifacts);
}
IgpSubCmd::InitOverheadIgpAccount(init) => {
let environments_dir = create_new_directory(&init.environments_dir, &init.environment);
let environments_dir =
create_new_directory(&init.env_args.environments_dir, &init.env_args.environment);
let ism_dir = create_new_directory(&environments_dir, "igp");
let chain_dir = create_new_directory(&ism_dir, &init.chain);
let context_dir =
Expand Down Expand Up @@ -241,8 +245,11 @@ pub(crate) fn process_igp_cmd(mut ctx: Context, cmd: IgpCmd) {
.send_with_payer();
}
IgpSubCmd::GasOracleConfig(args) => {
let core_program_ids =
read_core_program_ids(&args.environments_dir, &args.environment, &args.chain_name);
let core_program_ids = read_core_program_ids(
&args.env_args.environments_dir,
&args.env_args.environment,
&args.chain_name,
);
match args.cmd {
GetSetCmd::Set(set_args) => {
let remote_gas_data = RemoteGasData {
Expand Down Expand Up @@ -287,8 +294,11 @@ pub(crate) fn process_igp_cmd(mut ctx: Context, cmd: IgpCmd) {
}
}
IgpSubCmd::DestinationGasOverhead(args) => {
let core_program_ids =
read_core_program_ids(&args.environments_dir, &args.environment, &args.chain_name);
let core_program_ids = read_core_program_ids(
&args.env_args.environments_dir,
&args.env_args.environment,
&args.chain_name,
);
match args.cmd {
GasOverheadSubCmd::Get => {
// Read the gas overhead config
Expand Down
62 changes: 26 additions & 36 deletions rust/sealevel/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ enum HyperlaneSealevelCmd {
HelloWorld(HelloWorldCmd),
}

#[derive(Args)]
struct EnvironmentArgs {
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
}

#[derive(Args)]
pub(crate) struct WarpRouteCmd {
#[command(subcommand)]
Expand All @@ -127,10 +135,8 @@ pub(crate) enum WarpRouteSubCmd {

#[derive(Args)]
pub(crate) struct WarpRouteDeploy {
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
built_so_dir: PathBuf,
#[arg(long)]
Expand Down Expand Up @@ -166,8 +172,8 @@ enum CoreSubCmd {
struct CoreDeploy {
#[arg(long)]
local_domain: u32,
#[arg(long)]
environment: String,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
gas_oracle_config_file: Option<PathBuf>,
#[arg(long)]
Expand All @@ -176,8 +182,6 @@ struct CoreDeploy {
chain: String,
#[arg(long)]
use_existing_keys: bool,
#[arg(long)]
environments_dir: PathBuf,
#[arg(long, num_args = 1.., value_delimiter = ',')]
remote_domains: Vec<u32>,
#[arg(long)]
Expand Down Expand Up @@ -393,10 +397,8 @@ enum IgpSubCmd {

#[derive(Args)]
struct IgpDeployProgramArgs {
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
chain: String,
#[arg(long)]
Expand All @@ -407,10 +409,8 @@ struct IgpDeployProgramArgs {
struct InitIgpAccountArgs {
#[arg(long)]
program_id: Pubkey,
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
chain: String,
#[arg(long)]
Expand All @@ -425,10 +425,8 @@ struct InitIgpAccountArgs {
struct InitOverheadIgpAccountArgs {
#[arg(long)]
program_id: Pubkey,
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
chain: String,
#[arg(long)]
Expand Down Expand Up @@ -484,10 +482,8 @@ struct ClaimArgs {

#[derive(Args)]
struct GasOracleConfigArgs {
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
chain_name: String,
#[arg(long)]
Expand All @@ -511,10 +507,8 @@ struct GetGasOracleArgs;

#[derive(Args)]
struct DestinationGasOverheadArgs {
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
chain_name: String,
#[arg(long)]
Expand Down Expand Up @@ -595,10 +589,8 @@ enum MultisigIsmMessageIdSubCmd {

#[derive(Args)]
struct MultisigIsmMessageIdDeploy {
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
built_so_dir: PathBuf,
#[arg(long)]
Expand Down Expand Up @@ -657,10 +649,8 @@ pub(crate) enum HelloWorldSubCmd {

#[derive(Args)]
pub(crate) struct HelloWorldDeploy {
#[arg(long)]
environment: String,
#[arg(long)]
environments_dir: PathBuf,
#[command(flatten)]
env_args: EnvironmentArgs,
#[arg(long)]
built_so_dir: PathBuf,
#[arg(long)]
Expand Down
6 changes: 4 additions & 2 deletions rust/sealevel/client/src/multisig_ism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ impl From<MultisigIsmConfig> for ValidatorsAndThreshold {
pub(crate) fn process_multisig_ism_message_id_cmd(mut ctx: Context, cmd: MultisigIsmMessageIdCmd) {
match cmd.cmd {
MultisigIsmMessageIdSubCmd::Deploy(deploy) => {
let environments_dir =
create_new_directory(&deploy.environments_dir, &deploy.environment);
let environments_dir = create_new_directory(
&deploy.env_args.environments_dir,
&deploy.env_args.environment,
);
let ism_dir = create_new_directory(&environments_dir, "multisig-ism-message-id");
let chain_dir = create_new_directory(&ism_dir, &deploy.chain);
let context_dir = create_new_directory(&chain_dir, &deploy.context);
Expand Down
4 changes: 2 additions & 2 deletions rust/sealevel/client/src/warp_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ pub(crate) fn process_warp_route_cmd(mut ctx: Context, cmd: WarpRouteCmd) {
&deploy.warp_route_name,
deploy.token_config_file,
deploy.chain_config_file,
deploy.environments_dir,
&deploy.environment,
deploy.env_args.environments_dir,
&deploy.env_args.environment,
deploy.built_so_dir,
);
}
Expand Down

0 comments on commit d7e84ea

Please sign in to comment.