Skip to content

Commit

Permalink
Add exclude array for withRemainingAccountsForHanldePaymentWithRoyalties
Browse files Browse the repository at this point in the history
  • Loading branch information
Giannis Chatziveroglou committed Aug 2, 2022
1 parent aa43993 commit c46b1b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cardinal/token-manager",
"version": "1.5.0",
"version": "1.5.2",
"description": "Cardinal token manager SDK",
"keywords": [
"solana",
Expand Down
27 changes: 16 additions & 11 deletions src/programs/tokenManager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ 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(
transaction,
connection,
wallet,
mint,
paymentMint
paymentMint,
excludeATAs
);
const mintMetadataId = await Metadata.getPDA(mint);
const paymentRemainingAccounts = [
Expand Down Expand Up @@ -252,7 +254,8 @@ export const withRemainingAccountsForHanldePaymentWithRoyalties = async (
connection: Connection,
wallet: Wallet,
mint: PublicKey,
paymentMint: PublicKey
paymentMint: PublicKey,
excludeATAs?: string[]
): Promise<AccountMeta[]> => {
const creatorsRemainingAccounts: AccountMeta[] = [];
const mintMetadataId = await Metadata.getPDA(mint);
Expand All @@ -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,
Expand Down

0 comments on commit c46b1b1

Please sign in to comment.