@agentix/wallet-solana
Version:
87 lines (81 loc) • 4.2 kB
TypeScript
import { TransactionInstruction, Keypair, Connection, Transaction, VersionedTransaction, SendOptions, TransactionSignature, Signer, PublicKey } from '@solana/web3.js';
import { SolanaWalletBase } from 'agentix';
type SolanaTransaction = SolanaInstructionTransaction;
type SolanaInstructionTransaction = {
instructions: TransactionInstruction[];
addressLookupTableAddresses?: string[];
accountsToSign?: Keypair[];
signer?: Keypair;
};
type SolanWalletClientCtorParams = {
connection: Connection;
};
declare abstract class SolanaWalletClient extends SolanaWalletBase {
protected connection: Connection;
constructor(params: SolanWalletClientCtorParams);
getChain(): {
readonly type: "solana";
};
getConnection(): Connection;
balanceOf(address: string): Promise<{
decimals: number;
symbol: string;
name: string;
value: string;
inBaseUnits: string;
}>;
abstract signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
abstract signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
abstract sendTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<string>;
}
type SolanaKeypairWalletClientCtorParams = SolanWalletClientCtorParams & {
keypair: Keypair;
};
/**
* Check if a transaction object is a VersionedTransaction or not
*
* @param tx
* @returns bool
*/
declare const isVersionedTransaction: (tx: Transaction | VersionedTransaction) => tx is VersionedTransaction;
declare class SolanaKeypairWalletClient extends SolanaWalletClient {
#private;
constructor(params: SolanaKeypairWalletClientCtorParams);
getAddress(): string;
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]>;
sendTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<string>;
signMessage(message: string): Promise<{
signature: string;
}>;
signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
signature: TransactionSignature;
}>;
}
declare const solanaKeypair: (params: SolanaKeypairWalletClientCtorParams) => SolanaKeypairWalletClient;
interface SendTransactionOptions extends SendOptions {
signers?: Signer[];
}
type SolanaAdaptorWalletClientCtorParams = SolanWalletClientCtorParams & {
publicKey: PublicKey;
sendTransaction: (transaction: Transaction | VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<TransactionSignature>;
signAllTransactions: (<T extends Transaction | VersionedTransaction>(transactions: T[]) => Promise<T[]>);
signMessage: ((message: Uint8Array) => Promise<Uint8Array>);
signTransaction: (<T extends Transaction | VersionedTransaction>(transaction: T) => Promise<T>);
};
declare class SolanaAdaptorWalletClient extends SolanaWalletClient {
#private;
constructor(params: SolanaAdaptorWalletClientCtorParams);
getAddress(): string;
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]>;
sendTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<string>;
signMessage(message: string): Promise<{
signature: string;
}>;
signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
signature: TransactionSignature;
}>;
}
declare const solanaAdaptor: (params: SolanaAdaptorWalletClientCtorParams) => SolanaAdaptorWalletClient;
export { type SendTransactionOptions, type SolanWalletClientCtorParams, SolanaAdaptorWalletClient, type SolanaAdaptorWalletClientCtorParams, type SolanaInstructionTransaction, SolanaKeypairWalletClient, type SolanaKeypairWalletClientCtorParams, type SolanaTransaction, SolanaWalletClient, isVersionedTransaction, solanaAdaptor, solanaKeypair };