mirror of
https://github.com/stjet/banani.git
synced 2025-12-29 09:39:23 +00:00
added rpc calls get_stats and get_confirmation_history (#14)
* add get_stats method and StatsType definitions * add get_confirmation_history method and ConfirmationHistoryRPC definitions * added documentation comment for get_confirmation_history method
This commit is contained in:
15
rpc.ts
15
rpc.ts
@@ -1,4 +1,4 @@
|
||||
import type { Address, BlockHash, BlockCountRPC, BlockInfoRPC, BlocksRPC, BlocksInfoRPC, RepresentativesRPC, RepresentativesOnlineRPC, RepresentativesOnlineWeightRPC, AccountHistoryRPC, AccountHistoryRawRPC, AccountInfoRPC, AccountBalanceRPC, AccountsBalancesRPC, AccountRepresentativeRPC, AccountsRepresentativesRPC, AccountWeightRPC, AccountReceivableRPC, AccountReceivableThresholdRPC, AccountReceivableSourceRPC, DelegatorsRPC, DelegatorsCountRPC, TelemetryRPC, TelemetryRawRPC, TelemetryAddressRPC, VersionRPC } from "./rpc_types";
|
||||
import type { Address, BlockHash, BlockCountRPC, BlockInfoRPC, BlocksRPC, BlocksInfoRPC, RepresentativesRPC, RepresentativesOnlineRPC, RepresentativesOnlineWeightRPC, AccountHistoryRPC, AccountHistoryRawRPC, AccountInfoRPC, AccountBalanceRPC, AccountsBalancesRPC, AccountRepresentativeRPC, AccountsRepresentativesRPC, AccountWeightRPC, AccountReceivableRPC, AccountReceivableThresholdRPC, AccountReceivableSourceRPC, DelegatorsRPC, DelegatorsCountRPC, TelemetryRPC, TelemetryRawRPC, TelemetryAddressRPC, VersionRPC, StatsType, StatsRPC, ConfirmationHistoryRPC } from "./rpc_types";
|
||||
|
||||
/** Implement this interface if the built-in RPC class does not fit your needs. The easiest way to do this is by just extending the built-in RPC class */
|
||||
export interface RPCInterface {
|
||||
@@ -197,6 +197,19 @@ export class RPC implements RPCInterface {
|
||||
action: "version",
|
||||
})) as VersionRPC;
|
||||
}
|
||||
|
||||
/** https://docs.nano.org/commands/rpc-protocol/#stats */
|
||||
async get_stats<T extends StatsType>(type: T): Promise<StatsRPC<T>> {
|
||||
return (await this.call({
|
||||
action: "stats",
|
||||
type,
|
||||
})) as StatsRPC<T>;
|
||||
}
|
||||
|
||||
/** https://docs.nano.org/commands/rpc-protocol/#confirmation_history */
|
||||
async get_confirmation_history(hash?: string): Promise<ConfirmationHistoryRPC> {
|
||||
return (await this.call({ action: "confirmation_history" })) as ConfirmationHistoryRPC;
|
||||
}
|
||||
}
|
||||
|
||||
export class RPCWithBackup extends RPC {
|
||||
|
||||
Reference in New Issue
Block a user