adding onto the validator-api tests

This commit is contained in:
benedettadavico
2022-08-12 10:12:57 +02:00
parent a94a9aeaf5
commit 2f089e80ff
8 changed files with 10603 additions and 2032 deletions
@@ -0,0 +1,53 @@
import { AxiosResponse } from "axios";
import { MixnodesDetailed, AllGateways, AllMixnodes } from "../../src/interfaces/ContractInterfaces";
import { APIClient } from "./abstracts/APIClient";
export default class ContractCache extends APIClient {
public async getMixnodes(): Promise<AllMixnodes> {
const response = await this.restClient.sendGet({
route: `/mixnodes`,
});
return <AllMixnodes>{
pledge_amount: response.data.pledge_amount,
total_delegation: response.data.total_delegation,
owner: response.data.owner,
layer: response.data.layer,
block_height: response.data.block_height,
mix_node: response.data.mix_node,
proxy: response.data.proxy,
accumulated_rewards: response.data.accumulated_rewards
};
}
public async getMixnodesDetailed(): Promise<MixnodesDetailed> {
const response = await this.restClient.sendGet({
route: `/mixnodes/detailed`,
});
return <MixnodesDetailed>{
mixnode_bond: response.data.mixnode_bond,
stake_saturation: response.data.stake_saturation,
uptime: response.data.uptime,
estimated_operator_apy: response.data.estimated_operator_apy,
estimated_delegators_apy: response.data.estimated_delegators_apy
};
}
public async getGateways(): Promise<AllGateways> {
const response = await this.restClient.sendGet({
route: `/gateways`,
});
return <AllGateways>{
pledge_amount: response.data.pledge_amount,
owner: response.data.owner,
block_height: response.data.block_height,
gateway: response.data.gateway,
proxy: response.data.proxy
};
}
}
+13 -11
View File
@@ -56,6 +56,18 @@ export default class Status extends APIClient {
};
}
public async getMixnodeHistory(identity_key: string): Promise<NodeHistory> {
const response = await this.restClient.sendGet({
route: `/mixnode/${identity_key}/history`,
});
return <NodeHistory>{
identity: response.data.identity,
owner: response.data.owner,
history: response.data.history,
};
}
public async getMixnodeStakeSaturation(
identity_key: string
): Promise<StakeSaturation> {
@@ -127,17 +139,7 @@ export default class Status extends APIClient {
};
}
public async getMixnodeHistory(identity_key: string): Promise<NodeHistory> {
const response = await this.restClient.sendGet({
route: `/mixnode/${identity_key}/history`,
});
return <NodeHistory>{
identity: response.data.identity,
owner: response.data.owner,
history: response.data.history,
};
}
public async getMixnodeAverageUptime(
identity_key: string
@@ -0,0 +1,57 @@
export type AllMixnodes = {
pledge_amount: PledgeAmount;
total_delegation: TotalDelegation;
owner: string;
layer: string;
block_height: number;
mix_node: Mixnode;
proxy: string;
accumulated_rewards: string;
}
export type PledgeAmount = {
denom: string;
amount: string;
}
export type TotalDelegation = {
denom: string;
amount: string;
}
export type Mixnode = {
host: string;
mix_port: number;
verloc_port: number;
http_api_port: number;
sphinx_key: string;
identity_key: string;
version: string;
profit_margin_percent: number;
}
export type MixnodesDetailed = {
mixnode_bond: AllMixnodes;
stake_saturation: number;
uptime: number;
estimated_operator_apy: number;
estimated_delegators_apy: number;
}
export type AllGateways = {
pledge_amount: PledgeAmount;
owner: string;
block_height: number;
gateway: Gateway;
proxy: string;
}
export type Gateway = {
host: string;
mix_port: number;
clients_port: number;
location: string;
sphinx_key: string;
identity_key: string;
version: string;
}
@@ -69,4 +69,4 @@ export type CoreCount = {
export type ActiveStatus = {
status: string;
};
};