Skip to content

Commit

Permalink
fix swap error
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Oct 26, 2024
1 parent 0e320db commit c34022e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/actions/swap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Connection, PublicKey, Transaction } from "@solana/web3.js";
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
import fetch from "cross-fetch";
import {
ActionExample,
Expand Down Expand Up @@ -56,7 +56,7 @@ export default {

try {
const connection = new Connection("https://api.mainnet-beta.solana.com");
const walletPublicKey = new PublicKey(runtime.walletPublicKey);
const walletPublicKey = new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY"));

const swapResult = await swapToken(
connection,
Expand All @@ -76,7 +76,9 @@ export default {
}

const transaction = Transaction.from(Buffer.from(swapResult.swapTransaction, "base64"));
transaction.sign(runtime.walletKeyPair);
const privateKey = runtime.getSetting("WALLET_PRIVATE_KEY");
const keypair = Keypair.fromSecretKey(Uint8Array.from(Buffer.from(privateKey, 'base64')));
transaction.sign(keypair);

const txid = await connection.sendRawTransaction(transaction.serialize());
await connection.confirmTransaction(txid);
Expand Down

0 comments on commit c34022e

Please sign in to comment.