Skip to content

Refactor to client factories#93

Merged
ryangoree merged 14 commits intomainfrom
ryan-object-comp
Jan 28, 2025
Merged

Refactor to client factories#93
ryangoree merged 14 commits intomainfrom
ryan-object-comp

Conversation

@ryangoree
Copy link
Owner

@ryangoree ryangoree commented Jan 27, 2025

This PR refactors client classes to factory functions that extend the prototype of the Adapter they're given. This brings a number of benefits:

  • Avoids the diamond problem
  • The client API can be more dynamic based on the adapter you give it without being limited by the requirement of Class definitions to have a statically known interface.
  • Clients can now be used as drop-in replacements for the adapters they're given.
  • The factory only needs to extend the adapter with additional logic instead of defining forwarders for every part of the adapter interface it wants to expose. All methods and properties from the adapter will be available on the client.
  • Doc comments, param types, and return types, no longer have to be repeated in each client definition since they're retained from the adapter.

Additional patches in the PR:

  • Added Eval to each union member of the OneOf type to prettify the computed type.
  • Added a default fromBlock of "earliest" to the base client in createClient

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2025

🦋 Changeset detected

Latest commit: ef0de69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@delvtech/drift Patch
@delvtech/drift-ethers-v5 Patch
@delvtech/drift-ethers Patch
@delvtech/drift-viem Patch
@delvtech/drift-web3 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ryangoree ryangoree changed the title [WIP] Refactor to client factories Refactor to client factories Jan 28, 2025
@ryangoree ryangoree merged commit 602f1a3 into main Jan 28, 2025
4 checks passed
@ryangoree ryangoree deleted the ryan-object-comp branch January 28, 2025 17:46
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.

2 participants