Skip to content

Commit

Permalink
Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Feb 29, 2024
1 parent 40adb68 commit 0e68936
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions target_chains/solana/sdk/js/pyth_solana_receiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const {postInstructions, cleanupInstructions, priceFeedIdToPriceUpdateAccount} =


const myFirstPythApp = new Program<MyFirstPythApp>(IDL as MyFirstPythApp, , PublicKey.unique(), {})
const consumerInstruction = {instruction: await myFirstApp.methods.consume().accounts({ solPriceUpdate: priceFeedIdToPriceUpdateAccount[SOL_PRICE_FEED_ID], ethPriceUpdate: priceFeedIdToPriceUpdateAccount[ETH_PRICE_FEED_ID] }).instruction(), signers: []}
const consumerInstruction : InstructionWithEphemeralSigners = {instruction: await myFirstApp.methods.consume().accounts({ solPriceUpdate: priceFeedIdToPriceUpdateAccount[SOL_PRICE_FEED_ID], ethPriceUpdate: priceFeedIdToPriceUpdateAccount[ETH_PRICE_FEED_ID] }).instruction(), signers: []}
consumed

const transactions = await TransactionBuilder.batchIntoVersionedTransactions(wallet.publicKey, connection, [...postInstructions, consumerInstruction, ...cleanupInstructions], {}); // Put all the instructions together
const transactions = pythSolanaReceiver.batchIntoVersionedTransactions([...postInstructions, consumerInstruction, ...cleanupInstructions], {}); // Put all the instructions together
await pythSolanaReceiver.provider.sendAll(transactions);
```

Expand All @@ -56,6 +56,6 @@ const myFirstPythApp = new Program<MyFirstPythApp>(IDL as MyFirstPythApp, , Publ
const getInstructions = async (priceFeedIdToPriceUpdateAccount : Record<string, PublicKey>) => { return [{instruction: await myFirstApp.methods.consume().accounts({ solPriceUpdate: priceFeedIdToPriceUpdateAccount[SOL_PRICE_FEED_ID], ethPriceUpdate: priceFeedIdToPriceUpdateAccount[ETH_PRICE_FEED_ID] }).instruction(), signers: []}] };

const pythSolanaReceiver = new PythSolanaReceiver({ connection, wallet });
const transactions = await pythSolanaReceiver.withPriceUpdate(priceUpdateData, getInstructions, {computeUnitPriceMicroLamports : 1})
const transactions = await pythSolanaReceiver.withPriceUpdate(priceUpdateData, getInstructions, {})
await pythSolanaReceiver.provider.sendAll(transactions);
```

0 comments on commit 0e68936

Please sign in to comment.