mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-17 15:10:27 +00:00
Merged main
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { BN } from "@coral-xyz/anchor";
|
||||
import { Wallet } from "../../utils/keypair";
|
||||
import { Decimal } from "decimal.js";
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
|
||||
import {
|
||||
Keypair,
|
||||
PublicKey,
|
||||
Transaction,
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import bs58 from "bs58";
|
||||
|
||||
export const keypair = Keypair.generate();
|
||||
@@ -6,7 +11,6 @@ export const keypair = Keypair.generate();
|
||||
console.log(keypair.publicKey.toString());
|
||||
console.log(bs58.encode(keypair.secretKey));
|
||||
|
||||
|
||||
export class Wallet {
|
||||
private _signer: Keypair;
|
||||
|
||||
@@ -14,7 +18,9 @@ export class Wallet {
|
||||
this._signer = signer;
|
||||
}
|
||||
|
||||
async signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T> {
|
||||
async signTransaction<T extends Transaction | VersionedTransaction>(
|
||||
tx: T,
|
||||
): Promise<T> {
|
||||
if (tx instanceof Transaction) {
|
||||
tx.sign(this._signer);
|
||||
} else if (tx instanceof VersionedTransaction) {
|
||||
@@ -25,11 +31,13 @@ export class Wallet {
|
||||
return tx;
|
||||
}
|
||||
|
||||
async signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]> {
|
||||
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