Only use ts-rs in tests

This commit is contained in:
Drazen Urch
2021-11-10 15:02:59 +01:00
parent 10bf70b22b
commit c7007de1ea
13 changed files with 322 additions and 224 deletions
Generated
+4 -4
View File
@@ -6770,9 +6770,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "ts-rs"
version = "3.1.0"
version = "5.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "369e48de67506679b3a576b0faf666fa9f9acf2fd00b4c61e28bdb6c8e08ec06"
checksum = "f34750e8cbb4d87d09f6d7441921cc6d9435dcc58df53bbaec01f5f9945d4801"
dependencies = [
"dprint-plugin-typescript",
"ts-rs-macros",
@@ -6780,9 +6780,9 @@ dependencies = [
[[package]]
name = "ts-rs-macros"
version = "3.1.0"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f269e8fd28e26b4cdbd01f81f345aaf666131511e54a735a76a614b5062d0a5a"
checksum = "4c78e4905e64bb23c814098885e08778dfed7fd796ea503df29aa3ba5fead009"
dependencies = [
"Inflector",
"proc-macro2",
@@ -32,7 +32,7 @@ flate2 = { version = "1.0.20", optional = true }
sha2 = { version = "0.9.5", optional = true }
itertools = { version = "0.10", optional = true }
cosmwasm-std = { git = "https://github.com/jstuczyn/cosmwasm", branch="0.14.1-updatedk256", optional = true }
ts-rs = "3.0"
ts-rs = {version = "5.1", optional = true}
[features]
nymd-client = ["async-trait", "bip39", "config", "cosmrs", "prost", "flate2", "sha2", "itertools", "cosmwasm-std"]
@@ -6,9 +6,9 @@ use cosmrs::tx::{Fee, Gas};
use cosmrs::Coin;
use serde::{Deserialize, Serialize};
use std::fmt;
use ts_rs::TS;
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize, TS)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub enum Operation {
Upload,
Init,
+2 -2
View File
@@ -14,7 +14,7 @@ cosmwasm-std = { git = "https://github.com/jstuczyn/cosmwasm", branch = "0.14.1-
serde = { version = "1.0", features = ["derive"] }
serde_repr = "0.1"
schemars = "0.8"
ts-rs = { version = "3.0", optional = true }
ts-rs = { version = "5.1", optional = true }
thiserror = "1.0"
network-defaults = { path = "../network-defaults" }
fixed = "1.1"
@@ -22,4 +22,4 @@ az = "1.1"
log = "0.4.14"
[features]
default = ["ts-rs"]
default = []
+266 -183
View File
File diff suppressed because it is too large Load Diff
+13 -3
View File
@@ -20,15 +20,14 @@ serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-beta.8", features = [] }
tokio = { version = "1.10", features = ["sync"] }
dirs = "3.0"
# url = "2.2"
dirs = "4.0"
bip39 = "1.0"
thiserror = "1.0"
tendermint-rpc = "0.23.0"
ts-rs = "3.0"
url = "2.0"
rand = "0.6.5"
cosmrs = { version = "0.3", features = ["rpc", "bip32", "cosmwasm"] }
cosmwasm-std = { git = "https://github.com/jstuczyn/cosmwasm", branch = "0.14.1-updatedk256" }
@@ -40,6 +39,17 @@ config = { path = "../../common/config" }
coconut-interface = { path = "../../common/coconut-interface" }
credentials = { path = "../../common/credentials" }
[dev-dependencies]
ts-rs = "5.1"
[dev-dependencies.mixnet-contract]
path = "../../common/mixnet-contract"
features = ["ts-rs"]
[dev-dependencies.validator-client]
path = "../../common/client-libs/validator-client"
features = ["ts-rs"]
[features]
default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
+4 -3
View File
@@ -10,12 +10,12 @@ use std::convert::TryFrom;
use std::fmt;
use std::ops::{Add, Sub};
use std::str::FromStr;
use ts_rs::TS;
use validator_client::nymd::{CosmosCoin, GasPrice};
use crate::format_err;
#[derive(TS, Serialize, Deserialize, Clone, PartialEq, Debug)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum Denom {
Major,
Minor,
@@ -50,7 +50,8 @@ impl FromStr for Denom {
}
}
#[derive(TS, Serialize, Deserialize, Clone, PartialEq, Debug)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct Coin {
amount: String,
denom: Denom,
+15 -13
View File
@@ -7,7 +7,6 @@ use mixnet_contract::{Gateway, MixNode};
use std::sync::Arc;
use tauri::{Menu, MenuItem};
use tokio::sync::RwLock;
use ts_rs::export;
use validator_client::nymd::fee_helpers::Operation;
mod coin;
@@ -70,16 +69,19 @@ fn main() {
.expect("error while running tauri application");
}
export! {
MixNode => "../src/types/rust/mixnode.ts",
Coin => "../src/types/rust/coin.ts",
Balance => "../src/types/rust/balance.ts",
Gateway => "../src/types/rust/gateway.ts",
TauriTxResult => "../src/types/rust/tauritxresult.ts",
TransactionDetails => "../src/types/rust/transactiondetails.ts",
Operation => "../src/types/rust/operation.ts",
Denom => "../src/types/rust/denom.ts",
DelegationResult => "../src/types/rust/delegationresult.ts",
Account => "../src/types/rust/account.ts",
TauriStateParams => "../src/types/rust/stateparams.ts"
#[cfg(test)]
mod test {
ts_rs::export! {
mixnet_contract::MixNode => "../src/types/rust/mixnode.ts",
crate::Coin => "../src/types/rust/coin.ts",
crate::Balance => "../src/types/rust/balance.ts",
mixnet_contract::Gateway => "../src/types/rust/gateway.ts",
crate::TauriTxResult => "../src/types/rust/tauritxresult.ts",
crate::TransactionDetails => "../src/types/rust/transactiondetails.ts",
validator_client::nymd::fee_helpers::Operation => "../src/types/rust/operation.ts",
crate::Denom => "../src/types/rust/denom.ts",
crate::DelegationResult => "../src/types/rust/delegationresult.ts",
crate::Account => "../src/types/rust/account.ts",
crate::TauriStateParams => "../src/types/rust/stateparams.ts"
}
}
@@ -8,10 +8,10 @@ use serde::{Deserialize, Serialize};
use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::RwLock;
use ts_rs::TS;
use validator_client::nymd::{AccountId, NymdClient, SigningNymdClient};
#[derive(TS, Serialize, Deserialize)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Serialize, Deserialize)]
pub struct Account {
contract_address: String,
client_address: String,
@@ -19,7 +19,8 @@ pub struct Account {
mnemonic: Option<String>,
}
#[derive(TS, Serialize, Deserialize)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Serialize, Deserialize)]
pub struct Balance {
coin: Coin,
printable_balance: String,
@@ -8,9 +8,9 @@ use std::convert::{TryFrom, TryInto};
use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::RwLock;
use ts_rs::TS;
#[derive(Serialize, Deserialize, TS)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Serialize, Deserialize)]
pub struct TauriStateParams {
epoch_length: u32,
minimum_mixnode_bond: String,
@@ -7,9 +7,9 @@ use serde::{Deserialize, Serialize};
use std::convert::TryInto;
use std::sync::Arc;
use tokio::sync::RwLock;
use ts_rs::TS;
#[derive(TS, Serialize, Deserialize)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Serialize, Deserialize)]
pub struct DelegationResult {
source_address: String,
target_address: String,
@@ -7,10 +7,10 @@ use std::str::FromStr;
use std::sync::Arc;
use tendermint_rpc::endpoint::broadcast::tx_commit::Response;
use tokio::sync::RwLock;
use ts_rs::TS;
use validator_client::nymd::{AccountId, CosmosCoin};
#[derive(Deserialize, Serialize, TS)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Deserialize, Serialize)]
pub struct TauriTxResult {
code: u32,
gas_wanted: u64,
@@ -19,7 +19,8 @@ pub struct TauriTxResult {
details: TransactionDetails,
}
#[derive(Deserialize, Serialize, TS)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[derive(Deserialize, Serialize)]
pub struct TransactionDetails {
from_address: String,
to_address: String,
+3 -3
View File
@@ -2,8 +2,8 @@ import { TransactionDetails } from "./transactiondetails";
export interface TauriTxResult {
code: number;
gas_wanted: number;
gas_used: number;
block_height: number;
gas_wanted: bigint;
gas_used: bigint;
block_height: bigint;
details: TransactionDetails;
}