Compare commits

...

2 Commits

Author SHA1 Message Date
Jędrzej Stuczyński bf9ae009ee Exporting intermediate structs, but RewardEstimationResponse fails to calculate import path 2022-04-13 10:55:51 +01:00
Jędrzej Stuczyński 8bf3efcef7 Try to export typescript types for RewardEstimationResponse again 2022-04-13 10:28:10 +01:00
19 changed files with 77 additions and 45 deletions
@@ -21,9 +21,10 @@ time = { version = "0.3.6", features = ["parsing", "formatting"] }
contracts-common = { path = "../contracts-common" }
ts-rs = { version = "6.1.2", optional = true }
[dev-dependencies]
time = { version = "0.3.5", features = ["serde", "macros"] }
ts-rs = "6.1.2"
[features]
default = []
@@ -8,9 +8,9 @@ use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::fmt::Display;
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(
test,
all(feature = "ts-rs", test),
ts(export, export_to = "../../../nym-wallet/src/types/rust/gateway.ts")
)]
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
@@ -14,9 +14,9 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
use std::cmp::Ordering;
use std::fmt::Display;
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(
test,
all(feature = "ts-rs", test),
ts(
export,
export_to = "../../../nym-wallet/src/types/rust/rewardedsetnodestatus.ts"
@@ -109,9 +109,9 @@ impl PendingUndelegate {
}
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(
test,
all(feature = "ts-rs", test),
ts(export, export_to = "../../../nym-wallet/src/types/rust/mixnode.ts")
)]
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
@@ -96,10 +96,25 @@ impl NodeEpochRewards {
}
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(
all(feature = "ts-rs", test),
ts(
export,
export_to = "../../../nym-wallet/src/types/rust/epochrewardparams.ts"
)
)]
pub struct EpochRewardParams {
#[cfg_attr(feature = "ts-rs", ts(type = "string"))]
epoch_reward_pool: Uint128,
#[cfg_attr(feature = "ts-rs", ts(type = "string"))]
rewarded_set_size: Uint128,
#[cfg_attr(feature = "ts-rs", ts(type = "string"))]
active_set_size: Uint128,
#[cfg_attr(feature = "ts-rs", ts(type = "string"))]
circulating_supply: Uint128,
sybil_resistance_percent: u8,
active_set_work_factor: u8,
@@ -157,8 +172,17 @@ impl EpochRewardParams {
}
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(
all(feature = "ts-rs", test),
ts(
export,
export_to = "../../../nym-wallet/src/types/rust/noderewardparams.ts"
)
)]
pub struct NodeRewardParams {
reward_blockstamp: u64,
#[cfg_attr(feature = "ts-rs", ts(type = "string"))]
uptime: Uint128,
in_active_set: bool,
}
@@ -186,6 +210,14 @@ impl NodeRewardParams {
}
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(
all(feature = "ts-rs", test),
ts(
export,
export_to = "../../../nym-wallet/src/types/rust/rewardparams.ts"
)
)]
pub struct RewardParams {
pub epoch: EpochRewardParams,
pub node: NodeRewardParams,
+1
View File
@@ -5387,6 +5387,7 @@ dependencies = [
name = "validator-api-requests"
version = "0.1.0"
dependencies = [
"mixnet-contract-common",
"serde",
]
@@ -1,4 +1,2 @@
export interface CoreNodeStatusResponse {
identity: string;
count: number;
}
export interface CoreNodeStatusResponse { identity: string, count: number, }
@@ -0,0 +1,2 @@
export interface EpochRewardParams { epoch_reward_pool: string, rewarded_set_size: string, active_set_size: string, circulating_supply: string, sybil_resistance_percent: number, active_set_work_factor: number, }
+2 -9
View File
@@ -1,9 +1,2 @@
export interface Gateway {
host: string;
mix_port: number;
clients_port: number;
location: string;
sphinx_key: string;
identity_key: string;
version: string;
}
export interface Gateway { host: string, mix_port: number, clients_port: number, location: string, sphinx_key: string, identity_key: string, version: string, }
@@ -1,4 +1,2 @@
export interface InclusionProbabilityResponse {
in_active: number;
in_reserve: number;
}
export interface InclusionProbabilityResponse { in_active: number, in_reserve: number, }
+2 -10
View File
@@ -1,10 +1,2 @@
export interface 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 interface 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, }
+2 -1
View File
@@ -1 +1,2 @@
export type MixnodeStatus = 'active' | 'standby' | 'inactive' | 'not_found';
export type MixnodeStatus = "active" | "standby" | "inactive" | "not_found";
@@ -1,5 +1,3 @@
import type { MixnodeStatus } from './mixnodestatus';
import type { MixnodeStatus } from "./mixnodestatus";
export interface MixnodeStatusResponse {
status: MixnodeStatus;
}
export interface MixnodeStatusResponse { status: MixnodeStatus, }
@@ -0,0 +1,2 @@
export interface NodeRewardParams { reward_blockstamp: bigint, uptime: string, in_active_set: boolean, }
@@ -1 +1,2 @@
export type RewardedSetNodeStatus = 'Active' | 'Standby';
export type RewardedSetNodeStatus = "Active" | "Standby";
@@ -0,0 +1,2 @@
export interface RewardEstimationResponse { estimated_total_node_reward: bigint, estimated_operator_reward: bigint, estimated_delegators_reward: bigint, as_at: bigint, }
@@ -0,0 +1,4 @@
import type { EpochRewardParams } from "./epochrewardparams";
import type { NodeRewardParams } from "./noderewardparams";
export interface RewardParams { epoch: EpochRewardParams, node: NodeRewardParams, }
@@ -1,4 +1,2 @@
export interface StakeSaturationResponse {
saturation: number;
as_at: bigint;
}
export interface StakeSaturationResponse { saturation: number, as_at: bigint, }
@@ -10,4 +10,5 @@ serde = "1.0"
mixnet-contract-common = { path= ".../../../../common/cosmwasm-smart-contracts/mixnet-contract" }
[dev-dependencies]
ts-rs = "6.1.2"
ts-rs = "6.1.2"
mixnet-contract-common = { path= ".../../../../common/cosmwasm-smart-contracts/mixnet-contract", features = ["ts-rs"] }
@@ -53,6 +53,14 @@ pub struct MixnodeStatusResponse {
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(
export,
export_to = "../../nym-wallet/src/types/rust/rewardestimationresponse.ts"
)
)]
pub struct RewardEstimationResponse {
pub estimated_total_node_reward: u64,
pub estimated_operator_reward: u64,