(transaction: VersionedTransaction, latestBlockhash: Blockhash, isBuy: boolean = true)
| 9 | } |
| 10 | |
| 11 | export const execute = async (transaction: VersionedTransaction, latestBlockhash: Blockhash, isBuy: boolean = true) => { |
| 12 | const solanaConnection = new Connection(RPC_ENDPOINT, { |
| 13 | wsEndpoint: RPC_WEBSOCKET_ENDPOINT, |
| 14 | }) |
| 15 | |
| 16 | const signature = await solanaConnection.sendRawTransaction(transaction.serialize(), { skipPreflight: true }) |
| 17 | const confirmation = await solanaConnection.confirmTransaction( |
| 18 | { |
| 19 | signature, |
| 20 | lastValidBlockHeight: latestBlockhash.lastValidBlockHeight, |
| 21 | blockhash: latestBlockhash.blockhash, |
| 22 | } |
| 23 | ); |
| 24 | |
| 25 | if (confirmation.value.err) { |
| 26 | console.log("Confrimtaion error") |
| 27 | return "" |
| 28 | } else { |
| 29 | if (isBuy) |
| 30 | console.log(`Success in buy transaction: https://solscan.io/tx/${signature}`) |
| 31 | else |
| 32 | console.log(`Success in Sell transaction: https://solscan.io/tx/${signature}`) |
| 33 | } |
| 34 | return signature |
| 35 | } |
no outgoing calls
no test coverage detected