Compare commits

..

23 Commits

Author SHA1 Message Date
Gala 1dae3c3fc2 remove vAxis label 2022-08-16 14:08:00 +02:00
Gala 574e5cf10a change legend 2022-08-16 13:42:48 +02:00
Gala b3fcbb6726 remove log 2022-08-16 12:28:09 +02:00
Gala f96a60b6a2 log in staging 2022-08-16 12:10:17 +02:00
Gala f7b979825b Merge branch 'develop' into 340-ne-content 2022-08-10 16:44:02 +02:00
Raphaël Walther d080d661f7 Added audit workflow 2022-08-10 16:29:54 +02:00
Raphaël Walther 6deb481e5d Added audit workflow 2022-08-10 16:09:05 +02:00
Raphaël Walther 5b98e18a4e Added audit workflow 2022-08-10 16:03:11 +02:00
Raphaël Walther 506a0da89c Added audit workflow 2022-08-10 16:00:50 +02:00
Gala 6ac1259f7a changing content 2022-08-10 11:24:02 +02:00
Fouad f7d38a7ec6 modal style updates (#1508)
remove commented code

remove unused props

fix props
2022-08-10 10:14:48 +01:00
Pierre Dommerc 4459aca933 fix(wallet-delegation): add error feedback on wrong address (#1510)
* fix(wallet-delegation): add error feedback on wrong address

* fix(wallet-delegation): use generic component for modal error
2022-08-10 09:31:14 +01:00
Pierre Dommerc 5b84c58985 feat(wallet-balance): hide vesting ui when vesting balance is empty (#1505)
* feat(wallet-balance): hide vesting ui when vesting balance is empty

* refactor(wallet-balance): feedback review
2022-08-10 09:29:01 +01:00
Fouad 4301d91f6c Feature/wallet style updates (#1506)
* update buttons hover colours

* fix nymcard title size

* style updates for accounts!

* fix delegations page lock-up on network switch
2022-08-10 09:28:03 +01:00
Fouad 03d28c115e delegations page style updates (#1507) 2022-08-10 09:27:03 +01:00
Jędrzej Stuczyński de78ca8d9b Removed unnecessary to-owned conversion 2022-08-09 15:25:45 +01:00
Gala 58d09e382a Merge pull request #1504 from nymtech/smooth-filter-slider
Smooth filter slider
2022-08-09 14:59:11 +02:00
Gala 0cef12d05b Merge pull request #1502 from nymtech/1501-contrast-text
fixing text color
2022-08-09 14:58:07 +02:00
Jon Häggblad 30e73ee795 Explorer: tweak selection probability categories (#1503)
* validator-api: tweak SelectionChance

* wallet: update SelectionChance colorMap

* changelog: add note
2022-08-09 12:57:47 +02:00
Tommy Verrall d918b69664 Update .env.qa
Fix wrong denoms for the qa.env
2022-08-09 11:53:11 +01:00
Gala b3b8d2ab46 adding the value to the cursor 2022-08-08 17:03:05 +02:00
Gala 67130a1289 adding smooth prop 2022-08-08 16:30:10 +02:00
Gala e8e2f195e6 fixing text color 2022-08-08 14:09:33 +02:00
53 changed files with 242 additions and 259 deletions
+37
View File
@@ -0,0 +1,37 @@
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"
IS_SUCCESS: "${{ env.WORKFLOW_CONCLUSION == 'success' }}"
uses: docker://keybaseio/client:stable-node
with:
args: .github/workflows/support-files/notifications/entry_point.sh
@@ -45,4 +45,3 @@ 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,6 +52,7 @@ 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
@@ -79,6 +80,7 @@ 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.2"
version = "1.0.1"
dependencies = [
"clap 3.2.8",
"client-core",
@@ -3090,7 +3090,7 @@ dependencies = [
[[package]]
name = "nym-gateway"
version = "1.0.2"
version = "1.0.1"
dependencies = [
"anyhow",
"async-trait",
@@ -3138,7 +3138,7 @@ dependencies = [
[[package]]
name = "nym-mixnode"
version = "1.0.2"
version = "1.0.1"
dependencies = [
"anyhow",
"bs58",
@@ -3178,7 +3178,7 @@ dependencies = [
[[package]]
name = "nym-network-requester"
version = "1.0.2"
version = "1.0.1"
dependencies = [
"async-trait",
"clap 2.34.0",
@@ -3206,7 +3206,7 @@ dependencies = [
[[package]]
name = "nym-network-statistics"
version = "1.0.2"
version = "0.1.0"
dependencies = [
"dirs",
"log",
@@ -3222,7 +3222,7 @@ dependencies = [
[[package]]
name = "nym-socks5-client"
version = "1.0.2"
version = "1.0.1"
dependencies = [
"clap 3.2.8",
"client-core",
@@ -3283,7 +3283,7 @@ dependencies = [
[[package]]
name = "nym-validator-api"
version = "1.0.2"
version = "1.0.1"
dependencies = [
"anyhow",
"async-trait",
-1
View File
@@ -76,7 +76,6 @@ 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.2"
version = "1.0.1"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
description = "Implementation of the Nym Client"
edition = "2021"
+1 -1
View File
@@ -82,7 +82,7 @@ fn version_check(cfg: &Config) -> bool {
if binary_version == config_version {
true
} else {
warn!("The native-client binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
warn!("The mixnode 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.2"
version = "1.0.1"
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"
+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 = "https://mainnet-stats.nymte.ch:8090/";
pub(crate) const STATISTICS_SERVICE_DOMAIN_ADDRESS: &str = "http://127.0.0.1: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="https://mainnet-stats.nymte.ch:8090"
STATISTICS_SERVICE_DOMAIN_ADDRESS="http://127.0.0.1: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=unymt
CURRENCY_STAKING_DENOM=unyxt
CURRENCY_DENOM=unym
CURRENCY_STAKING_DENOM=unyx
+4 -2
View File
@@ -26,6 +26,7 @@ const FilterItem = ({
id,
tooltipInfo,
value,
isSmooth,
marks,
scale,
min,
@@ -40,9 +41,9 @@ const FilterItem = ({
<Slider
value={value}
onChange={(e: Event, newValue: number | number[]) => onChange(id, newValue as number[])}
valueLabelDisplay="off"
valueLabelDisplay={isSmooth ? 'auto' : 'off'}
marks={marks}
step={null}
step={isSmooth ? 1 : null}
scale={scale}
min={min}
max={max}
@@ -128,6 +129,7 @@ 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,6 +5,7 @@ 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 },
+5 -5
View File
@@ -8,7 +8,7 @@ import { ApiState, UptimeStoryResponse } from '../typeDefs/explorer-api';
interface ChartProps {
title?: string;
xLabel: string;
yLabel: string;
yLabel?: string;
uptimeStory: ApiState<UptimeStoryResponse>;
loading: boolean;
}
@@ -23,7 +23,7 @@ export const UptimeChart: React.FC<ChartProps> = ({ title, xLabel, yLabel, uptim
const color = theme.palette.text.primary;
React.useEffect(() => {
if (uptimeStory.data?.history) {
const allFormattedChartData: FormattedChartData = [['Date', 'Uptime']];
const allFormattedChartData: FormattedChartData = [['Date', 'Score']];
uptimeStory.data.history.forEach((eachDate) => {
const formattedDateUptimeRecord: FormattedDateRecord = [
format(new Date(eachDate.date), 'MMM dd'),
@@ -34,7 +34,7 @@ export const UptimeChart: React.FC<ChartProps> = ({ title, xLabel, yLabel, uptim
setFormattedChartData(allFormattedChartData);
} else {
const emptyData: any = [
['Date', 'Uptime'],
['Date', 'Score'],
['Jul 27', 10],
];
setFormattedChartData(emptyData);
@@ -55,7 +55,7 @@ export const UptimeChart: React.FC<ChartProps> = ({ title, xLabel, yLabel, uptim
uptimeStory.data
? formattedChartData
: [
['Date', 'Uptime'],
['Date', 'Routing Score'],
[format(new Date(Date.now()), 'MMM dd'), 0],
]
}
@@ -87,7 +87,7 @@ export const UptimeChart: React.FC<ChartProps> = ({ title, xLabel, yLabel, uptim
},
},
vAxis: {
// % uptime vertical
// vertical / % Routing Score
viewWindow: {
min: 0,
max: 100,
+3 -3
View File
@@ -137,9 +137,9 @@ const PageMixnodeDetailWithState: React.FC = () => {
</Grid>
<Grid item xs={12} md={8}>
{uptimeStory && (
<ContentCard title="Uptime story">
{uptimeStory.error && <ComponentError text="There was a problem retrieving uptime history." />}
<UptimeChart loading={uptimeStory.isLoading} xLabel="date" yLabel="uptime" uptimeStory={uptimeStory} />
<ContentCard title="Routing Score">
{uptimeStory.error && <ComponentError text="There was a problem retrieving routing score." />}
<UptimeChart loading={uptimeStory.isLoading} xLabel="date" uptimeStory={uptimeStory} />
</ContentCard>
)}
</Grid>
+1
View File
@@ -11,6 +11,7 @@ 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.2"
version = "1.0.1"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
description = "Implementation of the Nym Mixnet Gateway"
edition = "2021"
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-mixnode"
version = "1.0.2"
version = "1.0.1"
authors = [
"Dave Hrycyszyn <futurechimp@users.noreply.github.com>",
"Jędrzej Stuczyński <andrew@nymtech.net>",
@@ -1,8 +1,12 @@
import React from 'react';
import { Avatar } from '@mui/material';
import { Avatar, Typography } from '@mui/material';
import stc from 'string-to-color';
import { TAccount } from 'src/types';
export const AccountAvatar = ({ name }: Pick<TAccount, 'name'>) => (
<Avatar sx={{ bgcolor: stc(name), width: 20, height: 20 }}>{name?.split('')[0]}</Avatar>
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>
);
@@ -5,10 +5,10 @@ import { AccountAvatar } from './AccountAvatar';
export const AccountOverview = ({ account, onClick }: { account: AccountEntry; onClick: () => void }) => (
<Button
startIcon={<AccountAvatar name={account.id} />}
startIcon={<AccountAvatar name={account.id} small />}
sx={{ color: 'text.primary' }}
color="inherit"
onClick={onClick}
disableRipple
>
{account.id}
</Button>
@@ -9,6 +9,7 @@ import {
DialogTitle,
IconButton,
Typography,
Divider,
} from '@mui/material';
import { Add, ArrowDownwardSharp, Close } from '@mui/icons-material';
import { AccountsContext } from 'src/context';
@@ -51,7 +52,7 @@ export const AccountsModal = () => {
<Close />
</IconButton>
</Box>
<Typography variant="body1" sx={{ color: (theme) => theme.palette.text.disabled }}>
<Typography fontSize="small" sx={{ color: 'grey.600' }}>
Switch between accounts
</Typography>
</DialogTitle>
@@ -69,6 +70,7 @@ export const AccountsModal = () => {
/>
))}
</DialogContent>
<Divider variant="middle" sx={{ mt: 3 }} />
<DialogActions sx={{ p: 3 }}>
<Button startIcon={<ArrowDownwardSharp />} onClick={() => setDialogToDisplay('Import')}>
Import account
@@ -7,17 +7,16 @@ 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',
@@ -30,14 +29,15 @@ const importAccountSteps = [
'Confirm the password used to login to your wallet',
];
const MnemonicStep = ({ mnemonic, onNext }: { mnemonic: string; onNext: () => void }) => {
const MnemonicStep = ({ mnemonic, onNext, onBack }: { mnemonic: string; onNext: () => void; onBack: () => 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 }}>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
<StyledBackButton onBack={onBack} />
<Button disabled={!copied} fullWidth disableElevation variant="contained" size="large" onClick={onNext}>
I saved my mnemonic
</Button>
@@ -50,10 +50,12 @@ const ImportMnemonic = ({
value,
onChange,
onNext,
onBack,
}: {
value: string;
onChange: (value: string) => void;
onNext: () => void;
onBack: () => void;
}) => {
const [error, setError] = useState<string>();
@@ -77,7 +79,8 @@ const ImportMnemonic = ({
}}
/>
</DialogContent>
<DialogActions sx={{ p: 3, pt: 0 }}>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
<StyledBackButton onBack={onBack} />
<Button
disabled={value.length === 0}
fullWidth
@@ -93,7 +96,7 @@ const ImportMnemonic = ({
);
};
const NameAccount = ({ onNext }: { onNext: (value: string) => void }) => {
const NameAccount = ({ onNext, onBack }: { onNext: (value: string) => void; onBack: () => void }) => {
const [value, setValue] = useState('');
const [error, setError] = useState<string>();
@@ -121,7 +124,8 @@ const NameAccount = ({ onNext }: { onNext: (value: string) => void }) => {
fullWidth
/>
</DialogContent>
<DialogActions sx={{ p: 3, pt: 0 }}>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
<StyledBackButton onBack={onBack} />
<Button
disabled={!value.length}
fullWidth
@@ -178,9 +182,6 @@ 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]}
@@ -190,12 +191,17 @@ export const AddAccountModal = () => {
switch (step) {
case 0:
return dialogToDisplay === 'Add' ? (
<MnemonicStep mnemonic={data.mnemonic} onNext={() => setStep((s) => s + 1)} />
<MnemonicStep
mnemonic={data.mnemonic}
onNext={() => setStep((s) => s + 1)}
onBack={() => (step === 0 ? handleClose() : 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:
@@ -205,6 +211,7 @@ export const AddAccountModal = () => {
setData((d) => ({ ...d, accountName }));
setStep((s) => s + 1);
}}
onBack={() => setStep((s) => s - 1)}
/>
);
case 2:
@@ -222,6 +229,7 @@ export const AddAccountModal = () => {
}
}
}}
onCancel={() => setStep((s) => s - 1)}
isLoading={isLoading}
error={error}
/>
@@ -19,17 +19,18 @@ export const ConfirmPasswordModal = ({
<Dialog open={Boolean(accountName)} onClose={onClose} fullWidth>
<Paper>
<DialogTitle>
<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 }}>
<Typography variant="h6">Switch account</Typography>
<Typography fontSize="small" sx={{ color: 'grey.600' }}>
Confirm password
</Typography>
</DialogTitle>
<ConfirmPassword onConfirm={onConfirm} error={error} isLoading={isLoading} buttonTitle="Switch account" />
<ConfirmPassword
onConfirm={onConfirm}
error={error}
isLoading={isLoading}
buttonTitle="Switch account"
onCancel={onClose}
/>
</Paper>
</Dialog>
);
@@ -33,7 +33,7 @@ export const EditAccountModal = () => {
<Close />
</IconButton>
</Box>
<Typography variant="body1" sx={{ color: (theme) => theme.palette.text.disabled }}>
<Typography fontSize="small" sx={{ color: 'grey.600' }}>
New wallet address
</Typography>
</DialogTitle>
@@ -1,69 +0,0 @@
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,16 +2,19 @@ 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('');
@@ -39,7 +42,8 @@ export const ConfirmPassword = ({
disabled={isLoading}
/>
</DialogContent>
<DialogActions sx={{ p: 3, pt: 0 }}>
<DialogActions sx={{ p: 3, pt: 0, gap: 2 }}>
{onCancel && <StyledBackButton onBack={onCancel} />}
<Button
disabled={!value.length || isLoading}
fullWidth
@@ -13,12 +13,13 @@ 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;
@@ -62,7 +63,7 @@ export const DelegateModal: React.FC<{
const [tokenPool, setTokenPool] = useState<TPoolOption>('balance');
const [errorIdentityKey, setErrorIdentityKey] = useState<string>();
const { fee, getFee, resetFeeState } = useGetFee();
const { fee, getFee, resetFeeState, feeError } = useGetFee();
const handleCheckStakeSaturation = async (identity: string) => {
try {
@@ -174,6 +175,18 @@ 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}
@@ -193,7 +206,7 @@ export const DelegateModal: React.FC<{
<IdentityKeyFormField
required
fullWidth
placeholder="Node identity key"
label="Node identity key"
onChanged={handleIdentityKeyChanged}
initialValue={identityKey}
readOnly={Boolean(initialIdentityKey)}
@@ -215,7 +228,7 @@ export const DelegateModal: React.FC<{
<CurrencyFormField
required
fullWidth
placeholder="Amount"
label="Amount"
initialValue={amount}
autoFocus={Boolean(initialIdentityKey)}
onChanged={handleAmountChanged}
@@ -231,25 +244,25 @@ export const DelegateModal: React.FC<{
{errorAmount}
</Typography>
<Box sx={{ mt: 3 }}>
<ModalListItem label="Account balance:" value={accountBalance?.toUpperCase()} divider strong />
<ModalListItem label="Account balance" value={accountBalance?.toUpperCase()} divider fontWeight={600} />
</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 { Box, Button, Modal, Typography, SxProps, Stack } from '@mui/material';
import { 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,20 +48,9 @@ export const DelegationModal: React.FC<
if (status === 'error') {
return (
<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>
<ErrorModal message={message} sx={sx} open={open} onClose={onClose}>
{children}
</ErrorModal>
);
}
@@ -40,7 +40,6 @@ export const UndelegateModal: React.FC<{
onClose={onClose}
onOk={handleOk}
header="Undelegate"
subHeader="Undelegate from mixnode"
okLabel="Undelegate stake"
okDisabled={!fee}
sx={sx}
@@ -55,14 +54,10 @@ export const UndelegateModal: React.FC<{
/>
<Box sx={{ mt: 3 }}>
<ModalListItem label="Delegation amount:" value={`${amount} ${currency}`} divider />
<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 />
</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,15 +4,16 @@ import { modalStyle } from './styles';
export const ErrorModal: React.FC<{
open: boolean;
title?: string;
message?: string;
sx?: SxProps;
backdropProps?: object;
onClose: () => void;
}> = ({ children, open, message, sx, backdropProps, onClose }) => (
}> = ({ children, open, title, 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}>
Oh no! Something went wrong...
{title || '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,21 +1,25 @@
import React from 'react';
import { Box, Stack, Typography } from '@mui/material';
import { Box, Stack, Typography, TypographyProps } 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;
strong?: boolean;
fontWeight?: TypographyProps['fontWeight'];
light?: boolean;
value?: React.ReactNode;
}> = ({ label, value, hidden, divider, strong }) => (
}> = ({ label, value, hidden, fontWeight, divider }) => (
<Box sx={{ display: hidden ? 'none' : 'block' }}>
<Stack direction="row" justifyContent="space-between">
<Typography fontSize="smaller" fontWeight={strong ? 600 : undefined} sx={{ color: 'text.primary' }}>
<Typography fontSize="smaller" fontWeight={fontWeight} sx={{ color: 'text.primary' }}>
{label}
</Typography>
{value && (
<Typography fontSize="smaller" fontWeight={strong ? 600 : undefined} sx={{ color: 'text.primary' }}>
<Typography fontSize="smaller" fontWeight={fontWeight} sx={{ color: 'text.primary' }}>
{value}
</Typography>
)}
@@ -50,17 +50,16 @@ export const SimpleModal: React.FC<{
)}
{!hideCloseIcon && <CloseIcon onClick={onClose} cursor="pointer" />}
</Stack>
{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>
)}
<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="primary"
color="inherit"
sx={{ color: 'text.primary' }}
onClick={handleClick}
disableElevation
@@ -1,42 +1,33 @@
import React, { useContext } from 'react';
import { AppContext } from 'src/context';
import { Box, Stack, Typography, SxProps } from '@mui/material';
import { Box, Stack, Typography, SxProps, Dialog, DialogTitle, DialogContent } 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,
open,
sx,
backdropProps,
}: {
onClose: () => void;
open: boolean;
sx?: SxProps;
backdropProps?: object;
}) => {
export const ReceiveModal = ({ onClose }: { onClose: () => void; sx?: SxProps; backdropProps?: object }) => {
const { clientDetails } = useContext(AppContext);
return (
<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 }}>
<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 }}>
{clientDetails && <QRCode data-testid="qr-code" value={clientDetails?.client_address} />}
</Box>
</Stack>
</Stack>
</SimpleModal>
</DialogContent>
</Dialog>
);
};
+1 -2
View File
@@ -5,8 +5,7 @@ import { ReceiveModal } from './ReceiveModal';
export const Receive = ({ hasStorybookStyles }: { hasStorybookStyles?: {} }) => {
const { showReceiveModal, handleShowReceiveModal } = useContext(AppContext);
if (showReceiveModal)
return <ReceiveModal onClose={handleShowReceiveModal} open={showReceiveModal} {...hasStorybookStyles} />;
if (showReceiveModal) return <ReceiveModal onClose={handleShowReceiveModal} {...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,6 +1,7 @@
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;
@@ -9,15 +10,17 @@ export const RewardsSummary: React.FC<{
}> = ({ isLoading, totalDelegation, totalRewards }) => {
const theme = useTheme();
return (
<Stack direction="row" justifyContent="space-between" alignItems="center">
<Stack direction="row" justifyContent="space-between">
<Stack direction="row" spacing={4}>
<Stack direction="row" spacing={2}>
<Stack direction="row" spacing={1} alignItems="center">
<InfoTooltip title="This is the total amount you have delgated across multiple nodes" />
<Typography>Total delegations:</Typography>
<Typography fontWeight={600} fontSize={16} textTransform="uppercase">
{isLoading ? <CircularProgress size={theme.typography.fontSize} /> : totalDelegation || '-'}
</Typography>
</Stack>
<Stack direction="row" spacing={2}>
<Stack direction="row" spacing={1} alignItems="center">
<InfoTooltip title="Awaiting rewards accrue per epoch (hourly). You can redeem or compound them" />
<Typography>New rewards:</Typography>
<Typography fontWeight={600} fontSize={16} textTransform="uppercase">
{isLoading ? <CircularProgress size={theme.typography.fontSize} /> : totalRewards || '-'}
@@ -56,6 +56,7 @@ export const SendInputModal = ({
backdropProps={backdropProps}
>
<Stack gap={2} sx={{ mt: 2 }}>
<ModalListItem label="Your address:" value={fromAddress} fontWeight="light" />
<TextField
placeholder="Recipient address"
fullWidth
@@ -76,9 +77,8 @@ export const SendInputModal = ({
{error}
</Typography>
</Stack>
<Stack gap={0.5} sx={{ mt: 2 }}>
<ModalListItem label="Account balance:" value={balance?.toUpperCase()} divider strong />
<ModalListItem label="Your address:" value={fromAddress} divider />
<Stack gap={0.5} sx={{ mt: 1 }}>
<ModalListItem label="Account balance:" value={balance?.toUpperCase()} divider fontWeight={600} />
<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="h6" sx={{ fontWeight: 600 }}>
<Typography width="100%" variant="h5" sx={{ fontWeight: 600 }}>
{title}
</Typography>
</Box>
+3 -3
View File
@@ -81,6 +81,7 @@ export const DelegationContextProvider: FC<{
};
const refresh = useCallback(async () => {
resetState();
setIsLoading(true);
try {
const data = await getDelegationSummary();
@@ -94,12 +95,11 @@ export const DelegationContextProvider: FC<{
setError((e as Error).message);
}
setIsLoading(false);
}, [network]);
}, []);
useEffect(() => {
resetState();
refresh();
}, [network]);
}, []);
const memoizedValue = useMemo(
() => ({
+4 -12
View File
@@ -1,5 +1,4 @@
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';
@@ -29,11 +28,8 @@ export const RewardsContext = createContext<TRewardsContext>({
},
});
export const RewardsContextProvider: FC<{
network?: Network;
}> = ({ network, children }) => {
export const RewardsContextProvider: FC<{}> = ({ children }) => {
const { isLoading, totalRewards, refresh } = useDelegationContext();
const [currentNetwork, setCurrentNetwork] = useState<undefined | Network>();
const [error, setError] = useState<string>();
const resetState = async () => {
@@ -41,12 +37,8 @@ export const RewardsContextProvider: FC<{
};
useEffect(() => {
if (currentNetwork !== network) {
// reset state and refresh
resetState();
setCurrentNetwork(network);
}
}, [network]);
resetState();
}, []);
const memoizedValue = useMemo(
() => ({
@@ -60,7 +52,7 @@ export const RewardsContextProvider: FC<{
throw new Error('Not implemented');
},
}),
[isLoading, error, totalRewards, network],
[isLoading, error, totalRewards],
);
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/main';
import { AppContext } from '../../../context';
const calculateMarkerPosition = (arrLength: number, index: number) => (1 / arrLength) * 100 * index;
+18 -2
View File
@@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import { Box } from '@mui/material';
import { AppContext } from '../../context/main';
@@ -9,9 +9,25 @@ 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);
@@ -21,7 +37,7 @@ export const Balance = () => {
<PageLayout>
<Box display="flex" flexDirection="column" gap={2}>
<BalanceCard />
<VestingCard onTransfer={handleShowTransferModal} />
{showVestingCard && <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();
}, [network, clientDetails, confirmationModalProps]);
}, [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="center">
<Box display="flex" justifyContent="space-between" alignItems="end">
<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 network={network}>
<RewardsContextProvider network={network}>
<DelegationContextProvider>
<RewardsContextProvider>
<Delegation isStorybook={isStorybook} />
</RewardsContextProvider>
</DelegationContextProvider>
@@ -30,18 +30,14 @@ 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.2"
version = "1.0.1"
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 = "1.0.2"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -1 +1 @@
export type SelectionChance = 'VeryHigh' | 'High' | 'Moderate' | 'Low' | 'VeryLow';
export type SelectionChance = 'VeryHigh' | 'Moderate' | 'Low';
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-validator-api"
version = "1.0.2"
version = "1.0.1"
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.to_string()),
hash_to_scalar(voucher_info),
];
let theta = theta_from_keys_and_attributes(&params, &key_pairs, &public_attributes).unwrap();
let key_pair = key_pairs.remove(0);
@@ -101,20 +101,16 @@ 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 >= 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,
p if p > 0.15 => SelectionChance::VeryHigh,
p if p >= 0.05 => SelectionChance::Moderate,
_ => SelectionChance::Low,
}
}
}
@@ -123,10 +119,8 @@ 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"),
}
}
}