Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk-coin-sol): ignore zero value prio fee #5409

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/sdk-coin-sol/src/lib/tokenTransferBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class TokenTransferBuilder extends TransactionBuilder {
},
};

if (!this._priorityFee) {
if (!this._priorityFee || this._priorityFee === BigInt(0)) {
this._instructionsData = [...createAtaInstructions, ...sendInstructions];
} else {
// order is important, createAtaInstructions must be before sendInstructions
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-sol/src/lib/transferBuilderV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class TransferBuilderV2 extends TransactionBuilder {

let addPriorityFeeInstruction: SetPriorityFee;
// If there are createAtaInstructions, then token is involved and we need to add a priority fee instruction
if (!this._priorityFee) {
if (!this._priorityFee || this._priorityFee === BigInt(0)) {
this._instructionsData = [...createAtaInstructions, ...sendInstructions];
} else if (
createAtaInstructions.length !== 0 ||
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-sol/test/resources/sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export const MULTI_TOKEN_TRANSFER_SIGNED =
export const MULTI_ASSET_TOKEN_TRANSFER_UNSIGNED =
'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAUNCoMkjRrCRUK+mb1OrcYVsRHoGOkX5c9n9deT5Gq/d1YY19xOQg+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wULCgALBAMHBAAKDOCTBAAAAAAACQgACXRlc3QgbWVtbw==';

export const MULTI_TOKEN_TRANSFER_UNSIGNED_WITH_UNIQUE_CREATE_ATA_AND_MEMO_AND_DURABLE_NONCE =
'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAgNAGymKVqOJEQemBHH67uu8ISJV4rtwTejLrjw7VSeW6dJP1r3FCCofxhWCBv6dIPMrDQrI7IXh1M2k+lzW80KTW/6Eon6nFlovAcYTKTZK+nk98ALlkSL/BgjW09MceFuldLxXAw5t3p9Od8IqufG/BDksWGKlVuIb5qJM0zV4WypGBtS9+2Q6usNrUtxvrRTg2FnYTFxfpMJWBBft6OJ1QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjJclj04kifG7PRApFI4NgwtaE5na/xCEBI572Nvp+FkDBkZv5SEXMv/srbpyw5vnvIzlu8X3EmssQ5s6QAAAANEDifvO5SjyCGEdzMc0sxCSVAyyuNWNEA8uqizttNpeBUpTWpkpIQZNJOhxYNo4fHw1td28kruB5B+oQEEFRI0Gp9UXGSxWjuCKhF9z0peIzwNcMUWyGrNE2AYuqUAAAAan1RcZLFxRIYzJTD1K8X9Y2u4Im6H9ROPb2YoAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKnjMtr5L6vs6LY/96RABeX9/Zr6FYdWthxalfkEs7jQgQcFAwIKAAQEAAAABwAJA4CWmAAAAAAABgcAAQQIBQwLAAwEAwgEAAoM4JMEAAAAAAAJDAQDCAQACgzgkwQAAAAAAAkMBAMIBAAKDOCTBAAAAAAACQkACXRlc3QgbWVtbw==';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ describe('Sol Token Transfer Builder', () => {
txBuilder.send({ address: otherAccount.pub, amount, tokenName: nameUSDC });
txBuilder.memo(memo);
txBuilder.createAssociatedTokenAccount({ ownerAddress: otherAccount.pub, tokenName: nameUSDC });
const prioFeeMicroLamports = '0';
const priorityFee: FeeOptions = {
amount: prioFeeMicroLamports,
};
txBuilder.setPriorityFee(priorityFee);
const tx = await txBuilder.build();
tx.inputs.length.should.equal(1);
Expand All @@ -371,26 +375,26 @@ describe('Sol Token Transfer Builder', () => {
coin: nameUSDC,
});
const txJson = tx.toJson();
txJson.instructionsData.length.should.equal(4);
txJson.instructionsData[0].type.should.equal('SetPriorityFee');
txJson.instructionsData[1].type.should.equal('CreateAssociatedTokenAccount');
txJson.instructionsData[1].params.should.deepEqual({
// Since prio fee is 0, we are not adding compute unit price instruction
txJson.instructionsData.length.should.equal(3);
txJson.instructionsData[0].type.should.equal('CreateAssociatedTokenAccount');
txJson.instructionsData[0].params.should.deepEqual({
mintAddress: mintUSDC,
ataAddress: ataAddress,
ownerAddress: otherAccount.pub,
payerAddress: walletPK,
tokenName: nameUSDC,
});
txJson.instructionsData[2].type.should.equal('TokenTransfer');
txJson.instructionsData[2].params.should.deepEqual({
txJson.instructionsData[1].type.should.equal('TokenTransfer');
txJson.instructionsData[1].params.should.deepEqual({
fromAddress: walletPK,
toAddress: otherAccount.pub,
amount: amount,
tokenName: nameUSDC,
sourceAddress: 'B5rJjuVi7En63iK6o3ijKdJwAoTe2gwCYmJsVdHQ2aKV',
});
txJson.instructionsData[3].type.should.equal('Memo');
txJson.instructionsData[3].params.memo.should.equal(memo);
txJson.instructionsData[2].type.should.equal('Memo');
txJson.instructionsData[2].params.memo.should.equal(memo);

const rawTx = tx.toBroadcastFormat();
should.equal(Utils.isValidRawTransaction(rawTx), true);
Expand Down
Loading