Skip to content

Commit

Permalink
Update withRemainingAccountsForPayment
Browse files Browse the repository at this point in the history
  • Loading branch information
Giannis Chatziveroglou committed Aug 2, 2022
1 parent 4ba2a4b commit c817472
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/programs/tokenManager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ export const withRemainingAccountsForPayment = async (
paymentMint,
excludeCreators
);
const mintMetadataId = await Metadata.getPDA(mint);
const paymentRemainingAccounts = [
{
pubkey: paymentMint,
isSigner: false,
isWritable: true,
},
{
pubkey: mint,
isSigner: false,
isWritable: true,
},
{
pubkey: mintMetadataId,
isSigner: false,
isWritable: true,
},
];

if (receiptMint) {
const receiptMintLargestAccount = await connection.getTokenLargestAccounts(
Expand Down Expand Up @@ -123,6 +141,7 @@ export const withRemainingAccountsForPayment = async (
isSigner: false,
isWritable: true,
},
...paymentRemainingAccounts,
...royaltiesRemainingAccounts,
],
];
Expand Down Expand Up @@ -152,7 +171,7 @@ export const withRemainingAccountsForPayment = async (
return [
issuerTokenAccountId,
feeCollectorTokenAccountId,
royaltiesRemainingAccounts,
[...paymentRemainingAccounts, ...royaltiesRemainingAccounts],
];
}
};
Expand Down Expand Up @@ -274,22 +293,5 @@ export const withRemainingAccountsForHanldePaymentWithRoyalties = async (
}
}

return [
{
pubkey: paymentMint,
isSigner: false,
isWritable: true,
},
{
pubkey: mint,
isSigner: false,
isWritable: true,
},
{
pubkey: mintMetadataId,
isSigner: false,
isWritable: true,
},
...creatorsRemainingAccounts,
];
return creatorsRemainingAccounts;
};

0 comments on commit c817472

Please sign in to comment.