chore: update doc comments (#16267)

This commit is contained in:
Justin Starry
2021-03-31 18:48:41 +08:00
committed by GitHub
parent d0e3aae39f
commit b0f4e2b738
8 changed files with 194 additions and 323 deletions

View File

@ -112,8 +112,6 @@ export type ConfirmOptions = {
/** /**
* Options for getConfirmedSignaturesForAddress2 * Options for getConfirmedSignaturesForAddress2
*
* @typedef {Object} ConfirmedSignaturesForAddress2Options
*/ */
export type ConfirmedSignaturesForAddress2Options = { export type ConfirmedSignaturesForAddress2Options = {
/** /**
@ -208,8 +206,6 @@ function notificationResultAndContext<T, U>(value: Struct<T, U>) {
* 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
* 'finalized': Query the most recent block which has been finalized by the cluster * 'finalized': Query the most recent block which has been finalized by the cluster
* </pre> * </pre>
*
* @typedef {'processed' | 'confirmed' | 'finalized'} Commitment
*/ */
export type Commitment = export type Commitment =
| 'processed' | 'processed'
@ -227,95 +223,76 @@ export type Commitment =
* 'circulating': Return the largest accounts that are part of the circulating supply * 'circulating': Return the largest accounts that are part of the circulating supply
* 'nonCirculating': Return the largest accounts that are not part of the circulating supply * 'nonCirculating': Return the largest accounts that are not part of the circulating supply
* </pre> * </pre>
*
* @typedef {'circulating' | 'nonCirculating'} LargestAccountsFilter
*/ */
export type LargestAccountsFilter = 'circulating' | 'nonCirculating'; export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
/** /**
* Configuration object for changing `getLargestAccounts` query behavior * Configuration object for changing `getLargestAccounts` query behavior
*
* @typedef {Object} GetLargestAccountsConfig
* @property {Commitment|undefined} commitment The level of commitment desired
* @property {LargestAccountsFilter|undefined} filter Filter largest accounts by whether they are part of the circulating supply
*/ */
export type GetLargestAccountsConfig = { export type GetLargestAccountsConfig = {
/** The level of commitment desired */
commitment?: Commitment; commitment?: Commitment;
/** Filter largest accounts by whether they are part of the circulating supply */
filter?: LargestAccountsFilter; filter?: LargestAccountsFilter;
}; };
/** /**
* Configuration object for changing query behavior * Configuration object for changing query behavior
*
* @typedef {Object} SignatureStatusConfig
* @property {boolean} searchTransactionHistory enable searching status history, not needed for recent transactions
*/ */
export type SignatureStatusConfig = { export type SignatureStatusConfig = {
/** enable searching status history, not needed for recent transactions */
searchTransactionHistory: boolean; searchTransactionHistory: boolean;
}; };
/** /**
* Information describing a cluster node * Information describing a cluster node
*
* @typedef {Object} ContactInfo
* @property {string} pubkey Identity public key of the node
* @property {string|null} gossip Gossip network address for the node
* @property {string|null} tpu TPU network address for the node (null if not available)
* @property {string|null} rpc JSON RPC network address for the node (null if not available)
* @property {string|null} version Software version of the node (null if not available)
*/ */
export type ContactInfo = { export type ContactInfo = {
/** Identity public key of the node */
pubkey: string; pubkey: string;
/** Gossip network address for the node */
gossip: string | null; gossip: string | null;
/** TPU network address for the node (null if not available) */
tpu: string | null; tpu: string | null;
/** JSON RPC network address for the node (null if not available) */
rpc: string | null; rpc: string | null;
/** Software version of the node (null if not available) */
version: string | null; version: string | null;
}; };
/** /**
* Information describing a vote account * Information describing a vote account
*
* @typedef {Object} VoteAccountInfo
* @property {string} votePubkey Public key of the vote account
* @property {string} nodePubkey Identity public key of the node voting with this account
* @property {number} activatedStake The stake, in lamports, delegated to this vote account and activated
* @property {boolean} epochVoteAccount Whether the vote account is staked for this epoch
* @property {Array<Array<number>>} epochCredits Recent epoch voting credit history for this voter
* @property {number} commission A percentage (0-100) of rewards payout owed to the voter
* @property {number} lastVote Most recent slot voted on by this vote account
*/ */
export type VoteAccountInfo = { export type VoteAccountInfo = {
/** Public key of the vote account */
votePubkey: string; votePubkey: string;
/** Identity public key of the node voting with this account */
nodePubkey: string; nodePubkey: string;
/** The stake, in lamports, delegated to this vote account and activated */
activatedStake: number; activatedStake: number;
/** Whether the vote account is staked for this epoch */
epochVoteAccount: boolean; epochVoteAccount: boolean;
/** Recent epoch voting credit history for this voter */
epochCredits: Array<[number, number, number]>; epochCredits: Array<[number, number, number]>;
/** A percentage (0-100) of rewards payout owed to the voter */
commission: number; commission: number;
/** Most recent slot voted on by this vote account */
lastVote: number; lastVote: number;
}; };
/** /**
* A collection of cluster vote accounts * A collection of cluster vote accounts
*
* @typedef {Object} VoteAccountStatus
* @property {Array<VoteAccountInfo>} current Active vote accounts
* @property {Array<VoteAccountInfo>} delinquent Inactive vote accounts
*/ */
export type VoteAccountStatus = { export type VoteAccountStatus = {
/** Active vote accounts */
current: Array<VoteAccountInfo>; current: Array<VoteAccountInfo>;
/** Inactive vote accounts */
delinquent: Array<VoteAccountInfo>; delinquent: Array<VoteAccountInfo>;
}; };
/** /**
* Network Inflation * Network Inflation
* (see https://docs.solana.com/implemented-proposals/ed_overview) * (see https://docs.solana.com/implemented-proposals/ed_overview)
*
* @typedef {Object} InflationGovernor
* @property {number} foundation
* @property {number} foundation_term
* @property {number} initial
* @property {number} taper
* @property {number} terminal
*/ */
export type InflationGovernor = { export type InflationGovernor = {
foundation: number; foundation: number;
@ -335,14 +312,6 @@ const GetInflationGovernorResult = pick({
/** /**
* Information about the current epoch * Information about the current epoch
*
* @typedef {Object} EpochInfo
* @property {number} epoch
* @property {number} slotIndex
* @property {number} slotsInEpoch
* @property {number} absoluteSlot
* @property {number} blockHeight
* @property {number} transactionCount
*/ */
export type EpochInfo = { export type EpochInfo = {
epoch: number; epoch: number;
@ -365,19 +334,17 @@ const GetEpochInfoResult = pick({
/** /**
* Epoch schedule * Epoch schedule
* (see https://docs.solana.com/terminology#epoch) * (see https://docs.solana.com/terminology#epoch)
*
* @typedef {Object} EpochSchedule
* @property {number} slotsPerEpoch The maximum number of slots in each epoch
* @property {number} leaderScheduleSlotOffset The number of slots before beginning of an epoch to calculate a leader schedule for that epoch
* @property {boolean} warmup Indicates whether epochs start short and grow
* @property {number} firstNormalEpoch The first epoch with `slotsPerEpoch` slots
* @property {number} firstNormalSlot The first slot of `firstNormalEpoch`
*/ */
export type EpochSchedule = { export type EpochSchedule = {
/** The maximum number of slots in each epoch */
slotsPerEpoch: number; slotsPerEpoch: number;
/** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */
leaderScheduleSlotOffset: number; leaderScheduleSlotOffset: number;
/** Indicates whether epochs start short and grow */
warmup: boolean; warmup: boolean;
/** The first epoch with `slotsPerEpoch` slots */
firstNormalEpoch: number; firstNormalEpoch: number;
/** The first slot of `firstNormalEpoch` */
firstNormalSlot: number; firstNormalSlot: number;
}; };
@ -392,8 +359,6 @@ const GetEpochScheduleResult = pick({
/** /**
* Leader schedule * Leader schedule
* (see https://docs.solana.com/terminology#leader-schedule) * (see https://docs.solana.com/terminology#leader-schedule)
*
* @typedef {Object} LeaderSchedule
*/ */
export type LeaderSchedule = { export type LeaderSchedule = {
[address: string]: number[]; [address: string]: number[];
@ -418,17 +383,15 @@ const SignatureStatusResult = pick({
*/ */
const SignatureReceivedResult = literal('receivedSignature'); const SignatureReceivedResult = literal('receivedSignature');
/**
* Version info for a node
*/
export type Version = { export type Version = {
/** Version of solana-core */
'solana-core': string; 'solana-core': string;
'feature-set'?: number; 'feature-set'?: number;
}; };
/**
* Version info for a node
*
* @typedef {Object} Version
* @property {string} solana-core Version of solana-core
*/
const VersionResult = pick({ const VersionResult = pick({
'solana-core': string(), 'solana-core': string(),
'feature-set': optional(number()), 'feature-set': optional(number()),
@ -459,25 +422,23 @@ export type TokenBalance = {
/** /**
* Metadata for a parsed confirmed transaction on the ledger * Metadata for a parsed confirmed transaction on the ledger
*
* @typedef {Object} ParsedConfirmedTransactionMeta
* @property {number} fee The fee charged for processing the transaction
* @property {Array<ParsedInnerInstruction>} innerInstructions An array of cross program invoked parsed instructions
* @property {Array<number>} preBalances The balances of the transaction accounts before processing
* @property {Array<number>} postBalances The balances of the transaction accounts after processing
* @property {Array<string>} logMessages An array of program log messages emitted during a transaction
* @property {Array<TokenBalance>} preTokenBalances The token balances of the transaction accounts before processing
* @property {Array<TokenBalance>} postTokenBalances The token balances of the transaction accounts after processing
* @property {object|null} err The error result of transaction processing
*/ */
export type ParsedConfirmedTransactionMeta = { export type ParsedConfirmedTransactionMeta = {
/** The fee charged for processing the transaction */
fee: number; fee: number;
/** An array of cross program invoked parsed instructions */
innerInstructions?: ParsedInnerInstruction[] | null; innerInstructions?: ParsedInnerInstruction[] | null;
/** The balances of the transaction accounts before processing */
preBalances: Array<number>; preBalances: Array<number>;
/** The balances of the transaction accounts after processing */
postBalances: Array<number>; postBalances: Array<number>;
/** An array of program log messages emitted during a transaction */
logMessages?: Array<string> | null; logMessages?: Array<string> | null;
/** The token balances of the transaction accounts before processing */
preTokenBalances?: Array<TokenBalance> | null; preTokenBalances?: Array<TokenBalance> | null;
/** The token balances of the transaction accounts after processing */
postTokenBalances?: Array<TokenBalance> | null; postTokenBalances?: Array<TokenBalance> | null;
/** The error result of transaction processing */
err: TransactionError | null; err: TransactionError | null;
}; };
@ -488,41 +449,37 @@ export type CompiledInnerInstruction = {
/** /**
* Metadata for a confirmed transaction on the ledger * Metadata for a confirmed transaction on the ledger
*
* @typedef {Object} ConfirmedTransactionMeta
* @property {number} fee The fee charged for processing the transaction
* @property {Array<CompiledInnerInstruction>} innerInstructions An array of cross program invoked instructions
* @property {Array<number>} preBalances The balances of the transaction accounts before processing
* @property {Array<number>} postBalances The balances of the transaction accounts after processing
* @property {Array<string>} logMessages An array of program log messages emitted during a transaction
* @property {Array<TokenBalance>} preTokenBalances The token balances of the transaction accounts before processing
* @property {Array<TokenBalance>} postTokenBalances The token balances of the transaction accounts after processing
* @property {object|null} err The error result of transaction processing
*/ */
export type ConfirmedTransactionMeta = { export type ConfirmedTransactionMeta = {
/** The fee charged for processing the transaction */
fee: number; fee: number;
/** An array of cross program invoked instructions */
innerInstructions?: CompiledInnerInstruction[] | null; innerInstructions?: CompiledInnerInstruction[] | null;
/** The balances of the transaction accounts before processing */
preBalances: Array<number>; preBalances: Array<number>;
/** The balances of the transaction accounts after processing */
postBalances: Array<number>; postBalances: Array<number>;
/** An array of program log messages emitted during a transaction */
logMessages?: Array<string> | null; logMessages?: Array<string> | null;
/** The token balances of the transaction accounts before processing */
preTokenBalances?: Array<TokenBalance> | null; preTokenBalances?: Array<TokenBalance> | null;
/** The token balances of the transaction accounts after processing */
postTokenBalances?: Array<TokenBalance> | null; postTokenBalances?: Array<TokenBalance> | null;
/** The error result of transaction processing */
err: TransactionError | null; err: TransactionError | null;
}; };
/** /**
* A confirmed transaction on the ledger * A confirmed transaction on the ledger
*
* @typedef {Object} ConfirmedTransaction
* @property {number} slot The slot during which the transaction was processed
* @property {Transaction} transaction The details of the transaction
* @property {ConfirmedTransactionMeta|null} meta Metadata produced from the transaction
* @property {number|null|undefined} blockTime The unix timestamp of when the transaction was processed
*/ */
export type ConfirmedTransaction = { export type ConfirmedTransaction = {
/** The slot during which the transaction was processed */
slot: number; slot: number;
/** The details of the transaction */
transaction: Transaction; transaction: Transaction;
/** Metadata produced from the transaction */
meta: ConfirmedTransactionMeta | null; meta: ConfirmedTransactionMeta | null;
/** The unix timestamp of when the transaction was processed */
blockTime?: number | null; blockTime?: number | null;
}; };
@ -540,115 +497,101 @@ export type PartiallyDecodedInstruction = {
/** /**
* A parsed transaction message account * A parsed transaction message account
*
* @typedef {Object} ParsedMessageAccount
* @property {PublicKey} pubkey Public key of the account
* @property {boolean} signer Indicates if the account signed the transaction
* @property {boolean} writable Indicates if the account is writable for this transaction
*/ */
export type ParsedMessageAccount = { export type ParsedMessageAccount = {
/** Public key of the account */
pubkey: PublicKey; pubkey: PublicKey;
/** Indicates if the account signed the transaction */
signer: boolean; signer: boolean;
/** Indicates if the account is writable for this transaction */
writable: boolean; writable: boolean;
}; };
/** /**
* A parsed transaction instruction * A parsed transaction instruction
*
* @typedef {Object} ParsedInstruction
* @property {string} program Name of the program for this instruction
* @property {PublicKey} programId ID of the program for this instruction
* @property {any} parsed Parsed instruction info
*/ */
export type ParsedInstruction = { export type ParsedInstruction = {
/** Name of the program for this instruction */
program: string; program: string;
/** ID of the program for this instruction */
programId: PublicKey; programId: PublicKey;
/** Parsed instruction info */
parsed: any; parsed: any;
}; };
/** /**
* A parsed transaction message * A parsed transaction message
*
* @typedef {Object} ParsedMessage
* @property {Array<ParsedMessageAccount>} accountKeys Accounts used in the instructions
* @property {Array<ParsedInstruction | PartiallyDecodedInstruction>} instructions The atomically executed instructions for the transaction
* @property {string} recentBlockhash Recent blockhash
*/ */
export type ParsedMessage = { export type ParsedMessage = {
/** Accounts used in the instructions */
accountKeys: ParsedMessageAccount[]; accountKeys: ParsedMessageAccount[];
/** The atomically executed instructions for the transaction */
instructions: (ParsedInstruction | PartiallyDecodedInstruction)[]; instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
/** Recent blockhash */
recentBlockhash: string; recentBlockhash: string;
}; };
/** /**
* A parsed transaction * A parsed transaction
*
* @typedef {Object} ParsedTransaction
* @property {Array<string>} signatures Signatures for the transaction
* @property {ParsedMessage} message Message of the transaction
*/ */
export type ParsedTransaction = { export type ParsedTransaction = {
/** Signatures for the transaction */
signatures: Array<string>; signatures: Array<string>;
/** Message of the transaction */
message: ParsedMessage; message: ParsedMessage;
}; };
/** /**
* A parsed and confirmed transaction on the ledger * A parsed and confirmed transaction on the ledger
*
* @typedef {Object} ParsedConfirmedTransaction
* @property {number} slot The slot during which the transaction was processed
* @property {ParsedTransaction} transaction The details of the transaction
* @property {ConfirmedTransactionMeta|null} meta Metadata produced from the transaction
* @property {number|null|undefined} blockTime The unix timestamp of when the transaction was processed
*/ */
export type ParsedConfirmedTransaction = { export type ParsedConfirmedTransaction = {
/** The slot during which the transaction was processed */
slot: number; slot: number;
/** The details of the transaction */
transaction: ParsedTransaction; transaction: ParsedTransaction;
/** Metadata produced from the transaction */
meta: ParsedConfirmedTransactionMeta | null; meta: ParsedConfirmedTransactionMeta | null;
/** The unix timestamp of when the transaction was processed */
blockTime?: number | null; blockTime?: number | null;
}; };
/** /**
* A ConfirmedBlock on the ledger * A ConfirmedBlock on the ledger
*
* @typedef {Object} ConfirmedBlock
* @property {Blockhash} blockhash Blockhash of this block
* @property {Blockhash} previousBlockhash Blockhash of this block's parent
* @property {number} parentSlot Slot index of this block's parent
* @property {Array<object>} transactions Vector of transactions and status metas
* @property {Array<object>} rewards Vector of block rewards
* @property {number|null} blockTime The unix timestamp of when the block was processed
*/ */
export type ConfirmedBlock = { export type ConfirmedBlock = {
/** Blockhash of this block */
blockhash: Blockhash; blockhash: Blockhash;
/** Blockhash of this block's parent */
previousBlockhash: Blockhash; previousBlockhash: Blockhash;
/** Slot index of this block's parent */
parentSlot: number; parentSlot: number;
/** Vector of transactions and status metas */
transactions: Array<{ transactions: Array<{
transaction: Transaction; transaction: Transaction;
meta: ConfirmedTransactionMeta | null; meta: ConfirmedTransactionMeta | null;
}>; }>;
/** Vector of block rewards */
rewards?: Array<{ rewards?: Array<{
pubkey: string; pubkey: string;
lamports: number; lamports: number;
postBalance: number | null; postBalance: number | null;
rewardType: string | null; rewardType: string | null;
}>; }>;
/** The unix timestamp of when the block was processed */
blockTime: number | null; blockTime: number | null;
}; };
/** /**
* A performance sample * A performance sample
*
* @typedef {Object} PerfSample
* @property {number} slot Slot number of sample
* @property {number} numTransactions Number of transactions in a sample window
* @property {number} numSlots Number of slots in a sample window
* @property {number} samplePeriodSecs Sample window in seconds
*/ */
export type PerfSample = { export type PerfSample = {
/** Slot number of sample */
slot: number; slot: number;
/** Number of transactions in a sample window */
numTransactions: number; numTransactions: number;
/** Number of slots in a sample window */
numSlots: number; numSlots: number;
/** Sample window in seconds */
samplePeriodSecs: number; samplePeriodSecs: number;
}; };
@ -767,17 +710,15 @@ const SlotRpcResult = jsonRpcResult(number());
/** /**
* Supply * Supply
*
* @typedef {Object} Supply
* @property {number} total Total supply in lamports
* @property {number} circulating Circulating supply in lamports
* @property {number} nonCirculating Non-circulating supply in lamports
* @property {Array<PublicKey>} nonCirculatingAccounts List of non-circulating account addresses
*/ */
export type Supply = { export type Supply = {
/** Total supply in lamports */
total: number; total: number;
/** Circulating supply in lamports */
circulating: number; circulating: number;
/** Non-circulating supply in lamports */
nonCirculating: number; nonCirculating: number;
/** List of non-circulating account addresses */
nonCirculatingAccounts: Array<PublicKey>; nonCirculatingAccounts: Array<PublicKey>;
}; };
@ -796,17 +737,15 @@ const GetSupplyRpcResult = jsonRpcResultAndContext(
/** /**
* Token amount object which returns a token amount in different formats * Token amount object which returns a token amount in different formats
* for various client use cases. * for various client use cases.
*
* @typedef {Object} TokenAmount
* @property {string} amount Raw amount of tokens as string ignoring decimals
* @property {number} decimals Number of decimals configured for token's mint
* @property {number | null} uiAmount Token amount as float, accounts for decimals
* @property {string | undefined} uiAmountString Token amount as string, accounts for decimals
*/ */
export type TokenAmount = { export type TokenAmount = {
/** Raw amount of tokens as string ignoring decimals */
amount: string; amount: string;
/** Number of decimals configured for token's mint */
decimals: number; decimals: number;
/** Token amount as float, accounts for decimals */
uiAmount: number | null; uiAmount: number | null;
/** Token amount as string, accounts for decimals */
uiAmountString?: string; uiAmountString?: string;
}; };
@ -822,19 +761,17 @@ const TokenAmountResult = pick({
/** /**
* Token address and balance. * Token address and balance.
*
* @typedef {Object} TokenAccountBalancePair
* @property {PublicKey} address Address of the token account
* @property {string} amount Raw amount of tokens as string ignoring decimals
* @property {number} decimals Number of decimals configured for token's mint
* @property {number | null} uiAmount Token amount as float, accounts for decimals
* @property {string | undefined} uiAmountString Token amount as string, accounts for decimals
*/ */
export type TokenAccountBalancePair = { export type TokenAccountBalancePair = {
/** Address of the token account */
address: PublicKey; address: PublicKey;
/** Raw amount of tokens as string ignoring decimals */
amount: string; amount: string;
/** Number of decimals configured for token's mint */
decimals: number; decimals: number;
/** Token amount as float, accounts for decimals */
uiAmount: number | null; uiAmount: number | null;
/** Token amount as string, accounts for decimals */
uiAmountString?: string; uiAmountString?: string;
}; };
@ -897,10 +834,6 @@ const GetParsedTokenAccountsByOwner = jsonRpcResultAndContext(
/** /**
* Pair of an account address and its balance * Pair of an account address and its balance
*
* @typedef {Object} AccountBalancePair
* @property {PublicKey} address
* @property {number} lamports
*/ */
export type AccountBalancePair = { export type AccountBalancePair = {
address: PublicKey; address: PublicKey;
@ -1375,68 +1308,56 @@ const SendTransactionRpcResult = jsonRpcResult(string());
/** /**
* Information about the latest slot being processed by a node * Information about the latest slot being processed by a node
*
* @typedef {Object} SlotInfo
* @property {number} slot Currently processing slot
* @property {number} parent Parent of the current slot
* @property {number} root The root block of the current slot's fork
*/ */
export type SlotInfo = { export type SlotInfo = {
/** Currently processing slot */
slot: number; slot: number;
/** Parent of the current slot */
parent: number; parent: number;
/** The root block of the current slot's fork */
root: number; root: number;
}; };
/** /**
* Parsed account data * Parsed account data
*
* @typedef {Object} ParsedAccountData
* @property {string} program Name of the program that owns this account
* @property {any} parsed Parsed account data
* @property {number} space Space used by account data
*/ */
export type ParsedAccountData = { export type ParsedAccountData = {
/** Name of the program that owns this account */
program: string; program: string;
/** Parsed account data */
parsed: any; parsed: any;
/** Space used by account data */
space: number; space: number;
}; };
/** /**
* Stake Activation data * Stake Activation data
*
* @typedef {Object} StakeActivationData
* @property {string} state: <string - the stake account's activation state, one of: active, inactive, activating, deactivating
* @property {number} active: stake active during the epoch
* @property {number} inactive: stake inactive during the epoch
*/ */
export type StakeActivationData = { export type StakeActivationData = {
/** the stake account's activation state */
state: 'active' | 'inactive' | 'activating' | 'deactivating'; state: 'active' | 'inactive' | 'activating' | 'deactivating';
/** stake active during the epoch */
active: number; active: number;
/** stake inactive during the epoch */
inactive: number; inactive: number;
}; };
/** /**
* Information describing an account * Information describing an account
*
* @typedef {Object} AccountInfo
* @property {number} lamports Number of lamports assigned to the account
* @property {PublicKey} owner Identifier of the program that owns the account
* @property {T} data Optional data assigned to the account
* @property {boolean} executable `true` if this account's data contains a loaded program
*/ */
export type AccountInfo<T> = { export type AccountInfo<T> = {
/** `true` if this account's data contains a loaded program */
executable: boolean; executable: boolean;
/** Identifier of the program that owns the account */
owner: PublicKey; owner: PublicKey;
/** Number of lamports assigned to the account */
lamports: number; lamports: number;
/** Optional data assigned to the account */
data: T; data: T;
}; };
/** /**
* Account information identified by pubkey * Account information identified by pubkey
*
* @typedef {Object} KeyedAccountInfo
* @property {PublicKey} accountId
* @property {AccountInfo<Buffer>} accountInfo
*/ */
export type KeyedAccountInfo = { export type KeyedAccountInfo = {
accountId: PublicKey; accountId: PublicKey;
@ -1570,8 +1491,6 @@ const LogsResult = pick({
/** /**
* Logs result. * Logs result.
*
* @typedef {Object} Logs.
*/ */
export type Logs = { export type Logs = {
err: TransactionError | null; err: TransactionError | null;
@ -1609,8 +1528,6 @@ type LogsSubscriptionInfo = {
/** /**
* Signature result * Signature result
*
* @typedef {Object} SignatureResult
*/ */
export type SignatureResult = { export type SignatureResult = {
err: TransactionError | null; err: TransactionError | null;
@ -1618,8 +1535,6 @@ export type SignatureResult = {
/** /**
* Transaction error * Transaction error
*
* @typedef {Object} TransactionError
*/ */
export type TransactionError = {}; export type TransactionError = {};
@ -1652,19 +1567,17 @@ export type SignatureStatus = {
/** /**
* A confirmed signature with its status * A confirmed signature with its status
*
* @typedef {Object} ConfirmedSignatureInfo
* @property {string} signature the transaction signature
* @property {number} slot when the transaction was processed
* @property {TransactionError | null} err error, if any
* @property {string | null} memo memo associated with the transaction, if any
* @property {number | null | undefined} blockTime The unix timestamp of when the transaction was processed
*/ */
export type ConfirmedSignatureInfo = { export type ConfirmedSignatureInfo = {
/** the transaction signature */
signature: string; signature: string;
/** when the transaction was processed */
slot: number; slot: number;
/** error, if any */
err: TransactionError | null; err: TransactionError | null;
/** memo associated with the transaction, if any */
memo: string | null; memo: string | null;
/** The unix timestamp of when the transaction was processed */
blockTime?: number | null; blockTime?: number | null;
}; };

View File

@ -4,13 +4,12 @@ import * as BufferLayout from 'buffer-layout';
import * as Layout from './layout'; import * as Layout from './layout';
/** /**
* @typedef {Object} InstructionType
* @property (index} The Instruction index (from solana upstream program)
* @property (BufferLayout} The BufferLayout to use to build data
* @internal * @internal
*/ */
export type InstructionType = { export type InstructionType = {
/** The Instruction index (from solana upstream program) */
index: number; index: number;
/** The BufferLayout to use to build data */
layout: typeof BufferLayout; layout: typeof BufferLayout;
}; };

View File

@ -11,46 +11,46 @@ import {toBuffer} from './util/to-buffer';
/** /**
* The message header, identifying signed and read-only account * The message header, identifying signed and read-only account
*
* @typedef {Object} MessageHeader
* @property {number} numRequiredSignatures The number of signatures required for this message to be considered valid. The
* signatures must match the first `numRequiredSignatures` of `accountKeys`.
* @property {number} numReadonlySignedAccounts: The last `numReadonlySignedAccounts` of the signed keys are read-only accounts
* @property {number} numReadonlyUnsignedAccounts The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts
*/ */
export type MessageHeader = { export type MessageHeader = {
/**
* The number of signatures required for this message to be considered valid. The
* signatures must match the first `numRequiredSignatures` of `accountKeys`.
*/
numRequiredSignatures: number; numRequiredSignatures: number;
/** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
numReadonlySignedAccounts: number; numReadonlySignedAccounts: number;
/** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
numReadonlyUnsignedAccounts: number; numReadonlyUnsignedAccounts: number;
}; };
/** /**
* An instruction to execute by a program * An instruction to execute by a program
* *
* @typedef {Object} CompiledInstruction * @property {number} programIdIndex
* @property {number} programIdIndex Index into the transaction keys array indicating the program account that executes this instruction * @property {number[]} accounts
* @property {number[]} accounts Ordered indices into the transaction keys array indicating which accounts to pass to the program * @property {string} data
* @property {string} data The program input data encoded as base 58
*/ */
export type CompiledInstruction = { export type CompiledInstruction = {
/** Index into the transaction keys array indicating the program account that executes this instruction */
programIdIndex: number; programIdIndex: number;
/** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
accounts: number[]; accounts: number[];
/** The program input data encoded as base 58 */
data: string; data: string;
}; };
/** /**
* Message constructor arguments * Message constructor arguments
*
* @typedef {Object} MessageArgs
* @property {MessageHeader} header The message header, identifying signed and read-only `accountKeys`
* @property {string[]} accounts All the account keys used by this transaction
* @property {Blockhash} recentBlockhash The hash of a recent ledger block
* @property {CompiledInstruction[]} instructions Instructions that will be executed in sequence and committed in one atomic transaction if all succeed.
*/ */
export type MessageArgs = { export type MessageArgs = {
/** The message header, identifying signed and read-only `accountKeys` */
header: MessageHeader; header: MessageHeader;
/** All the account keys used by this transaction */
accountKeys: string[]; accountKeys: string[];
/** The hash of a recent ledger block */
recentBlockhash: Blockhash; recentBlockhash: Blockhash;
/** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
instructions: CompiledInstruction[]; instructions: CompiledInstruction[];
}; };

View File

@ -17,11 +17,6 @@ const SIGNATURE_OFFSETS_SERIALIZED_SIZE = 11;
/** /**
* Params for creating an secp256k1 instruction using a public key * Params for creating an secp256k1 instruction using a public key
* @typedef {Object} CreateSecp256k1InstructionWithPublicKeyParams
* @property {Buffer | Uint8Array | Array<number>} publicKey
* @property {Buffer | Uint8Array | Array<number>} message
* @property {Buffer | Uint8Array | Array<number>} signature
* @property {number} recoveryId
*/ */
export type CreateSecp256k1InstructionWithPublicKeyParams = { export type CreateSecp256k1InstructionWithPublicKeyParams = {
publicKey: Buffer | Uint8Array | Array<number>; publicKey: Buffer | Uint8Array | Array<number>;
@ -32,11 +27,6 @@ export type CreateSecp256k1InstructionWithPublicKeyParams = {
/** /**
* Params for creating an secp256k1 instruction using an Ethereum address * Params for creating an secp256k1 instruction using an Ethereum address
* @typedef {Object} CreateSecp256k1InstructionWithEthAddressParams
* @property {Buffer | Uint8Array | Array<number>} ethAddress
* @property {Buffer | Uint8Array | Array<number>} message
* @property {Buffer | Uint8Array | Array<number>} signature
* @property {number} recoveryId
*/ */
export type CreateSecp256k1InstructionWithEthAddressParams = { export type CreateSecp256k1InstructionWithEthAddressParams = {
ethAddress: Buffer | Uint8Array | Array<number> | string; ethAddress: Buffer | Uint8Array | Array<number> | string;
@ -47,9 +37,6 @@ export type CreateSecp256k1InstructionWithEthAddressParams = {
/** /**
* Params for creating an secp256k1 instruction using a private key * Params for creating an secp256k1 instruction using a private key
* @typedef {Object} CreateSecp256k1InstructionWithPrivateKeyParams
* @property {Buffer | Uint8Array | Array<number>} privateKey
* @property {Buffer | Uint8Array | Array<number>} message
*/ */
export type CreateSecp256k1InstructionWithPrivateKeyParams = { export type CreateSecp256k1InstructionWithPrivateKeyParams = {
privateKey: Buffer | Uint8Array | Array<number>; privateKey: Buffer | Uint8Array | Array<number>;

View File

@ -454,10 +454,10 @@ export const STAKE_INSTRUCTION_LAYOUTS: {
}); });
/** /**
* @typedef {Object} StakeAuthorizationType * Stake authorization type
* @property (index} The Stake Authorization index (from solana-stake-program)
*/ */
export type StakeAuthorizationType = { export type StakeAuthorizationType = {
/** The Stake Authorization index (from solana-stake-program) */
index: number; index: number;
}; };

View File

@ -10,209 +10,195 @@ import {toBuffer} from './util/to-buffer';
/** /**
* Create account system transaction params * Create account system transaction params
* @typedef {Object} CreateAccountParams
* @property {PublicKey} fromPubkey
* @property {PublicKey} newAccountPubkey
* @property {number} lamports
* @property {number} space
* @property {PublicKey} programId
*/ */
export type CreateAccountParams = { export type CreateAccountParams = {
/** The account that will transfer lamports to the created account */
fromPubkey: PublicKey; fromPubkey: PublicKey;
/** Public key of the created account */
newAccountPubkey: PublicKey; newAccountPubkey: PublicKey;
/** Amount of lamports to transfer to the created account */
lamports: number; lamports: number;
/** Amount of space in bytes to allocate to the created account */
space: number; space: number;
/** Public key of the program to assign as the owner of the created account */
programId: PublicKey; programId: PublicKey;
}; };
/** /**
* Transfer system transaction params * Transfer system transaction params
* @typedef {Object} TransferParams
* @property {PublicKey} fromPubkey
* @property {PublicKey} toPubkey
* @property {number} lamports
*/ */
export type TransferParams = { export type TransferParams = {
/** Account that will transfer lamports */
fromPubkey: PublicKey; fromPubkey: PublicKey;
/** Account that will receive transferred lamports */
toPubkey: PublicKey; toPubkey: PublicKey;
/** Amount of lamports to transfer */
lamports: number; lamports: number;
}; };
/** /**
* Assign system transaction params * Assign system transaction params
* @typedef {Object} AssignParams
* @property {PublicKey} accountPubkey
* @property {PublicKey} programId
*/ */
export type AssignParams = { export type AssignParams = {
/** Public key of the account which will be assigned a new owner */
accountPubkey: PublicKey; accountPubkey: PublicKey;
/** Public key of the program to assign as the owner */
programId: PublicKey; programId: PublicKey;
}; };
/** /**
* Create account with seed system transaction params * Create account with seed system transaction params
* @typedef {Object} CreateAccountWithSeedParams
* @property {PublicKey} fromPubkey
* @property {PublicKey} newAccountPubkey
* @property {PublicKey} basePubkey
* @property {string} seed
* @property {number} lamports
* @property {number} space
* @property {PublicKey} programId
*/ */
export type CreateAccountWithSeedParams = { export type CreateAccountWithSeedParams = {
/** The account that will transfer lamports to the created account */
fromPubkey: PublicKey; fromPubkey: PublicKey;
/** Public key of the created account */
newAccountPubkey: PublicKey; newAccountPubkey: PublicKey;
/** Base public key to use to derive the address of the created account */
basePubkey: PublicKey; basePubkey: PublicKey;
/** Seed to use to derive the address of the created account */
seed: string; seed: string;
/** Amount of lamports to transfer to the created account */
lamports: number; lamports: number;
/** Amount of space in bytes to allocate to the created account */
space: number; space: number;
/** Public key of the program to assign as the owner of the created account */
programId: PublicKey; programId: PublicKey;
}; };
/** /**
* Create nonce account system transaction params * Create nonce account system transaction params
* @typedef {Object} CreateNonceAccountParams
* @property {PublicKey} fromPubkey
* @property {PublicKey} noncePubkey
* @property {PublicKey} authorizedPubkey
* @property {number} lamports
*/ */
export type CreateNonceAccountParams = { export type CreateNonceAccountParams = {
/** The account that will transfer lamports to the created nonce account */
fromPubkey: PublicKey; fromPubkey: PublicKey;
/** Public key of the created nonce account */
noncePubkey: PublicKey; noncePubkey: PublicKey;
/** Public key to set as authority of the created nonce account */
authorizedPubkey: PublicKey; authorizedPubkey: PublicKey;
/** Amount of lamports to transfer to the created nonce account */
lamports: number; lamports: number;
}; };
/** /**
* Create nonce account with seed system transaction params * Create nonce account with seed system transaction params
* @typedef {Object} CreateNonceAccountWithSeedParams
* @property {PublicKey} fromPubkey
* @property {PublicKey} noncePubkey
* @property {PublicKey} authorizedPubkey
* @property {PublicKey} basePubkey
* @property {string} seed
* @property {number} lamports
*/ */
export type CreateNonceAccountWithSeedParams = { export type CreateNonceAccountWithSeedParams = {
/** The account that will transfer lamports to the created nonce account */
fromPubkey: PublicKey; fromPubkey: PublicKey;
/** Public key of the created nonce account */
noncePubkey: PublicKey; noncePubkey: PublicKey;
/** Public key to set as authority of the created nonce account */
authorizedPubkey: PublicKey; authorizedPubkey: PublicKey;
/** Amount of lamports to transfer to the created nonce account */
lamports: number; lamports: number;
/** Base public key to use to derive the address of the nonce account */
basePubkey: PublicKey; basePubkey: PublicKey;
/** Seed to use to derive the address of the nonce account */
seed: string; seed: string;
}; };
/** /**
* Initialize nonce account system instruction params * Initialize nonce account system instruction params
* @typedef {Object} InitializeNonceParams
* @property {PublicKey} noncePubkey
* @property {PublicKey} authorizedPubkey
*/ */
export type InitializeNonceParams = { export type InitializeNonceParams = {
/** Nonce account which will be initialized */
noncePubkey: PublicKey; noncePubkey: PublicKey;
/** Public key to set as authority of the initialized nonce account */
authorizedPubkey: PublicKey; authorizedPubkey: PublicKey;
}; };
/** /**
* Advance nonce account system instruction params * Advance nonce account system instruction params
* @typedef {Object} AdvanceNonceParams
* @property {PublicKey} noncePubkey
* @property {PublicKey} authorizedPubkey
*/ */
export type AdvanceNonceParams = { export type AdvanceNonceParams = {
/** Nonce account */
noncePubkey: PublicKey; noncePubkey: PublicKey;
/** Public key of the nonce authority */
authorizedPubkey: PublicKey; authorizedPubkey: PublicKey;
}; };
/** /**
* Withdraw nonce account system transaction params * Withdraw nonce account system transaction params
* @typedef {Object} WithdrawNonceParams
* @property {PublicKey} noncePubkey
* @property {PublicKey} authorizedPubkey
* @property {PublicKey} toPubkey
* @property {number} lamports
*/ */
export type WithdrawNonceParams = { export type WithdrawNonceParams = {
/** Nonce account */
noncePubkey: PublicKey; noncePubkey: PublicKey;
/** Public key of the nonce authority */
authorizedPubkey: PublicKey; authorizedPubkey: PublicKey;
/** Public key of the account which will receive the withdrawn nonce account balance */
toPubkey: PublicKey; toPubkey: PublicKey;
/** Amount of lamports to withdraw from the nonce account */
lamports: number; lamports: number;
}; };
/** /**
* Authorize nonce account system transaction params * Authorize nonce account system transaction params
* @typedef {Object} AuthorizeNonceParams
* @property {PublicKey} noncePubkey
* @property {PublicKey} authorizedPubkey
* @property {PublicKey} newAuthorizedPubkey
*/ */
export type AuthorizeNonceParams = { export type AuthorizeNonceParams = {
/** Nonce account */
noncePubkey: PublicKey; noncePubkey: PublicKey;
/** Public key of the current nonce authority */
authorizedPubkey: PublicKey; authorizedPubkey: PublicKey;
/** Public key to set as the new nonce authority */
newAuthorizedPubkey: PublicKey; newAuthorizedPubkey: PublicKey;
}; };
/** /**
* Allocate account system transaction params * Allocate account system transaction params
* @typedef {Object} AllocateParams
* @property {PublicKey} accountPubkey
* @property {number} space
*/ */
export type AllocateParams = { export type AllocateParams = {
/** Account to allocate */
accountPubkey: PublicKey; accountPubkey: PublicKey;
/** Amount of space in bytes to allocate */
space: number; space: number;
}; };
/** /**
* Allocate account with seed system transaction params * Allocate account with seed system transaction params
* @typedef {Object} AllocateWithSeedParams
* @property {PublicKey} accountPubkey
* @property {PublicKey} basePubkey
* @property {string} seed
* @property {number} space
* @property {PublicKey} programId
*/ */
export type AllocateWithSeedParams = { export type AllocateWithSeedParams = {
/** Account to allocate */
accountPubkey: PublicKey; accountPubkey: PublicKey;
/** Base public key to use to derive the address of the allocated account */
basePubkey: PublicKey; basePubkey: PublicKey;
/** Seed to use to derive the address of the allocated account */
seed: string; seed: string;
/** Amount of space in bytes to allocate */
space: number; space: number;
/** Public key of the program to assign as the owner of the allocated account */
programId: PublicKey; programId: PublicKey;
}; };
/** /**
* Assign account with seed system transaction params * Assign account with seed system transaction params
* @typedef {Object} AssignWithSeedParams
* @property {PublicKey} accountPubkey
* @property {PublicKey} basePubkey
* @property {string} seed
* @property {PublicKey} programId
*/ */
export type AssignWithSeedParams = { export type AssignWithSeedParams = {
/** Public key of the account which will be assigned a new owner */
accountPubkey: PublicKey; accountPubkey: PublicKey;
/** Base public key to use to derive the address of the assigned account */
basePubkey: PublicKey; basePubkey: PublicKey;
/** Seed to use to derive the address of the assigned account */
seed: string; seed: string;
/** Public key of the program to assign as the owner */
programId: PublicKey; programId: PublicKey;
}; };
/** /**
* Transfer with seed system transaction params * Transfer with seed system transaction params
* @typedef {Object} TransferWithSeedParams
* @property {PublicKey} fromPubkey
* @property {PublicKey} basePubkey
* @property {PublicKey} toPubkey
* @property {number} lamports
* @property {string} seed
* @property {PublicKey} programId
*/ */
export type TransferWithSeedParams = { export type TransferWithSeedParams = {
/** Account that will transfer lamports */
fromPubkey: PublicKey; fromPubkey: PublicKey;
/** Base public key to use to derive the funding account address */
basePubkey: PublicKey; basePubkey: PublicKey;
/** Account that will receive transferred lamports */
toPubkey: PublicKey; toPubkey: PublicKey;
/** Amount of lamports to transfer */
lamports: number; lamports: number;
/** Seed to use to derive the funding account address */
seed: string; seed: string;
/** Program id to use to derive the funding account address */
programId: PublicKey; programId: PublicKey;
}; };

View File

@ -12,7 +12,7 @@ import type {Blockhash} from './blockhash';
import {toBuffer} from './util/to-buffer'; import {toBuffer} from './util/to-buffer';
/** /**
* @typedef {string} TransactionSignature * Transaction signature as base-58 encoded string
*/ */
export type TransactionSignature = string; export type TransactionSignature = string;
@ -36,25 +36,18 @@ const SIGNATURE_LENGTH = 64;
/** /**
* Account metadata used to define instructions * Account metadata used to define instructions
*
* @typedef {Object} AccountMeta
* @property {PublicKey} pubkey An account's public key
* @property {boolean} isSigner True if an instruction requires a transaction signature matching `pubkey`
* @property {boolean} isWritable True if the `pubkey` can be loaded as a read-write account.
*/ */
export type AccountMeta = { export type AccountMeta = {
/** An account's public key */
pubkey: PublicKey; pubkey: PublicKey;
/** True if an instruction requires a transaction signature matching `pubkey` */
isSigner: boolean; isSigner: boolean;
/** True if the `pubkey` can be loaded as a read-write account. */
isWritable: boolean; isWritable: boolean;
}; };
/** /**
* List of TransactionInstruction object fields that may be initialized at construction * List of TransactionInstruction object fields that may be initialized at construction
*
* @typedef {Object} TransactionInstructionCtorFields
* @property {Array<PublicKey>} keys
* @property {PublicKey} programId
* @property {?Buffer} data
*/ */
export type TransactionInstructionCtorFields = { export type TransactionInstructionCtorFields = {
keys: Array<AccountMeta>; keys: Array<AccountMeta>;
@ -64,13 +57,11 @@ export type TransactionInstructionCtorFields = {
/** /**
* Configuration object for Transaction.serialize() * Configuration object for Transaction.serialize()
*
* @typedef {Object} SerializeConfig
* @property {boolean|undefined} requireAllSignatures Require all transaction signatures be present (default: true)
* @property {boolean|undefined} verifySignatures Verify provided signatures (default: true)
*/ */
export type SerializeConfig = { export type SerializeConfig = {
/** Require all transaction signatures be present (default: true) */
requireAllSignatures?: boolean; requireAllSignatures?: boolean;
/** Verify provided signatures (default: true) */
verifySignatures?: boolean; verifySignatures?: boolean;
}; };
@ -114,28 +105,25 @@ export type SignaturePubkeyPair = {
/** /**
* List of Transaction object fields that may be initialized at construction * List of Transaction object fields that may be initialized at construction
* *
* @typedef {Object} TransactionCtorFields
* @property {?Blockhash} recentBlockhash A recent blockhash
* @property {?PublicKey} feePayer The transaction fee payer
* @property {?Array<SignaturePubkeyPair>} signatures One or more signatures
*
*/ */
type TransactionCtorFields = { type TransactionCtorFields = {
/** A recent blockhash */
recentBlockhash?: Blockhash | null; recentBlockhash?: Blockhash | null;
/** Optional nonce information used for offline nonce'd transactions */
nonceInfo?: NonceInformation | null; nonceInfo?: NonceInformation | null;
/** The transaction fee payer */
feePayer?: PublicKey | null; feePayer?: PublicKey | null;
/** One or more signatures */
signatures?: Array<SignaturePubkeyPair>; signatures?: Array<SignaturePubkeyPair>;
}; };
/** /**
* NonceInformation to be used to build a Transaction. * Nonce information to be used to build an offline Transaction.
*
* @typedef {Object} NonceInformation
* @property {Blockhash} nonce The current Nonce blockhash
* @property {TransactionInstruction} nonceInstruction AdvanceNonceAccount Instruction
*/ */
type NonceInformation = { type NonceInformation = {
/** The current blockhash stored in the nonce */
nonce: Blockhash; nonce: Blockhash;
/** AdvanceNonceAccount Instruction */
nonceInstruction: TransactionInstruction; nonceInstruction: TransactionInstruction;
}; };

View File

@ -24,17 +24,15 @@ type ConfigKey = {
/** /**
* Info used to identity validators. * Info used to identity validators.
*
* @typedef {Object} Info
* @property {string} name validator name
* @property {?string} website optional, validator website
* @property {?string} details optional, extra information the validator chose to share
* @property {?string} keybaseUsername optional, used to identify validators on keybase.io
*/ */
export type Info = { export type Info = {
/** validator name */
name: string; name: string;
/** optional, validator website */
website?: string; website?: string;
/** optional, extra information the validator chose to share */
details?: string; details?: string;
/** optional, used to identify validators on keybase.io */
keybaseUsername?: string; keybaseUsername?: string;
}; };