updated ts_rs and derived it for more types
This commit is contained in:
Generated
+5
-11
@@ -2,12 +2,6 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "Inflector"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
||||
|
||||
[[package]]
|
||||
name = "accessory"
|
||||
version = "1.3.1"
|
||||
@@ -9680,10 +9674,11 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||
|
||||
[[package]]
|
||||
name = "ts-rs"
|
||||
version = "7.1.1"
|
||||
version = "10.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc2cae1fc5d05d47aa24b64f9a4f7cba24cdc9187a2084dd97ac57bef5eccae6"
|
||||
checksum = "3a2f31991cee3dce1ca4f929a8a04fdd11fd8801aac0f2030b0fa8a0a3fef6b9"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"thiserror",
|
||||
"ts-rs-macros",
|
||||
]
|
||||
@@ -9705,11 +9700,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ts-rs-macros"
|
||||
version = "7.1.1"
|
||||
version = "10.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73f7f9b821696963053a89a7bd8b292dc34420aea8294d7b225274d488f3ec92"
|
||||
checksum = "0ea0b99e8ec44abd6f94a18f28f7934437809dd062820797c52401298116f70e"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.66",
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ tracing = "0.1.37"
|
||||
tracing-opentelemetry = "0.19.0"
|
||||
tracing-subscriber = "0.3.16"
|
||||
tracing-tree = "0.2.2"
|
||||
ts-rs = "7.0.0"
|
||||
ts-rs = "10.0.0"
|
||||
tungstenite = { version = "0.20.1", default-features = false }
|
||||
url = "2.5"
|
||||
utoipa = "4.2"
|
||||
|
||||
@@ -12,6 +12,11 @@ use std::fmt::{Display, Formatter};
|
||||
#[cw_serde]
|
||||
#[derive(PartialOrd, Copy, Hash, Eq)]
|
||||
#[repr(u8)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Role.ts")
|
||||
)]
|
||||
pub enum Role {
|
||||
#[serde(rename = "eg", alias = "entry", alias = "entry_gateway")]
|
||||
EntryGateway = 0,
|
||||
|
||||
@@ -303,14 +303,21 @@ impl RewardedSetParams {
|
||||
}
|
||||
|
||||
/// Parameters used for rewarding particular node.
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/NodeRewardingParameters.ts")
|
||||
)]
|
||||
#[cw_serde]
|
||||
#[derive(Copy)]
|
||||
pub struct NodeRewardingParameters {
|
||||
/// Performance of the particular node in the current epoch.
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub performance: Performance,
|
||||
|
||||
/// Amount of work performed by this node in the current epoch
|
||||
/// also known as 'omega' in the paper
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub work_factor: WorkFactor,
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,9 @@ use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use std::fmt::{Display, Formatter};
|
||||
use strum::{Display, EnumString, VariantNames};
|
||||
|
||||
#[cfg(feature = "generate-ts")]
|
||||
use ts_rs::{Dependency, TS};
|
||||
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
@@ -248,40 +244,20 @@ impl From<DenomDetailsOwned> for CoinMetadata {
|
||||
// tries to semi-replicate cosmos-sdk's DecCoin for being able to handle tokens with decimal amounts
|
||||
// https://github.com/cosmos/cosmos-sdk/blob/v0.45.4/types/dec_coin.go
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DecCoin.ts")
|
||||
)]
|
||||
pub struct DecCoin {
|
||||
#[cfg_attr(feature = "generate-ts", ts(as = "CurrencyDenom"))]
|
||||
pub denom: Denom,
|
||||
// Decimal is already serialized to string and using string in its schema, so lets also go straight to string for ts_rs
|
||||
// todo: is `Decimal` the correct type to use? Do we want to depend on cosmwasm_std here?
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub amount: Decimal,
|
||||
}
|
||||
|
||||
// I had to implement it manually to correctly set dependencies
|
||||
#[cfg(feature = "generate-ts")]
|
||||
impl TS for DecCoin {
|
||||
const EXPORT_TO: Option<&'static str> = Some("ts-packages/types/src/types/rust/DecCoin.ts");
|
||||
|
||||
fn decl() -> String {
|
||||
format!("type {} = {};", Self::name(), Self::inline())
|
||||
}
|
||||
|
||||
fn name() -> String {
|
||||
"DecCoin".into()
|
||||
}
|
||||
|
||||
fn inline() -> String {
|
||||
"{ denom: CurrencyDenom, amount: string }".into()
|
||||
}
|
||||
|
||||
fn dependencies() -> Vec<Dependency> {
|
||||
vec![Dependency::from_ty::<CurrencyDenom>()
|
||||
.expect("TS was incorrectly defined on `CurrencyDenom`")]
|
||||
}
|
||||
|
||||
fn transparent() -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl DecCoin {
|
||||
pub fn new_base<S: Into<String>>(amount: impl Into<Uint128>, denom: S) -> Self {
|
||||
DecCoin {
|
||||
|
||||
@@ -2,13 +2,16 @@ use crate::currency::DecCoin;
|
||||
use nym_validator_client::nyxd::Fee;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "generate-ts")]
|
||||
use ts_rs::{Dependency, TS};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/FeeDetails.ts")
|
||||
)]
|
||||
pub struct FeeDetails {
|
||||
// expected to be used by the wallet in order to display detailed fee information to the user
|
||||
pub amount: Option<DecCoin>,
|
||||
#[cfg_attr(feature = "generate-ts", ts(as = "ts_type_helpers::Fee"))]
|
||||
pub fee: Fee,
|
||||
}
|
||||
|
||||
@@ -18,35 +21,6 @@ impl FeeDetails {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "generate-ts")]
|
||||
impl TS for FeeDetails {
|
||||
const EXPORT_TO: Option<&'static str> = Some("ts-packages/types/src/types/rust/FeeDetails.ts");
|
||||
|
||||
fn decl() -> String {
|
||||
format!("type {} = {};", Self::name(), Self::inline())
|
||||
}
|
||||
|
||||
fn name() -> String {
|
||||
"FeeDetails".into()
|
||||
}
|
||||
|
||||
fn inline() -> String {
|
||||
"{ amount: DecCoin | null, fee: Fee }".into()
|
||||
}
|
||||
|
||||
fn dependencies() -> Vec<Dependency> {
|
||||
vec![
|
||||
Dependency::from_ty::<DecCoin>().expect("TS was incorrectly defined on `DecCoin`"),
|
||||
Dependency::from_ty::<ts_type_helpers::Fee>()
|
||||
.expect("TS was incorrectly defined on `ts_type_helpers::Fee`"),
|
||||
]
|
||||
}
|
||||
|
||||
fn transparent() -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// this should really be sealed and NEVER EVER used as "normal" types,
|
||||
// but due to our typescript requirements, we have to expose it to generate
|
||||
// the types...
|
||||
|
||||
@@ -130,12 +130,23 @@ pub struct NodePerformance {
|
||||
// nym-api shouldn't be calculating apy or stake saturation for you.
|
||||
// it should just return its own metrics (performance) and then you can do with it as you wish
|
||||
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/NodeAnnotation.ts")
|
||||
)]
|
||||
pub struct NodeAnnotation {
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub last_24h_performance: Performance,
|
||||
pub current_role: Option<Role>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/AnnotationResponse.ts")
|
||||
)]
|
||||
pub struct AnnotationResponse {
|
||||
#[schema(value_type = u32)]
|
||||
pub node_id: NodeId,
|
||||
@@ -143,6 +154,11 @@ pub struct AnnotationResponse {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/NodePerformanceResponse.ts")
|
||||
)]
|
||||
pub struct NodePerformanceResponse {
|
||||
#[schema(value_type = u32)]
|
||||
pub node_id: NodeId,
|
||||
@@ -150,11 +166,17 @@ pub struct NodePerformanceResponse {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/NodeDatePerformanceResponse.ts")
|
||||
)]
|
||||
pub struct NodeDatePerformanceResponse {
|
||||
#[schema(value_type = u32)]
|
||||
pub node_id: NodeId,
|
||||
#[schema(value_type = String, example = "1970-01-01")]
|
||||
#[schemars(with = "String")]
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub date: Date,
|
||||
pub performance: Option<f64>,
|
||||
}
|
||||
@@ -490,6 +512,11 @@ pub struct GatewayStatusReportResponse {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, schemars::JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/PerformanceHistoryResponse.ts")
|
||||
)]
|
||||
pub struct PerformanceHistoryResponse {
|
||||
#[schema(value_type = u32)]
|
||||
pub node_id: NodeId,
|
||||
@@ -497,6 +524,11 @@ pub struct PerformanceHistoryResponse {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, schemars::JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/UptimeHistoryResponse.ts")
|
||||
)]
|
||||
pub struct UptimeHistoryResponse {
|
||||
#[schema(value_type = u32)]
|
||||
pub node_id: NodeId,
|
||||
@@ -504,18 +536,30 @@ pub struct UptimeHistoryResponse {
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, schemars::JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/HistoricalUptimeResponse.ts")
|
||||
)]
|
||||
pub struct HistoricalUptimeResponse {
|
||||
#[schema(value_type = String, example = "1970-01-01")]
|
||||
#[schemars(with = "String")]
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub date: Date,
|
||||
|
||||
pub uptime: Uptime,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, schemars::JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/HistoricalPerformanceResponse.ts")
|
||||
)]
|
||||
pub struct HistoricalPerformanceResponse {
|
||||
#[schema(value_type = String, example = "1970-01-01")]
|
||||
#[schemars(with = "String")]
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub date: Date,
|
||||
|
||||
pub performance: f64,
|
||||
@@ -745,6 +789,11 @@ impl NymNodeDescription {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, schemars::JsonSchema, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DescribedNodeType.ts")
|
||||
)]
|
||||
pub enum DescribedNodeType {
|
||||
LegacyMixnode,
|
||||
LegacyGateway,
|
||||
@@ -752,6 +801,11 @@ pub enum DescribedNodeType {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, schemars::JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DeclaredRoles.ts")
|
||||
)]
|
||||
pub struct DeclaredRoles {
|
||||
pub mixnode: bool,
|
||||
pub entry: bool,
|
||||
|
||||
@@ -6,6 +6,11 @@ use serde::{Deserialize, Serialize};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Pagination.ts")
|
||||
)]
|
||||
pub struct Pagination {
|
||||
pub total: usize,
|
||||
pub page: u32,
|
||||
@@ -13,6 +18,11 @@ pub struct Pagination {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, ToSchema)]
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/PaginatedResponse.ts")
|
||||
)]
|
||||
pub struct PaginatedResponse<T> {
|
||||
pub pagination: Pagination,
|
||||
pub data: Vec<T>,
|
||||
|
||||
@@ -10,7 +10,7 @@ hex-literal = "0.3.3"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
strum = { version = "0.23", features = ["derive"] }
|
||||
ts-rs = "7.0.0"
|
||||
ts-rs = "10.0.0"
|
||||
|
||||
cosmwasm-std = "1.4.3"
|
||||
cosmrs = "=0.15.0"
|
||||
|
||||
@@ -67,7 +67,7 @@ nym-store-cipher = { path = "../../common/store-cipher", features = ["json"] }
|
||||
nym-crypto = { path = "../../common/crypto", features = ["rand"] }
|
||||
rand_chacha = "0.3"
|
||||
tempfile = "3.3.0"
|
||||
ts-rs = "7.0.0"
|
||||
ts-rs = "10.0.0"
|
||||
|
||||
[features]
|
||||
default = ["custom-protocol"]
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
use nym_api_requests::models::{
|
||||
GatewayCoreStatusResponse, InclusionProbabilityResponse, MixnodeCoreStatusResponse,
|
||||
MixnodeStatus, MixnodeStatusResponse, RewardEstimationResponse, SelectionChance,
|
||||
StakeSaturationResponse,
|
||||
AnnotationResponse, DeclaredRoles, DescribedNodeType, GatewayCoreStatusResponse,
|
||||
HistoricalPerformanceResponse, HistoricalUptimeResponse, InclusionProbabilityResponse,
|
||||
MixnodeCoreStatusResponse, MixnodeStatus, MixnodeStatusResponse, NodeAnnotation,
|
||||
NodeDatePerformanceResponse, NodePerformanceResponse, PerformanceHistoryResponse,
|
||||
RewardEstimationResponse, SelectionChance, StakeSaturationResponse, UptimeHistoryResponse,
|
||||
};
|
||||
use nym_api_requests::pagination::{PaginatedResponse, Pagination};
|
||||
use nym_mixnet_contract_common::nym_node::{NodeConfigUpdate, Role};
|
||||
use nym_mixnet_contract_common::reward_params::{
|
||||
ActiveSetUpdate, NodeRewardingParameters, RewardedSetParams,
|
||||
};
|
||||
use nym_mixnet_contract_common::rewarding::RewardEstimate;
|
||||
use nym_mixnet_contract_common::{
|
||||
@@ -70,11 +77,16 @@ fn main() {
|
||||
do_export!(MixNode);
|
||||
do_export!(MixNodeConfigUpdate);
|
||||
do_export!(RewardingParams);
|
||||
do_export!(RewardedSetParams);
|
||||
do_export!(NodeRewardingParameters);
|
||||
do_export!(ActiveSetUpdate);
|
||||
do_export!(UnbondedMixnode);
|
||||
do_export!(RewardEstimate);
|
||||
do_export!(ContractInterval);
|
||||
do_export!(NymNode);
|
||||
do_export!(PendingNodeChanges);
|
||||
do_export!(NodeConfigUpdate);
|
||||
do_export!(Role);
|
||||
|
||||
// common/types/src
|
||||
do_export!(Account);
|
||||
@@ -133,6 +145,18 @@ fn main() {
|
||||
do_export!(SelectionChance);
|
||||
do_export!(StakeSaturationResponse);
|
||||
do_export!(RewardEstimationResponse);
|
||||
do_export!(NodeAnnotation);
|
||||
do_export!(AnnotationResponse);
|
||||
do_export!(NodePerformanceResponse);
|
||||
do_export!(NodeDatePerformanceResponse);
|
||||
do_export!(PerformanceHistoryResponse);
|
||||
do_export!(UptimeHistoryResponse);
|
||||
do_export!(HistoricalUptimeResponse);
|
||||
do_export!(HistoricalPerformanceResponse);
|
||||
do_export!(DescribedNodeType);
|
||||
do_export!(DeclaredRoles);
|
||||
do_export!(PaginatedResponse<ts_rs::Dummy>);
|
||||
do_export!(Pagination);
|
||||
|
||||
// nym-wallet
|
||||
do_export!(AppEnv);
|
||||
|
||||
Reference in New Issue
Block a user