Skip to content

wallet: Make fetch injectable in NetworkController initialization #8793

@grypez

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions