osmosis-labs / beaker

Beaker helps streamlining CosmWasm development workflow.
Apache License 2.0
106 stars 30 forks source link

[Refactoring] Make command definition compact #65

Open iboss-ptk opened 2 years ago

iboss-ptk commented 2 years ago

Currently defining new command or changing old command interface needs to edit entrypoint and ops modules.

The purpose of this refactoring it to

Benefits

/// Instanitate .wasm stored on chain
#[derive(Subcommand,Hook)]
struct Instantiate {
  /// Name of the contract to instantiate
  contract_name: String,
  /// Label for the instantiated contract for later reference
  #[clap(short, long, default_value = "default")]
  label: String,

  /// Raw json string to use as instantiate msg
  #[clap(short, long)]
  raw: Option<String>,

  /// Specifying admin required for contract migration.
  /// Use "signer" for setting tx signer as admin.
  /// Use bech32 address (eg. "osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks") for custom admin.
  #[clap(long)]
  admin: Option<String>,

  /// Funds to send to instantiated contract
  #[clap(short, long)]
  funds: Option<String>,

  #[clap(flatten)]
  tx_cmd: TransactionCmd, // this comes with simulation hook, needs to `impl Hookable for TransactionCmd`
}

impl Executable for Instantiate {
  fn execute(&self) {
    ...
  }
}