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

feat: lazy load hdwallet adapter modules part 1 #5463

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Oct 13, 2023

Description

i.e technically lazy loads said packages, but doesn't effectively do so for now, because of this bad boy:

const walletAdapters = await SUPPORTED_WALLETS[keyManager]?.adapters.reduce<
Promise<GenericAdapter[]>
>(async (acc, cur) => {
const adapters = await acc
const options = getKeyManagerOptions(keyManager)
try {
const { loadAdapter } = cur
const Adapter = await loadAdapter()
// eslint is drunk, this isn't a hook
// eslint-disable-next-line react-hooks/rules-of-hooks
const adapter = Adapter.useKeyring(state.keyring, options)
adapters.push(adapter)
} catch (e) {
console.error(e)
}
return acc
}, Promise.resolve([]))

This however, puts us in a better position to get wallet adapters lazy loaded as a follow-up, the intent being to only populate (and by extension, import the npm packages) adapters when clicking on a wallet option.

Pull Request Type

  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..)
  • 💅 New Feature (Breaking/Non-breaking Change)

Issue (if applicable)

Risk

  • Moderate. Theoretically, the surface area brings huge regression risks for all wallets. In effect, the flow is effectively the same for the time being.

Testing

  • All wallets are still displayed as option
  • Wallet pairing still work

Engineering

  • ☝🏽

Operations

  • ☝🏽

Screenshots (if applicable)

Copy link
Contributor Author

gomesalexandre commented Oct 13, 2023

@gomesalexandre gomesalexandre changed the title feat: lazy load hdwallet adapter modules feat: lazy load hdwallet adapter modules part 1 Oct 13, 2023
@gomesalexandre gomesalexandre marked this pull request as ready for review October 13, 2023 19:20
@gomesalexandre gomesalexandre requested a review from a team as a code owner October 13, 2023 19:20
Base automatically changed from feat_perf_lazy_1 to develop October 15, 2023 21:16
@woodenfurniture woodenfurniture merged commit 1d31ad6 into develop Oct 17, 2023
6 checks passed
@woodenfurniture woodenfurniture deleted the feat_perf_lazy_2 branch October 17, 2023 00:20
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