metaplex-foundation / solita

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

feat: accounts api fromAccounts improvement #88

Closed thlorenz closed 2 years ago

thlorenz commented 2 years ago

Summary

The accounts method fromAccountAddress now supports a commitment parameter to be specified.

Fixes: #84

Sample Code

  static async fromAccountAddress(
    connection: web3.Connection,
    address: web3.PublicKey,
    commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig
  ): Promise<MasterEditionV1> {
    const accountInfo = await connection.getAccountInfo(
      address,
      commitmentOrConfig
    )
    if (accountInfo == null) {
      throw new Error(`Unable to find MasterEditionV1 account at ${address}`)
    }
    return MasterEditionV1.fromAccountInfo(accountInfo, 0)[0]
  }