Compare commits

..

8 Commits

Author SHA1 Message Date
Bogdan-Ștefan Neacșu c2a6eb4d39 Use 1.. indices and fix the blind sign request multiple generation 2022-03-07 12:49:55 +02:00
Jon Häggblad 835a915f25 wallet: initial backend support for config file with validator urls 2022-03-07 10:53:31 +01:00
durch 9c16e5ebfa Remove core-graphics pin 2022-03-04 14:21:32 +01:00
durch 5dc57d2a3e Fix type generation, upgrade ts-rs 2022-03-03 22:17:35 +01:00
Raphaël Walther fd619cad51 Moved clean task at an earlier stage 2022-03-03 18:47:28 +01:00
durch 953c0915d1 Lock tauri-versions, break type generation 2022-03-03 18:10:58 +01:00
Jon Häggblad acb1aa8df0 network-defaults: make defaults a bit more dynamic
By attaching network defaults to the selector enum, we can get them
either from DEFAULT_NETWORK or a selector passed as a dependency.
Hopefully this opens up some venues for being able to toggle between
networks at runtime.
2022-03-03 13:26:53 +01:00
fmtabbara b9ef848523 fix clipboard and screen maximize 2022-03-03 12:18:08 +00:00
58 changed files with 1202 additions and 4052 deletions
+7 -6
View File
@@ -56,6 +56,12 @@ jobs:
command: fmt
args: --all -- --check
- name: Reclaim some disk space (because Windows is being annoying)
uses: actions-rs/cargo@v1
if: ${{ matrix.os == 'windows-latest' }}
with:
command: clean
- uses: actions-rs/clippy-check@v1
name: Clippy checks
with:
@@ -69,13 +75,8 @@ jobs:
command: clippy
args: -- -D warnings
# COCONUT stuff
- name: Reclaim some disk space (because Windows is being annoying)
uses: actions-rs/cargo@v1
if: ${{ matrix.os == 'windows-latest' }}
with:
command: clean
# COCONUT stuff
- name: Build all binaries with coconut enabled
uses: actions-rs/cargo@v1
with:
Generated
+526 -2634
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -17,7 +17,7 @@ members = [
"clients/native",
"clients/native/websocket-requests",
"clients/socks5",
"clients/tauri-client/src-tauri",
# "clients/tauri-client/src-tauri",
"common/client-libs/gateway-client",
"common/client-libs/mixnet-client",
"common/client-libs/validator-client",
+2 -2
View File
@@ -3,7 +3,7 @@ happy: fmt clippy-happy test
clippy-all: clippy-all-main clippy-all-contracts clippy-all-wallet
clippy-happy: clippy-happy-main clippy-happy-contracts clippy-happy-wallet
cargo-test: test-main test-contracts test-wallet
build: build-main build-contracts build-wallet
build: build-contracts build-wallet build-main
fmt: fmt-main fmt-contracts fmt-wallet
clippy-happy-main:
@@ -25,7 +25,7 @@ clippy-all-wallet:
cargo clippy --manifest-path nym-wallet/Cargo.toml --all-features -- -D warnings
test-main:
cargo test --all-features
cargo test --all-features --all
test-contracts:
cargo test --manifest-path contracts/Cargo.toml --all-features
+6 -2
View File
@@ -12,15 +12,19 @@ build = "src/build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.0.0-rc.3" }
tauri-build = { version = "=1.0.0-rc.2" }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-rc.3", features = [] }
tauri = { version = "=1.0.0-rc.2", features = [] }
tokio = "1.4"
url = "2.2"
tauri-codegen = "=1.0.0-rc.1"
tauri-macros = "=1.0.0-rc.1"
core-graphics = "=0.22.2"
coconut-interface = { path = "../../../common/coconut-interface" }
credentials = { path = "../../../common/credentials" }
validator-client = {path = "../../../common/client-libs/validator-client"}
@@ -39,8 +39,9 @@ flate2 = { version = "1.0.20", optional = true }
sha2 = { version = "0.9.5", optional = true }
itertools = { version = "0.10", optional = true }
cosmwasm-std = { version = "1.0.0-beta3", optional = true }
# Leaving it as * so that it inherits whatever the wallet is using
ts-rs = { version = "*", optional = true }
[dev-dependencies]
ts-rs = "6.1.2"
[features]
nymd-client = [
@@ -54,4 +55,3 @@ nymd-client = [
"itertools",
"cosmwasm-std",
]
typescript-types = ["ts-rs", "validator-api-requests/ts-rs"]
@@ -7,7 +7,11 @@ use cosmrs::Coin;
use serde::{Deserialize, Serialize};
use std::fmt;
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../../../nym-wallet/src/types/rust/operation.ts")
)]
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub enum Operation {
Upload,
@@ -12,8 +12,6 @@ cosmwasm-std = "1.0.0-beta3"
serde = { version = "1.0", features = ["derive"] }
serde_repr = "0.1"
schemars = "0.8"
# Leaving it as * so that it inherits whatever the wallet is using
ts-rs = { version = "*", optional = true }
thiserror = "1.0"
network-defaults = { path = "../../network-defaults" }
fixed = { version = "1.1", features = ["serde"] }
@@ -25,7 +23,7 @@ contracts-common = { path = "../contracts-common" }
[dev-dependencies]
time = { version = "0.3.5", features = ["serde", "macros"] }
ts-rs = "6.1.2"
[features]
default = []
@@ -8,7 +8,11 @@ use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::fmt::Display;
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../../../nym-wallet/src/types/rust/gateway.ts")
)]
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
pub struct Gateway {
pub host: String,
@@ -18,7 +18,14 @@ fixed::const_fixed_from_int! {
const ONE: U128 = 1;
}
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(
export,
export_to = "../../../nym-wallet/src/types/rust/rewardedsetnodestatus.ts"
)
)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
pub enum RewardedSetNodeStatus {
Active,
@@ -31,7 +38,11 @@ impl RewardedSetNodeStatus {
}
}
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../../../nym-wallet/src/types/rust/mixnode.ts")
)]
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
pub struct MixNode {
pub host: String,
@@ -12,4 +12,6 @@ serde = { version = "1.0", features = ["derive"] }
schemars = "0.8"
cw-storage-plus = "0.11.1"
config = { path = "../../config" }
ts-rs = { version = "*", optional = true }
[dev-dependencies]
ts-rs = "6.1.2"
@@ -12,7 +12,11 @@ pub fn one_ucoin() -> Coin {
Coin::new(1, DENOM)
}
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../../../nym-wallet/src/types/rust/period.ts")
)]
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, JsonSchema)]
pub enum Period {
Before,
+22 -16
View File
@@ -3,8 +3,8 @@
use coconut_interface::{
aggregate_signature_shares, aggregate_verification_keys, prepare_blind_sign,
prove_bandwidth_credential, Attribute, BlindSignRequestBody, Credential, Parameters, Signature,
SignatureShare, VerificationKey,
prove_bandwidth_credential, Attribute, BlindSignRequest, BlindSignRequestBody, Credential,
ElGamalKeyPair, Parameters, Signature, SignatureShare, VerificationKey,
};
use url::Url;
@@ -47,13 +47,13 @@ pub async fn obtain_aggregate_verification_key(
let mut client = validator_client::ApiClient::new(validators[0].clone());
let response = client.get_coconut_verification_key().await?;
indices.push(0);
indices.push(1);
shares.push(response.key);
for (id, validator_url) in validators.iter().enumerate().skip(1) {
client.change_validator_api(validator_url.clone());
let response = client.get_coconut_verification_key().await?;
indices.push(id as u64);
indices.push((id + 1) as u64);
shares.push(response.key);
}
@@ -66,17 +66,11 @@ async fn obtain_partial_credential(
private_attributes: &[Attribute],
client: &validator_client::ApiClient,
validator_vk: &VerificationKey,
blind_sign_request: &BlindSignRequest,
elgamal_keypair: &ElGamalKeyPair,
) -> Result<Signature, Error> {
let elgamal_keypair = coconut_interface::elgamal_keygen(params);
let blind_sign_request = prepare_blind_sign(
params,
&elgamal_keypair,
private_attributes,
public_attributes,
)?;
let blind_sign_request_body = BlindSignRequestBody::new(
&blind_sign_request,
blind_sign_request,
elgamal_keypair.public_key(),
public_attributes,
(public_attributes.len() + private_attributes.len()) as u32,
@@ -116,15 +110,25 @@ pub async fn obtain_aggregate_signature(
let validator_partial_vk = client.get_coconut_verification_key().await?;
validators_partial_vks.push(validator_partial_vk.key.clone());
let elgamal_keypair = coconut_interface::elgamal_keygen(params);
let blind_sign_request = prepare_blind_sign(
params,
&elgamal_keypair,
private_attributes,
public_attributes,
)?;
let first = obtain_partial_credential(
params,
public_attributes,
private_attributes,
&client,
&validator_partial_vk.key,
&blind_sign_request,
&elgamal_keypair,
)
.await?;
shares.push(SignatureShare::new(first, 0));
shares.push(SignatureShare::new(first, 1));
for (id, validator_url) in validators.iter().enumerate().skip(1) {
client.change_validator_api(validator_url.clone());
@@ -136,9 +140,11 @@ pub async fn obtain_aggregate_signature(
private_attributes,
&client,
&validator_partial_vk.key,
&blind_sign_request,
&elgamal_keypair,
)
.await?;
let share = SignatureShare::new(signature, id as u64);
let share = SignatureShare::new(signature, (id + 1) as u64);
shares.push(share)
}
@@ -148,7 +154,7 @@ pub async fn obtain_aggregate_signature(
let mut indices: Vec<u64> = Vec::with_capacity(validators_partial_vks.len());
for i in 0..validators_partial_vks.len() {
indices.push(i as u64);
indices.push((i + 1) as u64);
}
let verification_key =
aggregate_verification_keys(&validators_partial_vks, Some(indices.as_ref()))?;
+2 -2
View File
@@ -86,7 +86,7 @@ impl fmt::Display for Network {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct NetworkDetails {
bech32_prefix: String,
denom: String,
@@ -111,7 +111,7 @@ impl From<&DefaultNetworkDetails<'_>> for NetworkDetails {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
pub struct SupportedNetworks {
networks: HashMap<Network, NetworkDetails>,
}
+1 -1
View File
@@ -84,7 +84,7 @@ static QA_DEFAULTS: Lazy<DefaultNetworkDetails<'static>> = Lazy::new(|| DefaultN
validators: qa::validators(),
});
#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct ValidatorDetails {
// it is assumed those values are always valid since they're being provided in our defaults file
pub nymd_url: String,
+15 -505
View File
@@ -27,17 +27,6 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "async-trait"
version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "autocfg"
version = "1.0.1"
@@ -71,42 +60,12 @@ dependencies = [
"serde",
]
[[package]]
name = "base16ct"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce"
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "base64ct"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "874f8444adcb4952a8bc51305c8be95c8ec8237bb0d2e78d2e039f771f8828a0"
[[package]]
name = "bip32"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "873faa4363bfc54c36a48321da034c92a0645a363eed34d948683ffc1706e37f"
dependencies = [
"bs58",
"hmac",
"k256 0.10.2",
"once_cell",
"pbkdf2",
"rand_core 0.6.3",
"ripemd160",
"sha2",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -131,7 +90,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
dependencies = [
"block-padding 0.1.5",
"block-padding",
"byte-tools",
"byteorder",
"generic-array 0.12.4",
@@ -143,7 +102,6 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"block-padding 0.2.1",
"generic-array 0.14.5",
]
@@ -156,20 +114,11 @@ dependencies = [
"byte-tools",
]
[[package]]
name = "block-padding"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae"
[[package]]
name = "bs58"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3"
dependencies = [
"sha2",
]
[[package]]
name = "bumpalo"
@@ -195,12 +144,6 @@ version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cc"
version = "1.0.72"
@@ -266,12 +209,6 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b"
[[package]]
name = "const-oid"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3"
[[package]]
name = "contracts-common"
version = "0.1.0"
@@ -279,39 +216,6 @@ dependencies = [
"cosmwasm-std",
]
[[package]]
name = "cosmos-sdk-proto"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0254ffee603f5301d6a66963d9e1cc5091479c22e2e925e1f7689c8027a0828"
dependencies = [
"prost",
"prost-types",
"tendermint-proto",
]
[[package]]
name = "cosmrs"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "505ea048e9ff2f906d6b954f9f8157d903ca468bfb301d906b40ecc25ba6838d"
dependencies = [
"bip32",
"cosmos-sdk-proto",
"ecdsa 0.13.4",
"eyre",
"getrandom 0.2.3",
"k256 0.10.2",
"prost",
"prost-types",
"rand_core 0.6.3",
"serde",
"serde_json",
"subtle-encoding",
"tendermint",
"thiserror",
]
[[package]]
name = "cosmwasm-crypto"
version = "1.0.0-beta4"
@@ -320,7 +224,7 @@ checksum = "f903ebbabc0d4880dbc76148efb8be8fc29fa4bf294c440c3d70da1c8bcafff7"
dependencies = [
"digest 0.9.0",
"ed25519-zebra",
"k256 0.9.6",
"k256",
"rand_core 0.5.1",
"thiserror",
]
@@ -411,18 +315,6 @@ dependencies = [
"zeroize",
]
[[package]]
name = "crypto-bigint"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21"
dependencies = [
"generic-array 0.14.5",
"rand_core 0.6.3",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "crypto-mac"
version = "0.7.0"
@@ -482,16 +374,7 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4"
dependencies = [
"const-oid 0.6.2",
]
[[package]]
name = "der"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c"
dependencies = [
"const-oid 0.7.1",
"const-oid",
]
[[package]]
@@ -524,24 +407,12 @@ version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372"
dependencies = [
"der 0.4.5",
"elliptic-curve 0.10.6",
"der",
"elliptic-curve",
"hmac",
"signature",
]
[[package]]
name = "ecdsa"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9"
dependencies = [
"der 0.5.1",
"elliptic-curve 0.11.12",
"rfc6979",
"signature",
]
[[package]]
name = "ed25519"
version = "1.4.0"
@@ -579,46 +450,22 @@ dependencies = [
"thiserror",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "elliptic-curve"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b"
dependencies = [
"crypto-bigint 0.2.11",
"ff 0.10.1",
"crypto-bigint",
"ff",
"generic-array 0.14.5",
"group 0.10.0",
"pkcs8 0.7.6",
"group",
"pkcs8",
"rand_core 0.6.3",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "elliptic-curve"
version = "0.11.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6"
dependencies = [
"base16ct",
"crypto-bigint 0.3.2",
"der 0.5.1",
"ff 0.11.0",
"generic-array 0.14.5",
"group 0.11.0",
"rand_core 0.6.3",
"sec1",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "enum-iterator"
version = "0.7.0"
@@ -639,16 +486,6 @@ dependencies = [
"syn",
]
[[package]]
name = "eyre"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9289ed2c0440a6536e65119725cf91fc2c6b5e513bfd2e36e1134d7cca6ca12f"
dependencies = [
"indenter",
"once_cell",
]
[[package]]
name = "fake-simd"
version = "0.1.2"
@@ -665,16 +502,6 @@ dependencies = [
"subtle 2.4.1",
]
[[package]]
name = "ff"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2958d04124b9f27f175eaeb9a9f383d026098aa837eadd8ba22c11f13a05b9e"
dependencies = [
"rand_core 0.6.3",
"subtle 2.4.1",
]
[[package]]
name = "fixed"
version = "1.11.0"
@@ -688,16 +515,6 @@ dependencies = [
"typenum",
]
[[package]]
name = "flex-error"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b"
dependencies = [
"eyre",
"paste",
]
[[package]]
name = "form_urlencoded"
version = "1.0.1"
@@ -708,67 +525,6 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "futures"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
name = "futures-core"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
[[package]]
name = "futures-io"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
[[package]]
name = "futures-sink"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868"
[[package]]
name = "futures-task"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a"
[[package]]
name = "futures-util"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a"
dependencies = [
"futures-core",
"futures-sink",
"futures-task",
"pin-project-lite",
"pin-utils",
]
[[package]]
name = "generic-array"
version = "0.12.4"
@@ -808,10 +564,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasm-bindgen",
]
[[package]]
@@ -845,18 +599,7 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912"
dependencies = [
"ff 0.10.1",
"rand_core 0.6.3",
"subtle 2.4.1",
]
[[package]]
name = "group"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89"
dependencies = [
"ff 0.11.0",
"ff",
"rand_core 0.6.3",
"subtle 2.4.1",
]
@@ -940,21 +683,6 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "indenter"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "itertools"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.1"
@@ -986,31 +714,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea"
dependencies = [
"cfg-if",
"ecdsa 0.12.4",
"elliptic-curve 0.10.6",
"ecdsa",
"elliptic-curve",
"sha2",
]
[[package]]
name = "k256"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cc5937366afd3b38071f400d1ce5bd8b1d40b5083cc14e6f8dbcc4032a7f5bb"
dependencies = [
"cfg-if",
"ecdsa 0.13.4",
"elliptic-curve 0.11.12",
"sec1",
"sha2",
"sha3",
]
[[package]]
name = "keccak"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7"
[[package]]
name = "keystream"
version = "1.0.0"
@@ -1137,7 +845,6 @@ name = "network-defaults"
version = "0.1.0"
dependencies = [
"cfg-if",
"cosmrs",
"hex-literal",
"once_cell",
"serde",
@@ -1145,17 +852,6 @@ dependencies = [
"url",
]
[[package]]
name = "num-derive"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "num-integer"
version = "0.1.44"
@@ -1210,21 +906,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "paste"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5"
[[package]]
name = "pbkdf2"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739"
dependencies = [
"crypto-mac 0.11.1",
]
[[package]]
name = "pem"
version = "0.8.3"
@@ -1292,37 +973,14 @@ dependencies = [
"sha-1",
]
[[package]]
name = "pin-project-lite"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkcs8"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447"
dependencies = [
"der 0.4.5",
"spki 0.4.1",
]
[[package]]
name = "pkcs8"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0"
dependencies = [
"der 0.5.1",
"spki 0.5.4",
"zeroize",
"der",
"spki",
]
[[package]]
@@ -1370,39 +1028,6 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "prost"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
dependencies = [
"bytes",
"prost-derive",
]
[[package]]
name = "prost-derive"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
dependencies = [
"anyhow",
"itertools",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "prost-types"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
dependencies = [
"bytes",
"prost",
]
[[package]]
name = "quick-error"
version = "2.0.1"
@@ -1493,28 +1118,6 @@ version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rfc6979"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525"
dependencies = [
"crypto-bigint 0.3.2",
"hmac",
"zeroize",
]
[[package]]
name = "ripemd160"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251"
dependencies = [
"block-buffer 0.9.0",
"digest 0.9.0",
"opaque-debug 0.3.0",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
@@ -1560,19 +1163,6 @@ dependencies = [
"syn",
]
[[package]]
name = "sec1"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1"
dependencies = [
"der 0.5.1",
"generic-array 0.14.5",
"pkcs8 0.8.0",
"subtle 2.4.1",
"zeroize",
]
[[package]]
name = "semver"
version = "1.0.4"
@@ -1597,15 +1187,6 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_bytes"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.133"
@@ -1675,18 +1256,6 @@ dependencies = [
"opaque-debug 0.3.0",
]
[[package]]
name = "sha3"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809"
dependencies = [
"block-buffer 0.9.0",
"digest 0.9.0",
"keccak",
"opaque-debug 0.3.0",
]
[[package]]
name = "signature"
version = "1.3.2"
@@ -1726,17 +1295,7 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32"
dependencies = [
"der 0.4.5",
]
[[package]]
name = "spki"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27"
dependencies = [
"base64ct",
"der 0.5.1",
"der",
]
[[package]]
@@ -1789,55 +1348,6 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "tendermint"
version = "0.23.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9ef686b8ecd36550d0581f0989c9d8607090b23005df479d8e6ba348b5800b9"
dependencies = [
"async-trait",
"bytes",
"ed25519",
"ed25519-dalek",
"flex-error",
"futures",
"k256 0.10.2",
"num-traits",
"once_cell",
"prost",
"prost-types",
"ripemd160",
"serde",
"serde_bytes",
"serde_json",
"serde_repr",
"sha2",
"signature",
"subtle 2.4.1",
"subtle-encoding",
"tendermint-proto",
"time 0.3.6",
"zeroize",
]
[[package]]
name = "tendermint-proto"
version = "0.23.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9e0a0251fd81bed7420bea0f4d91c2a58f6c9fa34d5b2f70bed0ba8890de5aa"
dependencies = [
"bytes",
"flex-error",
"num-derive",
"num-traits",
"prost",
"prost-types",
"serde",
"serde_bytes",
"subtle-encoding",
"time 0.3.6",
]
[[package]]
name = "thiserror"
version = "1.0.30"
+324 -615
View File
File diff suppressed because it is too large Load Diff
+21 -26
View File
@@ -8,26 +8,34 @@ repository = ""
default-run = "nym_wallet"
edition = "2021"
build = "src/build.rs"
rust-version = "1.56"
rust-version = "1.58"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.0.0-rc.3" }
tauri-build = { version = "=1.0.0-rc.2", features = [] }
tauri-codegen = "=1.0.0-rc.1"
tauri-macros = "=1.0.0-rc.1"
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
strum = { version = "0.23", features = ["derive"] }
tauri = { version = "1.0.0-rc.3", features = ["shell-open"] }
tokio = { version = "1.10", features = ["sync"] }
dirs = "4.0"
bip39 = "1.0"
thiserror = "1.0"
tendermint-rpc = "0.23.0"
url = "2.2"
rand = "0.6.5"
dirs = "4.0"
eyre = "0.6.5"
rand = "0.6.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
strum = { version = "0.23", features = ["derive"] }
tauri = { version = "=1.0.0-rc.2", features = [
"clipboard-all",
"shell-open",
"window-maximize",
] }
tendermint-rpc = "0.23.0"
thiserror = "1.0"
tokio = { version = "1.10", features = ["sync"] }
toml = "0.5.8"
url = "2.2"
aes-gcm = "0.9.4"
argon2 = { version = "0.3.2", features = ["std"] }
@@ -45,26 +53,13 @@ vesting-contract-common = { path = "../../common/cosmwasm-smart-contracts/vestin
config = { path = "../../common/config" }
coconut-interface = { path = "../../common/coconut-interface" }
credentials = { path = "../../common/credentials" }
# Used for Type conversion, can be extracted but its a lot of work
vesting-contract = { path = "../../contracts/vesting" }
[dev-dependencies]
ts-rs = "5.1"
ts-rs = "6.1.2"
tempfile = "3.3.0"
[dev-dependencies.mixnet-contract-common]
path = "../../common/cosmwasm-smart-contracts/mixnet-contract"
features = ["ts-rs"]
[dev-dependencies.validator-client]
path = "../../common/client-libs/validator-client"
features = ["typescript-types"]
[dev-dependencies.vesting-contract-common]
path = "../../common/cosmwasm-smart-contracts/vesting-contract"
features = ["ts-rs"]
[features]
default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
+2
View File
@@ -14,6 +14,7 @@ use strum::IntoEnumIterator;
use validator_client::nymd::{CosmosCoin, GasPrice};
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export, export_to = "../src/types/rust/denom.ts"))]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum Denom {
Major,
@@ -48,6 +49,7 @@ impl TryFrom<CosmosDenom> for Denom {
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/coin.ts"))]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct Coin {
amount: String,
+104 -17
View File
@@ -1,34 +1,37 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::network::Network;
use config::defaults::all::SupportedNetworks;
use crate::network::Network as WalletNetwork;
use config::defaults::{all::SupportedNetworks, ValidatorDetails};
use config::NymConfig;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::{fs, io, path::PathBuf};
use strum::IntoEnumIterator;
use url::Url;
mod template;
use template::config_template;
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct Config {
// Base configuration is not part of the configuration file as it's not intended to be changed.
#[serde(skip)]
base: Base,
// Network level configuration
network: Network,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct Base {
struct Base {
/// Information on all the networks that the wallet connects to.
networks: SupportedNetworks,
}
impl Default for Base {
fn default() -> Self {
let networks = Network::iter().map(|network| network.into()).collect();
let networks = WalletNetwork::iter()
.map(|network| network.into())
.collect();
Base {
networks: SupportedNetworks::new(networks),
}
@@ -37,7 +40,8 @@ impl Default for Base {
impl NymConfig for Config {
fn template() -> &'static str {
config_template()
// For now we're not using a template
unimplemented!();
}
fn default_root_directory() -> PathBuf {
@@ -58,10 +62,32 @@ impl NymConfig for Config {
fn data_directory(&self) -> PathBuf {
self.root_directory().join("data")
}
fn save_to_file(&self, custom_location: Option<PathBuf>) -> io::Result<()> {
let config_toml = toml::to_string_pretty(&self)
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))?;
// Make sure the whole directory structure actually exists
match custom_location.clone() {
Some(loc) => {
if let Some(parent_dir) = loc.parent() {
fs::create_dir_all(parent_dir)
} else {
Ok(())
}
}
None => fs::create_dir_all(self.config_directory()),
}?;
fs::write(
custom_location.unwrap_or_else(|| self.config_directory().join(Self::config_file_name())),
config_toml,
)
}
}
impl Config {
pub fn get_nymd_validator_url(&self, network: Network) -> Url {
pub fn get_nymd_validator_url(&self, network: WalletNetwork) -> Url {
// TODO make this a random choice
if let Some(Some(validator_details)) = self
.base
@@ -75,7 +101,7 @@ impl Config {
}
}
pub fn get_validator_api_url(&self, network: Network) -> Url {
pub fn get_validator_api_url(&self, network: WalletNetwork) -> Url {
// TODO make this a random choice
if let Some(Some(validator_details)) = self
.base
@@ -89,7 +115,7 @@ impl Config {
}
}
pub fn get_mixnet_contract_address(&self, network: Network) -> Option<cosmrs::AccountId> {
pub fn get_mixnet_contract_address(&self, network: WalletNetwork) -> Option<cosmrs::AccountId> {
self
.base
.networks
@@ -99,7 +125,7 @@ impl Config {
.ok()
}
pub fn get_vesting_contract_address(&self, network: Network) -> Option<cosmrs::AccountId> {
pub fn get_vesting_contract_address(&self, network: WalletNetwork) -> Option<cosmrs::AccountId> {
self
.base
.networks
@@ -111,7 +137,7 @@ impl Config {
pub fn get_bandwidth_claim_contract_address(
&self,
network: Network,
network: WalletNetwork,
) -> Option<cosmrs::AccountId> {
self
.base
@@ -122,3 +148,64 @@ impl Config {
.ok()
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
struct Network {
// User supplied additional validator urls in addition to the hardcoded ones.
// NOTE: these are separate fields, rather than a map, to force the serialization order.
mainnet: Option<Vec<ValidatorDetails>>,
sandbox: Option<Vec<ValidatorDetails>>,
qa: Option<Vec<ValidatorDetails>>,
}
#[cfg(test)]
mod tests {
use super::*;
use config::defaults::all::Network as NetworkConfig;
fn test_config() -> Config {
Config {
base: Base::default(),
network: Network {
mainnet: Some(vec![
// Add the default one, although the hardcoded default isn't intended to be included in
// the config file.
NetworkConfig::MAINNET.validators().next().unwrap().clone(),
// An additional one
ValidatorDetails {
nymd_url: "https://42".to_string(),
api_url: None,
},
]),
sandbox: Some(NetworkConfig::SANDBOX.validators().cloned().collect()),
qa: None,
},
}
}
#[test]
fn serialize_to_toml() {
assert_eq!(
toml::to_string_pretty(&test_config()).unwrap(),
r#"[[network.mainnet]]
nymd_url = 'https://rpc.nyx.nodes.guru/'
api_url = 'https://api.nyx.nodes.guru/'
[[network.mainnet]]
nymd_url = 'https://42'
[[network.sandbox]]
nymd_url = 'https://sandbox-validator.nymtech.net'
api_url = 'https://sandbox-validator.nymtech.net/api'
"#
);
}
#[test]
fn serialize_and_deserialize_to_toml() {
let config = test_config();
let config_str = toml::to_string_pretty(&config).unwrap();
let config_from_toml = toml::from_str(&config_str).unwrap();
assert_eq!(config, config_from_toml);
}
}
@@ -1,17 +0,0 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
pub(crate) fn config_template() -> &'static str {
r#"
# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml
##### main base tauri-wallet config options #####
[base]
# Validator server to which the API will be getting information about the network.
validator_url = '{{ base.validator_url }}'
"#
}
-30
View File
@@ -86,33 +86,3 @@ fn main() {
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
#[cfg(test)]
mod test {
ts_rs::export! {
mixnet_contract_common::MixNode => "../src/types/rust/mixnode.ts",
crate::coin::Coin => "../src/types/rust/coin.ts",
crate::network::Network => "../src/types/rust/network.ts",
crate::mixnet::account::Balance => "../src/types/rust/balance.ts",
mixnet_contract_common::Gateway => "../src/types/rust/gateway.ts",
crate::mixnet::send::TauriTxResult => "../src/types/rust/tauritxresult.ts",
crate::mixnet::send::TransactionDetails => "../src/types/rust/transactiondetails.ts",
validator_client::nymd::fee::helpers::Operation => "../src/types/rust/operation.ts",
crate::coin::Denom => "../src/types/rust/denom.ts",
crate::utils::DelegationResult => "../src/types/rust/delegationresult.ts",
crate::mixnet::account::Account => "../src/types/rust/account.ts",
crate::mixnet::account::CreatedAccount => "../src/types/rust/createdaccount.ts",
crate::mixnet::admin::TauriContractStateParams => "../src/types/rust/stateparams.ts",
validator_client::models::CoreNodeStatusResponse => "../src/types/corenodestatusresponse.ts",
validator_client::models::MixnodeStatus => "../src/types/rust/mixnodestatus.ts",
validator_client::models::MixnodeStatusResponse => "../src/types/rust/mixnodestatusresponse.ts",
validator_client::models::RewardEstimationResponse => "../src/types/rust/rewardestimationresponse.ts",
validator_client::models::StakeSaturationResponse => "../src/types/rust/stakesaturaionresponse.ts",
validator_client::models::InclusionProbabilityResponse => "../src/types/rust/inclusionprobabilityresponse.ts",
vesting_contract_common::Period => "../src/types/rust/period.ts",
crate::vesting::PledgeData => "../src/types/rust/pledgedata.ts",
crate::vesting::OriginalVestingResponse => "../src/types/rust/originalvestingresponse.ts",
crate::vesting::VestingAccountInfo => "../src/types/rust/vestingaccountinfo.ts",
crate::vesting::VestingPeriod => "../src/types/rust/vestingperiod.ts",
}
}
+1
View File
@@ -13,6 +13,7 @@ use config::defaults::{mainnet, qa, sandbox};
#[allow(clippy::upper_case_acronyms)]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/network.ts"))]
#[derive(Copy, Clone, Debug, Deserialize, EnumIter, Eq, Hash, PartialEq, Serialize)]
pub enum Network {
QA,
@@ -13,6 +13,7 @@ use strum::IntoEnumIterator;
use tokio::sync::RwLock;
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/account.ts"))]
#[derive(Serialize, Deserialize)]
pub struct Account {
contract_address: String,
@@ -31,6 +32,7 @@ impl Account {
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/createdaccount.ts"))]
#[derive(Serialize, Deserialize)]
pub struct CreatedAccount {
account: Account,
@@ -38,6 +40,7 @@ pub struct CreatedAccount {
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/balance.ts"))]
#[derive(Serialize, Deserialize)]
pub struct Balance {
coin: Coin,
@@ -9,6 +9,7 @@ use std::sync::Arc;
use tokio::sync::RwLock;
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/stateparams.ts"))]
#[derive(Serialize, Deserialize)]
pub struct TauriContractStateParams {
minimum_mixnode_pledge: String,
@@ -10,6 +10,7 @@ use tokio::sync::RwLock;
use validator_client::nymd::{AccountId, CosmosCoin};
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/tauritxresult.ts"))]
#[derive(Deserialize, Serialize)]
pub struct TauriTxResult {
block_height: u64,
@@ -21,6 +22,10 @@ pub struct TauriTxResult {
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../src/types/rust/transactiondetails.ts")
)]
#[derive(Deserialize, Serialize)]
pub struct TransactionDetails {
amount: Coin,
@@ -10,6 +10,7 @@ pub mod delegate;
pub mod queries;
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/pledgedata.ts"))]
#[derive(Serialize, Deserialize, Debug)]
pub struct PledgeData {
pub amount: Coin,
@@ -32,6 +33,10 @@ impl PledgeData {
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../src/types/rust/originalvestingresponse.ts")
)]
#[derive(Serialize, Deserialize, Debug)]
pub struct OriginalVestingResponse {
amount: Coin,
@@ -50,6 +55,10 @@ impl From<VestingOriginalVestingResponse> for OriginalVestingResponse {
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../src/types/rust/vestingaccountinfo.ts")
)]
#[derive(Serialize, Deserialize, Debug)]
pub struct VestingAccountInfo {
owner_address: String,
@@ -76,6 +85,7 @@ impl From<VestingAccount> for VestingAccountInfo {
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/vestingperiod.ts"))]
#[derive(Serialize, Deserialize, Debug)]
pub struct VestingPeriod {
start_time: u64,
+1
View File
@@ -59,6 +59,7 @@ pub async fn outdated_get_approximate_fee(
}
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/types/rust/delegationresult.ts"))]
#[derive(Serialize, Deserialize)]
pub struct DelegationResult {
source_address: String,
+6
View File
@@ -49,6 +49,12 @@
"active": false
},
"allowlist": {
"window": {
"maximize": true
},
"clipboard": {
"all": true
},
"shell": {
"open": true
}
+2 -6
View File
@@ -1,7 +1,3 @@
import { Denom } from "./denom";
import type { Denom } from "./denom";
export interface Account {
contract_address: string;
client_address: string;
denom: Denom;
}
export interface Account { contract_address: string, client_address: string, denom: Denom, }
+2 -5
View File
@@ -1,6 +1,3 @@
import { Coin } from "./coin";
import type { Coin } from "./coin";
export interface Balance {
coin: Coin;
printable_balance: string;
}
export interface Balance { coin: Coin, printable_balance: string, }
+2 -5
View File
@@ -1,6 +1,3 @@
import { Denom } from "./denom";
import type { Denom } from "./denom";
export interface Coin {
amount: string;
denom: Denom;
}
export interface Coin { amount: string, denom: Denom, }
@@ -1,4 +1,2 @@
export interface CoreNodeStatusResponse {
identity: string;
count: number;
}
export interface CoreNodeStatusResponse { identity: string, count: number, }
+2 -5
View File
@@ -1,6 +1,3 @@
import { Account } from "./account";
import type { Account } from "./account";
export interface CreatedAccount {
account: Account;
mnemonic: string;
}
export interface CreatedAccount { account: Account, mnemonic: string, }
@@ -1,7 +1,3 @@
import { Coin } from "./coin";
import type { Coin } from "./coin";
export interface DelegationResult {
source_address: string;
target_address: string;
amount: Coin | null;
}
export interface DelegationResult { source_address: string, target_address: string, amount: Coin | null, }
+1
View File
@@ -1 +1,2 @@
export type Denom = "Major" | "Minor";
+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, }
+11 -10
View File
@@ -4,19 +4,20 @@ export * from './coin'
export * from './delegationresult'
export * from './denom'
export * from './gateway'
export * from './inclusionprobabilityresponse'
export * from './mixnode'
export * from './mixnodestatus'
export * from './mixnodestatus'
export * from './mixnodestatusresponse'
export * from './mixnodestatusresponse'
export * from './network'
export * from './operation'
export * from './originalvestingresponse'
export * from './rewardedsetnodestatus'
export * from './rewardestimationresponse'
export * from './stakesaturationresponse'
export * from './stateparams'
export * from './tauritxresult'
export * from './transactiondetails'
export * from './mixnodestatus'
export * from './mixnodestatusresponse'
export * from './stakesaturaionresponse'
export * from './rewardestimationresponse'
export * from './mixnodestatus'
export * from './mixnodestatusresponse'
export * from './inclusionprobabilityresponse'
export * from './network'
export * from './originalvestingresponse'
export * from './vestingperiod'
export * from './vestingaccountinfo'
export * from './vestingperiod'
+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" | "NotFound";
export type MixnodeStatus = "active" | "standby" | "inactive" | "not_found";
@@ -1,5 +1,3 @@
import { MixnodeStatus } from "./mixnodestatus";
import type { MixnodeStatus } from "./mixnodestatus";
export interface MixnodeStatusResponse {
status: MixnodeStatus;
}
export interface MixnodeStatusResponse { status: MixnodeStatus, }
+1
View File
@@ -1 +1,2 @@
export type Network = "QA" | "SANDBOX" | "MAINNET";
+2 -31
View File
@@ -1,31 +1,2 @@
export type Operation =
| "Upload"
| "Init"
| "Migrate"
| "ChangeAdmin"
| "Send"
| "BondMixnode"
| "BondMixnodeOnBehalf"
| "UnbondMixnode"
| "UnbondMixnodeOnBehalf"
| "UpdateMixnodeConfig"
| "DelegateToMixnode"
| "DelegateToMixnodeOnBehalf"
| "UndelegateFromMixnode"
| "UndelegateFromMixnodeOnBehalf"
| "BondGateway"
| "BondGatewayOnBehalf"
| "UnbondGateway"
| "UnbondGatewayOnBehalf"
| "UpdateContractSettings"
| "BeginMixnodeRewarding"
| "FinishMixnodeRewarding"
| "TrackUnbondGateway"
| "TrackUnbondMixnode"
| "WithdrawVestedCoins"
| "TrackUndelegation"
| "CreatePeriodicVestingAccount"
| "AdvanceCurrentInterval"
| "WriteRewardedSet"
| "ClearRewardedSet"
| "UpdateMixnetAddress";
export type Operation = "Upload" | "Init" | "Migrate" | "ChangeAdmin" | "Send" | "BondMixnode" | "BondMixnodeOnBehalf" | "UnbondMixnode" | "UnbondMixnodeOnBehalf" | "UpdateMixnodeConfig" | "DelegateToMixnode" | "DelegateToMixnodeOnBehalf" | "UndelegateFromMixnode" | "UndelegateFromMixnodeOnBehalf" | "BondGateway" | "BondGatewayOnBehalf" | "UnbondGateway" | "UnbondGatewayOnBehalf" | "UpdateContractSettings" | "BeginMixnodeRewarding" | "FinishMixnodeRewarding" | "TrackUnbondGateway" | "TrackUnbondMixnode" | "WithdrawVestedCoins" | "TrackUndelegation" | "CreatePeriodicVestingAccount" | "AdvanceCurrentInterval" | "WriteRewardedSet" | "ClearRewardedSet" | "UpdateMixnetAddress";
@@ -1,7 +1,3 @@
import { Coin } from "./coin";
import type { Coin } from "./coin";
export interface OriginalVestingResponse {
amount: Coin;
number_of_periods: number;
period_duration: bigint;
}
export interface OriginalVestingResponse { amount: Coin, number_of_periods: number, period_duration: bigint, }
+2 -1
View File
@@ -1 +1,2 @@
export type Period = "Before" | number | "After";
export type Period = "Before" | { In: number } | "After";
+2 -5
View File
@@ -1,6 +1,3 @@
import { Coin } from "./coin";
import type { Coin } from "./coin";
export interface PledgeData {
amount: Coin;
block_time: bigint;
}
export interface PledgeData { amount: Coin, block_time: bigint, }
@@ -0,0 +1,2 @@
export type RewardedSetNodeStatus = "Active" | "Standby";
@@ -1,9 +1,2 @@
export interface RewardEstimationResponse {
estimated_total_node_reward: bigint;
estimated_operator_reward: bigint;
estimated_delegators_reward: bigint;
current_interval_start: bigint;
current_interval_end: bigint;
current_interval_uptime: number;
as_at: bigint;
}
export interface RewardEstimationResponse { estimated_total_node_reward: bigint, estimated_operator_reward: bigint, estimated_delegators_reward: bigint, current_interval_start: bigint, current_interval_end: bigint, current_interval_uptime: number, as_at: bigint, }
@@ -1,4 +0,0 @@
export interface StakeSaturationResponse {
saturation: number;
as_at: bigint;
}
@@ -0,0 +1,2 @@
export interface StakeSaturationResponse { saturation: number, as_at: bigint, }
+2 -6
View File
@@ -1,6 +1,2 @@
export interface TauriContractStateParams {
minimum_mixnode_pledge: string;
minimum_gateway_pledge: string;
mixnode_rewarded_set_size: number;
mixnode_active_set_size: number;
}
export interface TauriContractStateParams { minimum_mixnode_pledge: string, minimum_gateway_pledge: string, mixnode_rewarded_set_size: number, mixnode_active_set_size: number, }
+2 -9
View File
@@ -1,10 +1,3 @@
import { TransactionDetails } from "./transactiondetails";
import type { TransactionDetails } from "./transactiondetails";
export interface TauriTxResult {
block_height: bigint;
code: number;
details: TransactionDetails;
gas_used: bigint;
gas_wanted: bigint;
tx_hash: string;
}
export interface TauriTxResult { block_height: bigint, code: number, details: TransactionDetails, gas_used: bigint, gas_wanted: bigint, tx_hash: string, }
@@ -1,7 +1,3 @@
import { Coin } from "./coin";
import type { Coin } from "./coin";
export interface TransactionDetails {
amount: Coin;
from_address: string;
to_address: string;
}
export interface TransactionDetails { amount: Coin, from_address: string, to_address: string, }
@@ -1,10 +1,4 @@
import { Coin } from "./coin";
import { VestingPeriod } from "./vestingperiod";
import type { Coin } from "./coin";
import type { VestingPeriod } from "./vestingperiod";
export interface VestingAccountInfo {
owner_address: string;
staking_address: string | null;
start_time: bigint;
periods: Array<VestingPeriod>;
coin: Coin;
}
export interface VestingAccountInfo { owner_address: string, staking_address: string | null, start_time: bigint, periods: Array<VestingPeriod>, coin: Coin, }
+2 -4
View File
@@ -1,4 +1,2 @@
export interface VestingPeriod {
start_time: bigint;
period_seconds: bigint;
}
export interface VestingPeriod { start_time: bigint, period_seconds: bigint, }
@@ -7,5 +7,6 @@ edition = "2021"
[dependencies]
serde = "1.0"
ts-rs = { version = "5.1", optional = true }
[dev-dependencies]
ts-rs = "6.1.2"
@@ -5,7 +5,11 @@ use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(export, export_to = "../../nym-wallet/src/types/rust/mixnodestatus.ts")
)]
#[serde(rename_all = "snake_case")]
pub enum MixnodeStatus {
Active, // in both the active set and the rewarded set
@@ -21,20 +25,41 @@ impl MixnodeStatus {
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(
export,
export_to = "../../nym-wallet/src/types/rust/corenodestatusresponse.ts"
)
)]
pub struct CoreNodeStatusResponse {
pub identity: String,
pub count: i32,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(
export,
export_to = "../../nym-wallet/src/types/rust/mixnodestatusresponse.ts"
)
)]
pub struct MixnodeStatusResponse {
pub status: MixnodeStatus,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[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,
@@ -47,14 +72,28 @@ pub struct RewardEstimationResponse {
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(
export,
export_to = "../../nym-wallet/src/types/rust/stakesaturationresponse.ts"
)
)]
pub struct StakeSaturationResponse {
pub saturation: f32,
pub as_at: i64,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(test, derive(ts_rs::TS))]
#[cfg_attr(
test,
ts(
export,
export_to = "../../nym-wallet/src/types/rust/inclusionprobabilityresponse.ts"
)
)]
pub struct InclusionProbabilityResponse {
pub in_active: f32,
pub in_reserve: f32,