diff --git a/web3.js/module.d.ts b/web3.js/module.d.ts index 93afab340d..6fa45bbb73 100644 --- a/web3.js/module.d.ts +++ b/web3.js/module.d.ts @@ -83,30 +83,27 @@ declare module '@solana/web3.js' { rpc?: string; }; + export type ConfirmedTransactionMeta = { + fee: number; + preBalances: Array; + postBalances: Array; + err: TransactionError | null; + }; + export type ConfirmedBlock = { blockhash: Blockhash; previousBlockhash: Blockhash; parentSlot: number; transactions: Array<{ transaction: Transaction; - meta: { - fee: number; - preBalances: Array; - postBalances: Array; - err: TransactionError | null; - } | null; + meta: ConfirmedTransactionMeta | null; }>; }; export type ConfirmedTransaction = { slot: number; transaction: Transaction; - meta: { - fee: number; - preBalances: Array; - postBalances: Array; - err: TransactionError | null; - } | null; + meta: ConfirmedTransactionMeta | null; }; export type KeyedAccountInfo = { diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 016da03e26..a7bccc7477 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -96,30 +96,27 @@ declare module '@solana/web3.js' { rpc: string | null, }; + declare export type ConfirmedTransactionMeta = { + fee: number, + preBalances: Array, + postBalances: Array, + err: TransactionError | null, + }; + declare export type ConfirmedBlock = { blockhash: Blockhash, previousBlockhash: Blockhash, parentSlot: number, transactions: Array<{ transaction: Transaction, - meta: { - fee: number, - preBalances: Array, - postBalances: Array, - err: TransactionError | null, - } | null, + meta: ConfirmedTransactionMeta | null, }>, }; declare export type ConfirmedTransaction = { slot: number, transaction: Transaction, - meta: { - fee: number, - preBalances: Array, - postBalances: Array, - err: TransactionError | null, - } | null, + meta: ConfirmedTransactionMeta | null, }; declare export type KeyedAccountInfo = { diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index a4ad386c65..3c5466b01a 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -233,23 +233,34 @@ const Version = struct({ 'solana-core': 'string', }); +/** + * Metadata for a confirmed transaction on the ledger + * + * @typedef {Object} ConfirmedTransactionMeta + * @property {number} fee The fee charged for processing the transaction + * @property {Array} preBalances The balances of the transaction accounts before processing + * @property {Array} postBalances The balances of the transaction accounts after processing + * @property {object|null} err The error result of transaction processing + */ +type ConfirmedTransactionMeta = { + fee: number, + preBalances: Array, + postBalances: Array, + 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 {object} meta Slot index of this block's parent + * @property {ConfirmedTransactionMeta|null} meta Metadata produced from the transaction */ type ConfirmedTransaction = { slot: number, transaction: Transaction, - meta: { - fee: number, - err: TransactionError | null, - preBalances: Array, - postBalances: Array, - } | null, + meta: ConfirmedTransactionMeta | null, }; /** @@ -268,12 +279,7 @@ type ConfirmedBlock = { parentSlot: number, transactions: Array<{ transaction: Transaction, - meta: { - fee: number, - preBalances: Array, - postBalances: Array, - err: TransactionError | null, - } | null, + meta: ConfirmedTransactionMeta | null, }>, rewards: Array<{ pubkey: string,