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) {
...
}
}
Currently defining new command or changing old command interface needs to edit
entrypoint
andops
modules.The purpose of this refactoring it to
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.simulation
logic, so that all the tx type command are simulate-able from the get go.Benefits