@exodus/solana-web3.js
Version:
Solana Javascript API
215 lines (214 loc) • 7.19 kB
TypeScript
/// <reference types="node" />
import { Buffer } from 'buffer';
import { Message } from '../message/index.js';
import { PublicKey } from '../publickey.js';
import type { Signer } from '../keypair.js';
import type { Blockhash } from '../blockhash.js';
/**
* Transaction signature as base-58 encoded string
*/
export declare type TransactionSignature = string;
export declare const enum TransactionStatus {
BLOCKHEIGHT_EXCEEDED = 0,
PROCESSED = 1,
TIMED_OUT = 2
}
/**
* Account metadata used to define instructions
*/
export declare type AccountMeta = {
/** An account's public key */
pubkey: PublicKey;
/** True if an instruction requires a transaction signature matching `pubkey` */
isSigner: boolean;
/** True if the `pubkey` can be loaded as a read-write account. */
isWritable: boolean;
};
/**
* List of TransactionInstruction object fields that may be initialized at construction
*/
export declare type TransactionInstructionCtorFields = {
keys: Array<AccountMeta>;
programId: PublicKey;
data?: Buffer;
};
/**
* Configuration object for Transaction.serialize()
*/
export declare type SerializeConfig = {
/** Require all transaction signatures be present (default: true) */
requireAllSignatures?: boolean;
/** Verify provided signatures (default: true) */
verifySignatures?: boolean;
};
/**
* Transaction Instruction class
*/
export declare class TransactionInstruction {
/**
* Public keys to include in this transaction
* Boolean represents whether this pubkey needs to sign the transaction
*/
keys: Array<AccountMeta>;
/**
* Program Id to execute
*/
programId: PublicKey;
/**
* Program input
*/
data: Buffer;
constructor(opts: TransactionInstructionCtorFields);
}
/**
* Pair of signature and corresponding public key
*/
export declare type SignaturePubkeyPair = {
signature: Buffer | null;
publicKey: PublicKey;
};
/**
* List of Transaction object fields that may be initialized at construction
*/
export declare type TransactionCtorFields_DEPRECATED = {
/** Optional nonce information used for offline nonce'd transactions */
nonceInfo?: NonceInformation | null;
/** The transaction fee payer */
feePayer?: PublicKey | null;
/** One or more signatures */
signatures?: Array<SignaturePubkeyPair>;
/** A recent blockhash */
recentBlockhash?: Blockhash;
};
export declare type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
/**
* List of Transaction object fields that may be initialized at construction
*/
export declare type TransactionBlockhashCtor = {
/** The transaction fee payer */
feePayer?: PublicKey | null;
/** One or more signatures */
signatures?: Array<SignaturePubkeyPair>;
/** A recent blockhash */
blockhash: Blockhash;
/** the last block chain can advance to before tx is declared expired */
lastValidBlockHeight: number;
};
/**
* Nonce information to be used to build an offline Transaction.
*/
export declare type NonceInformation = {
/** The current blockhash stored in the nonce */
nonce: Blockhash;
/** AdvanceNonceAccount Instruction */
nonceInstruction: TransactionInstruction;
};
/**
* Transaction class
*/
export declare class Transaction {
/**
* Signatures for the transaction. Typically created by invoking the
* `sign()` method
*/
signatures: Array<SignaturePubkeyPair>;
/**
* The first (payer) Transaction signature
*/
get signature(): Buffer | null;
/**
* The transaction fee payer
*/
feePayer?: PublicKey;
/**
* The instructions to atomically execute
*/
instructions: Array<TransactionInstruction>;
/**
* A recent transaction id. Must be populated by the caller
*/
recentBlockhash?: Blockhash;
/**
* the last block chain can advance to before tx is declared expired
* */
lastValidBlockHeight?: number;
/**
* Optional Nonce information. If populated, transaction will use a durable
* Nonce hash instead of a recentBlockhash. Must be populated by the caller
*/
nonceInfo?: NonceInformation;
constructor(opts?: TransactionBlockhashCtor);
/**
* @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
* Please supply a `TransactionBlockhashCtor` instead.
*/
constructor(opts?: TransactionCtorFields_DEPRECATED);
/**
* Add one or more instructions to this Transaction
*/
add(...items: Array<Transaction | TransactionInstruction | TransactionInstructionCtorFields>): Transaction;
/**
* Compile transaction data
*/
compileMessage(): Message;
/**
* Get a buffer of the Transaction data that need to be covered by signatures
*/
serializeMessage(): Buffer;
/**
* Specify the public keys which will be used to sign the Transaction.
* The first signer will be used as the transaction fee payer account.
*
* Signatures can be added with either `partialSign` or `addSignature`
*
* @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
* specified and it can be set in the Transaction constructor or with the
* `feePayer` property.
*/
setSigners(...signers: Array<PublicKey>): void;
/**
* Sign the Transaction with the specified signers. Multiple signatures may
* be applied to a Transaction. The first signature is considered "primary"
* and is used identify and confirm transactions.
*
* If the Transaction `feePayer` is not set, the first signer will be used
* as the transaction fee payer account.
*
* Transaction fields should not be modified after the first call to `sign`,
* as doing so may invalidate the signature and cause the Transaction to be
* rejected.
*
* The Transaction must be assigned a valid `recentBlockhash` before invoking this method
*/
sign(...signers: Array<Signer>): void;
/**
* Partially sign a transaction with the specified accounts. All accounts must
* correspond to either the fee payer or a signer account in the transaction
* instructions.
*
* All the caveats from the `sign` method apply to `partialSign`
*/
partialSign(...signers: Array<Signer>): void;
/**
* Add an externally created signature to a transaction. The public key
* must correspond to either the fee payer or a signer account in the transaction
* instructions.
*/
addSignature(pubkey: PublicKey, signature: Buffer): void;
/**
* Verify signatures of a complete, signed Transaction
*/
verifySignatures(): boolean;
/**
* Serialize the Transaction in the wire format.
*/
serialize(config?: SerializeConfig): Buffer;
/**
* Parse a wire transaction into a Transaction object.
*/
static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
/**
* Populate Transaction object from message and signatures
*/
static populate(message: Message, signatures?: Array<string>): Transaction;
}