@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.js CHANGED
@@ -2737,30 +2737,20 @@ function getPositionAccountPDA(lavarageProgram, offer, seed) {
2737
2737
  function getTokenAccountOrCreateIfNotExists(lavarageProgram, ownerPublicKey, tokenAddress, tokenProgram) {
2738
2738
  return __async(this, null, function* () {
2739
2739
  const associatedTokenAddress = (0, import_spl_token.getAssociatedTokenAddressSync)(tokenAddress, ownerPublicKey, true, tokenProgram, import_spl_token.ASSOCIATED_TOKEN_PROGRAM_ID);
2740
- try {
2741
- const tokenAccount = yield (0, import_spl_token.getAccount)(lavarageProgram.provider.connection, associatedTokenAddress, "finalized", tokenProgram);
2742
- return { account: tokenAccount, instruction: null };
2743
- } catch (error) {
2744
- if (error instanceof import_spl_token.TokenAccountNotFoundError || error instanceof import_spl_token.TokenInvalidAccountOwnerError) {
2745
- const instruction = (0, import_spl_token.createAssociatedTokenAccountInstruction)(
2746
- lavarageProgram.provider.publicKey,
2747
- associatedTokenAddress,
2748
- ownerPublicKey,
2749
- tokenAddress,
2750
- tokenProgram,
2751
- import_spl_token.ASSOCIATED_TOKEN_PROGRAM_ID
2752
- );
2753
- return {
2754
- account: {
2755
- address: associatedTokenAddress
2756
- },
2757
- instruction
2758
- };
2759
- } else {
2760
- console.error("Error in getTokenAccountOrCreateIfNotExists: ", error);
2761
- return { account: null, instruction: null };
2762
- }
2763
- }
2740
+ const instruction = (0, import_spl_token.createAssociatedTokenAccountIdempotentInstruction)(
2741
+ lavarageProgram.provider.publicKey,
2742
+ associatedTokenAddress,
2743
+ ownerPublicKey,
2744
+ tokenAddress,
2745
+ tokenProgram,
2746
+ import_spl_token.ASSOCIATED_TOKEN_PROGRAM_ID
2747
+ );
2748
+ return {
2749
+ account: {
2750
+ address: associatedTokenAddress
2751
+ },
2752
+ instruction
2753
+ };
2764
2754
  });
2765
2755
  }
2766
2756
  var getOffers = (lavarageProgram) => {