Compare commits

..

5 Commits

Author SHA1 Message Date
Bogdan-Ștefan Neacșu c7fdcf0a79 Change for default mainnet and fix typo 2022-08-10 13:40:28 +03:00
tommy 8edc762df9 Update
- update the cargo toml
- amend the work flow file
- and the envs to mainnet (disclaimer add qa after)
2022-08-10 11:10:38 +02:00
tommy 7b15f350cd add service-provider vesioning to match other binaries 2022-08-10 10:14:07 +02:00
tommy 2b4917b8b1 fix messaging on init for nym-client 2022-08-10 10:11:00 +02:00
tommy 921e558660 Update versions on binaries 2022-08-09 11:56:54 +02:00
61 changed files with 326 additions and 260 deletions
-36
View File
@@ -1,36 +0,0 @@
name: Daily security audit
on: workflow_dispatch
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
notification:
if: ${{ failure() }}
needs: security_audit
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Keybase - Node Install
run: npm install
working-directory: .github/workflows/support-files
- name: Keybase - Send Notification
env:
NYM_NOTIFICATION_KIND: nightly
NYM_PROJECT_NAME: "Nym daily audit"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}"
GIT_BRANCH: "${GITHUB_REF##*/}"
KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}"
KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}"
KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBTECH_TEAM }}"
KEYBASE_NYM_CHANNEL: "test"
uses: docker://keybaseio/client:stable-node
with:
args: .github/workflows/support-files/notifications/entry_point.sh
@@ -45,3 +45,4 @@ jobs:
target/release/nym-socks5-client
target/release/nym-validator-api
target/release/nym-network-requester
target/release/nym-network-statistics
-2
View File
@@ -52,7 +52,6 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
- multisig-contract: Limit the proposal creating functionality to one address (coconut-bandwidth-contract address) ([#1457])
- All binaries and cosmwasm blobs are configured at runtime now; binaries are configured using environment variables or .env files and contracts keep the configuration parameters in storage ([#1463])
- gateway, network-statistics: include gateway id in the sent statistical data ([#1478])
- network explorer: tweak how active set probability is shown ([#1503])
[#1249]: https://github.com/nymtech/nym/pull/1249
@@ -80,7 +79,6 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
[#1482]: https://github.com/nymtech/nym/pull/1482
[#1487]: https://github.com/nymtech/nym/pull/1487
[#1496]: https://github.com/nymtech/nym/pull/1496
[#1503]: https://github.com/nymtech/nym/pull/1503
## [nym-connect-v1.0.1](https://github.com/nymtech/nym/tree/nym-connect-v1.0.1) (2022-07-22)
Generated
+7 -7
View File
@@ -3056,7 +3056,7 @@ dependencies = [
[[package]]
name = "nym-client"
version = "1.0.1"
version = "1.0.2"
dependencies = [
"clap 3.2.8",
"client-core",
@@ -3090,7 +3090,7 @@ dependencies = [
[[package]]
name = "nym-gateway"
version = "1.0.1"
version = "1.0.2"
dependencies = [
"anyhow",
"async-trait",
@@ -3138,7 +3138,7 @@ dependencies = [
[[package]]
name = "nym-mixnode"
version = "1.0.1"
version = "1.0.2"
dependencies = [
"anyhow",
"bs58",
@@ -3178,7 +3178,7 @@ dependencies = [
[[package]]
name = "nym-network-requester"
version = "1.0.1"
version = "1.0.2"
dependencies = [
"async-trait",
"clap 2.34.0",
@@ -3206,7 +3206,7 @@ dependencies = [
[[package]]
name = "nym-network-statistics"
version = "0.1.0"
version = "1.0.2"
dependencies = [
"dirs",
"log",
@@ -3222,7 +3222,7 @@ dependencies = [
[[package]]
name = "nym-socks5-client"
version = "1.0.1"
version = "1.0.2"
dependencies = [
"clap 3.2.8",
"client-core",
@@ -3283,7 +3283,7 @@ dependencies = [
[[package]]
name = "nym-validator-api"
version = "1.0.1"
version = "1.0.2"
dependencies = [
"anyhow",
"async-trait",
+1
View File
@@ -76,6 +76,7 @@ default-members = [
"clients/socks5",
"gateway",
"service-providers/network-requester",
"service-providers/network-statistics",
"mixnode",
"validator-api",
"explorer-api",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "nym-client"
version = "1.0.1"
version = "1.0.2"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
description = "Implementation of the Nym Client"
edition = "2021"
+14 -2
View File
@@ -3,6 +3,7 @@
use crate::client::config::{Config, SocketType};
use clap::{Parser, Subcommand};
use url::Url;
#[cfg(not(feature = "coconut"))]
pub(crate) const DEFAULT_ETH_ENDPOINT: &str =
@@ -96,17 +97,28 @@ pub(crate) async fn execute(args: &Cli) {
}
}
fn parse_validators(raw: &str) -> Vec<Url> {
raw.split(',')
.map(|raw_validator| {
raw_validator
.trim()
.parse()
.expect("one of the provided validator api urls is invalid")
})
.collect()
}
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
if let Some(raw_validators) = args.validators {
config
.get_base_mut()
.set_custom_validator_apis(config::parse_validators(&raw_validators));
.set_custom_validator_apis(parse_validators(&raw_validators));
} else if std::env::var(network_defaults::var_names::CONFIGURED).is_ok() {
let raw_validators = std::env::var(network_defaults::var_names::API_VALIDATOR)
.expect("api validator not set");
config
.get_base_mut()
.set_custom_validator_apis(config::parse_validators(&raw_validators));
.set_custom_validator_apis(parse_validators(&raw_validators));
}
if args.disable_socket {
+1 -1
View File
@@ -82,7 +82,7 @@ fn version_check(cfg: &Config) -> bool {
if binary_version == config_version {
true
} else {
warn!("The mixnode binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
warn!("The native-client binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
if is_minor_version_compatible(binary_version, config_version) {
info!("but they are still semver compatible. However, consider running the `upgrade` command");
true
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "nym-socks5-client"
version = "1.0.1"
version = "1.0.2"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>"]
description = "A SOCKS5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address"
edition = "2021"
+12 -1
View File
@@ -3,7 +3,7 @@
use crate::client::config::Config;
use clap::{Parser, Subcommand};
use config::parse_validators;
use url::Url;
pub mod init;
pub(crate) mod run;
@@ -96,6 +96,17 @@ pub(crate) async fn execute(args: &Cli) {
}
}
pub fn parse_validators(raw: &str) -> Vec<Url> {
raw.split(',')
.map(|raw_validator| {
raw_validator
.trim()
.parse()
.expect("one of the provided validator api urls is invalid")
})
.collect()
}
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
if let Some(raw_validators) = args.validators {
config
+5
View File
@@ -2,4 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
pub mod client;
// This is only used as we reach into the init functions in nym-connect. We need to refactor the
// init functions so that nym-connect can just call the same init function as the regular socks5
// client.
#[allow(unused)]
pub mod commands;
pub mod socks;
-11
View File
@@ -88,14 +88,3 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
}
}
pub fn parse_validators(raw: &str) -> Vec<url::Url> {
raw.split(',')
.map(|raw_validator| {
raw_validator
.trim()
.parse()
.expect("one of the provided validator api urls is invalid")
})
.collect()
}
@@ -37,7 +37,7 @@ impl SpendCredentialData {
}
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
pub enum SpendCredentialStatus {
InProgress,
Spent,
@@ -213,7 +213,7 @@ pub enum QueryMsg {
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct MigrateMsg {
pub mixnet_denom: String,
@@ -226,7 +226,7 @@ impl MigrateMsg {
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct NodeToRemove {
owner: String,
proxy: Option<String>,
+1 -1
View File
@@ -24,7 +24,7 @@ pub(crate) const _ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] =
hex_literal::hex!("0000000000000000000000000000000000000000");
pub(crate) const REWARDING_VALIDATOR_ADDRESS: &str = "n10yyd98e2tuwu0f7ypz9dy3hhjw7v772q6287gy";
pub(crate) const STATISTICS_SERVICE_DOMAIN_ADDRESS: &str = "http://127.0.0.1:8090";
pub(crate) const STATISTICS_SERVICE_DOMAIN_ADDRESS: &str = "https://mainnet-stats.nymte.ch:8090/";
pub const NYMD_VALIDATOR: &str = "https://rpc.nyx.nodes.guru/";
pub const API_VALIDATOR: &str = "https://validator.nymtech.net/api/";
pub(crate) fn validators() -> Vec<ValidatorDetails> {
+1 -1
View File
@@ -15,6 +15,6 @@ BANDWIDTH_CLAIM_CONTRACT_ADDRESS=n19lc9u84cz0yz3fww5283nucc9yvr8gsjmgeul0
COCONUT_BANDWIDTH_CONTRACT_ADDRESS=n19lc9u84cz0yz3fww5283nucc9yvr8gsjmgeul0
MULTISIG_CONTRACT_ADDRESS=n19lc9u84cz0yz3fww5283nucc9yvr8gsjmgeul0
REWARDING_VALIDATOR_ADDRESS=n10yyd98e2tuwu0f7ypz9dy3hhjw7v772q6287gy
STATISTICS_SERVICE_DOMAIN_ADDRESS="http://127.0.0.1:8090"
STATISTICS_SERVICE_DOMAIN_ADDRESS="https://mainnet-stats.nymte.ch:8090"
NYMD_VALIDATOR="https://rpc.nyx.nodes.guru/"
API_VALIDATOR="https://validator.nymtech.net/api/"
+2 -2
View File
@@ -2,5 +2,5 @@ EXPLORER_API_URL=https://qa-explorer.nymtech.net/api/v1
VALIDATOR_API_URL=https://qa-validator-api.nymtech.net
VALIDATOR_URL=https://qa-validator.nymtech.net
BIG_DIPPER_URL=https://qa-blocks.nymtech.net
CURRENCY_DENOM=unym
CURRENCY_STAKING_DENOM=unyx
CURRENCY_DENOM=unymt
CURRENCY_STAKING_DENOM=unyxt
+2 -4
View File
@@ -26,7 +26,6 @@ const FilterItem = ({
id,
tooltipInfo,
value,
isSmooth,
marks,
scale,
min,
@@ -41,9 +40,9 @@ const FilterItem = ({
<Slider
value={value}
onChange={(e: Event, newValue: number | number[]) => onChange(id, newValue as number[])}
valueLabelDisplay={isSmooth ? 'auto' : 'off'}
valueLabelDisplay="off"
marks={marks}
step={isSmooth ? 1 : null}
step={null}
scale={scale}
min={min}
max={max}
@@ -129,7 +128,6 @@ export const Filters = () => {
<Alert
severity="info"
variant={isMobile ? 'standard' : 'outlined'}
sx={{ color: (t) => t.palette.info.light }}
action={
<Button size="small" onClick={onClearFilters}>
CLEAR FILTERS
@@ -5,7 +5,6 @@ export const generateFilterSchema = (upperSaturationValue?: number) => ({
label: 'Profit margin (%)',
id: EnumFilterKey.profitMargin,
value: [0, 100],
isSmooth: true,
marks: [
{ label: '0', value: 0 },
{ label: '10', value: 10 },
-1
View File
@@ -11,7 +11,6 @@ export type TFilterItem = {
label: string;
id: EnumFilterKey;
value: number[];
isSmooth?: boolean;
marks: Mark[];
min?: number;
max?: number;
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-gateway"
version = "1.0.1"
version = "1.0.2"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
description = "Implementation of the Nym Mixnet Gateway"
edition = "2021"
+12 -1
View File
@@ -6,11 +6,11 @@ use std::{process, str::FromStr};
use crate::{config::Config, Cli};
use clap::Subcommand;
use colored::Colorize;
use config::parse_validators;
use crypto::bech32_address_validation;
use network_defaults::var_names::{
API_VALIDATOR, BECH32_PREFIX, CONFIGURED, NYMD_VALIDATOR, STATISTICS_SERVICE_DOMAIN_ADDRESS,
};
use url::Url;
pub(crate) mod init;
pub(crate) mod node_details;
@@ -69,6 +69,17 @@ pub(crate) async fn execute(args: Cli) {
}
}
fn parse_validators(raw: &str) -> Vec<Url> {
raw.split(',')
.map(|raw_validator| {
raw_validator
.trim()
.parse()
.expect("one of the provided validator api urls is invalid")
})
.collect()
}
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
let mut was_host_overridden = false;
if let Some(host) = args.host {
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-mixnode"
version = "1.0.1"
version = "1.0.2"
authors = [
"Dave Hrycyszyn <futurechimp@users.noreply.github.com>",
"Jędrzej Stuczyński <andrew@nymtech.net>",
+13 -4
View File
@@ -6,11 +6,9 @@ use std::process;
use crate::{config::Config, Cli};
use clap::Subcommand;
use colored::Colorize;
use config::{
defaults::var_names::{API_VALIDATOR, BECH32_PREFIX, CONFIGURED},
parse_validators,
};
use config::defaults::var_names::{API_VALIDATOR, BECH32_PREFIX, CONFIGURED};
use crypto::bech32_address_validation;
use url::Url;
mod describe;
mod init;
@@ -63,6 +61,17 @@ pub(crate) async fn execute(args: Cli) {
}
}
fn parse_validators(raw: &str) -> Vec<Url> {
raw.split(',')
.map(|raw_validator| {
raw_validator
.trim()
.parse()
.expect("one of the provided validator api urls is invalid")
})
.collect()
}
fn override_config(mut config: Config, args: OverrideConfig) -> Config {
let mut was_host_overridden = false;
if let Some(host) = args.host {
+2 -3
View File
@@ -7,7 +7,7 @@ use tokio::sync::RwLock;
use client_core::config::Config as BaseConfig;
use config_common::NymConfig;
use nym_socks5::client::config::Config as Socks5Config;
use nym_socks5::{client::config::Config as Socks5Config, commands::parse_validators};
use crate::{
error::{BackendError, Result},
@@ -134,11 +134,10 @@ pub async fn init_socks5_config(provider_address: String, chosen_gateway_id: Str
config
.get_base_mut()
.with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY);
if let Ok(raw_validators) = std::env::var(config_common::defaults::var_names::API_VALIDATOR) {
config
.get_base_mut()
.set_custom_validator_apis(config_common::parse_validators(&raw_validators));
.set_custom_validator_apis(parse_validators(&raw_validators));
}
let gateway = setup_gateway(
@@ -1,12 +1,8 @@
import React from 'react';
import { Avatar, Typography } from '@mui/material';
import { Avatar } from '@mui/material';
import stc from 'string-to-color';
import { TAccount } from 'src/types';
export const AccountAvatar = ({ name, small }: { name: TAccount['name']; small?: boolean }) => (
<Avatar sx={{ bgcolor: stc(name), ...(small ? { width: 25, height: 25 } : {}) }}>
<Typography fontSize={small ? 14 : 'inherit'} fontWeight={600}>
{name?.split('')[0]}
</Typography>
</Avatar>
export const AccountAvatar = ({ name }: Pick<TAccount, 'name'>) => (
<Avatar sx={{ bgcolor: stc(name), width: 20, height: 20 }}>{name?.split('')[0]}</Avatar>
);
@@ -5,10 +5,10 @@ import { AccountAvatar } from './AccountAvatar';
export const AccountOverview = ({ account, onClick }: { account: AccountEntry; onClick: () => void }) => (
<Button
startIcon={<AccountAvatar name={account.id} small />}
startIcon={<AccountAvatar name={account.id} />}
sx={{ color: 'text.primary' }}
color="inherit"
onClick={onClick}
disableRipple
>
{account.id}
</Button>
@@ -9,7 +9,6 @@ import {
DialogTitle,
IconButton,
Typography,
Divider,
} from '@mui/material';
import { Add, ArrowDownwardSharp, Close } from '@mui/icons-material';
import { AccountsContext } from 'src/context';
@@ -52,7 +51,7 @@ export const AccountsModal = () => {
<Close />
</IconButton>
</Box>
<Typography fontSize="small" sx={{ color: 'grey.600' }}>
<Typography variant="body1" sx={{ color: (theme) => theme.palette.text.disabled }}>
Switch between accounts
</Typography>
</DialogTitle>
@@ -70,7 +69,6 @@ export const AccountsModal = () => {
/>
))}
</DialogContent>
<Divider variant="middle" sx={{ mt: 3 }} />
<DialogActions sx={{ p: 3 }}>
<Button startIcon={<ArrowDownwardSharp />} onClick={() => setDialogToDisplay('Import')}>
Import account
@@ -7,16 +7,17 @@ import {
DialogActions,
DialogContent,
DialogTitle,
IconButton,
TextField,
Typography,
} from '@mui/material';
import { ArrowBackSharp } from '@mui/icons-material';
import { useClipboard } from 'use-clipboard-copy';
import { createMnemonic, validateMnemonic } from 'src/requests';
import { Console } from 'src/utils/console';
import { AccountsContext } from 'src/context';
import { ConfirmPassword, Mnemonic } from 'src/components';
import { MnemonicInput } from 'src/components/textfields';
import { StyledBackButton } from 'src/components/StyledBackButton';
const createAccountSteps = [
'Copy and save mnemonic for your new account',
@@ -29,15 +30,14 @@ const importAccountSteps = [
'Confirm the password used to login to your wallet',
];
const MnemonicStep = ({ mnemonic, onNext, onBack }: { mnemonic: string; onNext: () => void; onBack: () => void }) => {
const MnemonicStep = ({ mnemonic, onNext }: { mnemonic: string; onNext: () => void }) => {
const { copy, copied } = useClipboard({ copiedTimeout: 5000 });
return (
<Box sx={{ mt: 1 }}>
<DialogContent>
<Mnemonic mnemonic={mnemonic} handleCopy={copy} copied={copied} />
</DialogContent>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
<StyledBackButton onBack={onBack} />
<DialogActions sx={{ p: 3, pt: 0 }}>
<Button disabled={!copied} fullWidth disableElevation variant="contained" size="large" onClick={onNext}>
I saved my mnemonic
</Button>
@@ -50,12 +50,10 @@ const ImportMnemonic = ({
value,
onChange,
onNext,
onBack,
}: {
value: string;
onChange: (value: string) => void;
onNext: () => void;
onBack: () => void;
}) => {
const [error, setError] = useState<string>();
@@ -79,8 +77,7 @@ const ImportMnemonic = ({
}}
/>
</DialogContent>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
<StyledBackButton onBack={onBack} />
<DialogActions sx={{ p: 3, pt: 0 }}>
<Button
disabled={value.length === 0}
fullWidth
@@ -96,7 +93,7 @@ const ImportMnemonic = ({
);
};
const NameAccount = ({ onNext, onBack }: { onNext: (value: string) => void; onBack: () => void }) => {
const NameAccount = ({ onNext }: { onNext: (value: string) => void }) => {
const [value, setValue] = useState('');
const [error, setError] = useState<string>();
@@ -124,8 +121,7 @@ const NameAccount = ({ onNext, onBack }: { onNext: (value: string) => void; onBa
fullWidth
/>
</DialogContent>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
<StyledBackButton onBack={onBack} />
<DialogActions sx={{ p: 3, pt: 0 }}>
<Button
disabled={!value.length}
fullWidth
@@ -182,6 +178,9 @@ export const AddAccountModal = () => {
<DialogTitle sx={{ pb: 0 }}>
<Box display="flex" justifyContent="space-between" alignItems="center">
<Typography variant="h6">{`${dialogToDisplay} new account`}</Typography>
<IconButton onClick={() => (step === 0 ? handleClose() : setStep((s) => s - 1))}>
<ArrowBackSharp />
</IconButton>
</Box>
<Typography sx={{ mt: 2 }}>
{dialogToDisplay === 'Add' ? createAccountSteps[step] : importAccountSteps[step]}
@@ -191,17 +190,12 @@ export const AddAccountModal = () => {
switch (step) {
case 0:
return dialogToDisplay === 'Add' ? (
<MnemonicStep
mnemonic={data.mnemonic}
onNext={() => setStep((s) => s + 1)}
onBack={() => (step === 0 ? handleClose() : setStep((s) => s - 1))}
/>
<MnemonicStep mnemonic={data.mnemonic} onNext={() => setStep((s) => s + 1)} />
) : (
<ImportMnemonic
value={data.mnemonic}
onChange={(value) => setData((d) => ({ ...d, mnemonic: value }))}
onNext={() => setStep((s) => s + 1)}
onBack={() => (step === 0 ? handleClose() : setStep((s) => s - 1))}
/>
);
case 1:
@@ -211,7 +205,6 @@ export const AddAccountModal = () => {
setData((d) => ({ ...d, accountName }));
setStep((s) => s + 1);
}}
onBack={() => setStep((s) => s - 1)}
/>
);
case 2:
@@ -229,7 +222,6 @@ export const AddAccountModal = () => {
}
}
}}
onCancel={() => setStep((s) => s - 1)}
isLoading={isLoading}
error={error}
/>
@@ -19,18 +19,17 @@ export const ConfirmPasswordModal = ({
<Dialog open={Boolean(accountName)} onClose={onClose} fullWidth>
<Paper>
<DialogTitle>
<Typography variant="h6">Switch account</Typography>
<Typography fontSize="small" sx={{ color: 'grey.600' }}>
<Box display="flex" justifyContent="space-between" alignItems="center">
<Typography variant="h6">Switch account</Typography>
<IconButton onClick={onClose}>
<ArrowBack />
</IconButton>
</Box>
<Typography variant="body1" sx={{ color: (theme) => theme.palette.text.disabled }}>
Confirm password
</Typography>
</DialogTitle>
<ConfirmPassword
onConfirm={onConfirm}
error={error}
isLoading={isLoading}
buttonTitle="Switch account"
onCancel={onClose}
/>
<ConfirmPassword onConfirm={onConfirm} error={error} isLoading={isLoading} buttonTitle="Switch account" />
</Paper>
</Dialog>
);
@@ -33,7 +33,7 @@ export const EditAccountModal = () => {
<Close />
</IconButton>
</Box>
<Typography fontSize="small" sx={{ color: 'grey.600' }}>
<Typography variant="body1" sx={{ color: (theme) => theme.palette.text.disabled }}>
New wallet address
</Typography>
</DialogTitle>
@@ -0,0 +1,69 @@
import React, { useContext, useState } from 'react';
import {
Box,
Button,
Paper,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
IconButton,
TextField,
Typography,
} from '@mui/material';
import { Close } from '@mui/icons-material';
import { AccountsContext } from 'src/context';
export const ImportAccountModal = () => {
const [mnemonic, setMnemonic] = useState('');
const { dialogToDisplay, setDialogToDisplay, handleImportAccount } = useContext(AccountsContext);
const handleClose = () => {
setMnemonic('');
setDialogToDisplay('Accounts');
};
return (
<Dialog open={dialogToDisplay === 'Import'} onClose={handleClose} fullWidth>
<Paper>
<DialogTitle>
<Box display="flex" justifyContent="space-between" alignItems="center">
<Typography variant="h6">Import account</Typography>
<IconButton onClick={handleClose}>
<Close />
</IconButton>
</Box>
<Typography variant="body1" sx={{ color: (theme) => theme.palette.text.disabled }}>
Provide mnemonic of account you want to import
</Typography>
</DialogTitle>
<DialogContent sx={{ p: 0 }}>
<Box sx={{ px: 3, mt: 1 }}>
<TextField
placeholder="Paste or type your mnemonic here"
fullWidth
value={mnemonic}
onChange={(e) => setMnemonic(e.target.value)}
autoFocus
multiline
rows={3}
/>
</Box>
</DialogContent>
<DialogActions sx={{ p: 3 }}>
<Button
fullWidth
disableElevation
variant="contained"
size="large"
onClick={() => handleImportAccount({ id: '', address: '' })}
disabled={!mnemonic.length}
>
Import account
</Button>
</DialogActions>
</Paper>
</Dialog>
);
};
@@ -2,19 +2,16 @@ import React, { useEffect, useState } from 'react';
import { Button, CircularProgress, DialogActions, DialogContent, Typography } from '@mui/material';
import { useKeyPress } from 'src/hooks/useKeyPress';
import { PasswordInput } from './textfields';
import { StyledBackButton } from './StyledBackButton';
export const ConfirmPassword = ({
error,
isLoading,
onConfirm,
onCancel,
buttonTitle,
}: {
error?: string;
isLoading?: boolean;
buttonTitle: string;
onCancel?: () => void;
onConfirm: (password: string) => void;
}) => {
const [value, setValue] = useState('');
@@ -42,8 +39,7 @@ export const ConfirmPassword = ({
disabled={isLoading}
/>
</DialogContent>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
{onCancel && <StyledBackButton onBack={onCancel} />}
<DialogActions sx={{ p: 3, pt: 0 }}>
<Button
disabled={!value.length || isLoading}
fullWidth
@@ -13,13 +13,12 @@ import { TokenPoolSelector, TPoolOption } from '../TokenPoolSelector';
import { ConfirmTx } from '../ConfirmTX';
import { getMixnodeStakeSaturation } from '../../requests';
import { ErrorModal } from '../Modals/ErrorModal';
const MIN_AMOUNT_TO_DELEGATE = 10;
export const DelegateModal: React.FC<{
open: boolean;
onClose: () => void;
onClose?: () => void;
onOk?: (identityKey: string, amount: DecCoin, tokenPool: TPoolOption, fee?: FeeDetails) => Promise<void>;
identityKey?: string;
onIdentityKeyChanged?: (identityKey: string) => void;
@@ -63,7 +62,7 @@ export const DelegateModal: React.FC<{
const [tokenPool, setTokenPool] = useState<TPoolOption>('balance');
const [errorIdentityKey, setErrorIdentityKey] = useState<string>();
const { fee, getFee, resetFeeState, feeError } = useGetFee();
const { fee, getFee, resetFeeState } = useGetFee();
const handleCheckStakeSaturation = async (identity: string) => {
try {
@@ -175,18 +174,6 @@ export const DelegateModal: React.FC<{
);
}
if (feeError) {
return (
<ErrorModal
title="Something went wrong while calculating fee. Are you sure you entered a valid node address?"
message={feeError}
sx={sx}
open={open}
onClose={onClose}
/>
);
}
return (
<SimpleModal
open={open}
@@ -206,7 +193,7 @@ export const DelegateModal: React.FC<{
<IdentityKeyFormField
required
fullWidth
label="Node identity key"
placeholder="Node identity key"
onChanged={handleIdentityKeyChanged}
initialValue={identityKey}
readOnly={Boolean(initialIdentityKey)}
@@ -228,7 +215,7 @@ export const DelegateModal: React.FC<{
<CurrencyFormField
required
fullWidth
label="Amount"
placeholder="Amount"
initialValue={amount}
autoFocus={Boolean(initialIdentityKey)}
onChanged={handleAmountChanged}
@@ -244,25 +231,25 @@ export const DelegateModal: React.FC<{
{errorAmount}
</Typography>
<Box sx={{ mt: 3 }}>
<ModalListItem label="Account balance" value={accountBalance?.toUpperCase()} divider fontWeight={600} />
<ModalListItem label="Account balance:" value={accountBalance?.toUpperCase()} divider strong />
</Box>
<ModalListItem label="Rewards payout interval" value={rewardInterval} hidden divider />
<ModalListItem label="Rewards payout interval:" value={rewardInterval} hidden divider />
<ModalListItem
label="Node profit margin"
label="Node profit margin:"
value={`${profitMarginPercentage ? `${profitMarginPercentage}%` : '-'}`}
hidden={profitMarginPercentage === undefined}
divider
/>
<ModalListItem
label="Node avg. uptime"
label="Node avg. uptime:"
value={`${nodeUptimePercentage ? `${nodeUptimePercentage}%` : '-'}`}
hidden={nodeUptimePercentage === undefined}
divider
/>
<ModalListItem
label="Node est. reward per epoch"
label="Node est. reward per epoch:"
value={`${estimatedReward} ${denom.toUpperCase()}`}
hidden
divider
@@ -1,10 +1,10 @@
import React from 'react';
import { Typography, SxProps, Stack } from '@mui/material';
import { Box, Button, Modal, Typography, SxProps, Stack } from '@mui/material';
import { Link } from '@nymproject/react/link/Link';
import { Console } from 'src/utils/console';
import { modalStyle } from '../Modals/styles';
import { LoadingModal } from '../Modals/LoadingModal';
import { ConfirmationModal } from '../Modals/ConfirmationModal';
import { ErrorModal } from '../Modals/ErrorModal';
export type ActionType = 'delegate' | 'undelegate' | 'redeem' | 'redeem-all' | 'compound';
@@ -39,7 +39,7 @@ export type DelegationModalProps = {
export const DelegationModal: React.FC<
DelegationModalProps & {
open: boolean;
onClose: () => void;
onClose?: () => void;
sx?: SxProps;
backdropProps?: object;
}
@@ -48,9 +48,20 @@ export const DelegationModal: React.FC<
if (status === 'error') {
return (
<ErrorModal message={message} sx={sx} open={open} onClose={onClose}>
{children}
</ErrorModal>
<Modal open={open} onClose={onClose} BackdropProps={backdropProps}>
<Box sx={{ ...modalStyle, ...sx }} textAlign="center">
<Typography color={(theme) => theme.palette.error.main} mb={1}>
Oh no! Something went wrong...
</Typography>
<Typography my={5} color="text.primary">
{message}
</Typography>
{children}
<Button variant="contained" onClick={onClose}>
Close
</Button>
</Box>
</Modal>
);
}
@@ -40,6 +40,7 @@ export const UndelegateModal: React.FC<{
onClose={onClose}
onOk={handleOk}
header="Undelegate"
subHeader="Undelegate from mixnode"
okLabel="Undelegate stake"
okDisabled={!fee}
sx={sx}
@@ -54,10 +55,14 @@ export const UndelegateModal: React.FC<{
/>
<Box sx={{ mt: 3 }}>
<ModalListItem label="Delegation amount" value={`${amount} ${currency.toUpperCase()}`} divider />
<ModalFee fee={fee} isLoading={isFeeLoading} error={feeError} divider />
<ModalListItem label=" Tokens will be transferred to account you are logged in with now" value="" divider />
<ModalListItem label="Delegation amount:" value={`${amount} ${currency}`} divider />
</Box>
<Typography mb={5} fontSize="smaller" sx={{ color: 'text.primary' }}>
Tokens will be transferred to account you are logged in with now
</Typography>
<ModalFee fee={fee} isLoading={isFeeLoading} error={feeError} />
</SimpleModal>
);
};
@@ -4,16 +4,15 @@ import { modalStyle } from './styles';
export const ErrorModal: React.FC<{
open: boolean;
title?: string;
message?: string;
sx?: SxProps;
backdropProps?: object;
onClose: () => void;
}> = ({ children, open, title, message, sx, backdropProps, onClose }) => (
}> = ({ children, open, message, sx, backdropProps, onClose }) => (
<Modal open={open} onClose={onClose} BackdropProps={backdropProps}>
<Box sx={{ ...modalStyle, ...sx }} textAlign="center">
<Typography color={(theme) => theme.palette.error.main} mb={1}>
{title || 'Oh no! Something went wrong...'}
Oh no! Something went wrong...
</Typography>
<Typography my={5} color="text.primary">
{message}
@@ -15,7 +15,7 @@ const getValue = ({ fee, isLoading, error }: TFeeProps) => {
export const ModalFee = ({ fee, isLoading, error, divider }: TFeeProps) => (
<>
<ModalListItem label="Fee for this operation" value={getValue({ fee, isLoading, error })} />
<ModalListItem label="Fee for this operation:" value={getValue({ fee, isLoading, error })} />
{divider && <ModalDivider />}
</>
);
@@ -1,25 +1,21 @@
import React from 'react';
import { Box, Stack, Typography, TypographyProps } from '@mui/material';
import { Box, Stack, Typography } from '@mui/material';
import { ModalDivider } from './ModalDivider';
import { fontWeight } from '@mui/system';
type TFontWeight = 'strong' | 'light';
export const ModalListItem: React.FC<{
label: string;
divider?: boolean;
hidden?: boolean;
fontWeight?: TypographyProps['fontWeight'];
light?: boolean;
strong?: boolean;
value?: React.ReactNode;
}> = ({ label, value, hidden, fontWeight, divider }) => (
}> = ({ label, value, hidden, divider, strong }) => (
<Box sx={{ display: hidden ? 'none' : 'block' }}>
<Stack direction="row" justifyContent="space-between">
<Typography fontSize="smaller" fontWeight={fontWeight} sx={{ color: 'text.primary' }}>
<Typography fontSize="smaller" fontWeight={strong ? 600 : undefined} sx={{ color: 'text.primary' }}>
{label}
</Typography>
{value && (
<Typography fontSize="smaller" fontWeight={fontWeight} sx={{ color: 'text.primary' }}>
<Typography fontSize="smaller" fontWeight={strong ? 600 : undefined} sx={{ color: 'text.primary' }}>
{value}
</Typography>
)}
@@ -50,16 +50,17 @@ export const SimpleModal: React.FC<{
)}
{!hideCloseIcon && <CloseIcon onClick={onClose} cursor="pointer" />}
</Stack>
<Typography
mt={0.5}
mb={3}
fontSize={12}
color={(theme) => theme.palette.text.secondary}
sx={{ color: (theme) => theme.palette.nym.nymWallet.text.muted, ...subHeaderStyles }}
>
{subHeader}
</Typography>
{subHeader && (
<Typography
mt={0.5}
mb={3}
fontSize={12}
color={(theme) => theme.palette.text.secondary}
sx={{ color: (theme) => theme.palette.nym.nymWallet.text.muted, ...subHeaderStyles }}
>
{subHeader}
</Typography>
)}
{children}
@@ -39,7 +39,7 @@ export const NetworkSelector = () => {
<>
<Button
variant="text"
color="inherit"
color="primary"
sx={{ color: 'text.primary' }}
onClick={handleClick}
disableElevation
@@ -1,33 +1,42 @@
import React, { useContext } from 'react';
import { AppContext } from 'src/context';
import { Box, Stack, Typography, SxProps, Dialog, DialogTitle, DialogContent } from '@mui/material';
import { Box, Stack, Typography, SxProps } from '@mui/material';
import QRCode from 'qrcode.react';
import { SimpleModal } from '../Modals/SimpleModal';
import { ClientAddress } from '../ClientAddress';
import { ModalListItem } from '../Modals/ModalListItem';
import { Close as CloseIcon } from '@mui/icons-material';
export const ReceiveModal = ({ onClose }: { onClose: () => void; sx?: SxProps; backdropProps?: object }) => {
export const ReceiveModal = ({
onClose,
open,
sx,
backdropProps,
}: {
onClose: () => void;
open: boolean;
sx?: SxProps;
backdropProps?: object;
}) => {
const { clientDetails } = useContext(AppContext);
return (
<Dialog open maxWidth="sm" fullWidth onClose={onClose}>
<DialogTitle>
<Box sx={{ mt: 1, display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<Typography fontSize={20} fontWeight={600}>
Receive
</Typography>
<CloseIcon onClick={onClose} cursor="pointer" />
</Box>
</DialogTitle>
<DialogContent sx={{ p: 0 }}>
<Box sx={{ px: 3 }}>
<ModalListItem label="Your address:" value={<ClientAddress withCopy showEntireAddress />} />
</Box>
<Stack alignItems="center" sx={{ px: 0, py: 3, mt: 3, bgcolor: 'rgba(251, 110, 78, 5%)' }}>
<Box sx={{ border: (t) => `1px solid ${t.palette.nym.highlight}`, bgcolor: 'white', borderRadius: 2, p: 3 }}>
<SimpleModal
header="Receive"
okLabel="Ok"
onClose={onClose}
open={open}
sx={{ width: 'small', ...sx }}
backdropProps={backdropProps}
>
<Stack spacing={3} sx={{ mt: 1.6 }}>
<Stack direction="row" alignItems="center" gap={4}>
<Typography>Your address:</Typography>
<ClientAddress withCopy showEntireAddress />
</Stack>
<Stack alignItems="center">
<Box sx={{ border: (t) => `1px solid ${t.palette.nym.highlight}`, borderRadius: 2, p: 2 }}>
{clientDetails && <QRCode data-testid="qr-code" value={clientDetails?.client_address} />}
</Box>
</Stack>
</DialogContent>
</Dialog>
</Stack>
</SimpleModal>
);
};
+2 -1
View File
@@ -5,7 +5,8 @@ import { ReceiveModal } from './ReceiveModal';
export const Receive = ({ hasStorybookStyles }: { hasStorybookStyles?: {} }) => {
const { showReceiveModal, handleShowReceiveModal } = useContext(AppContext);
if (showReceiveModal) return <ReceiveModal onClose={handleShowReceiveModal} {...hasStorybookStyles} />;
if (showReceiveModal)
return <ReceiveModal onClose={handleShowReceiveModal} open={showReceiveModal} {...hasStorybookStyles} />;
return null;
};
@@ -46,9 +46,9 @@ export const CompoundModal: React.FC<{
<IdentityKeyFormField readOnly fullWidth initialValue={identityKey} showTickOnValid={false} sx={{ mb: 2 }} />
)}
<ModalListItem label="Rewards amount" value={` ${amount} ${denom.toUpperCase()}`} divider />
{fee && <FeeWarning amount={amount} fee={fee} />}
<ModalFee fee={fee} isLoading={isFeeLoading} error={feeError} divider />
<ModalListItem label="Rewards will be added to this delegation" value="" divider />
{fee && <FeeWarning amount={amount} fee={fee} />}
</SimpleModal>
);
};
@@ -52,9 +52,9 @@ export const RedeemModal: React.FC<{
<IdentityKeyFormField readOnly fullWidth initialValue={identityKey} showTickOnValid={false} sx={{ mb: 2 }} />
)}
<ModalListItem label="Rewards amount" value={` ${amount} ${denom.toUpperCase()}`} divider />
{fee && <FeeWarning amount={amount} fee={fee} />}
<ModalFee fee={fee} isLoading={isFeeLoading} error={feeError} divider />
<ModalListItem label="Rewards will be transferred to account you are logged in with now" value="" divider />
{fee && <FeeWarning amount={amount} fee={fee} />}
</SimpleModal>
);
};
@@ -1,7 +1,6 @@
import React from 'react';
import { CircularProgress, Stack, Typography } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { InfoTooltip } from '../InfoToolTip';
export const RewardsSummary: React.FC<{
isLoading?: boolean;
@@ -10,17 +9,15 @@ export const RewardsSummary: React.FC<{
}> = ({ isLoading, totalDelegation, totalRewards }) => {
const theme = useTheme();
return (
<Stack direction="row" justifyContent="space-between">
<Stack direction="row" justifyContent="space-between" alignItems="center">
<Stack direction="row" spacing={4}>
<Stack direction="row" spacing={1} alignItems="center">
<InfoTooltip title="This is the total amount you have delgated across multiple nodes" />
<Stack direction="row" spacing={2}>
<Typography>Total delegations:</Typography>
<Typography fontWeight={600} fontSize={16} textTransform="uppercase">
{isLoading ? <CircularProgress size={theme.typography.fontSize} /> : totalDelegation || '-'}
</Typography>
</Stack>
<Stack direction="row" spacing={1} alignItems="center">
<InfoTooltip title="Awaiting rewards accrue per epoch (hourly). You can redeem or compound them" />
<Stack direction="row" spacing={2}>
<Typography>New rewards:</Typography>
<Typography fontWeight={600} fontSize={16} textTransform="uppercase">
{isLoading ? <CircularProgress size={theme.typography.fontSize} /> : totalRewards || '-'}
@@ -56,7 +56,6 @@ export const SendInputModal = ({
backdropProps={backdropProps}
>
<Stack gap={2} sx={{ mt: 2 }}>
<ModalListItem label="Your address:" value={fromAddress} fontWeight="light" />
<TextField
placeholder="Recipient address"
fullWidth
@@ -77,8 +76,9 @@ export const SendInputModal = ({
{error}
</Typography>
</Stack>
<Stack gap={0.5} sx={{ mt: 1 }}>
<ModalListItem label="Account balance:" value={balance?.toUpperCase()} divider fontWeight={600} />
<Stack gap={0.5} sx={{ mt: 2 }}>
<ModalListItem label="Account balance:" value={balance?.toUpperCase()} divider strong />
<ModalListItem label="Your address:" value={fromAddress} divider />
<Typography fontSize="smaller" sx={{ color: 'text.primary' }}>
Est. fee for this transaction will be show on the next page
</Typography>
+1 -1
View File
@@ -4,7 +4,7 @@ import { Box, Typography } from '@mui/material';
export const Title: React.FC<{ title: string | React.ReactNode; Icon?: React.ReactNode }> = ({ title, Icon }) => (
<Box width="100%" display="flex" alignItems="center">
{Icon}
<Typography width="100%" variant="h5" sx={{ fontWeight: 600 }}>
<Typography width="100%" variant="h6" sx={{ fontWeight: 600 }}>
{title}
</Typography>
</Box>
+3 -3
View File
@@ -81,7 +81,6 @@ export const DelegationContextProvider: FC<{
};
const refresh = useCallback(async () => {
resetState();
setIsLoading(true);
try {
const data = await getDelegationSummary();
@@ -95,11 +94,12 @@ export const DelegationContextProvider: FC<{
setError((e as Error).message);
}
setIsLoading(false);
}, []);
}, [network]);
useEffect(() => {
resetState();
refresh();
}, []);
}, [network]);
const memoizedValue = useMemo(
() => ({
+12 -4
View File
@@ -1,4 +1,5 @@
import React, { createContext, FC, useContext, useEffect, useMemo, useState } from 'react';
import { Network } from 'src/types';
import { FeeDetails, TransactionExecuteResult } from '@nymproject/types';
import { useDelegationContext } from './delegations';
import { claimDelegatorRewards, compoundDelegatorRewards } from '../requests';
@@ -28,8 +29,11 @@ export const RewardsContext = createContext<TRewardsContext>({
},
});
export const RewardsContextProvider: FC<{}> = ({ children }) => {
export const RewardsContextProvider: FC<{
network?: Network;
}> = ({ network, children }) => {
const { isLoading, totalRewards, refresh } = useDelegationContext();
const [currentNetwork, setCurrentNetwork] = useState<undefined | Network>();
const [error, setError] = useState<string>();
const resetState = async () => {
@@ -37,8 +41,12 @@ export const RewardsContextProvider: FC<{}> = ({ children }) => {
};
useEffect(() => {
resetState();
}, []);
if (currentNetwork !== network) {
// reset state and refresh
resetState();
setCurrentNetwork(network);
}
}, [network]);
const memoizedValue = useMemo(
() => ({
@@ -52,7 +60,7 @@ export const RewardsContextProvider: FC<{}> = ({ children }) => {
throw new Error('Not implemented');
},
}),
[isLoading, error, totalRewards],
[isLoading, error, totalRewards, network],
);
return <RewardsContext.Provider value={memoizedValue}>{children}</RewardsContext.Provider>;
@@ -3,7 +3,7 @@ import React, { useContext } from 'react';
import { useTheme } from '@mui/material/styles';
import { Box, Tooltip, Typography } from '@mui/material';
import { format } from 'date-fns';
import { AppContext } from '../../../context';
import { AppContext } from '../../../context/main';
const calculateMarkerPosition = (arrLength: number, index: number) => (1 / arrLength) * 100 * index;
+2 -18
View File
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useState } from 'react';
import React, { useContext, useState } from 'react';
import { Box } from '@mui/material';
import { AppContext } from '../../context/main';
@@ -9,25 +9,9 @@ import { TransferModal } from './components/TransferModal';
export const Balance = () => {
const [showTransferModal, setShowTransferModal] = useState(false);
const [showVestingCard, setShowVestingCard] = useState(false);
const { userBalance } = useContext(AppContext);
useEffect(() => {
const { originalVesting, currentVestingPeriod, tokenAllocation } = userBalance;
if (
originalVesting &&
currentVestingPeriod === 'After' &&
tokenAllocation?.locked === '0' &&
tokenAllocation?.vesting === '0' &&
tokenAllocation?.spendable === '0'
) {
setShowVestingCard(false);
} else if (originalVesting) {
setShowVestingCard(true);
}
}, [userBalance]);
const handleShowTransferModal = async () => {
await userBalance.refreshBalances();
setShowTransferModal(true);
@@ -37,7 +21,7 @@ export const Balance = () => {
<PageLayout>
<Box display="flex" flexDirection="column" gap={2}>
<BalanceCard />
{showVestingCard && <VestingCard onTransfer={handleShowTransferModal} />}
<VestingCard onTransfer={handleShowTransferModal} />
{showTransferModal && <TransferModal onClose={() => setShowTransferModal(false)} />}
</Box>
</PageLayout>
+4 -4
View File
@@ -85,7 +85,7 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => {
useEffect(() => {
refresh();
}, [clientDetails, confirmationModalProps]);
}, [network, clientDetails, confirmationModalProps]);
const handleDelegationItemActionClick = (item: DelegationWithEverything, action: DelegationListItemActions) => {
if ((action === 'delegate' || action === 'compound') && item.stake_saturation && item.stake_saturation > 1) {
@@ -302,7 +302,7 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => {
noIcon
/>
</Box>
<Box display="flex" justifyContent="space-between" alignItems="end">
<Box display="flex" justifyContent="space-between" alignItems="center">
<RewardsSummary isLoading={isLoading} totalDelegation={totalDelegations} totalRewards={totalRewards} />
<Button
variant="contained"
@@ -427,8 +427,8 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => {
export const DelegationPage: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => {
const { network } = useContext(AppContext);
return (
<DelegationContextProvider>
<RewardsContextProvider>
<DelegationContextProvider network={network}>
<RewardsContextProvider network={network}>
<Delegation isStorybook={isStorybook} />
</RewardsContextProvider>
</DelegationContextProvider>
@@ -30,14 +30,18 @@ const DataField = ({ title, info, Indicator }: { title: string; info: string; In
);
const colorMap: { [key in SelectionChance]: string } = {
VeryLow: 'error.main',
Low: 'error.main',
Moderate: 'warning.main',
High: 'success.main',
VeryHigh: 'success.main',
};
const textMap: { [key in SelectionChance]: string } = {
VeryLow: 'Very low',
Low: 'Low',
Moderate: 'Moderate',
High: 'High',
VeryHigh: 'Very high',
};
@@ -3,7 +3,7 @@
[package]
name = "nym-network-requester"
version = "1.0.1"
version = "1.0.2"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
edition = "2021"
@@ -1,6 +1,6 @@
[package]
name = "nym-network-statistics"
version = "0.1.0"
version = "1.0.2"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -1 +1 @@
export type SelectionChance = 'VeryHigh' | 'Moderate' | 'Low';
export type SelectionChance = 'VeryHigh' | 'High' | 'Moderate' | 'Low' | 'VeryLow';
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-validator-api"
version = "1.0.1"
version = "1.0.2"
authors = [
"Dave Hrycyszyn <futurechimp@users.noreply.github.com>",
"Jędrzej Stuczyński <andrew@nymtech.net>",
+1 -1
View File
@@ -716,7 +716,7 @@ async fn verification_of_bandwidth_credential() {
let voucher_info = "voucher info";
let public_attributes = vec![
hash_to_scalar(voucher_value.to_string()),
hash_to_scalar(voucher_info),
hash_to_scalar(voucher_info.to_string()),
];
let theta = theta_from_keys_and_attributes(&params, &key_pairs, &public_attributes).unwrap();
let key_pair = key_pairs.remove(0);
+14 -2
View File
@@ -82,6 +82,18 @@ const REWARDING_MONITOR_THRESHOLD_ARG: &str = "monitor-threshold";
const MIN_MIXNODE_RELIABILITY_ARG: &str = "min_mixnode_reliability";
const MIN_GATEWAY_RELIABILITY_ARG: &str = "min_gateway_reliability";
#[cfg(feature = "coconut")]
fn parse_validators(raw: &str) -> Vec<url::Url> {
raw.split(',')
.map(|raw_validator| {
raw_validator
.trim()
.parse()
.expect("one of the provided validator api urls is invalid")
})
.collect()
}
fn long_version() -> String {
format!(
r#"
@@ -300,10 +312,10 @@ fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> Config {
#[cfg(feature = "coconut")]
if let Some(raw_validators) = matches.value_of(API_VALIDATORS_ARG) {
config = config.with_custom_validator_apis(::config::parse_validators(raw_validators));
config = config.with_custom_validator_apis(parse_validators(raw_validators));
} else if std::env::var(CONFIGURED).is_ok() {
let raw_validators = std::env::var(API_VALIDATOR).expect("api validator not set");
config = config.with_custom_validator_apis(::config::parse_validators(&raw_validators))
config = config.with_custom_validator_apis(parse_validators(&raw_validators))
}
if let Some(raw_validator) = matches.value_of(NYMD_VALIDATOR_ARG) {
@@ -101,16 +101,20 @@ pub type StakeSaturation = f32;
)]
pub enum SelectionChance {
VeryHigh,
High,
Moderate,
Low,
VeryLow,
}
impl From<f64> for SelectionChance {
fn from(p: f64) -> SelectionChance {
match p {
p if p > 0.15 => SelectionChance::VeryHigh,
p if p >= 0.05 => SelectionChance::Moderate,
_ => SelectionChance::Low,
p if p >= 1. => SelectionChance::VeryHigh,
p if p > 0.9 => SelectionChance::High,
p if p > 0.7 => SelectionChance::Moderate,
p if p > 0.5 => SelectionChance::Low,
_ => SelectionChance::VeryLow,
}
}
}
@@ -119,8 +123,10 @@ impl fmt::Display for SelectionChance {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SelectionChance::VeryHigh => write!(f, "VeryHigh"),
SelectionChance::High => write!(f, "High"),
SelectionChance::Moderate => write!(f, "Moderate"),
SelectionChance::Low => write!(f, "Low"),
SelectionChance::VeryLow => write!(f, "VeryLow"),
}
}
}