Class GpaBuilder<T>

Provides an Account specific GPA builder.

Type Parameters

  • T

    the type of the account for which the GpaBuilder is used

Hierarchy

  • GpaBuilder

Properties

config: GetProgramAccountsConfig = {}

web3.js GetProgramAccountsConfig configured via filter GpaBuilder filter methods.

Methods

  • Adds a memcmp filter for the provided key of the struct.

    Parameters

    • key: keyof T & string

      the name of the field by which to filter

    • val: T[keyof T]

      the field value that the filter should match

    Returns GpaBuilder<T>

  • Adds a memcmp filter for a field inside a field which is a struct value. The provided keys need to be separated by a . and only one level of nesting is supported at this point.

    The filter is applied to the inner value.

    Example

    Given:

    type Inner = {
    a: number
    }
    type Outer = {
    idx: number
    inner: Inner
    }

    Apply a filter on a of the Inner type:

    gpaBuilder.addInnerFilter('inner.a', 2)
    

    Parameters

    • keys: string

      the names of the fields by which to filter, i.e. 'outer.inner'

    • val: T[keyof T] & {}

      the field value that the filter should match

    Returns GpaBuilder<T>

  • Adds a dataSize filter which will match on account's sizes. You have to provide that size for accounts that don't have a fixed size. For fixed size accounts that size is determined for you.

    Parameters

    • Optional size: number

      the account size to match for

    Returns GpaBuilder<T>

  • Attempts to find the accounts matching the configured filters.

    Parameters

    • connection: Connection

      used to query the program accounts on the cluster

    Returns Promise<{
        account: AccountInfo<Buffer>;
        pubkey: PublicKey;
    }[]>

  • Creates a GPA builder that supports adding up to four filters for fixed size fields.

    Once a non-fixed field is encountered, the remaining fields following it will not be included as a filter option since their position in the bytes array will change depending on the content of the non-fixed field.

    Type Parameters

    • T

    Parameters

    • programId: PublicKey

      the id of the program that owns the accounts we are querying

    • beetFields: BeetField<T, T[keyof T]>[]

      the beet fields that make up the structure of the account data

    Returns GpaBuilder<T>

  • Convenience wrapper around fromBeetFields that allows providing a struct which contains the beet fields.

    Type Parameters

    • T

    Parameters

    • programId: PublicKey

      the id of the program that owns the accounts we are querying

    • struct: {
          fields: BeetField<T, T[keyof T]>[];
      }

      containing the beet fields specifying the layout of the account

      • fields: BeetField<T, T[keyof T]>[]

    Returns GpaBuilder<T>

Generated using TypeDoc