Fix up look sharp

- added missing .git files
- fixed paths
- run the linter
This commit is contained in:
tommy
2022-08-12 11:18:17 +02:00
parent 2f089e80ff
commit 472085ca52
13 changed files with 2202 additions and 10584 deletions
+7
View File
@@ -0,0 +1,7 @@
.vscode
node_modules
build
coverage
dist
.cache
jest.config.js
+32
View File
@@ -0,0 +1,32 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"rules": {
"import/extensions": "off",
"no-console": ["warn", { "allow": ["warn", "error"] }],
"import/prefer-default-export": "off",
"prettier/prettier": ["error"]
},
"overrides": [
{
"files": ["**/*.ts", "**/*.tsx"],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"]
}
}
]
}
+6
View File
@@ -0,0 +1,6 @@
node_modules
dist
coverage/
.DS_Store
.idea/
junit.xml
@@ -1,30 +0,0 @@
import ContractCache from "../../../tests/src/endpoints/ContractCache";
import ConfigHandler from "../../src/config/configHandler";
let contract: ContractCache;
let config: ConfigHandler;
describe("Get mixnode data", (): void => {
beforeAll(async (): Promise<void> => {
contract = new ContractCache();
config = ConfigHandler.getInstance();
});
it("Get all mixnodes", async (): Promise<void> => {
const response = await contract.getMixnodes();
response.forEach((x) => {
console.log(x.pledge_amount);
console.log(x.total_delegation);
console.log(x.owner);
console.log(x.layer);
console.log(x.block_height);
console.log(x.mix_node);
console.log(x.proxy);
console.log(x.accumulated_rewards);
});
expect(typeof response.as_at).toBe("number");
expect(typeof response.saturation).toBe("number");
});
})
@@ -0,0 +1,31 @@
import ContractCache from "../../../../src/endpoints/ContractCache";
import ConfigHandler from "../../../../src/config/configHandler";
let contract: ContractCache;
let config: ConfigHandler;
describe("Get mixnode data", (): void => {
beforeAll(async (): Promise<void> => {
contract = new ContractCache();
config = ConfigHandler.getInstance();
});
it("Get all mixnodes", async (): Promise<void> => {
const response = await contract.getMixnodes();
console.log(response);
// response.forEach((x) => {
// console.log(x.pledge_amount);
// console.log(x.total_delegation);
// console.log(x.owner);
// console.log(x.layer);
// console.log(x.block_height);
// console.log(x.mix_node);
// console.log(x.proxy);
// console.log(x.accumulated_rewards);
// });
// expect(typeof response.x).toBe("number");
// expect(typeof response.saturation).toBe("number");
});
});
-23
View File
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="9" failures="0" errors="0" time="3.223">
<testsuite name="Get mixnode data" errors="0" failures="0" skipped="0" timestamp="2022-08-12T08:12:05" time="3.021" tests="9">
<testcase classname="Get mixnode data Get a mixnode stake saturation" name="Get mixnode data Get a mixnode stake saturation" time="0.216">
</testcase>
<testcase classname="Get mixnode data Get a mixnode average uptime" name="Get mixnode data Get a mixnode average uptime" time="0.196">
</testcase>
<testcase classname="Get mixnode data Get a mixnode history" name="Get mixnode data Get a mixnode history" time="0.386">
</testcase>
<testcase classname="Get mixnode data Get a gateway history" name="Get mixnode data Get a gateway history" time="0.211">
</testcase>
<testcase classname="Get mixnode data Get a gateway history" name="Get mixnode data Get a gateway history" time="0.321">
</testcase>
<testcase classname="Get mixnode data Get a gateway history" name="Get mixnode data Get a gateway history" time="0.269">
</testcase>
<testcase classname="Get mixnode data Get a mixnode status" name="Get mixnode data Get a mixnode status" time="0.244">
</testcase>
<testcase classname="Get mixnode data Get a mixnode reward estimation" name="Get mixnode data Get a mixnode reward estimation" time="0.185">
</testcase>
<testcase classname="Get mixnode data Get a mixnode inclusion probability" name="Get mixnode data Get a mixnode inclusion probability" time="0.179">
</testcase>
</testsuite>
</testsuites>
File diff suppressed because it is too large Load Diff
@@ -1,53 +1,57 @@
import { AxiosResponse } from "axios";
import { MixnodesDetailed, AllGateways, AllMixnodes } from "../../src/interfaces/ContractInterfaces";
import {
MixnodesDetailed,
AllGateways,
AllMixnodes,
} from "../types/ContractCacheTypes";
import { APIClient } from "./abstracts/APIClient";
export default class ContractCache extends APIClient {
constructor() {
super("/");
}
public async getMixnodes(): Promise<AllMixnodes> {
const response = await this.restClient.sendGet({
route: `/mixnodes`,
});
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
};
}
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`,
});
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
};
}
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,
};
}
}
+1 -4
View File
@@ -1,4 +1,3 @@
import { AxiosResponse } from "axios";
import {
ActiveStatus,
AvgUptime,
@@ -8,7 +7,7 @@ import {
NodeHistory,
Report,
StakeSaturation,
} from "../../src/interfaces/StatusInterfaces";
} from "../types/StatusTypes";
import { APIClient } from "./abstracts/APIClient";
export default class Status extends APIClient {
@@ -139,8 +138,6 @@ export default class Status extends APIClient {
};
}
public async getMixnodeAverageUptime(
identity_key: string
): Promise<AvgUptime> {
@@ -1,57 +0,0 @@
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;
}
@@ -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;
};
};
+2020 -2038
View File
File diff suppressed because it is too large Load Diff