diff --git a/package.json b/package.json index 445e7a3fd..2c4fd6558 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cardinal/token-manager", - "version": "1.5.0", + "version": "1.5.2", "description": "Cardinal token manager SDK", "keywords": [ "solana", diff --git a/src/programs/tokenManager/utils.ts b/src/programs/tokenManager/utils.ts index 9c952612c..d1f092322 100644 --- a/src/programs/tokenManager/utils.ts +++ b/src/programs/tokenManager/utils.ts @@ -58,7 +58,8 @@ export const withRemainingAccountsForPayment = async ( issuerId: PublicKey, paymentManagerId: PublicKey, receiptMint?: PublicKey | null, - payer = wallet.publicKey + payer = wallet.publicKey, + excludeATAs?: string[] ): Promise<[PublicKey, PublicKey, AccountMeta[]]> => { const royaltiesRemainingAccounts = await withRemainingAccountsForHanldePaymentWithRoyalties( @@ -66,7 +67,8 @@ export const withRemainingAccountsForPayment = async ( connection, wallet, mint, - paymentMint + paymentMint, + excludeATAs ); const mintMetadataId = await Metadata.getPDA(mint); const paymentRemainingAccounts = [ @@ -252,7 +254,8 @@ export const withRemainingAccountsForHanldePaymentWithRoyalties = async ( connection: Connection, wallet: Wallet, mint: PublicKey, - paymentMint: PublicKey + paymentMint: PublicKey, + excludeATAs?: string[] ): Promise => { const creatorsRemainingAccounts: AccountMeta[] = []; const mintMetadataId = await Metadata.getPDA(mint); @@ -270,14 +273,16 @@ export const withRemainingAccountsForHanldePaymentWithRoyalties = async ( if (creator.share !== 0) { const creatorAddress = new PublicKey(creator.address); const creatorMintTokenAccount = - await withFindOrInitAssociatedTokenAccount( - transaction, - connection, - paymentMint, - creatorAddress, - wallet.publicKey, - true - ); + !excludeATAs || !excludeATAs.includes(creator.address.toString()) + ? await withFindOrInitAssociatedTokenAccount( + transaction, + connection, + paymentMint, + creatorAddress, + wallet.publicKey, + true + ) + : await findAta(mint, wallet.publicKey, true); creatorsRemainingAccounts.push({ pubkey: creatorMintTokenAccount, isSigner: false,