Skip to content

Avoid passing chain twice when creating viem clients with getTransport #929

Description

@hugomrdias

Summary

Docs and app code currently create viem clients like this:

createPublicClient({
  chain: calibration,
  transport: getTransport(calibration),
})

chain is passed twice: once to the factory, once to derive the transport. That feels odd and is easy to get wrong (mismatched chain vs transport).

Raised on #909: #909 (comment)

Ideas

  • createFilecoinClient(chain) / createFilecoinWalletClient({ chain, account }) wrappers that call getTransport(chain) internally
  • Or a small { chain, transport: getTransport(chain) } helper used by both public and wallet factories

Keep viem's factories as the escape hatch for custom transports.

Out of scope for #909

#909 is the client/type split. This is a follow-up API, not a blocker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    🎉 Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions