@lavarage/sdk 6.4.6 → 6.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -46,7 +46,7 @@ var __async = (__this, __arguments, generator) => {
46
46
  import { BN } from "@coral-xyz/anchor";
47
47
  import bs58 from "bs58";
48
48
  import { AddressLookupTableAccount, ComputeBudgetProgram, Keypair, PublicKey, SystemProgram, SYSVAR_CLOCK_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction } from "@solana/web3.js";
49
- import { ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, getAccount, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, TokenAccountNotFoundError, TokenInvalidAccountOwnerError } from "@solana/spl-token";
49
+ import { ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from "@solana/spl-token";
50
50
 
51
51
  // idl/lavarage.ts
52
52
  var IDL = {
@@ -2690,30 +2690,20 @@ function getPositionAccountPDA(lavarageProgram, offer, seed) {
2690
2690
  function getTokenAccountOrCreateIfNotExists(lavarageProgram, ownerPublicKey, tokenAddress, tokenProgram) {
2691
2691
  return __async(this, null, function* () {
2692
2692
  const associatedTokenAddress = getAssociatedTokenAddressSync(tokenAddress, ownerPublicKey, true, tokenProgram, ASSOCIATED_TOKEN_PROGRAM_ID);
2693
- try {
2694
- const tokenAccount = yield getAccount(lavarageProgram.provider.connection, associatedTokenAddress, "finalized", tokenProgram);
2695
- return { account: tokenAccount, instruction: null };
2696
- } catch (error) {
2697
- if (error instanceof TokenAccountNotFoundError || error instanceof TokenInvalidAccountOwnerError) {
2698
- const instruction = createAssociatedTokenAccountInstruction(
2699
- lavarageProgram.provider.publicKey,
2700
- associatedTokenAddress,
2701
- ownerPublicKey,
2702
- tokenAddress,
2703
- tokenProgram,
2704
- ASSOCIATED_TOKEN_PROGRAM_ID
2705
- );
2706
- return {
2707
- account: {
2708
- address: associatedTokenAddress
2709
- },
2710
- instruction
2711
- };
2712
- } else {
2713
- console.error("Error in getTokenAccountOrCreateIfNotExists: ", error);
2714
- return { account: null, instruction: null };
2715
- }
2716
- }
2693
+ const instruction = createAssociatedTokenAccountIdempotentInstruction(
2694
+ lavarageProgram.provider.publicKey,
2695
+ associatedTokenAddress,
2696
+ ownerPublicKey,
2697
+ tokenAddress,
2698
+ tokenProgram,
2699
+ ASSOCIATED_TOKEN_PROGRAM_ID
2700
+ );
2701
+ return {
2702
+ account: {
2703
+ address: associatedTokenAddress
2704
+ },
2705
+ instruction
2706
+ };
2717
2707
  });
2718
2708
  }
2719
2709
  var getOffers = (lavarageProgram) => {