Skip to content
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

[Refactoring] Make command definition compact #65

Open
iboss-ptk opened this issue Jul 4, 2022 · 0 comments
Open

[Refactoring] Make command definition compact #65

iboss-ptk opened this issue Jul 4, 2022 · 0 comments

Comments

@iboss-ptk
Copy link
Collaborator

iboss-ptk commented Jul 4, 2022

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

The purpose of this refactoring it to

  • make command definition compact, one place change
  • has clear framwork to deal with recurring job like
    • using value in config as default
    • recurring transformation due to clap only accept string, there are steps for transforming input into non primitive eg. gas
      • using type wrapper with fn for recurring transformation?
    • query / tx, could even create QueryCmd, TransactionCmd kinda type to bundle all this logic together eg. broadcasting, simulation and such and has the basic args for query / tx in the struct so they can parse the cmd input.
      • reusable simulation logic, so that all the tx type command are simulate-able from the get go.

Benefits

  • code organization and faster iteration
  • testing will be easier to organize, which means it helps for better code cov and confidence in not breaking stuffs without test locking you from easy changes.
/// 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) {
    ...
  }
}
@iboss-ptk iboss-ptk moved this to Todo in CosmWasm Ecosystem Jul 5, 2022
@iboss-ptk iboss-ptk modified the milestone: 0.0.5 Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant