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

Reduce download time by maximizing static composition and dependency injection. Eliminate runtime configs. #1202

Open
6 tasks
MantisClone opened this issue Oct 16, 2023 · 1 comment

Comments

@MantisClone
Copy link
Member

MantisClone commented Oct 16, 2023

Problem

Request Network uses config variables at runtime. This means that the package MUST contain code to support all possible configurations even if they're not used.

Proposed Solution

Use dependency injection to empower the user to select the features and dependencies they want. This will involve API BREAKING CHANGES and refactoring package boundaries.

Definition of Done

This issue is an EPIC that encompasses the following subtasks:

Example

In the following code snippet, notice that the currencyManager, chains, and balanceDetectors are all injected.

const requestNetwork = new RequestNetwork({
  decryptionProvider,
  signatureProvider,
  currencyManager,
  chains,
  // if no compatible balance detector is found, the balance will be null. 
  balanceDetectors: [
    new EvmTheGraphBalanceDetector(chains, currencyManager),
    new NearTheGraphBalanceDetector(chains),
    new BtcBalanceDetector(),
    new SolanaBalanceDetector(),
    new SuperfluidBalanceDetector(chains),
    // ...
  ]
})

Reference

@MantisClone
Copy link
Member Author

If we (@skiv and I) were to rebuild this system from scratch, we would write it in a functional style, with less OOP and inheritance. We believe a functional style would lend itself to automated static analysis and tree-shaking. But we've already got a system that uses OOP and inheritance, so we're choosing to double down and make it manually composable via dependency injection so that the user chooses the packages that fit their use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🎫 Backlog
Development

No branches or pull requests

1 participant