Skip to content

Add MethodPubkeys utility type to simplify account resolution in tests #4135

@Neocryptoquant

Description

@Neocryptoquant

Currently, extracting the types for resolved account addresses (public keys) in integration tests requires verbose return type chaining.

Current boilerplate

let pubkeys: Awaited<
  ReturnType<
    ReturnType<typeof program["methods"]["myMethod"]>["rpcAndKeys"]
  >
>["pubkeys"];

Proposed Solution

Introduce a MethodPubkeys utility type in the TypeScript client.
This provides a better way to extract these types directly from the IDL instructions.

New Usage

let pubkeys: anchor.MethodPubkeys<MyIdl, "myMethod">;

Code Locations Affected

  • ts/packages/anchor/src/program/namespace/types.ts
  • ts/packages/anchor/src/program/namespace/index.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions