@debridge-finance/solana-utils 5.4.2 → 5.5.0

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.
@@ -11468,13 +11468,15 @@ function getTokenInfo(connection, tokenAddress) {
11468
11468
  * @param associatedAccount associated account address
11469
11469
  * @param owner owner of the associated account
11470
11470
  * @param payer who pays for account creation
11471
+ * @param isToken2022
11472
+ * @param associatedTokenProgramId
11471
11473
  */
11472
- function createAssociatedWalletInstruction(tokenMint, associatedAccount, owner, payer, associatedTokenProramId) {
11474
+ function createAssociatedWalletInstruction(tokenMint, associatedAccount, owner, payer, isToken2022, associatedTokenProgramId) {
11473
11475
  tokenMint = new PublicKey(tokenMint);
11474
11476
  payer = new PublicKey(payer);
11475
11477
  owner = new PublicKey(owner);
11476
11478
  return new TransactionInstruction({
11477
- programId: associatedTokenProramId || ASSOCIATED_TOKEN_PROGRAM_ID,
11479
+ programId: associatedTokenProgramId !== null && associatedTokenProgramId !== void 0 ? associatedTokenProgramId : ASSOCIATED_TOKEN_PROGRAM_ID,
11478
11480
  data: buffer.Buffer.from([1]),
11479
11481
  keys: [
11480
11482
  {
@@ -11503,7 +11505,7 @@ function createAssociatedWalletInstruction(tokenMint, associatedAccount, owner,
11503
11505
  isWritable: false,
11504
11506
  },
11505
11507
  {
11506
- pubkey: TOKEN_PROGRAM_ID$1,
11508
+ pubkey: isToken2022 ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID$1,
11507
11509
  isSigner: false,
11508
11510
  isWritable: false,
11509
11511
  },
@@ -11596,9 +11598,17 @@ function getSPLWalletBalance(connection, wallet) {
11596
11598
  */
11597
11599
  function getAllTokenAccountsWithBalances(connection, owner) {
11598
11600
  return __awaiter(this, void 0, void 0, function* () {
11599
- const walletsData = yield connection.getParsedTokenAccountsByOwner(new PublicKey(owner), { programId: TOKEN_PROGRAM_ID$1 });
11601
+ const [walletsData, walletsDataToken22] = yield Promise.all([
11602
+ connection.getParsedTokenAccountsByOwner(new PublicKey(owner), {
11603
+ programId: TOKEN_PROGRAM_ID$1,
11604
+ }),
11605
+ connection.getParsedTokenAccountsByOwner(new PublicKey(owner), {
11606
+ programId: TOKEN_2022_PROGRAM_ID,
11607
+ }),
11608
+ ]);
11600
11609
  const wallets = walletsData.value;
11601
- return wallets.map((wallet) => {
11610
+ const walletsToken22 = walletsDataToken22.value;
11611
+ const parseTokenAccount = (isToken22) => (wallet) => {
11602
11612
  const tokenInfo = wallet.account.data.parsed;
11603
11613
  return {
11604
11614
  address: wallet.pubkey,
@@ -11608,8 +11618,13 @@ function getAllTokenAccountsWithBalances(connection, owner) {
11608
11618
  isInitialized: true,
11609
11619
  isNative: tokenInfo.info.isNative,
11610
11620
  owner: new PublicKey(tokenInfo.info.owner),
11621
+ isToken22,
11611
11622
  };
11612
- });
11623
+ };
11624
+ return [
11625
+ ...wallets.map(parseTokenAccount(false)),
11626
+ ...walletsToken22.map(parseTokenAccount(true)),
11627
+ ];
11613
11628
  });
11614
11629
  }
11615
11630
  /**
@@ -11620,7 +11635,11 @@ function getAllTokenAccountsWithBalances(connection, owner) {
11620
11635
  */
11621
11636
  function getTokenAccountsWithBalance(connection, tokenMint, owner) {
11622
11637
  return __awaiter(this, void 0, void 0, function* () {
11623
- const walletsData = yield connection.getParsedTokenAccountsByOwner(new PublicKey(owner), { mint: new PublicKey(tokenMint) });
11638
+ const mint = new PublicKey(tokenMint);
11639
+ const [walletsData, accountInfo] = yield Promise.all([
11640
+ connection.getParsedTokenAccountsByOwner(new PublicKey(owner), { mint }),
11641
+ connection.getAccountInfo(mint),
11642
+ ]);
11624
11643
  const wallets = walletsData.value;
11625
11644
  return wallets.map((wallet) => {
11626
11645
  const tokenInfo = wallet.account.data.parsed;
@@ -11632,6 +11651,7 @@ function getTokenAccountsWithBalance(connection, tokenMint, owner) {
11632
11651
  isInitialized: true,
11633
11652
  isNative: tokenInfo.info.isNative,
11634
11653
  owner: new PublicKey(tokenInfo.info.owner),
11654
+ isToken22: accountInfo.owner.equals(TOKEN_2022_PROGRAM_ID),
11635
11655
  };
11636
11656
  });
11637
11657
  });