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

Refactor the Sender creation and Sender traits #438

Merged
merged 117 commits into from
Jul 9, 2024
Merged

Conversation

CyberHoward
Copy link
Contributor

@CyberHoward CyberHoward commented Jul 1, 2024

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

  • Changelog updated.
  • Docs updated.

Copy link
Contributor

@Buckram123 Buckram123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! There is many cool breaking changes 🚀

cw-orch-daemon/src/senders/cosmos.rs Outdated Show resolved Hide resolved
cw-orch-daemon/src/senders/tx.rs Show resolved Hide resolved
@CyberHoward CyberHoward changed the base branch from nicolas/orc-126-daemon-should-become-a-wrapper-around-sender-types to main July 5, 2024 13:25
@CyberHoward
Copy link
Contributor Author

Still need to update docs

@CyberHoward CyberHoward merged commit 59451dd into main Jul 9, 2024
20 checks passed
@CyberHoward CyberHoward deleted the sender_refactor branch July 9, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants