Skip to content

wallet: Make fetch injectable in NetworkController initialization #8793

Open

Description

@grypez

Problem

getRpcServiceOptions in packages/wallet/src/initialization/instances/network-controller.ts hardcodes fetch to globalThis.fetch. Platforms that provide their own fetch implementation — React Native being the primary example — cannot supply it, making the wallet non-portable across those environments.

Proposed direction

Add an optional fetch?: typeof globalThis.fetch field to WalletOptions. The NetworkController init should use options.fetch ?? globalThis.fetch.bind(globalThis) when building getRpcServiceOptions, so the default behaviour is unchanged and platform-specific implementations can be injected at construction time.

Acceptance

  • WalletOptions has an optional fetch field.
  • getRpcServiceOptions uses the injected fetch when provided, falling back to globalThis.fetch.
  • Existing tests pass; a test covers the injected-fetch path.
  • Changelog entry added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions