fix: fix getEpochInfo type definition
This commit is contained in:
committed by
Michael Vines
parent
6558e05fd0
commit
7f9a2e477f
2
web3.js/module.d.ts
vendored
2
web3.js/module.d.ts
vendored
@ -230,7 +230,7 @@ declare module '@solana/web3.js' {
|
|||||||
getVersion(): Promise<Version>;
|
getVersion(): Promise<Version>;
|
||||||
getInflation(commitment?: Commitment): Promise<Inflation>;
|
getInflation(commitment?: Commitment): Promise<Inflation>;
|
||||||
getEpochSchedule(): Promise<EpochSchedule>;
|
getEpochSchedule(): Promise<EpochSchedule>;
|
||||||
getEpochInfo(): Promise<EpochInfo>;
|
getEpochInfo(commitment?: Commitment): Promise<EpochInfo>;
|
||||||
getRecentBlockhashAndContext(
|
getRecentBlockhashAndContext(
|
||||||
commitment?: Commitment,
|
commitment?: Commitment,
|
||||||
): Promise<RpcResponseAndContext<BlockhashAndFeeCalculator>>;
|
): Promise<RpcResponseAndContext<BlockhashAndFeeCalculator>>;
|
||||||
|
@ -243,7 +243,7 @@ declare module '@solana/web3.js' {
|
|||||||
getVersion(): Promise<Version>;
|
getVersion(): Promise<Version>;
|
||||||
getInflation(commitment: ?Commitment): Promise<Inflation>;
|
getInflation(commitment: ?Commitment): Promise<Inflation>;
|
||||||
getEpochSchedule(): Promise<EpochSchedule>;
|
getEpochSchedule(): Promise<EpochSchedule>;
|
||||||
getEpochInfo(): Promise<EpochInfo>;
|
getEpochInfo(commitment: ?Commitment): Promise<EpochInfo>;
|
||||||
getRecentBlockhashAndContext(
|
getRecentBlockhashAndContext(
|
||||||
commitment: ?Commitment,
|
commitment: ?Commitment,
|
||||||
): Promise<RpcResponseAndContext<BlockhashAndFeeCalculator>>;
|
): Promise<RpcResponseAndContext<BlockhashAndFeeCalculator>>;
|
||||||
|
@ -163,7 +163,7 @@ type VoteAccountStatus = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Network Inflation parameters
|
* Network Inflation
|
||||||
* (see https://docs.solana.com/implemented-proposals/ed_overview)
|
* (see https://docs.solana.com/implemented-proposals/ed_overview)
|
||||||
*
|
*
|
||||||
* @typedef {Object} Inflation
|
* @typedef {Object} Inflation
|
||||||
@ -174,6 +174,15 @@ type VoteAccountStatus = {
|
|||||||
* @property {number} taper
|
* @property {number} taper
|
||||||
* @property {number} terminal
|
* @property {number} terminal
|
||||||
*/
|
*/
|
||||||
|
type Inflation = {
|
||||||
|
foundation: number,
|
||||||
|
foundationTerm: number,
|
||||||
|
initial: number,
|
||||||
|
storage: number,
|
||||||
|
taper: number,
|
||||||
|
terminal: number,
|
||||||
|
};
|
||||||
|
|
||||||
const GetInflationResult = struct({
|
const GetInflationResult = struct({
|
||||||
foundation: 'number',
|
foundation: 'number',
|
||||||
foundationTerm: 'number',
|
foundationTerm: 'number',
|
||||||
@ -184,8 +193,7 @@ const GetInflationResult = struct({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EpochInfo parameters
|
* Information about the current epoch
|
||||||
* (see https://docs.solana.com/terminology#epoch)
|
|
||||||
*
|
*
|
||||||
* @typedef {Object} EpochInfo
|
* @typedef {Object} EpochInfo
|
||||||
* @property {number} epoch
|
* @property {number} epoch
|
||||||
@ -193,6 +201,13 @@ const GetInflationResult = struct({
|
|||||||
* @property {number} slotsInEpoch
|
* @property {number} slotsInEpoch
|
||||||
* @property {number} absoluteSlot
|
* @property {number} absoluteSlot
|
||||||
*/
|
*/
|
||||||
|
type EpochInfo = {
|
||||||
|
epoch: number,
|
||||||
|
slotIndex: number,
|
||||||
|
slotsInEpoch: number,
|
||||||
|
absoluteSlot: number,
|
||||||
|
};
|
||||||
|
|
||||||
const GetEpochInfoResult = struct({
|
const GetEpochInfoResult = struct({
|
||||||
epoch: 'number',
|
epoch: 'number',
|
||||||
slotIndex: 'number',
|
slotIndex: 'number',
|
||||||
@ -201,7 +216,7 @@ const GetEpochInfoResult = struct({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EpochSchedule parameters
|
* Epoch schedule
|
||||||
* (see https://docs.solana.com/terminology#epoch)
|
* (see https://docs.solana.com/terminology#epoch)
|
||||||
*
|
*
|
||||||
* @typedef {Object} EpochSchedule
|
* @typedef {Object} EpochSchedule
|
||||||
@ -211,6 +226,14 @@ const GetEpochInfoResult = struct({
|
|||||||
* @property {number} firstNormalEpoch The first epoch with `slotsPerEpoch` slots
|
* @property {number} firstNormalEpoch The first epoch with `slotsPerEpoch` slots
|
||||||
* @property {number} firstNormalSlot The first slot of `firstNormalEpoch`
|
* @property {number} firstNormalSlot The first slot of `firstNormalEpoch`
|
||||||
*/
|
*/
|
||||||
|
type EpochSchedule = {
|
||||||
|
slotsPerEpoch: number,
|
||||||
|
leaderScheduleSlotOffset: number,
|
||||||
|
warmup: boolean,
|
||||||
|
firstNormalEpoch: number,
|
||||||
|
firstNormalSlot: number,
|
||||||
|
};
|
||||||
|
|
||||||
const GetEpochScheduleResult = struct({
|
const GetEpochScheduleResult = struct({
|
||||||
slotsPerEpoch: 'number',
|
slotsPerEpoch: 'number',
|
||||||
leaderScheduleSlotOffset: 'number',
|
leaderScheduleSlotOffset: 'number',
|
||||||
@ -1245,7 +1268,7 @@ export class Connection {
|
|||||||
/**
|
/**
|
||||||
* Fetch the cluster Inflation parameters
|
* Fetch the cluster Inflation parameters
|
||||||
*/
|
*/
|
||||||
async getInflation(commitment: ?Commitment): Promise<GetInflationRpcResult> {
|
async getInflation(commitment: ?Commitment): Promise<Inflation> {
|
||||||
const args = this._argsWithCommitment([], commitment);
|
const args = this._argsWithCommitment([], commitment);
|
||||||
const unsafeRes = await this._rpcRequest('getInflation', args);
|
const unsafeRes = await this._rpcRequest('getInflation', args);
|
||||||
const res = GetInflationRpcResult(unsafeRes);
|
const res = GetInflationRpcResult(unsafeRes);
|
||||||
@ -1259,7 +1282,7 @@ export class Connection {
|
|||||||
/**
|
/**
|
||||||
* Fetch the Epoch Info parameters
|
* Fetch the Epoch Info parameters
|
||||||
*/
|
*/
|
||||||
async getEpochInfo(commitment: ?Commitment): Promise<GetEpochInfoRpcResult> {
|
async getEpochInfo(commitment: ?Commitment): Promise<EpochInfo> {
|
||||||
const args = this._argsWithCommitment([], commitment);
|
const args = this._argsWithCommitment([], commitment);
|
||||||
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
||||||
const res = GetEpochInfoRpcResult(unsafeRes);
|
const res = GetEpochInfoRpcResult(unsafeRes);
|
||||||
@ -1273,7 +1296,7 @@ export class Connection {
|
|||||||
/**
|
/**
|
||||||
* Fetch the Epoch Schedule parameters
|
* Fetch the Epoch Schedule parameters
|
||||||
*/
|
*/
|
||||||
async getEpochSchedule(): Promise<GetEpochScheduleRpcResult> {
|
async getEpochSchedule(): Promise<EpochSchedule> {
|
||||||
const unsafeRes = await this._rpcRequest('getEpochSchedule', []);
|
const unsafeRes = await this._rpcRequest('getEpochSchedule', []);
|
||||||
const res = GetEpochScheduleRpcResult(unsafeRes);
|
const res = GetEpochScheduleRpcResult(unsafeRes);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
|
Reference in New Issue
Block a user