Skip to content

Commit

Permalink
Add useful static
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Feb 28, 2024
1 parent 4b0094a commit 5926166
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"access": "public"
},
"scripts": {
"test": "jest",
"build": "tsc",
"format": "prettier --write \"src/**/*.ts\"",
"lint": "eslint src/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,21 @@ export class PythSolanaReceiver {
) => Promise<InstructionWithEphemeralSigners[]>,
priorityFeeConfig?: PriorityFeeConfig
): Promise<{ tx: VersionedTransaction; signers: Signer[] }[]> {
const builder = new TransactionBuilder(
this.wallet.publicKey,
this.connection
);

const {
postInstructions: instructions,
postInstructions,
priceFeedIdToPriceUpdateAccount: priceFeedIdToPriceUpdateAccount,
cleanupInstructions,
} = await this.buildPostPriceUpdateInstructions(priceUpdateDataArray);
builder.addInstructions(instructions);
builder.addInstructions(
await getInstructions(priceFeedIdToPriceUpdateAccount)
return TransactionBuilder.batchIntoVersionedTransactions(
this.wallet.publicKey,
this.connection,
[
...postInstructions,
...(await getInstructions(priceFeedIdToPriceUpdateAccount)),
...cleanupInstructions,
],
priorityFeeConfig ?? {}
);
builder.addInstructions(cleanupInstructions);
return builder.getVersionedTransactions(priorityFeeConfig ?? {});
}

async withPartiallyVerifiedPriceUpdate(
Expand All @@ -107,21 +106,21 @@ export class PythSolanaReceiver {
) => Promise<InstructionWithEphemeralSigners[]>,
priorityFeeConfig?: PriorityFeeConfig
): Promise<{ tx: VersionedTransaction; signers: Signer[] }[]> {
const builder = new TransactionBuilder(
this.wallet.publicKey,
this.connection
);
const {
postInstructions: instructions,
postInstructions,
priceFeedIdToPriceUpdateAccount,
cleanupInstructions,
} = await this.buildPostPriceUpdateAtomicInstructions(priceUpdateDataArray);
builder.addInstructions(instructions);
builder.addInstructions(
await getInstructions(priceFeedIdToPriceUpdateAccount)
return TransactionBuilder.batchIntoVersionedTransactions(
this.wallet.publicKey,
this.connection,
[
...postInstructions,
...(await getInstructions(priceFeedIdToPriceUpdateAccount)),
...cleanupInstructions,
],
priorityFeeConfig ?? {}
);
builder.addInstructions(cleanupInstructions);
return builder.getVersionedTransactions(priorityFeeConfig ?? {});
}

async buildPostPriceUpdateAtomicInstructions(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { PythSolanaReceiver } from "./PythSolanaReceiver";
export { TransactionBuilder } from "@pythnetwork/solana-utils";

0 comments on commit 5926166

Please sign in to comment.