Skip to content

Commit

Permalink
Add Fee Payer to Smart Transaction Creation (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIchigo authored Jun 19, 2024
1 parent 73b6763 commit 8da862d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/RpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,14 @@ export class RpcClient {
const payerKey = feePayer ? feePayer.publicKey : signers[0].publicKey;
this.addTipInstruction(instructions, payerKey, randomTipAccount, tipAmount);

// Create the smart transaction
// @todo merge PR #100 so we can pass in the feePayer here
const smartTransaction = await this.createSmartTransaction(instructions, signers, lookupTables);
// Create the smart transaction based on whether a separate fee payer was provided
let smartTransaction;

if (feePayer) {
smartTransaction = await this.createSmartTransaction(instructions, signers, lookupTables, feePayer);
} else {
smartTransaction = await this.createSmartTransaction(instructions, signers, lookupTables);
}

// Return the serialized transaction
return bs58.encode(smartTransaction.serialize());
Expand Down Expand Up @@ -813,9 +818,15 @@ export class RpcClient {
throw new Error("The transaction must have at least one signer");
}

// Create the smart transaction with tip
// @todo merge PR #100 so we can pass in the feePayer here
const serializedTransaction = await this.createSmartTransactionWithTip(instructions, signers, lookupTables, tipAmount);
// Create the smart transaction with tip based on whether a separate fee payer was provided
let serializedTransaction;

if (feePayer) {
serializedTransaction = await this.createSmartTransactionWithTip(instructions, signers, lookupTables, tipAmount, feePayer);
} else {
serializedTransaction = await this.createSmartTransactionWithTip(instructions, signers, lookupTables, tipAmount);
}


// Get the Jito API URL for the specified region
const jitoApiUrl = JITO_API_URLS[region] + "/api/v1/bundles";
Expand Down

0 comments on commit 8da862d

Please sign in to comment.