diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index f8de37cb25..ad8b31374b 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -112,8 +112,6 @@ export type ConfirmOptions = { /** * Options for getConfirmedSignaturesForAddress2 - * - * @typedef {Object} ConfirmedSignaturesForAddress2Options */ export type ConfirmedSignaturesForAddress2Options = { /** @@ -208,8 +206,6 @@ function notificationResultAndContext(value: Struct) { * '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 * - * - * @typedef {'processed' | 'confirmed' | 'finalized'} Commitment */ export type Commitment = | 'processed' @@ -227,95 +223,76 @@ export type Commitment = * '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 * - * - * @typedef {'circulating' | 'nonCirculating'} LargestAccountsFilter */ export type LargestAccountsFilter = 'circulating' | 'nonCirculating'; /** * 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 = { + /** The level of commitment desired */ commitment?: Commitment; + /** Filter largest accounts by whether they are part of the circulating supply */ filter?: LargestAccountsFilter; }; /** * Configuration object for changing query behavior - * - * @typedef {Object} SignatureStatusConfig - * @property {boolean} searchTransactionHistory enable searching status history, not needed for recent transactions */ export type SignatureStatusConfig = { + /** enable searching status history, not needed for recent transactions */ searchTransactionHistory: boolean; }; /** * 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 = { + /** Identity public key of the node */ pubkey: string; + /** Gossip network address for the node */ gossip: string | null; + /** TPU network address for the node (null if not available) */ tpu: string | null; + /** JSON RPC network address for the node (null if not available) */ rpc: string | null; + /** Software version of the node (null if not available) */ version: string | null; }; /** * 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>} 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 = { + /** Public key of the vote account */ votePubkey: string; + /** Identity public key of the node voting with this account */ nodePubkey: string; + /** The stake, in lamports, delegated to this vote account and activated */ activatedStake: number; + /** Whether the vote account is staked for this epoch */ epochVoteAccount: boolean; + /** Recent epoch voting credit history for this voter */ epochCredits: Array<[number, number, number]>; + /** A percentage (0-100) of rewards payout owed to the voter */ commission: number; + /** Most recent slot voted on by this vote account */ lastVote: number; }; /** * A collection of cluster vote accounts - * - * @typedef {Object} VoteAccountStatus - * @property {Array} current Active vote accounts - * @property {Array} delinquent Inactive vote accounts */ export type VoteAccountStatus = { + /** Active vote accounts */ current: Array; + /** Inactive vote accounts */ delinquent: Array; }; /** * Network Inflation * (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 = { foundation: number; @@ -335,14 +312,6 @@ const GetInflationGovernorResult = pick({ /** * 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 = { epoch: number; @@ -365,19 +334,17 @@ const GetEpochInfoResult = pick({ /** * Epoch schedule * (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 = { + /** The maximum number of slots in each epoch */ slotsPerEpoch: number; + /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */ leaderScheduleSlotOffset: number; + /** Indicates whether epochs start short and grow */ warmup: boolean; + /** The first epoch with `slotsPerEpoch` slots */ firstNormalEpoch: number; + /** The first slot of `firstNormalEpoch` */ firstNormalSlot: number; }; @@ -392,8 +359,6 @@ const GetEpochScheduleResult = pick({ /** * Leader schedule * (see https://docs.solana.com/terminology#leader-schedule) - * - * @typedef {Object} LeaderSchedule */ export type LeaderSchedule = { [address: string]: number[]; @@ -418,17 +383,15 @@ const SignatureStatusResult = pick({ */ const SignatureReceivedResult = literal('receivedSignature'); +/** + * Version info for a node + */ export type Version = { + /** Version of solana-core */ 'solana-core': string; 'feature-set'?: number; }; -/** - * Version info for a node - * - * @typedef {Object} Version - * @property {string} solana-core Version of solana-core - */ const VersionResult = pick({ 'solana-core': string(), 'feature-set': optional(number()), @@ -459,25 +422,23 @@ export type TokenBalance = { /** * Metadata for a parsed confirmed transaction on the ledger - * - * @typedef {Object} ParsedConfirmedTransactionMeta - * @property {number} fee The fee charged for processing the transaction - * @property {Array} innerInstructions An array of cross program invoked parsed instructions - * @property {Array} preBalances The balances of the transaction accounts before processing - * @property {Array} postBalances The balances of the transaction accounts after processing - * @property {Array} logMessages An array of program log messages emitted during a transaction - * @property {Array} preTokenBalances The token balances of the transaction accounts before processing - * @property {Array} postTokenBalances The token balances of the transaction accounts after processing - * @property {object|null} err The error result of transaction processing */ export type ParsedConfirmedTransactionMeta = { + /** The fee charged for processing the transaction */ fee: number; + /** An array of cross program invoked parsed instructions */ innerInstructions?: ParsedInnerInstruction[] | null; + /** The balances of the transaction accounts before processing */ preBalances: Array; + /** The balances of the transaction accounts after processing */ postBalances: Array; + /** An array of program log messages emitted during a transaction */ logMessages?: Array | null; + /** The token balances of the transaction accounts before processing */ preTokenBalances?: Array | null; + /** The token balances of the transaction accounts after processing */ postTokenBalances?: Array | null; + /** The error result of transaction processing */ err: TransactionError | null; }; @@ -488,41 +449,37 @@ export type CompiledInnerInstruction = { /** * Metadata for a confirmed transaction on the ledger - * - * @typedef {Object} ConfirmedTransactionMeta - * @property {number} fee The fee charged for processing the transaction - * @property {Array} innerInstructions An array of cross program invoked instructions - * @property {Array} preBalances The balances of the transaction accounts before processing - * @property {Array} postBalances The balances of the transaction accounts after processing - * @property {Array} logMessages An array of program log messages emitted during a transaction - * @property {Array} preTokenBalances The token balances of the transaction accounts before processing - * @property {Array} postTokenBalances The token balances of the transaction accounts after processing - * @property {object|null} err The error result of transaction processing */ export type ConfirmedTransactionMeta = { + /** The fee charged for processing the transaction */ fee: number; + /** An array of cross program invoked instructions */ innerInstructions?: CompiledInnerInstruction[] | null; + /** The balances of the transaction accounts before processing */ preBalances: Array; + /** The balances of the transaction accounts after processing */ postBalances: Array; + /** An array of program log messages emitted during a transaction */ logMessages?: Array | null; + /** The token balances of the transaction accounts before processing */ preTokenBalances?: Array | null; + /** The token balances of the transaction accounts after processing */ postTokenBalances?: Array | null; + /** The error result of transaction processing */ err: TransactionError | null; }; /** * 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 = { + /** The slot during which the transaction was processed */ slot: number; + /** The details of the transaction */ transaction: Transaction; + /** Metadata produced from the transaction */ meta: ConfirmedTransactionMeta | null; + /** The unix timestamp of when the transaction was processed */ blockTime?: number | null; }; @@ -540,115 +497,101 @@ export type PartiallyDecodedInstruction = { /** * 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 = { + /** Public key of the account */ pubkey: PublicKey; + /** Indicates if the account signed the transaction */ signer: boolean; + /** Indicates if the account is writable for this transaction */ writable: boolean; }; /** * 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 = { + /** Name of the program for this instruction */ program: string; + /** ID of the program for this instruction */ programId: PublicKey; + /** Parsed instruction info */ parsed: any; }; /** * A parsed transaction message - * - * @typedef {Object} ParsedMessage - * @property {Array} accountKeys Accounts used in the instructions - * @property {Array} instructions The atomically executed instructions for the transaction - * @property {string} recentBlockhash Recent blockhash */ export type ParsedMessage = { + /** Accounts used in the instructions */ accountKeys: ParsedMessageAccount[]; + /** The atomically executed instructions for the transaction */ instructions: (ParsedInstruction | PartiallyDecodedInstruction)[]; + /** Recent blockhash */ recentBlockhash: string; }; /** * A parsed transaction - * - * @typedef {Object} ParsedTransaction - * @property {Array} signatures Signatures for the transaction - * @property {ParsedMessage} message Message of the transaction */ export type ParsedTransaction = { + /** Signatures for the transaction */ signatures: Array; + /** Message of the transaction */ message: ParsedMessage; }; /** * 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 = { + /** The slot during which the transaction was processed */ slot: number; + /** The details of the transaction */ transaction: ParsedTransaction; + /** Metadata produced from the transaction */ meta: ParsedConfirmedTransactionMeta | null; + /** The unix timestamp of when the transaction was processed */ blockTime?: number | null; }; /** * 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} transactions Vector of transactions and status metas - * @property {Array} rewards Vector of block rewards - * @property {number|null} blockTime The unix timestamp of when the block was processed */ export type ConfirmedBlock = { + /** Blockhash of this block */ blockhash: Blockhash; + /** Blockhash of this block's parent */ previousBlockhash: Blockhash; + /** Slot index of this block's parent */ parentSlot: number; + /** Vector of transactions and status metas */ transactions: Array<{ transaction: Transaction; meta: ConfirmedTransactionMeta | null; }>; + /** Vector of block rewards */ rewards?: Array<{ pubkey: string; lamports: number; postBalance: number | null; rewardType: string | null; }>; + /** The unix timestamp of when the block was processed */ blockTime: number | null; }; /** * 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 = { + /** Slot number of sample */ slot: number; + /** Number of transactions in a sample window */ numTransactions: number; + /** Number of slots in a sample window */ numSlots: number; + /** Sample window in seconds */ samplePeriodSecs: number; }; @@ -767,17 +710,15 @@ const SlotRpcResult = jsonRpcResult(number()); /** * 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} nonCirculatingAccounts List of non-circulating account addresses */ export type Supply = { + /** Total supply in lamports */ total: number; + /** Circulating supply in lamports */ circulating: number; + /** Non-circulating supply in lamports */ nonCirculating: number; + /** List of non-circulating account addresses */ nonCirculatingAccounts: Array; }; @@ -796,17 +737,15 @@ const GetSupplyRpcResult = jsonRpcResultAndContext( /** * Token amount object which returns a token amount in different formats * 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 = { + /** Raw amount of tokens as string ignoring decimals */ amount: string; + /** Number of decimals configured for token's mint */ decimals: number; + /** Token amount as float, accounts for decimals */ uiAmount: number | null; + /** Token amount as string, accounts for decimals */ uiAmountString?: string; }; @@ -822,19 +761,17 @@ const TokenAmountResult = pick({ /** * 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 = { + /** Address of the token account */ address: PublicKey; + /** Raw amount of tokens as string ignoring decimals */ amount: string; + /** Number of decimals configured for token's mint */ decimals: number; + /** Token amount as float, accounts for decimals */ uiAmount: number | null; + /** Token amount as string, accounts for decimals */ uiAmountString?: string; }; @@ -897,10 +834,6 @@ const GetParsedTokenAccountsByOwner = jsonRpcResultAndContext( /** * Pair of an account address and its balance - * - * @typedef {Object} AccountBalancePair - * @property {PublicKey} address - * @property {number} lamports */ export type AccountBalancePair = { address: PublicKey; @@ -1375,68 +1308,56 @@ const SendTransactionRpcResult = jsonRpcResult(string()); /** * 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 = { + /** Currently processing slot */ slot: number; + /** Parent of the current slot */ parent: number; + /** The root block of the current slot's fork */ root: number; }; /** * 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 = { + /** Name of the program that owns this account */ program: string; + /** Parsed account data */ parsed: any; + /** Space used by account data */ space: number; }; /** * Stake Activation data - * - * @typedef {Object} StakeActivationData - * @property {string} state: = { + /** `true` if this account's data contains a loaded program */ executable: boolean; + /** Identifier of the program that owns the account */ owner: PublicKey; + /** Number of lamports assigned to the account */ lamports: number; + /** Optional data assigned to the account */ data: T; }; /** * Account information identified by pubkey - * - * @typedef {Object} KeyedAccountInfo - * @property {PublicKey} accountId - * @property {AccountInfo} accountInfo */ export type KeyedAccountInfo = { accountId: PublicKey; @@ -1570,8 +1491,6 @@ const LogsResult = pick({ /** * Logs result. - * - * @typedef {Object} Logs. */ export type Logs = { err: TransactionError | null; @@ -1609,8 +1528,6 @@ type LogsSubscriptionInfo = { /** * Signature result - * - * @typedef {Object} SignatureResult */ export type SignatureResult = { err: TransactionError | null; @@ -1618,8 +1535,6 @@ export type SignatureResult = { /** * Transaction error - * - * @typedef {Object} TransactionError */ export type TransactionError = {}; @@ -1652,19 +1567,17 @@ export type SignatureStatus = { /** * 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 = { + /** the transaction signature */ signature: string; + /** when the transaction was processed */ slot: number; + /** error, if any */ err: TransactionError | null; + /** memo associated with the transaction, if any */ memo: string | null; + /** The unix timestamp of when the transaction was processed */ blockTime?: number | null; }; diff --git a/web3.js/src/instruction.ts b/web3.js/src/instruction.ts index d8fec7b763..9c372529d5 100644 --- a/web3.js/src/instruction.ts +++ b/web3.js/src/instruction.ts @@ -4,13 +4,12 @@ import * as BufferLayout from 'buffer-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 */ export type InstructionType = { + /** The Instruction index (from solana upstream program) */ index: number; + /** The BufferLayout to use to build data */ layout: typeof BufferLayout; }; diff --git a/web3.js/src/message.ts b/web3.js/src/message.ts index d3cdebf8ce..9e7633175c 100644 --- a/web3.js/src/message.ts +++ b/web3.js/src/message.ts @@ -11,46 +11,46 @@ import {toBuffer} from './util/to-buffer'; /** * 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 = { + /** + * The number of signatures required for this message to be considered valid. The + * signatures must match the first `numRequiredSignatures` of `accountKeys`. + */ numRequiredSignatures: number; + /** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */ numReadonlySignedAccounts: number; + /** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */ numReadonlyUnsignedAccounts: number; }; /** * An instruction to execute by a program * - * @typedef {Object} CompiledInstruction - * @property {number} programIdIndex Index into the transaction keys array indicating the program account that executes this instruction - * @property {number[]} accounts Ordered indices into the transaction keys array indicating which accounts to pass to the program - * @property {string} data The program input data encoded as base 58 + * @property {number} programIdIndex + * @property {number[]} accounts + * @property {string} data */ export type CompiledInstruction = { + /** Index into the transaction keys array indicating the program account that executes this instruction */ programIdIndex: number; + /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */ accounts: number[]; + /** The program input data encoded as base 58 */ data: string; }; /** * 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 = { + /** The message header, identifying signed and read-only `accountKeys` */ header: MessageHeader; + /** All the account keys used by this transaction */ accountKeys: string[]; + /** The hash of a recent ledger block */ recentBlockhash: Blockhash; + /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */ instructions: CompiledInstruction[]; }; diff --git a/web3.js/src/secp256k1-program.ts b/web3.js/src/secp256k1-program.ts index 242e6cb883..9b129265db 100644 --- a/web3.js/src/secp256k1-program.ts +++ b/web3.js/src/secp256k1-program.ts @@ -17,11 +17,6 @@ const SIGNATURE_OFFSETS_SERIALIZED_SIZE = 11; /** * Params for creating an secp256k1 instruction using a public key - * @typedef {Object} CreateSecp256k1InstructionWithPublicKeyParams - * @property {Buffer | Uint8Array | Array} publicKey - * @property {Buffer | Uint8Array | Array} message - * @property {Buffer | Uint8Array | Array} signature - * @property {number} recoveryId */ export type CreateSecp256k1InstructionWithPublicKeyParams = { publicKey: Buffer | Uint8Array | Array; @@ -32,11 +27,6 @@ export type CreateSecp256k1InstructionWithPublicKeyParams = { /** * Params for creating an secp256k1 instruction using an Ethereum address - * @typedef {Object} CreateSecp256k1InstructionWithEthAddressParams - * @property {Buffer | Uint8Array | Array} ethAddress - * @property {Buffer | Uint8Array | Array} message - * @property {Buffer | Uint8Array | Array} signature - * @property {number} recoveryId */ export type CreateSecp256k1InstructionWithEthAddressParams = { ethAddress: Buffer | Uint8Array | Array | string; @@ -47,9 +37,6 @@ export type CreateSecp256k1InstructionWithEthAddressParams = { /** * Params for creating an secp256k1 instruction using a private key - * @typedef {Object} CreateSecp256k1InstructionWithPrivateKeyParams - * @property {Buffer | Uint8Array | Array} privateKey - * @property {Buffer | Uint8Array | Array} message */ export type CreateSecp256k1InstructionWithPrivateKeyParams = { privateKey: Buffer | Uint8Array | Array; diff --git a/web3.js/src/stake-program.ts b/web3.js/src/stake-program.ts index dc76d044d5..b97776e4fe 100644 --- a/web3.js/src/stake-program.ts +++ b/web3.js/src/stake-program.ts @@ -454,10 +454,10 @@ export const STAKE_INSTRUCTION_LAYOUTS: { }); /** - * @typedef {Object} StakeAuthorizationType - * @property (index} The Stake Authorization index (from solana-stake-program) + * Stake authorization type */ export type StakeAuthorizationType = { + /** The Stake Authorization index (from solana-stake-program) */ index: number; }; diff --git a/web3.js/src/system-program.ts b/web3.js/src/system-program.ts index 2050c6e0b7..391e3205bc 100644 --- a/web3.js/src/system-program.ts +++ b/web3.js/src/system-program.ts @@ -10,209 +10,195 @@ import {toBuffer} from './util/to-buffer'; /** * 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 = { + /** The account that will transfer lamports to the created account */ fromPubkey: PublicKey; + /** Public key of the created account */ newAccountPubkey: PublicKey; + /** Amount of lamports to transfer to the created account */ lamports: number; + /** Amount of space in bytes to allocate to the created account */ space: number; + /** Public key of the program to assign as the owner of the created account */ programId: PublicKey; }; /** * Transfer system transaction params - * @typedef {Object} TransferParams - * @property {PublicKey} fromPubkey - * @property {PublicKey} toPubkey - * @property {number} lamports */ export type TransferParams = { + /** Account that will transfer lamports */ fromPubkey: PublicKey; + /** Account that will receive transferred lamports */ toPubkey: PublicKey; + /** Amount of lamports to transfer */ lamports: number; }; /** * Assign system transaction params - * @typedef {Object} AssignParams - * @property {PublicKey} accountPubkey - * @property {PublicKey} programId */ export type AssignParams = { + /** Public key of the account which will be assigned a new owner */ accountPubkey: PublicKey; + /** Public key of the program to assign as the owner */ programId: PublicKey; }; /** * 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 = { + /** The account that will transfer lamports to the created account */ fromPubkey: PublicKey; + /** Public key of the created account */ newAccountPubkey: PublicKey; + /** Base public key to use to derive the address of the created account */ basePubkey: PublicKey; + /** Seed to use to derive the address of the created account */ seed: string; + /** Amount of lamports to transfer to the created account */ lamports: number; + /** Amount of space in bytes to allocate to the created account */ space: number; + /** Public key of the program to assign as the owner of the created account */ programId: PublicKey; }; /** * Create nonce account system transaction params - * @typedef {Object} CreateNonceAccountParams - * @property {PublicKey} fromPubkey - * @property {PublicKey} noncePubkey - * @property {PublicKey} authorizedPubkey - * @property {number} lamports */ export type CreateNonceAccountParams = { + /** The account that will transfer lamports to the created nonce account */ fromPubkey: PublicKey; + /** Public key of the created nonce account */ noncePubkey: PublicKey; + /** Public key to set as authority of the created nonce account */ authorizedPubkey: PublicKey; + /** Amount of lamports to transfer to the created nonce account */ lamports: number; }; /** * 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 = { + /** The account that will transfer lamports to the created nonce account */ fromPubkey: PublicKey; + /** Public key of the created nonce account */ noncePubkey: PublicKey; + /** Public key to set as authority of the created nonce account */ authorizedPubkey: PublicKey; + /** Amount of lamports to transfer to the created nonce account */ lamports: number; + /** Base public key to use to derive the address of the nonce account */ basePubkey: PublicKey; + /** Seed to use to derive the address of the nonce account */ seed: string; }; /** * Initialize nonce account system instruction params - * @typedef {Object} InitializeNonceParams - * @property {PublicKey} noncePubkey - * @property {PublicKey} authorizedPubkey */ export type InitializeNonceParams = { + /** Nonce account which will be initialized */ noncePubkey: PublicKey; + /** Public key to set as authority of the initialized nonce account */ authorizedPubkey: PublicKey; }; /** * Advance nonce account system instruction params - * @typedef {Object} AdvanceNonceParams - * @property {PublicKey} noncePubkey - * @property {PublicKey} authorizedPubkey */ export type AdvanceNonceParams = { + /** Nonce account */ noncePubkey: PublicKey; + /** Public key of the nonce authority */ authorizedPubkey: PublicKey; }; /** * Withdraw nonce account system transaction params - * @typedef {Object} WithdrawNonceParams - * @property {PublicKey} noncePubkey - * @property {PublicKey} authorizedPubkey - * @property {PublicKey} toPubkey - * @property {number} lamports */ export type WithdrawNonceParams = { + /** Nonce account */ noncePubkey: PublicKey; + /** Public key of the nonce authority */ authorizedPubkey: PublicKey; + /** Public key of the account which will receive the withdrawn nonce account balance */ toPubkey: PublicKey; + /** Amount of lamports to withdraw from the nonce account */ lamports: number; }; /** * Authorize nonce account system transaction params - * @typedef {Object} AuthorizeNonceParams - * @property {PublicKey} noncePubkey - * @property {PublicKey} authorizedPubkey - * @property {PublicKey} newAuthorizedPubkey */ export type AuthorizeNonceParams = { + /** Nonce account */ noncePubkey: PublicKey; + /** Public key of the current nonce authority */ authorizedPubkey: PublicKey; + /** Public key to set as the new nonce authority */ newAuthorizedPubkey: PublicKey; }; /** * Allocate account system transaction params - * @typedef {Object} AllocateParams - * @property {PublicKey} accountPubkey - * @property {number} space */ export type AllocateParams = { + /** Account to allocate */ accountPubkey: PublicKey; + /** Amount of space in bytes to allocate */ space: number; }; /** * 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 = { + /** Account to allocate */ accountPubkey: PublicKey; + /** Base public key to use to derive the address of the allocated account */ basePubkey: PublicKey; + /** Seed to use to derive the address of the allocated account */ seed: string; + /** Amount of space in bytes to allocate */ space: number; + /** Public key of the program to assign as the owner of the allocated account */ programId: PublicKey; }; /** * 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 = { + /** Public key of the account which will be assigned a new owner */ accountPubkey: PublicKey; + /** Base public key to use to derive the address of the assigned account */ basePubkey: PublicKey; + /** Seed to use to derive the address of the assigned account */ seed: string; + /** Public key of the program to assign as the owner */ programId: PublicKey; }; /** * 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 = { + /** Account that will transfer lamports */ fromPubkey: PublicKey; + /** Base public key to use to derive the funding account address */ basePubkey: PublicKey; + /** Account that will receive transferred lamports */ toPubkey: PublicKey; + /** Amount of lamports to transfer */ lamports: number; + /** Seed to use to derive the funding account address */ seed: string; + /** Program id to use to derive the funding account address */ programId: PublicKey; }; diff --git a/web3.js/src/transaction.ts b/web3.js/src/transaction.ts index 3cb91695e4..24e89ee3eb 100644 --- a/web3.js/src/transaction.ts +++ b/web3.js/src/transaction.ts @@ -12,7 +12,7 @@ import type {Blockhash} from './blockhash'; import {toBuffer} from './util/to-buffer'; /** - * @typedef {string} TransactionSignature + * Transaction signature as base-58 encoded string */ export type TransactionSignature = string; @@ -36,25 +36,18 @@ const SIGNATURE_LENGTH = 64; /** * 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 = { + /** 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 - * - * @typedef {Object} TransactionInstructionCtorFields - * @property {Array} keys - * @property {PublicKey} programId - * @property {?Buffer} data */ export type TransactionInstructionCtorFields = { keys: Array; @@ -64,13 +57,11 @@ export type TransactionInstructionCtorFields = { /** * 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 = { + /** Require all transaction signatures be present (default: true) */ requireAllSignatures?: boolean; + /** Verify provided signatures (default: true) */ verifySignatures?: boolean; }; @@ -114,28 +105,25 @@ export type SignaturePubkeyPair = { /** * 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} signatures One or more signatures - * */ type TransactionCtorFields = { + /** A recent blockhash */ recentBlockhash?: Blockhash | null; + /** 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; }; /** - * NonceInformation to be used to build a Transaction. - * - * @typedef {Object} NonceInformation - * @property {Blockhash} nonce The current Nonce blockhash - * @property {TransactionInstruction} nonceInstruction AdvanceNonceAccount Instruction + * Nonce information to be used to build an offline Transaction. */ type NonceInformation = { + /** The current blockhash stored in the nonce */ nonce: Blockhash; + /** AdvanceNonceAccount Instruction */ nonceInstruction: TransactionInstruction; }; diff --git a/web3.js/src/validator-info.ts b/web3.js/src/validator-info.ts index 3e5ebd4977..1bf31723ae 100644 --- a/web3.js/src/validator-info.ts +++ b/web3.js/src/validator-info.ts @@ -24,17 +24,15 @@ type ConfigKey = { /** * 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 = { + /** validator name */ name: string; + /** optional, validator website */ website?: string; + /** optional, extra information the validator chose to share */ details?: string; + /** optional, used to identify validators on keybase.io */ keybaseUsername?: string; };