mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-17 15:10:27 +00:00
Fix
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { Wallet } from "@coral-xyz/anchor";
|
||||
import { Wallet } from "../utils/keypair";
|
||||
import {
|
||||
ORCA_WHIRLPOOL_PROGRAM_ID,
|
||||
WhirlpoolContext,
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { Wallet } from "@coral-xyz/anchor";
|
||||
import { Wallet } from "../utils/keypair";
|
||||
import { Decimal } from "decimal.js";
|
||||
import {
|
||||
ORCA_WHIRLPOOL_PROGRAM_ID,
|
||||
|
||||
@@ -5,7 +5,8 @@ import {
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { BN, Wallet } from "@coral-xyz/anchor";
|
||||
import { BN } from "@coral-xyz/anchor";
|
||||
import { Wallet } from "../utils/keypair";
|
||||
import { Decimal } from "decimal.js";
|
||||
import {
|
||||
PDAUtil,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { Wallet } from "@coral-xyz/anchor";
|
||||
import { Wallet } from "../utils/keypair";
|
||||
import { Decimal } from "decimal.js";
|
||||
import {
|
||||
ORCA_WHIRLPOOL_PROGRAM_ID,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import {
|
||||
Keypair,
|
||||
PublicKey,
|
||||
TransactionInstruction,
|
||||
TransactionMessage,
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { Wallet } from "@coral-xyz/anchor";
|
||||
import { Wallet } from "../utils/keypair";
|
||||
import { Decimal } from "decimal.js";
|
||||
import {
|
||||
ORCA_WHIRLPOOL_PROGRAM_ID,
|
||||
@@ -119,17 +120,17 @@ export async function orcaOpenSingleSidedPosition(
|
||||
lowerTick,
|
||||
upperTick,
|
||||
]);
|
||||
let txIds: string = "";
|
||||
let instructions: TransactionInstruction[] = [];
|
||||
let signers: Keypair[] = [];
|
||||
if (txBuilderTickArrays !== null) {
|
||||
const txPayloadTickArrays = await txBuilderTickArrays.build();
|
||||
const txPayloadTickArraysDecompiled = TransactionMessage.decompile(
|
||||
(txPayloadTickArrays.transaction as VersionedTransaction).message,
|
||||
);
|
||||
const instructions = txPayloadTickArraysDecompiled.instructions;
|
||||
const signers = txPayloadTickArrays.signers as Keypair[];
|
||||
|
||||
const tickArrayTxId = await sendTx(agent, instructions, signers);
|
||||
txIds += tickArrayTxId + ",";
|
||||
instructions = instructions.concat(
|
||||
txPayloadTickArraysDecompiled.instructions,
|
||||
);
|
||||
signers = signers.concat(txPayloadTickArrays.signers as Keypair[]);
|
||||
}
|
||||
|
||||
const tokenExtensionCtx: TokenExtensionContextForPool = {
|
||||
@@ -161,14 +162,13 @@ export async function orcaOpenSingleSidedPosition(
|
||||
const txPayloadDecompiled = TransactionMessage.decompile(
|
||||
(txPayload.transaction as VersionedTransaction).message,
|
||||
);
|
||||
const instructions = txPayloadDecompiled.instructions;
|
||||
const signers = txPayload.signers as Keypair[];
|
||||
instructions = instructions.concat(txPayloadDecompiled.instructions);
|
||||
signers = signers.concat(txPayload.signers as Keypair[]);
|
||||
|
||||
const positionTxId = await sendTx(agent, instructions, signers);
|
||||
txIds += positionTxId;
|
||||
const txId = await sendTx(agent, instructions, signers);
|
||||
|
||||
return JSON.stringify({
|
||||
transactionIds: txIds,
|
||||
transactionIds: txId,
|
||||
positionMint: positionMint.toString(),
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,7 +1,35 @@
|
||||
import { Keypair } from "@solana/web3.js";
|
||||
import { Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
|
||||
import bs58 from "bs58";
|
||||
|
||||
export const keypair = Keypair.generate();
|
||||
|
||||
console.log(keypair.publicKey.toString());
|
||||
console.log(bs58.encode(keypair.secretKey));
|
||||
|
||||
|
||||
export class Wallet {
|
||||
private _signer: Keypair;
|
||||
|
||||
constructor(signer: Keypair) {
|
||||
this._signer = signer;
|
||||
}
|
||||
|
||||
async signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T> {
|
||||
if (tx instanceof Transaction) {
|
||||
tx.sign(this._signer);
|
||||
} else if (tx instanceof VersionedTransaction) {
|
||||
tx.sign([this._signer]);
|
||||
} else {
|
||||
throw new Error("Unsupported transaction type");
|
||||
}
|
||||
return tx;
|
||||
}
|
||||
|
||||
async signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]> {
|
||||
return Promise.all(txs.map((tx) => this.signTransaction(tx)));
|
||||
}
|
||||
|
||||
get publicKey(): PublicKey {
|
||||
return this._signer.publicKey;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user