AbstractSDK / cw-orchestrator

All-in-one Rust-based CosmWasm testing, scripting, and deployment tool.
https://orchestrator.abstract.money
GNU General Public License v3.0
75 stars 17 forks source link

Refactor the `Sender` creation and `Sender` traits #438

Closed CyberHoward closed 1 month ago

CyberHoward commented 1 month ago

This PR refactors the way that the Sender objects are constructed and configured.

The initial PR added a SenderTrait::SenderOptions associated type that allow for building a Sender object.

First, I renamed a few of the traits, types and methods to improve the clarity of the code's structure. Then I split up the SenderTrait into SenderBuilder, QuerySender and TxSender, each with their own scoped functions and types.

With this I refactored the DaemonBuilder(s) to now work as follows:

// Creates a Daemon with the env-var mnemonic. Minimal code required
let daemon = Daemon::builder(chain).mnemonic("...").build()?; // --> Chain now required to build `Builder`

// Creates a `Wallet` with a mnemonic
// Can also customize the `CosmosOptions` to use authz, different hd path, etc.
let my_mnemonic = "...";
let daemon = Daemon::builder(chain).build_sender(CosmosOptions::new(my_mnemonic))?;

// Or create a custom `Sender` or query-only sender
let daemon: QueryOnlyDaemon = Daemon::builder(chain).build_sender(())?;

Checklist

cloudflare-pages[bot] commented 1 month ago

Deploying cw-orchestrator with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8d9fb72
Status: ✅  Deploy successful!
Preview URL: https://e7402de0.cw-orchestrator.pages.dev
Branch Preview URL: https://sender-refactor.cw-orchestrator.pages.dev

View logs

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 59.37500% with 260 lines in your changes missing coverage. Please review.

Project coverage is 54.7%. Comparing base (90bc67b) to head (8d9fb72).

Additional details and impacted files | [Files](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK) | Coverage Δ | | |---|---|---| | [cw-orch-daemon/src/channel.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=cw-orch-daemon%2Fsrc%2Fchannel.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-Y3ctb3JjaC1kYWVtb24vc3JjL2NoYW5uZWwucnM=) | `83.9% <100.0%> (+0.1%)` | :arrow_up: | | [cw-orch-daemon/src/queriers/bank.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=cw-orch-daemon%2Fsrc%2Fqueriers%2Fbank.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-Y3ctb3JjaC1kYWVtb24vc3JjL3F1ZXJpZXJzL2JhbmsucnM=) | `90.7% <100.0%> (ø)` | | | [cw-orch-daemon/src/queriers/node.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=cw-orch-daemon%2Fsrc%2Fqueriers%2Fnode.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-Y3ctb3JjaC1kYWVtb24vc3JjL3F1ZXJpZXJzL25vZGUucnM=) | `44.4% <100.0%> (ø)` | | | [cw-orch-daemon/src/senders/tx.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=cw-orch-daemon%2Fsrc%2Fsenders%2Ftx.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-Y3ctb3JjaC1kYWVtb24vc3JjL3NlbmRlcnMvdHgucnM=) | `100.0% <100.0%> (ø)` | | | [cw-orch-daemon/src/state.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=cw-orch-daemon%2Fsrc%2Fstate.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-Y3ctb3JjaC1kYWVtb24vc3JjL3N0YXRlLnJz) | `81.1% <100.0%> (ø)` | | | [cw-orch-daemon/src/tx\_broadcaster.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=cw-orch-daemon%2Fsrc%2Ftx_broadcaster.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-Y3ctb3JjaC1kYWVtb24vc3JjL3R4X2Jyb2FkY2FzdGVyLnJz) | `75.7% <100.0%> (ø)` | | | [packages/clone-testing/src/core.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=packages%2Fclone-testing%2Fsrc%2Fcore.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvY2xvbmUtdGVzdGluZy9zcmMvY29yZS5ycw==) | `82.5% <100.0%> (ø)` | | | [packages/clone-testing/src/state.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=packages%2Fclone-testing%2Fsrc%2Fstate.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvY2xvbmUtdGVzdGluZy9zcmMvc3RhdGUucnM=) | `94.6% <100.0%> (ø)` | | | [packages/cw-orch-mock/src/core.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=packages%2Fcw-orch-mock%2Fsrc%2Fcore.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvY3ctb3JjaC1tb2NrL3NyYy9jb3JlLnJz) | `97.3% <100.0%> (ø)` | | | [packages/cw-orch-mock/src/queriers/wasm.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree&filepath=packages%2Fcw-orch-mock%2Fsrc%2Fqueriers%2Fwasm.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvY3ctb3JjaC1tb2NrL3NyYy9xdWVyaWVycy93YXNtLnJz) | `89.0% <100.0%> (+0.3%)` | :arrow_up: | | ... and [18 more](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/438/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK)
CyberHoward commented 1 month ago

Still need to update docs