Skip to content

Commit c113b65

Browse files
authored
Add logic to set priority fee ixs and sign versioned tx (#488)
1 parent d5d3f39 commit c113b65

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

platforms/solana/src/signer.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
PublicKey,
1212
SendTransactionError,
1313
TransactionExpiredBlockheightExceededError,
14+
TransactionMessage,
1415
} from '@solana/web3.js';
1516
import type {
1617
Network,
@@ -207,18 +208,24 @@ export class SolanaSendSigner<
207208
for (let i = 0; i < maxRetries; i++) {
208209
try {
209210
if (isVersionedTransaction(transaction)) {
211+
if (priorityFeeIx) {
212+
const msg = TransactionMessage.decompile(transaction.message);
213+
msg.instructions.push(...priorityFeeIx);
214+
transaction.message = msg.compileToV0Message();
215+
}
216+
transaction.message.recentBlockhash = blockhash;
217+
transaction.sign([this._keypair, ...(extraSigners ?? [])]);
210218
} else {
211219
if (priorityFeeIx) transaction.add(...priorityFeeIx);
212-
213220
transaction.recentBlockhash = blockhash;
214221
transaction.partialSign(this._keypair, ...(extraSigners ?? []));
215-
216-
const txid = await this._rpc.sendRawTransaction(
217-
transaction.serialize(),
218-
this._sendOpts,
219-
);
220-
txids.push(txid);
221222
}
223+
224+
const txid = await this._rpc.sendRawTransaction(
225+
transaction.serialize(),
226+
this._sendOpts,
227+
);
228+
txids.push(txid);
222229
break;
223230
} catch (e) {
224231
// No point checking if retryable if we're on the last retry

0 commit comments

Comments
 (0)