metaplex-foundation / solita

Genrates an SDK API from solana contract IDL.
Apache License 2.0
142 stars 33 forks source link

feat: expose beet-solana gpa builder on account struct #63

Closed thlorenz closed 2 years ago

thlorenz commented 2 years ago

Summary

Relying on the recent GPA beet-solana feature, solita now generates a method on each account struct to obtain a GPA builder for it.

Example

The below method is added to the AuctionHouse account.

export class AuctionHouse implements AuctionHouseArgs {
  // [ .. ]

  /**
   * Provides a {@link web3.Connection.getProgramAccounts} config builder,
   * to fetch accounts matching filters that can be specified on that builder.
   *
   * @param programId - the program that owns the accounts we are filtering
   */
  static gpaBuilder(
    programId: web3.PublicKey = new web3.PublicKey(
      'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk'
    )
  ) {
    return beetSolana.GpaBuilder.fromStruct(programId, auctionHouseBeet)
  }
  // [ .. ]
}

Caveats