diff --git a/web3.js/module.d.ts b/web3.js/module.d.ts index c9ad93a6d..35ba490b2 100644 --- a/web3.js/module.d.ts +++ b/web3.js/module.d.ts @@ -230,7 +230,7 @@ declare module '@solana/web3.js' { getVersion(): Promise; getInflation(commitment?: Commitment): Promise; getEpochSchedule(): Promise; - getEpochInfo(): Promise; + getEpochInfo(commitment?: Commitment): Promise; getRecentBlockhashAndContext( commitment?: Commitment, ): Promise>; diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index fe28f5a6c..46940d8bf 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -243,7 +243,7 @@ declare module '@solana/web3.js' { getVersion(): Promise; getInflation(commitment: ?Commitment): Promise; getEpochSchedule(): Promise; - getEpochInfo(): Promise; + getEpochInfo(commitment: ?Commitment): Promise; getRecentBlockhashAndContext( commitment: ?Commitment, ): Promise>; diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index baeb8491f..6a14802bd 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -163,7 +163,7 @@ type VoteAccountStatus = { }; /** - * Network Inflation parameters + * Network Inflation * (see https://docs.solana.com/implemented-proposals/ed_overview) * * @typedef {Object} Inflation @@ -174,6 +174,15 @@ type VoteAccountStatus = { * @property {number} taper * @property {number} terminal */ +type Inflation = { + foundation: number, + foundationTerm: number, + initial: number, + storage: number, + taper: number, + terminal: number, +}; + const GetInflationResult = struct({ foundation: 'number', foundationTerm: 'number', @@ -184,8 +193,7 @@ const GetInflationResult = struct({ }); /** - * EpochInfo parameters - * (see https://docs.solana.com/terminology#epoch) + * Information about the current epoch * * @typedef {Object} EpochInfo * @property {number} epoch @@ -193,6 +201,13 @@ const GetInflationResult = struct({ * @property {number} slotsInEpoch * @property {number} absoluteSlot */ +type EpochInfo = { + epoch: number, + slotIndex: number, + slotsInEpoch: number, + absoluteSlot: number, +}; + const GetEpochInfoResult = struct({ epoch: 'number', slotIndex: 'number', @@ -201,7 +216,7 @@ const GetEpochInfoResult = struct({ }); /** - * EpochSchedule parameters + * Epoch schedule * (see https://docs.solana.com/terminology#epoch) * * @typedef {Object} EpochSchedule @@ -211,6 +226,14 @@ const GetEpochInfoResult = struct({ * @property {number} firstNormalEpoch The first epoch with `slotsPerEpoch` slots * @property {number} firstNormalSlot The first slot of `firstNormalEpoch` */ +type EpochSchedule = { + slotsPerEpoch: number, + leaderScheduleSlotOffset: number, + warmup: boolean, + firstNormalEpoch: number, + firstNormalSlot: number, +}; + const GetEpochScheduleResult = struct({ slotsPerEpoch: 'number', leaderScheduleSlotOffset: 'number', @@ -1245,7 +1268,7 @@ export class Connection { /** * Fetch the cluster Inflation parameters */ - async getInflation(commitment: ?Commitment): Promise { + async getInflation(commitment: ?Commitment): Promise { const args = this._argsWithCommitment([], commitment); const unsafeRes = await this._rpcRequest('getInflation', args); const res = GetInflationRpcResult(unsafeRes); @@ -1259,7 +1282,7 @@ export class Connection { /** * Fetch the Epoch Info parameters */ - async getEpochInfo(commitment: ?Commitment): Promise { + async getEpochInfo(commitment: ?Commitment): Promise { const args = this._argsWithCommitment([], commitment); const unsafeRes = await this._rpcRequest('getEpochInfo', args); const res = GetEpochInfoRpcResult(unsafeRes); @@ -1273,7 +1296,7 @@ export class Connection { /** * Fetch the Epoch Schedule parameters */ - async getEpochSchedule(): Promise { + async getEpochSchedule(): Promise { const unsafeRes = await this._rpcRequest('getEpochSchedule', []); const res = GetEpochScheduleRpcResult(unsafeRes); if (res.error) {