From 0eb859467ee24a67aef10029063d7845c5b1e124 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 15:09:44 +0200 Subject: [PATCH 01/67] adding a switch between networks --- explorer/src/api/constants.ts | 2 +- explorer/src/api/index.ts | 7 +++++++ explorer/src/components/Nav.tsx | 21 +++++++++++++++++++-- explorer/src/context/main.tsx | 11 +++++++++-- explorer/src/typeDefs/explorer-api.ts | 2 ++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/explorer/src/api/constants.ts b/explorer/src/api/constants.ts index 109586c0fd..442fd68ad1 100644 --- a/explorer/src/api/constants.ts +++ b/explorer/src/api/constants.ts @@ -1,7 +1,7 @@ // master APIs export const API_BASE_URL = process.env.EXPLORER_API_URL; export const VALIDATOR_API_BASE_URL = process.env.VALIDATOR_API_URL; -export const VALIDATOR_URL = process.env.VALIDATOR_URL; +export const { VALIDATOR_URL } = process.env; export const BIG_DIPPER = process.env.BIG_DIPPER_URL; // specific API routes diff --git a/explorer/src/api/index.ts b/explorer/src/api/index.ts index 5a9b40ef9a..02b4190a01 100644 --- a/explorer/src/api/index.ts +++ b/explorer/src/api/index.ts @@ -1,4 +1,5 @@ import { + API_BASE_URL, BLOCK_API, COUNTRY_DATA_API, GATEWAYS_API, @@ -25,6 +26,7 @@ import { SummaryOverviewResponse, UptimeStoryResponse, ValidatorsResponse, + Environment, } from '../typeDefs/explorer-api'; function getFromCache(key: string) { @@ -135,3 +137,8 @@ export class Api { static fetchUptimeStoryById = async (id: string): Promise => (await fetch(`${UPTIME_STORY_API}/${id}/history`)).json(); } + +export const getEnvironment = (): Environment => { + const matchEnv = (env: Environment) => API_BASE_URL?.toLocaleLowerCase().includes(env) && env; + return matchEnv('sandbox') || matchEnv('qa') || 'mainnet'; +}; diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index ab6c2d36c8..9b0d7f4f51 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { ExpandLess, ExpandMore, Menu } from '@mui/icons-material'; import { CSSObject, styled, Theme, useTheme } from '@mui/material/styles'; +import Button from '@mui/material/Button'; import MuiLink from '@mui/material/Link'; import Box from '@mui/material/Box'; import ListItem from '@mui/material/ListItem'; @@ -229,11 +230,18 @@ ExpandableButton.defaultProps = { }; export const Nav: React.FC = ({ children }) => { - const { updateNavState, navState } = useMainContext(); + const { updateNavState, navState, environment } = useMainContext(); const [drawerIsOpen, setDrawerToOpen] = React.useState(false); const [fixedOpen, setFixedOpen] = React.useState(false); const theme = useTheme(); + const explorerName = + `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; + + const switchNetworkText = environment === 'mainnet' ? 'Switch to Testnet' : 'Switch to Mainnet'; + const switchNetworkLink = + environment === 'mainnet' ? 'https://sandbox-explorer.nymtech.net' : 'https://explorer.nymtech.net'; + const setToActive = (id: number) => { updateNavState(id); }; @@ -297,8 +305,17 @@ export const Nav: React.FC = ({ children }) => { }} > - Network Explorer + {explorerName} + ; + environment?: Environment; } interface StateApi { @@ -47,6 +49,9 @@ export const MainContext = React.createContext({ export const useMainContext = (): React.ContextType => React.useContext(MainContext); export const MainContextProvider: React.FC = ({ children }) => { + // network explorer environment + const [environment, setEnvironment] = React.useState('mainnet'); + // light/dark mode const [mode, setMode] = React.useState('dark'); @@ -163,10 +168,12 @@ export const MainContextProvider: React.FC = ({ children }) => { React.useEffect(() => { Promise.all([fetchOverviewSummary(), fetchGateways(), fetchValidators(), fetchBlock(), fetchCountryData()]); + setEnvironment(getEnvironment()); }, []); const state = React.useMemo( () => ({ + environment, block, countryData, fetchMixnodes, @@ -181,7 +188,7 @@ export const MainContextProvider: React.FC = ({ children }) => { updateNavState, validators, }), - [block, countryData, gateways, globalError, mixnodes, mode, navState, summaryOverview, validators], + [environment, block, countryData, gateways, globalError, mixnodes, mode, navState, summaryOverview, validators], ); return {children}; diff --git a/explorer/src/typeDefs/explorer-api.ts b/explorer/src/typeDefs/explorer-api.ts index 3463f55d98..3cf3c42b41 100644 --- a/explorer/src/typeDefs/explorer-api.ts +++ b/explorer/src/typeDefs/explorer-api.ts @@ -222,3 +222,5 @@ export type MixNodeEconomicDynamicsStatsResponse = { estimated_delegators_reward: number; current_interval_uptime: number; }; + +export type Environment = 'mainnet' | 'sandbox' | 'qa'; From fd90175e87786f31efe24b6f402d0d1209aa22f1 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 15:43:42 +0200 Subject: [PATCH 02/67] adding button on mov nav and make it smaller --- explorer/src/components/MobileNav.tsx | 22 ++++++++++++++++++++-- explorer/src/components/Nav.tsx | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/explorer/src/components/MobileNav.tsx b/explorer/src/components/MobileNav.tsx index cab6e50e5b..313a9ae8ba 100644 --- a/explorer/src/components/MobileNav.tsx +++ b/explorer/src/components/MobileNav.tsx @@ -30,9 +30,16 @@ type MobileNavProps = { export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: MobileNavProps) => { const theme = useTheme(); - const { navState, updateNavState } = useMainContext(); + const { navState, updateNavState, environment } = useMainContext(); const [drawerOpen, setDrawerOpen] = React.useState(false); + const explorerName = + `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; + + const switchNetworkText = environment === 'mainnet' ? 'Switch to Testnet' : 'Switch to Mainnet'; + const switchNetworkLink = + environment === 'mainnet' ? 'https://sandbox-explorer.nymtech.net' : 'https://explorer.nymtech.net'; + const toggleDrawer = () => { setDrawerOpen(!drawerOpen); }; @@ -81,11 +88,22 @@ export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: fontSize: '18px', fontWeight: 600, ml: 2, + display: 'flex', + flexDirection: 'column', }} > - Network Explorer + {explorerName} + diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index 9b0d7f4f51..4b13edda46 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -308,11 +308,11 @@ export const Nav: React.FC = ({ children }) => { {explorerName} From 76773c58d7fe8fed97fafd23763e3b2ff7aa3cbd Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 16:34:30 +0200 Subject: [PATCH 03/67] some styles --- explorer/src/components/MobileNav.tsx | 13 +++++-------- explorer/src/components/Nav.tsx | 2 +- explorer/src/components/Switch.tsx | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/explorer/src/components/MobileNav.tsx b/explorer/src/components/MobileNav.tsx index 313a9ae8ba..16846c4b42 100644 --- a/explorer/src/components/MobileNav.tsx +++ b/explorer/src/components/MobileNav.tsx @@ -78,7 +78,7 @@ export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: }} > - + = ({ children }: color: theme.palette.nym.networkExplorer.nav.text, fontSize: '18px', fontWeight: 600, - ml: 2, - display: 'flex', - flexDirection: 'column', }} > - + {explorerName} - + - diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index 4b13edda46..5203e1df62 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -312,7 +312,7 @@ export const Nav: React.FC = ({ children }) => { variant="outlined" color="inherit" href={switchNetworkLink} - sx={{ textTransform: 'none', width: 150, ml: 4 }} + sx={{ borderRadius: 2, textTransform: 'none', width: 150, ml: 4, fontSize: 14, fontWeight: 600 }} > {switchNetworkText} diff --git a/explorer/src/components/Switch.tsx b/explorer/src/components/Switch.tsx index 835100a1db..25e76ccdfa 100644 --- a/explorer/src/components/Switch.tsx +++ b/explorer/src/components/Switch.tsx @@ -54,7 +54,7 @@ export const DarkLightSwitch = styled(Switch)(({ theme }) => ({ export const DarkLightSwitchMobile: React.FC = () => { const { toggleMode } = useMainContext(); return ( - ); From a74a99d81d1024e7ad9c0193dae753c58b92c847 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 16:38:56 +0200 Subject: [PATCH 04/67] cleaning --- explorer/src/components/UptimeChart.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/explorer/src/components/UptimeChart.tsx b/explorer/src/components/UptimeChart.tsx index 44490c1196..8d6c934775 100644 --- a/explorer/src/components/UptimeChart.tsx +++ b/explorer/src/components/UptimeChart.tsx @@ -23,7 +23,7 @@ export const UptimeChart: React.FC = ({ title, xLabel, yLabel, uptim const color = theme.palette.text.primary; React.useEffect(() => { if (uptimeStory.data?.history) { - const allFormattedChartData: FormattedChartData = [['Date', 'Routing Score']]; + const allFormattedChartData: FormattedChartData = [['Date', 'Uptime']]; uptimeStory.data.history.forEach((eachDate) => { const formattedDateUptimeRecord: FormattedDateRecord = [ format(new Date(eachDate.date), 'MMM dd'), @@ -34,7 +34,7 @@ export const UptimeChart: React.FC = ({ title, xLabel, yLabel, uptim setFormattedChartData(allFormattedChartData); } else { const emptyData: any = [ - ['Date', 'Routing Score'], + ['Date', 'Uptime'], ['Jul 27', 10], ]; setFormattedChartData(emptyData); @@ -55,7 +55,7 @@ export const UptimeChart: React.FC = ({ title, xLabel, yLabel, uptim uptimeStory.data ? formattedChartData : [ - ['Date', 'Routing Score'], + ['Date', 'Uptime'], [format(new Date(Date.now()), 'MMM dd'), 0], ] } From 89bcb5649bf7290af44f88b34b1091b9fe0dc0c6 Mon Sep 17 00:00:00 2001 From: farbanas Date: Tue, 6 Dec 2022 17:23:08 +0100 Subject: [PATCH 05/67] changed ubuntu-latest on GH actions to ubuntu-20.04 --- .github/workflows/audit.yml | 4 ++-- .github/workflows/build_matrix_includes.json | 2 +- .github/workflows/contracts-build.yml | 2 +- .github/workflows/contracts.yml | 4 ++-- .github/workflows/network-explorer-api.yml | 2 +- .github/workflows/nightly_build.yml | 8 ++++---- .github/workflows/nightly_build_matrix_includes.json | 6 +++--- .github/workflows/nightly_build_release.yml | 10 +++++----- .github/workflows/nightly_build_release2.yml | 10 +++++----- .github/workflows/nym-cli-publish.yml | 2 +- .github/workflows/nym-connect-publish-ubuntu.yml | 2 +- .github/workflows/nym-release-publish.yml | 2 +- .github/workflows/nym-wallet-publish-ubuntu.yml | 2 +- .github/workflows/nym-wallet-release.yml | 2 +- .github/workflows/nym_wallet.yml | 2 +- .github/workflows/support-files/nightly/index.js | 2 +- .github/workflows/wasm_client_build.yml | 2 +- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index f43a1feb77..00b13da72b 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -5,7 +5,7 @@ on: - cron: '5 9 * * *' jobs: cargo-deny: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout repository code uses: actions/checkout@v2 @@ -26,7 +26,7 @@ jobs: path: .github/workflows/support-files/notifications/deny.message notification: needs: cargo-deny - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Check out repository code uses: actions/checkout@v2 diff --git a/.github/workflows/build_matrix_includes.json b/.github/workflows/build_matrix_includes.json index a75ca76530..8d8f8297bc 100644 --- a/.github/workflows/build_matrix_includes.json +++ b/.github/workflows/build_matrix_includes.json @@ -1,6 +1,6 @@ [ { - "os":"ubuntu-latest", + "os":"ubuntu-20.04", "rust":"stable", "runOnEvent":"always" }, diff --git a/.github/workflows/contracts-build.yml b/.github/workflows/contracts-build.yml index 3921bd3a6d..9ecc6b49d9 100644 --- a/.github/workflows/contracts-build.yml +++ b/.github/workflows/contracts-build.yml @@ -6,7 +6,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 2c1eaf40b2..6d51356a80 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -10,7 +10,7 @@ on: jobs: matrix_prep: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: @@ -24,7 +24,7 @@ jobs: contracts: # since it's going to be compiled into wasm, there's absolutely # no point in running CI on different OS-es - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 continue-on-error: ${{ matrix.rust == 'nightly' }} needs: matrix_prep strategy: diff --git a/.github/workflows/network-explorer-api.yml b/.github/workflows/network-explorer-api.yml index 2ad184be72..5c60038347 100644 --- a/.github/workflows/network-explorer-api.yml +++ b/.github/workflows/network-explorer-api.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest] + platform: [ubuntu-20.04] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/nightly_build.yml b/.github/workflows/nightly_build.yml index 8475b83b8b..d103b66278 100644 --- a/.github/workflows/nightly_build.yml +++ b/.github/workflows/nightly_build.yml @@ -5,7 +5,7 @@ on: - cron: '14 1 * * *' jobs: matrix_prep: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: @@ -25,7 +25,7 @@ jobs: steps: - name: Install Dependencies (Linux) run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-20.04' - name: Check out repository code uses: actions/checkout@v2 @@ -96,7 +96,7 @@ jobs: - name: Reclaim some disk space uses: actions-rs/cargo@v1 - if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' }} + if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-20.04' }} with: command: clean @@ -160,7 +160,7 @@ jobs: notification: needs: build - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Collect jobs status uses: technote-space/workflow-conclusion-action@v2 diff --git a/.github/workflows/nightly_build_matrix_includes.json b/.github/workflows/nightly_build_matrix_includes.json index a979c90a62..172944df28 100644 --- a/.github/workflows/nightly_build_matrix_includes.json +++ b/.github/workflows/nightly_build_matrix_includes.json @@ -1,6 +1,6 @@ [ { - "os":"ubuntu-latest", + "os":"ubuntu-20.04", "rust":"stable", "runOnEvent":"schedule" }, @@ -17,7 +17,7 @@ }, { - "os":"ubuntu-latest", + "os":"ubuntu-20.04", "rust":"beta", "runOnEvent":"schedule" }, @@ -33,7 +33,7 @@ }, { - "os":"ubuntu-latest", + "os":"ubuntu-20.04", "rust":"nightly", "runOnEvent":"schedule" }, diff --git a/.github/workflows/nightly_build_release.yml b/.github/workflows/nightly_build_release.yml index 4474b399b6..7e99137607 100644 --- a/.github/workflows/nightly_build_release.yml +++ b/.github/workflows/nightly_build_release.yml @@ -5,7 +5,7 @@ on: - cron: '14 2 * * *' jobs: matrix_prep: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: @@ -17,7 +17,7 @@ jobs: inputFile: '.github/workflows/nightly_build_matrix_includes.json' filter: '[?runOnEvent==`${{ github.event_name }}` || runOnEvent==`always`]' get_release: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: matrix_prep outputs: output1: ${{ steps.step2.outputs.latest_release }} @@ -38,7 +38,7 @@ jobs: steps: - name: Install Dependencies (Linux) run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-20.04' - name: Check out latest release branch uses: actions/checkout@v3 @@ -111,7 +111,7 @@ jobs: - name: Reclaim some disk space uses: actions-rs/cargo@v1 - if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' }} + if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-20.04' }} with: command: clean @@ -175,7 +175,7 @@ jobs: notification: needs: [build,get_release] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Collect jobs status uses: technote-space/workflow-conclusion-action@v2 diff --git a/.github/workflows/nightly_build_release2.yml b/.github/workflows/nightly_build_release2.yml index 71f89948c9..4da0f2ea62 100644 --- a/.github/workflows/nightly_build_release2.yml +++ b/.github/workflows/nightly_build_release2.yml @@ -5,7 +5,7 @@ on: - cron: '24 2 * * *' jobs: matrix_prep: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: @@ -17,7 +17,7 @@ jobs: inputFile: '.github/workflows/nightly_build_matrix_includes.json' filter: '[?runOnEvent==`${{ github.event_name }}` || runOnEvent==`always`]' get_release: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: matrix_prep outputs: output1: ${{ steps.step2.outputs.latest_release }} @@ -38,7 +38,7 @@ jobs: steps: - name: Install Dependencies (Linux) run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-20.04' - name: Check out latest release branch uses: actions/checkout@v3 @@ -111,7 +111,7 @@ jobs: - name: Reclaim some disk space uses: actions-rs/cargo@v1 - if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' }} + if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-20.04' }} with: command: clean @@ -175,7 +175,7 @@ jobs: notification: needs: [build,get_release] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Collect jobs status uses: technote-space/workflow-conclusion-action@v2 diff --git a/.github/workflows/nym-cli-publish.yml b/.github/workflows/nym-cli-publish.yml index 065e9f1658..5fd532c68b 100644 --- a/.github/workflows/nym-cli-publish.yml +++ b/.github/workflows/nym-cli-publish.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest, windows-latest, macos-latest] + platform: [ubuntu-20.04, windows-latest, macos-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/nym-connect-publish-ubuntu.yml b/.github/workflows/nym-connect-publish-ubuntu.yml index 52c6ed9c5e..a4eb77cae1 100644 --- a/.github/workflows/nym-connect-publish-ubuntu.yml +++ b/.github/workflows/nym-connect-publish-ubuntu.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest] + platform: [ubuntu-20.04] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/nym-release-publish.yml b/.github/workflows/nym-release-publish.yml index 700f1d697f..979781652f 100644 --- a/.github/workflows/nym-release-publish.yml +++ b/.github/workflows/nym-release-publish.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest] + platform: [ubuntu-20.04] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/nym-wallet-publish-ubuntu.yml b/.github/workflows/nym-wallet-publish-ubuntu.yml index 46ed4be076..04ff746851 100644 --- a/.github/workflows/nym-wallet-publish-ubuntu.yml +++ b/.github/workflows/nym-wallet-publish-ubuntu.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest] + platform: [ubuntu-20.04] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/nym-wallet-release.yml b/.github/workflows/nym-wallet-release.yml index 4e157903e6..34883144f3 100644 --- a/.github/workflows/nym-wallet-release.yml +++ b/.github/workflows/nym-wallet-release.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest] + platform: [ubuntu-20.04] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/nym_wallet.yml b/.github/workflows/nym_wallet.yml index bbc981d0f4..49b2381ed0 100644 --- a/.github/workflows/nym_wallet.yml +++ b/.github/workflows/nym_wallet.yml @@ -12,7 +12,7 @@ defaults: jobs: test: name: wallet tests - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/support-files/nightly/index.js b/.github/workflows/support-files/nightly/index.js index f913539235..3bf2516092 100644 --- a/.github/workflows/support-files/nightly/index.js +++ b/.github/workflows/support-files/nightly/index.js @@ -85,7 +85,7 @@ async function getMessageBody(context) { ... ], check_run_url: 'https://api.github.com/repos/nymtech/nym/check-runs/5182940024', - labels: [ 'ubuntu-latest' ], + labels: [ 'ubuntu-20.04' ], runner_id: 1, runner_name: 'Hosted Agent', runner_group_id: 2, diff --git a/.github/workflows/wasm_client_build.yml b/.github/workflows/wasm_client_build.yml index 2761aabcd2..e1da3b04b0 100644 --- a/.github/workflows/wasm_client_build.yml +++ b/.github/workflows/wasm_client_build.yml @@ -7,7 +7,7 @@ on: jobs: wasm: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 From f4711902bd9b0dcf788d4bf03fcb865a0232a0a7 Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Thu, 15 Dec 2022 11:11:53 +0000 Subject: [PATCH 06/67] display service info in tooltip trim provider address --- .../src/components/ConnectionStatus.tsx | 27 ++++++++++--------- .../src/components/ServiceProviderInfo.tsx | 20 ++++++++++++++ nym-connect/src/layouts/ConnectedLayout.tsx | 8 +++--- 3 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 nym-connect/src/components/ServiceProviderInfo.tsx diff --git a/nym-connect/src/components/ConnectionStatus.tsx b/nym-connect/src/components/ConnectionStatus.tsx index c2bfcc82f0..2f9b856c02 100644 --- a/nym-connect/src/components/ConnectionStatus.tsx +++ b/nym-connect/src/components/ConnectionStatus.tsx @@ -1,8 +1,9 @@ import React from 'react'; -import { Box, CircularProgress, Typography } from '@mui/material'; +import { Box, CircularProgress, Divider, Stack, Tooltip, Typography } from '@mui/material'; import { DateTime } from 'luxon'; import { ConnectionStatusKind } from '../types'; import { ServiceProvider } from '../types/directory'; +import { ServiceProviderInfo } from './ServiceProviderInfo'; const FONT_SIZE = '10px'; const FONT_WEIGHT = '600'; @@ -14,8 +15,8 @@ const ConnectionStatusContent: React.FC<{ switch (status) { case ConnectionStatusKind.connected: return ( - - Connected + + Connected to ); case ConnectionStatusKind.disconnecting: @@ -44,7 +45,7 @@ const ConnectionStatusContent: React.FC<{ ml={1} textTransform="uppercase" textAlign="center" - fontSize="10px" + fontSize={FONT_SIZE} sx={{ wordSpacing: 3, letterSpacing: 2 }} > You are not protected @@ -59,7 +60,9 @@ export const ConnectionStatus: React.FC<{ status: ConnectionStatusKind; connectedSince?: DateTime; serviceProvider?: ServiceProvider; -}> = ({ status, connectedSince, serviceProvider }) => { +}> = ({ status, serviceProvider }) => { + console.log(serviceProvider); + const color = status === ConnectionStatusKind.connected || status === ConnectionStatusKind.disconnecting ? '#21D072' @@ -70,13 +73,13 @@ export const ConnectionStatus: React.FC<{ - - {serviceProvider && ( - - To {serviceProvider.description} - - )} - + {serviceProvider ? ( + }> + + {serviceProvider && {serviceProvider.description}} + + + ) : null} ); }; diff --git a/nym-connect/src/components/ServiceProviderInfo.tsx b/nym-connect/src/components/ServiceProviderInfo.tsx new file mode 100644 index 0000000000..a6289b5c41 --- /dev/null +++ b/nym-connect/src/components/ServiceProviderInfo.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import { Divider, Stack, Typography } from '@mui/material'; +import { ServiceProvider } from 'src/types/directory'; + +export const ServiceProviderInfo = ({ serviceProvider }: { serviceProvider: ServiceProvider }) => ( + + + Connection info + + {serviceProvider.description} + + + Gateway {serviceProvider.gateway} + + + + Provider {serviceProvider.address.slice(0, 35)}... + + +); diff --git a/nym-connect/src/layouts/ConnectedLayout.tsx b/nym-connect/src/layouts/ConnectedLayout.tsx index 0bf61fd4c0..9cf37b9f12 100644 --- a/nym-connect/src/layouts/ConnectedLayout.tsx +++ b/nym-connect/src/layouts/ConnectedLayout.tsx @@ -37,11 +37,13 @@ export const ConnectedLayout: React.FC<{ }) => ( <> - + - - + + + + {/* */} From 14847d01b7b3793c486ed71068deebde555a5be2 Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Thu, 15 Dec 2022 17:10:47 +0000 Subject: [PATCH 07/67] remove console.log --- nym-connect/src/components/ConnectionStatus.tsx | 2 -- nym-connect/src/context/main.tsx | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nym-connect/src/components/ConnectionStatus.tsx b/nym-connect/src/components/ConnectionStatus.tsx index 2f9b856c02..c2f9add9ad 100644 --- a/nym-connect/src/components/ConnectionStatus.tsx +++ b/nym-connect/src/components/ConnectionStatus.tsx @@ -61,8 +61,6 @@ export const ConnectionStatus: React.FC<{ connectedSince?: DateTime; serviceProvider?: ServiceProvider; }> = ({ status, serviceProvider }) => { - console.log(serviceProvider); - const color = status === ConnectionStatusKind.connected || status === ConnectionStatusKind.disconnecting ? '#21D072' diff --git a/nym-connect/src/context/main.tsx b/nym-connect/src/context/main.tsx index 17b627c823..3258978ff8 100644 --- a/nym-connect/src/context/main.tsx +++ b/nym-connect/src/context/main.tsx @@ -86,6 +86,8 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode .catch((e) => console.log(e)); listen('socks5-event', (e: TauriEvent) => { + console.log(e); + setError(e.payload); }).then((result) => { unlisten.push(result); From f0d66fdd888f93e19e4e79a78a2c01e20b7decc4 Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Fri, 16 Dec 2022 10:20:04 +0000 Subject: [PATCH 08/67] add epoch info to unbond modal --- .../Bonding/modals/ConfirmationModal.tsx | 3 ++ .../bonding/node-settings/NodeSettings.tsx | 12 +++++-- .../general-settings/ParametersSettings.tsx | 28 +++-------------- nym-wallet/src/utils/index.ts | 31 ++++++++++++++++++- 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/nym-wallet/src/components/Bonding/modals/ConfirmationModal.tsx b/nym-wallet/src/components/Bonding/modals/ConfirmationModal.tsx index 9a3c683b55..53439a8e8c 100644 --- a/nym-wallet/src/components/Bonding/modals/ConfirmationModal.tsx +++ b/nym-wallet/src/components/Bonding/modals/ConfirmationModal.tsx @@ -14,6 +14,7 @@ export type ConfirmationDetailProps = { export const ConfirmationDetailsModal = ({ title, subtitle, + children, txUrl, status, onClose, @@ -23,6 +24,7 @@ export const ConfirmationDetailsModal = ({ onClose: () => void; sx?: SxProps; backdropProps?: object; + children?: React.ReactNode; }) => { if (status === 'error') { ; @@ -45,6 +47,7 @@ export const ConfirmationDetailsModal = ({ {title} {subtitle} + {children} {txUrl && } diff --git a/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx index 798993dc49..2a9ef67f13 100644 --- a/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/NodeSettings.tsx @@ -18,6 +18,7 @@ import { NodeUnbondPage } from './settings-pages/NodeUnbondPage'; import { createNavItems } from './node-settings.constant'; import { isMixnode } from 'src/types'; import { ApyPlayground } from './apy-playground'; +import { getIntervalAsDate } from 'src/utils'; export const NodeSettings = () => { const theme = useTheme(); @@ -26,7 +27,7 @@ export const NodeSettings = () => { const navigate = useNavigate(); const location = useLocation(); - const [confirmationDetails, setConfirmationDetails] = useState(); + const [confirmationDetails, setConfirmationDetails] = useState(); const [value, setValue] = React.useState('General'); const handleChange = (event: React.SyntheticEvent, tab: string) => { setValue(tab); @@ -40,9 +41,11 @@ export const NodeSettings = () => { const handleUnbond = async (fee?: FeeDetails) => { const tx = await unbond(fee); + const { nextEpoch } = await getIntervalAsDate(); setConfirmationDetails({ status: 'success', title: 'Unbond successful', + subtitle: `This operation will complete when the new epoch starts at: ${nextEpoch}`, txUrl: `${urls(network).blockExplorer}/transaction/${tx?.transaction_hash}`, }); }; @@ -135,7 +138,12 @@ export const NodeSettings = () => { setConfirmationDetails(undefined); navigate('/bonding'); }} - /> + > + + You should NOT shutdown your {isMixnode(bondedNode) ? 'mix node' : 'gateway'} until the unbond process is + complete + + )} diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index 7aa7407a48..c5a8437e2a 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -18,7 +18,6 @@ import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField' import { add, format, fromUnixTime } from 'date-fns'; import { isMixnode } from 'src/types'; import { - getCurrentInterval, getPendingIntervalEvents, simulateUpdateMixnodeCostParams, simulateVestingUpdateMixnodeCostParams, @@ -35,6 +34,7 @@ import { AppContext } from 'src/context'; import { useGetFee } from 'src/hooks/useGetFee'; import { ConfirmTx } from 'src/components/ConfirmTX'; import { LoadingModal } from 'src/components/Modals/LoadingModal'; +import { getIntervalAsDate } from 'src/utils'; export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }): JSX.Element => { const [openConfirmationModal, setOpenConfirmationModal] = useState(false); @@ -63,27 +63,9 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode defaultValues, }); - const getIntervalAsDate = async () => { - const interval = await getCurrentInterval(); - const secondsToNextInterval = - Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); - - setIntervalTime( - format( - add(new Date(), { - seconds: secondsToNextInterval, - }), - 'MM/dd/yyyy HH:mm', - ), - ); - setNextEpoch( - format( - add(fromUnixTime(Number(interval.current_epoch_start_unix)), { - seconds: Number(interval.epoch_length_seconds), - }), - 'HH:mm', - ), - ); + const getCurrentInterval = async () => { + const { nextEpoch } = await getIntervalAsDate(); + setNextEpoch(nextEpoch); }; const getPendingEvents = async () => { @@ -107,7 +89,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }; useEffect(() => { - getIntervalAsDate(); + getCurrentInterval(); getPendingEvents(); }, []); diff --git a/nym-wallet/src/utils/index.ts b/nym-wallet/src/utils/index.ts index 49d56c6f72..10cae9455a 100644 --- a/nym-wallet/src/utils/index.ts +++ b/nym-wallet/src/utils/index.ts @@ -2,9 +2,16 @@ import { appWindow } from '@tauri-apps/api/window'; import bs58 from 'bs58'; import Big from 'big.js'; import { valid } from 'semver'; +import { add, format, fromUnixTime } from 'date-fns'; import { isValidRawCoin, DecCoin, MixNodeCostParams } from '@nymproject/types'; import { TPoolOption } from 'src/components'; -import { getDefaultMixnodeCostParams, getLockedCoins, getSpendableCoins, userBalance } from '../requests'; +import { + getCurrentInterval, + getDefaultMixnodeCostParams, + getLockedCoins, + getSpendableCoins, + userBalance, +} from '../requests'; import { Console } from './console'; export const validateKey = (key: string, bytesLength: number): boolean => { @@ -198,3 +205,25 @@ export const unymToNym = (unym: string | Big, dp = 4) => { } return nym; }; + +export const getIntervalAsDate = async () => { + const interval = await getCurrentInterval(); + const secondsToNextInterval = + Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); + + const nextInterval = format( + add(new Date(), { + seconds: secondsToNextInterval, + }), + 'MM/dd/yyyy HH:mm', + ); + + const nextEpoch = format( + add(fromUnixTime(Number(interval.current_epoch_start_unix)), { + seconds: Number(interval.epoch_length_seconds), + }), + 'HH:mm', + ); + + return { nextEpoch, nextInterval }; +}; From c509555d15dc7c11ccffcf6e10c3ffdf72fa380e Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Fri, 16 Dec 2022 10:33:14 +0000 Subject: [PATCH 09/67] fix param input layout --- .../settings-pages/general-settings/ParametersSettings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index 7aa7407a48..45216a7137 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -223,7 +223,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode Changes to cost will be applied in the next interval. - + Date: Thu, 15 Dec 2022 14:18:01 +0100 Subject: [PATCH 10/67] bond table changes --- .../src/components/Bonding/BondedMixnode.tsx | 70 +++++++++++++------ nym-wallet/src/components/IdentityKey.tsx | 18 ++--- .../general-settings/ParametersSettings.tsx | 34 +++------ nym-wallet/src/utils/index.ts | 2 + nym-wallet/src/utils/nextEpoch.ts | 23 ++++++ 5 files changed, 92 insertions(+), 55 deletions(-) create mode 100644 nym-wallet/src/utils/nextEpoch.ts diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 6ff0151b29..69b37b64f5 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Box, Button, Chip, Stack, Tooltip, Typography } from '@mui/material'; import { Link } from '@nymproject/react/link/Link'; @@ -11,6 +11,9 @@ import { Node as NodeIcon } from '../../svg-icons/node'; import { Cell, Header, NodeTable } from './NodeTable'; import { BondedMixnodeActions, TBondedMixnodeActions } from './BondedMixnodeActions'; import { NodeStats } from './NodeStats'; +import { getIntervalAsDate } from 'src/utils'; + +const textWhenNotName = 'This node has not yet set a name'; const headers: Header[] = [ { @@ -63,6 +66,7 @@ export const BondedMixnode = ({ network?: Network; onActionSelect: (action: TBondedMixnodeActions) => void; }) => { + const [nextEpoch, setNextEpoch] = useState(); const navigate = useNavigate(); const { name, @@ -78,6 +82,15 @@ export const BondedMixnode = ({ identityKey, host, } = mixnode; + + const getNextInterval = async () => { + try { + const { nextEpoch } = await getIntervalAsDate(); + setNextEpoch(nextEpoch); + } catch { + setNextEpoch(Error()); + } + }; const cells: Cell[] = [ { cell: `${stake.amount} ${stake.denom}`, @@ -121,6 +134,10 @@ export const BondedMixnode = ({ }, ]; + useEffect(() => { + getNextInterval(); + }, []); + return ( - {name && ( - - - {name} - - + {name?.includes(textWhenNotName) ? null : ( + + {name} + )} - + } Action={ - isMixnode(mixnode) && ( - - - - - - ) + + {isMixnode(mixnode) && ( + + + + + + )} + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} + } > diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index bca08ab68c..372a6bf40d 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,13 +1,15 @@ import React from 'react'; -import { Stack, Typography } from '@mui/material'; +import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - - - {splice(6, identityKey)} - - - +export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( + + + + {splice(6, identityKey)} + + + + ); diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index 7aa7407a48..ba98640ddb 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -15,10 +15,8 @@ import { import { useTheme } from '@mui/material/styles'; import { CurrencyDenom, MixNodeCostParams } from '@nymproject/types'; import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField'; -import { add, format, fromUnixTime } from 'date-fns'; import { isMixnode } from 'src/types'; import { - getCurrentInterval, getPendingIntervalEvents, simulateUpdateMixnodeCostParams, simulateVestingUpdateMixnodeCostParams, @@ -29,6 +27,7 @@ import { TBondedMixnode } from 'src/context/bonding'; import { SimpleModal } from 'src/components/Modals/SimpleModal'; import { bondedNodeParametersValidationSchema } from 'src/components/Bonding/forms/mixnodeValidationSchema'; import { Console } from 'src/utils/console'; +import { getIntervalAsDate } from 'src/utils'; import { Alert } from 'src/components/Alert'; import { ChangeMixCostParams } from 'src/pages/bonding/types'; import { AppContext } from 'src/context'; @@ -63,27 +62,14 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode defaultValues, }); - const getIntervalAsDate = async () => { - const interval = await getCurrentInterval(); - const secondsToNextInterval = - Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); - - setIntervalTime( - format( - add(new Date(), { - seconds: secondsToNextInterval, - }), - 'MM/dd/yyyy HH:mm', - ), - ); - setNextEpoch( - format( - add(fromUnixTime(Number(interval.current_epoch_start_unix)), { - seconds: Number(interval.epoch_length_seconds), - }), - 'HH:mm', - ), - ); + const getNextInterval = async () => { + try { + const { intervalTime, nextEpoch } = await getIntervalAsDate(); + setNextEpoch(nextEpoch); + setIntervalTime(intervalTime); + } catch { + console.log('cant retrieve next interval'); + } }; const getPendingEvents = async () => { @@ -107,7 +93,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }; useEffect(() => { - getIntervalAsDate(); + getNextInterval(); getPendingEvents(); }, []); diff --git a/nym-wallet/src/utils/index.ts b/nym-wallet/src/utils/index.ts index 49d56c6f72..7e8cdca1f5 100644 --- a/nym-wallet/src/utils/index.ts +++ b/nym-wallet/src/utils/index.ts @@ -7,6 +7,8 @@ import { TPoolOption } from 'src/components'; import { getDefaultMixnodeCostParams, getLockedCoins, getSpendableCoins, userBalance } from '../requests'; import { Console } from './console'; +export * from './nextEpoch'; + export const validateKey = (key: string, bytesLength: number): boolean => { // it must be a valid base58 key try { diff --git a/nym-wallet/src/utils/nextEpoch.ts b/nym-wallet/src/utils/nextEpoch.ts new file mode 100644 index 0000000000..799cf635fd --- /dev/null +++ b/nym-wallet/src/utils/nextEpoch.ts @@ -0,0 +1,23 @@ +import { getCurrentInterval } from 'src/requests'; +import { add, format, fromUnixTime } from 'date-fns'; + +export const getIntervalAsDate = async () => { + const interval = await getCurrentInterval(); + const secondsToNextInterval = + Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); + + const intervalTime = format( + add(new Date(), { + seconds: secondsToNextInterval, + }), + 'MM/dd/yyyy HH:mm', + ); + const nextEpoch = format( + add(fromUnixTime(Number(interval.current_epoch_start_unix)), { + seconds: Number(interval.epoch_length_seconds), + }), + 'HH:mm', + ); + + return { intervalTime, nextEpoch }; +}; \ No newline at end of file From 5ecb03ffe9bac434c46d628560375c0a8959dea6 Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 15 Dec 2022 15:22:44 +0100 Subject: [PATCH 11/67] removing epoch on settings and fixing divider position --- .../general-settings/ParametersSettings.tsx | 20 +++++++++++-------- nym-wallet/src/utils/nextEpoch.ts | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index ba98640ddb..4315ba0d94 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -38,7 +38,6 @@ import { LoadingModal } from 'src/components/Modals/LoadingModal'; export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }): JSX.Element => { const [openConfirmationModal, setOpenConfirmationModal] = useState(false); const [intervalTime, setIntervalTime] = useState(); - const [nextEpoch, setNextEpoch] = useState(); const [pendingUpdates, setPendingUpdates] = useState(); const { clientDetails } = useContext(AppContext); const theme = useTheme(); @@ -65,7 +64,6 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode const getNextInterval = async () => { try { const { intervalTime, nextEpoch } = await getIntervalAsDate(); - setNextEpoch(nextEpoch); setIntervalTime(intervalTime); } catch { console.log('cant retrieve next interval'); @@ -123,7 +121,16 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }; return ( - + {fee && ( - - {`Next epoch ${nextEpoch}`} - {`Next interval: ${intervalTime}`} } @@ -192,7 +196,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode )} - + @@ -235,7 +239,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode - + + + {!!delegations?.length && ( + + )} + + + + + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} + )} {delegationsComponent(delegations)} From 808802aeb4abf6ea86bb35eabe7205503f3f49a8 Mon Sep 17 00:00:00 2001 From: Gala Date: Fri, 16 Dec 2022 08:04:33 +0100 Subject: [PATCH 15/67] delegations layout and tooltip when delegate with vesting --- .../components/Delegation/DelegationItem.tsx | 20 +++--- nym-wallet/src/pages/delegation/index.tsx | 69 ++++++++++--------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index d800f9f487..8a3df8dc17 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,16 +28,20 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; + const usesVestingContractTokens = item.uses_vesting_contract_tokens; + + const tooltipText = () => { + if (nodeIsUnbonded) { + return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; + } else if (usesVestingContractTokens) { + return 'Delegation made with locked tockens'; + } else { + return ''; + } + }; return ( - + {nodeIsUnbonded ? ( diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 5f581dd967..8fb399c6a8 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -343,42 +343,45 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { <> - - Delegations - + + {' '} + + + Delegations + + {!!delegations?.length && ( + + )} + + {!!delegations?.length && ( + + )} + {!!delegations?.length && ( - - {!!delegations?.length && ( - - )} - - - - - {nextEpoch instanceof Error ? null : ( - - Next epoch starts at {nextEpoch} - - )} - + + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} )} {delegationsComponent(delegations)} From c66312ee968e3ebdf38ac51a8acbbf4488911950 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 10:37:04 +0100 Subject: [PATCH 16/67] refactor --- nym-wallet/src/components/Delegation/DelegationItem.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index 8a3df8dc17..1b4327621c 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,12 +28,11 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; - const usesVestingContractTokens = item.uses_vesting_contract_tokens; const tooltipText = () => { if (nodeIsUnbonded) { return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; - } else if (usesVestingContractTokens) { + } else if (item.uses_vesting_contract_tokens) { return 'Delegation made with locked tockens'; } else { return ''; From e6ecf71cc3e8f48aeaa7308be9396fe2f97d889a Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 10:52:29 +0100 Subject: [PATCH 17/67] refactor --- nym-wallet/src/components/Bonding/BondedMixnode.tsx | 2 +- nym-wallet/src/pages/delegation/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 69b37b64f5..92b4bdb965 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -66,7 +66,7 @@ export const BondedMixnode = ({ network?: Network; onActionSelect: (action: TBondedMixnodeActions) => void; }) => { - const [nextEpoch, setNextEpoch] = useState(); + const [nextEpoch, setNextEpoch] = useState(); const navigate = useNavigate(); const { name, diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 8fb399c6a8..50ac86b354 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -36,10 +36,9 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { const [confirmationModalProps, setConfirmationModalProps] = useState(); const [currentDelegationListActionItem, setCurrentDelegationListActionItem] = useState(); const [saturationError, setSaturationError] = useState<{ action: 'compound' | 'delegate'; saturation: string }>(); - const [nextEpoch, setNextEpoch] = useState(); + const [nextEpoch, setNextEpoch] = useState(); const theme = useTheme(); - const { clientDetails, network, From ccbf06f179ac04065fd7e034daff1bc298690847 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:23:39 +0100 Subject: [PATCH 18/67] refactor from PR request --- .../src/components/Bonding/BondedMixnode.tsx | 6 +++++- nym-wallet/src/components/IdentityKey.tsx | 16 +++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 92b4bdb965..ae32fdefba 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -155,7 +155,11 @@ export const BondedMixnode = ({ {name} )} - + + + + + } Action={ diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index 372a6bf40d..acf4019ce7 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -3,13 +3,11 @@ import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( - - - - {splice(6, identityKey)} - - - - +export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( + + + {splice(6, identityKey)} + + + ); From 6780d58a98da665e944d9170a831cbd4fcf6952a Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:27:35 +0100 Subject: [PATCH 19/67] cleaning --- nym-wallet/src/components/IdentityKey.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index acf4019ce7..bca08ab68c 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { Stack, Typography, Tooltip } from '@mui/material'; +import { Stack, Typography } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - + {splice(6, identityKey)} From 40e5595d655bf78da7f48f0c0a4aec6b12ae792a Mon Sep 17 00:00:00 2001 From: pierre Date: Wed, 21 Dec 2022 11:46:12 +0100 Subject: [PATCH 20/67] fix(explorer): set gateway bond 6 decimals --- explorer/src/components/DetailTable.tsx | 4 ++-- explorer/src/pages/Gateways/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/explorer/src/components/DetailTable.tsx b/explorer/src/components/DetailTable.tsx index 1aab097a05..75aaae36ab 100644 --- a/explorer/src/components/DetailTable.tsx +++ b/explorer/src/components/DetailTable.tsx @@ -5,7 +5,7 @@ import { Tooltip } from '@nymproject/react/tooltip/Tooltip'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { Box } from '@mui/system'; import { cellStyles } from './Universal-DataGrid'; -import { currencyToString } from '../utils/currency'; +import { unymToNym } from '../utils/currency'; import { GatewayEnrichedRowType } from './Gateways'; import { MixnodeRowType } from './MixNodes'; @@ -38,7 +38,7 @@ function formatCellValues(val: string | number, field: string) { ); } if (field === 'bond') { - return currencyToString(val.toString()); + return unymToNym(val, 6); } return val; } diff --git a/explorer/src/pages/Gateways/index.tsx b/explorer/src/pages/Gateways/index.tsx index 2430e4f9a5..6775270292 100644 --- a/explorer/src/pages/Gateways/index.tsx +++ b/explorer/src/pages/Gateways/index.tsx @@ -10,7 +10,7 @@ import { TableToolbar } from '../../components/TableToolbar'; import { CustomColumnHeading } from '../../components/CustomColumnHeading'; import { Title } from '../../components/Title'; import { cellStyles, UniversalDataGrid } from '../../components/Universal-DataGrid'; -import { currencyToString } from '../../utils/currency'; +import { unymToNym } from '../../utils/currency'; import { Tooltip } from '../../components/Tooltip'; import { BIG_DIPPER } from '../../api/constants'; import { splice } from '../../utils'; @@ -77,7 +77,7 @@ export const PageGateways: React.FC = () => { to={`/network-components/gateway/${params.row.identityKey}`} data-testid="pledge-amount" > - {currencyToString(params.value)} + {unymToNym(params.value, 6)} ), }, From 4d08d62fc25d919a3654ee8eeb83fb0ad24c6627 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 11:54:41 +0100 Subject: [PATCH 21/67] wip adding gt version --- explorer/src/components/Gateways.ts | 17 ++++++++++------- explorer/src/pages/Gateways/index.tsx | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/explorer/src/components/Gateways.ts b/explorer/src/components/Gateways.ts index e75c9aeb05..6e6d08b1f9 100644 --- a/explorer/src/components/Gateways.ts +++ b/explorer/src/components/Gateways.ts @@ -7,6 +7,7 @@ export type GatewayRowType = { bond: number; host: string; location: string; + version: string; }; export type GatewayEnrichedRowType = GatewayRowType & { @@ -20,13 +21,14 @@ export function gatewayToGridRow(arrayOfGateways: GatewayResponse): GatewayRowTy return !arrayOfGateways ? [] : arrayOfGateways.map((gw) => ({ - id: gw.owner, - owner: gw.owner, - identityKey: gw.gateway.identity_key || '', - location: gw?.gateway?.location || '', - bond: gw.pledge_amount.amount || 0, - host: gw.gateway.host || '', - })); + id: gw.owner, + owner: gw.owner, + identityKey: gw.gateway.identity_key || '', + location: gw?.gateway?.location || '', + bond: gw.pledge_amount.amount || 0, + host: gw.gateway.host || '', + version: gw.gateway.version || '', + })); } export function gatewayEnrichedToGridRow( @@ -40,6 +42,7 @@ export function gatewayEnrichedToGridRow( location: gateway?.gateway?.location || '', bond: gateway.pledge_amount.amount || 0, host: gateway.gateway.host || '', + version: gateway.gateway.version || '', clientsPort: gateway.gateway.clients_port || 0, mixPort: gateway.gateway.mix_port || 0, routingScore: `${report.most_recent}%`, diff --git a/explorer/src/pages/Gateways/index.tsx b/explorer/src/pages/Gateways/index.tsx index 2430e4f9a5..60fdf28bd5 100644 --- a/explorer/src/pages/Gateways/index.tsx +++ b/explorer/src/pages/Gateways/index.tsx @@ -27,6 +27,7 @@ export const PageGateways: React.FC = () => { React.useEffect(() => { if (searchTerm === '' && gateways?.data) { + console.log('gateways?.data', gateways?.data); setFilteredGateways(gateways?.data); } else { const filtered = gateways?.data?.filter((g) => { @@ -142,6 +143,25 @@ export const PageGateways: React.FC = () => { ), }, + , + { + field: 'version', + headerName: 'Version', + renderHeader: () => , + width: 150, + headerAlign: 'left', + headerClassName: 'MuiDataGrid-header-override', + renderCell: (params: GridRenderCellParams) => ( + + {params.value} + + ), + }, ]; const handlePageSize = (event: SelectChangeEvent) => { From 2d71caf50a10092870ac5754f4bb271bcff9a86c Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 15 Dec 2022 14:18:01 +0100 Subject: [PATCH 22/67] bond table changes --- .../src/components/Bonding/BondedMixnode.tsx | 70 +++++++++++++------ nym-wallet/src/components/IdentityKey.tsx | 18 ++--- .../general-settings/ParametersSettings.tsx | 34 +++------ nym-wallet/src/utils/index.ts | 2 + nym-wallet/src/utils/nextEpoch.ts | 23 ++++++ 5 files changed, 92 insertions(+), 55 deletions(-) create mode 100644 nym-wallet/src/utils/nextEpoch.ts diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 6ff0151b29..69b37b64f5 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Box, Button, Chip, Stack, Tooltip, Typography } from '@mui/material'; import { Link } from '@nymproject/react/link/Link'; @@ -11,6 +11,9 @@ import { Node as NodeIcon } from '../../svg-icons/node'; import { Cell, Header, NodeTable } from './NodeTable'; import { BondedMixnodeActions, TBondedMixnodeActions } from './BondedMixnodeActions'; import { NodeStats } from './NodeStats'; +import { getIntervalAsDate } from 'src/utils'; + +const textWhenNotName = 'This node has not yet set a name'; const headers: Header[] = [ { @@ -63,6 +66,7 @@ export const BondedMixnode = ({ network?: Network; onActionSelect: (action: TBondedMixnodeActions) => void; }) => { + const [nextEpoch, setNextEpoch] = useState(); const navigate = useNavigate(); const { name, @@ -78,6 +82,15 @@ export const BondedMixnode = ({ identityKey, host, } = mixnode; + + const getNextInterval = async () => { + try { + const { nextEpoch } = await getIntervalAsDate(); + setNextEpoch(nextEpoch); + } catch { + setNextEpoch(Error()); + } + }; const cells: Cell[] = [ { cell: `${stake.amount} ${stake.denom}`, @@ -121,6 +134,10 @@ export const BondedMixnode = ({ }, ]; + useEffect(() => { + getNextInterval(); + }, []); + return ( - {name && ( - - - {name} - - + {name?.includes(textWhenNotName) ? null : ( + + {name} + )} - + } Action={ - isMixnode(mixnode) && ( - - - - - - ) + + {isMixnode(mixnode) && ( + + + + + + )} + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} + } > diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index bca08ab68c..372a6bf40d 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,13 +1,15 @@ import React from 'react'; -import { Stack, Typography } from '@mui/material'; +import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - - - {splice(6, identityKey)} - - - +export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( + + + + {splice(6, identityKey)} + + + + ); diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index 7aa7407a48..ba98640ddb 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -15,10 +15,8 @@ import { import { useTheme } from '@mui/material/styles'; import { CurrencyDenom, MixNodeCostParams } from '@nymproject/types'; import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField'; -import { add, format, fromUnixTime } from 'date-fns'; import { isMixnode } from 'src/types'; import { - getCurrentInterval, getPendingIntervalEvents, simulateUpdateMixnodeCostParams, simulateVestingUpdateMixnodeCostParams, @@ -29,6 +27,7 @@ import { TBondedMixnode } from 'src/context/bonding'; import { SimpleModal } from 'src/components/Modals/SimpleModal'; import { bondedNodeParametersValidationSchema } from 'src/components/Bonding/forms/mixnodeValidationSchema'; import { Console } from 'src/utils/console'; +import { getIntervalAsDate } from 'src/utils'; import { Alert } from 'src/components/Alert'; import { ChangeMixCostParams } from 'src/pages/bonding/types'; import { AppContext } from 'src/context'; @@ -63,27 +62,14 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode defaultValues, }); - const getIntervalAsDate = async () => { - const interval = await getCurrentInterval(); - const secondsToNextInterval = - Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); - - setIntervalTime( - format( - add(new Date(), { - seconds: secondsToNextInterval, - }), - 'MM/dd/yyyy HH:mm', - ), - ); - setNextEpoch( - format( - add(fromUnixTime(Number(interval.current_epoch_start_unix)), { - seconds: Number(interval.epoch_length_seconds), - }), - 'HH:mm', - ), - ); + const getNextInterval = async () => { + try { + const { intervalTime, nextEpoch } = await getIntervalAsDate(); + setNextEpoch(nextEpoch); + setIntervalTime(intervalTime); + } catch { + console.log('cant retrieve next interval'); + } }; const getPendingEvents = async () => { @@ -107,7 +93,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }; useEffect(() => { - getIntervalAsDate(); + getNextInterval(); getPendingEvents(); }, []); diff --git a/nym-wallet/src/utils/index.ts b/nym-wallet/src/utils/index.ts index 49d56c6f72..7e8cdca1f5 100644 --- a/nym-wallet/src/utils/index.ts +++ b/nym-wallet/src/utils/index.ts @@ -7,6 +7,8 @@ import { TPoolOption } from 'src/components'; import { getDefaultMixnodeCostParams, getLockedCoins, getSpendableCoins, userBalance } from '../requests'; import { Console } from './console'; +export * from './nextEpoch'; + export const validateKey = (key: string, bytesLength: number): boolean => { // it must be a valid base58 key try { diff --git a/nym-wallet/src/utils/nextEpoch.ts b/nym-wallet/src/utils/nextEpoch.ts new file mode 100644 index 0000000000..799cf635fd --- /dev/null +++ b/nym-wallet/src/utils/nextEpoch.ts @@ -0,0 +1,23 @@ +import { getCurrentInterval } from 'src/requests'; +import { add, format, fromUnixTime } from 'date-fns'; + +export const getIntervalAsDate = async () => { + const interval = await getCurrentInterval(); + const secondsToNextInterval = + Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); + + const intervalTime = format( + add(new Date(), { + seconds: secondsToNextInterval, + }), + 'MM/dd/yyyy HH:mm', + ); + const nextEpoch = format( + add(fromUnixTime(Number(interval.current_epoch_start_unix)), { + seconds: Number(interval.epoch_length_seconds), + }), + 'HH:mm', + ); + + return { intervalTime, nextEpoch }; +}; \ No newline at end of file From a8ccd2ec171be556c94ae28e2b13bdfc5ffb3e28 Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 15 Dec 2022 15:22:44 +0100 Subject: [PATCH 23/67] removing epoch on settings and fixing divider position --- .../general-settings/ParametersSettings.tsx | 20 +++++++++++-------- nym-wallet/src/utils/nextEpoch.ts | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index ba98640ddb..4315ba0d94 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -38,7 +38,6 @@ import { LoadingModal } from 'src/components/Modals/LoadingModal'; export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }): JSX.Element => { const [openConfirmationModal, setOpenConfirmationModal] = useState(false); const [intervalTime, setIntervalTime] = useState(); - const [nextEpoch, setNextEpoch] = useState(); const [pendingUpdates, setPendingUpdates] = useState(); const { clientDetails } = useContext(AppContext); const theme = useTheme(); @@ -65,7 +64,6 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode const getNextInterval = async () => { try { const { intervalTime, nextEpoch } = await getIntervalAsDate(); - setNextEpoch(nextEpoch); setIntervalTime(intervalTime); } catch { console.log('cant retrieve next interval'); @@ -123,7 +121,16 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }; return ( - + {fee && ( - - {`Next epoch ${nextEpoch}`} - {`Next interval: ${intervalTime}`} } @@ -192,7 +196,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode )} - + @@ -235,7 +239,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode - + + + {!!delegations?.length && ( + + )} + + + + + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} + )} {delegationsComponent(delegations)} From f98cc73a1f548b3b314d95d036872a90eb1ed1fd Mon Sep 17 00:00:00 2001 From: Gala Date: Fri, 16 Dec 2022 08:04:33 +0100 Subject: [PATCH 27/67] delegations layout and tooltip when delegate with vesting --- .../components/Delegation/DelegationItem.tsx | 20 +++--- nym-wallet/src/pages/delegation/index.tsx | 69 ++++++++++--------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index d800f9f487..8a3df8dc17 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,16 +28,20 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; + const usesVestingContractTokens = item.uses_vesting_contract_tokens; + + const tooltipText = () => { + if (nodeIsUnbonded) { + return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; + } else if (usesVestingContractTokens) { + return 'Delegation made with locked tockens'; + } else { + return ''; + } + }; return ( - + {nodeIsUnbonded ? ( diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 5f581dd967..8fb399c6a8 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -343,42 +343,45 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { <> - - Delegations - + + {' '} + + + Delegations + + {!!delegations?.length && ( + + )} + + {!!delegations?.length && ( + + )} + {!!delegations?.length && ( - - {!!delegations?.length && ( - - )} - - - - - {nextEpoch instanceof Error ? null : ( - - Next epoch starts at {nextEpoch} - - )} - + + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} )} {delegationsComponent(delegations)} From 6e499e5996ca4212ddbeaa3497af497b95fab13e Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 10:37:04 +0100 Subject: [PATCH 28/67] refactor --- nym-wallet/src/components/Delegation/DelegationItem.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index 8a3df8dc17..1b4327621c 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,12 +28,11 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; - const usesVestingContractTokens = item.uses_vesting_contract_tokens; const tooltipText = () => { if (nodeIsUnbonded) { return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; - } else if (usesVestingContractTokens) { + } else if (item.uses_vesting_contract_tokens) { return 'Delegation made with locked tockens'; } else { return ''; From 11fd42e187b3dc215d454d53657910d6e23bb794 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 10:52:29 +0100 Subject: [PATCH 29/67] refactor --- nym-wallet/src/components/Bonding/BondedMixnode.tsx | 2 +- nym-wallet/src/pages/delegation/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 69b37b64f5..92b4bdb965 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -66,7 +66,7 @@ export const BondedMixnode = ({ network?: Network; onActionSelect: (action: TBondedMixnodeActions) => void; }) => { - const [nextEpoch, setNextEpoch] = useState(); + const [nextEpoch, setNextEpoch] = useState(); const navigate = useNavigate(); const { name, diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 8fb399c6a8..50ac86b354 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -36,10 +36,9 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { const [confirmationModalProps, setConfirmationModalProps] = useState(); const [currentDelegationListActionItem, setCurrentDelegationListActionItem] = useState(); const [saturationError, setSaturationError] = useState<{ action: 'compound' | 'delegate'; saturation: string }>(); - const [nextEpoch, setNextEpoch] = useState(); + const [nextEpoch, setNextEpoch] = useState(); const theme = useTheme(); - const { clientDetails, network, From 9a077a09282f9b5f647d582e6766561a98251197 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:23:39 +0100 Subject: [PATCH 30/67] refactor from PR request --- .../src/components/Bonding/BondedMixnode.tsx | 6 +++++- nym-wallet/src/components/IdentityKey.tsx | 16 +++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 92b4bdb965..ae32fdefba 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -155,7 +155,11 @@ export const BondedMixnode = ({ {name} )} - + + + + + } Action={ diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index 372a6bf40d..acf4019ce7 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -3,13 +3,11 @@ import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( - - - - {splice(6, identityKey)} - - - - +export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( + + + {splice(6, identityKey)} + + + ); From e6bcd706ff7c704d0f7a6be332e45af85ec062d4 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:27:35 +0100 Subject: [PATCH 31/67] cleaning --- nym-wallet/src/components/IdentityKey.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index acf4019ce7..bca08ab68c 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { Stack, Typography, Tooltip } from '@mui/material'; +import { Stack, Typography } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - + {splice(6, identityKey)} From 8aa15fa467966b14f3a795485dac95b627246823 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 12:41:12 +0100 Subject: [PATCH 32/67] fix parameters settings layout --- .../general-settings/ParametersSettings.tsx | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index e927a3eebc..f0922eb557 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -157,7 +157,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode {isMixnode(bondedNode) && ( - + - - - { - setValue('operatorCost', newValue, { shouldValidate: true, shouldDirty: true }); - }} - validationError={errors.operatorCost?.amount?.message} - denom={clientDetails?.display_mix_denom || 'nym'} - initialValue={defaultValues.operatorCost.amount} - /> - {pendingUpdates && ( - - Your last change to{' '} - - {pendingUpdates.interval_operating_cost.amount}{' '} - {pendingUpdates?.interval_operating_cost.denom.toUpperCase()}{' '} - - will be applied in the next interval - - )} - + + { + setValue('operatorCost', newValue, { shouldValidate: true, shouldDirty: true }); + }} + validationError={errors.operatorCost?.amount?.message} + denom={clientDetails?.display_mix_denom || 'nym'} + initialValue={defaultValues.operatorCost.amount} + /> + {pendingUpdates && ( + + Your last change to{' '} + + {pendingUpdates.interval_operating_cost.amount}{' '} + {pendingUpdates?.interval_operating_cost.denom.toUpperCase()}{' '} + + will be applied in the next interval + + )} From a14ae298ae7eb05216ab409b2fdb8c779363d617 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 13:59:23 +0100 Subject: [PATCH 33/67] sdding version number on the gateways list and details --- explorer/src/pages/GatewayDetail/index.tsx | 6 ++++++ explorer/src/pages/Gateways/index.tsx | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/explorer/src/pages/GatewayDetail/index.tsx b/explorer/src/pages/GatewayDetail/index.tsx index 5fb7dd9c9f..3372ded2a7 100644 --- a/explorer/src/pages/GatewayDetail/index.tsx +++ b/explorer/src/pages/GatewayDetail/index.tsx @@ -58,6 +58,12 @@ const columns: ColumnsType[] = [ headerAlign: 'left', flex: 1, }, + { + field: 'version', + title: 'Version', + headerAlign: 'left', + flex: 1, + }, ]; /** diff --git a/explorer/src/pages/Gateways/index.tsx b/explorer/src/pages/Gateways/index.tsx index 60fdf28bd5..2edfe62527 100644 --- a/explorer/src/pages/Gateways/index.tsx +++ b/explorer/src/pages/Gateways/index.tsx @@ -129,7 +129,7 @@ export const PageGateways: React.FC = () => { field: 'owner', headerName: 'Owner', renderHeader: () => , - width: 380, + width: 180, headerAlign: 'left', headerClassName: 'MuiDataGrid-header-override', renderCell: (params: GridRenderCellParams) => ( @@ -143,7 +143,6 @@ export const PageGateways: React.FC = () => { ), }, - , { field: 'version', headerName: 'Version', From 246decac4a96cae86cdc9955e02eedb5533178fc Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 14:01:53 +0100 Subject: [PATCH 34/67] remove console log --- explorer/src/pages/Gateways/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/explorer/src/pages/Gateways/index.tsx b/explorer/src/pages/Gateways/index.tsx index 2edfe62527..8e01fad54c 100644 --- a/explorer/src/pages/Gateways/index.tsx +++ b/explorer/src/pages/Gateways/index.tsx @@ -27,7 +27,6 @@ export const PageGateways: React.FC = () => { React.useEffect(() => { if (searchTerm === '' && gateways?.data) { - console.log('gateways?.data', gateways?.data); setFilteredGateways(gateways?.data); } else { const filtered = gateways?.data?.filter((g) => { From 06eff652dd25228d86a5c228f833174f69cd7197 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 11:54:41 +0100 Subject: [PATCH 35/67] wip adding gt version --- explorer/src/components/Gateways.ts | 17 ++++++++++------- explorer/src/pages/Gateways/index.tsx | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/explorer/src/components/Gateways.ts b/explorer/src/components/Gateways.ts index e75c9aeb05..6e6d08b1f9 100644 --- a/explorer/src/components/Gateways.ts +++ b/explorer/src/components/Gateways.ts @@ -7,6 +7,7 @@ export type GatewayRowType = { bond: number; host: string; location: string; + version: string; }; export type GatewayEnrichedRowType = GatewayRowType & { @@ -20,13 +21,14 @@ export function gatewayToGridRow(arrayOfGateways: GatewayResponse): GatewayRowTy return !arrayOfGateways ? [] : arrayOfGateways.map((gw) => ({ - id: gw.owner, - owner: gw.owner, - identityKey: gw.gateway.identity_key || '', - location: gw?.gateway?.location || '', - bond: gw.pledge_amount.amount || 0, - host: gw.gateway.host || '', - })); + id: gw.owner, + owner: gw.owner, + identityKey: gw.gateway.identity_key || '', + location: gw?.gateway?.location || '', + bond: gw.pledge_amount.amount || 0, + host: gw.gateway.host || '', + version: gw.gateway.version || '', + })); } export function gatewayEnrichedToGridRow( @@ -40,6 +42,7 @@ export function gatewayEnrichedToGridRow( location: gateway?.gateway?.location || '', bond: gateway.pledge_amount.amount || 0, host: gateway.gateway.host || '', + version: gateway.gateway.version || '', clientsPort: gateway.gateway.clients_port || 0, mixPort: gateway.gateway.mix_port || 0, routingScore: `${report.most_recent}%`, diff --git a/explorer/src/pages/Gateways/index.tsx b/explorer/src/pages/Gateways/index.tsx index 2430e4f9a5..60fdf28bd5 100644 --- a/explorer/src/pages/Gateways/index.tsx +++ b/explorer/src/pages/Gateways/index.tsx @@ -27,6 +27,7 @@ export const PageGateways: React.FC = () => { React.useEffect(() => { if (searchTerm === '' && gateways?.data) { + console.log('gateways?.data', gateways?.data); setFilteredGateways(gateways?.data); } else { const filtered = gateways?.data?.filter((g) => { @@ -142,6 +143,25 @@ export const PageGateways: React.FC = () => { ), }, + , + { + field: 'version', + headerName: 'Version', + renderHeader: () => , + width: 150, + headerAlign: 'left', + headerClassName: 'MuiDataGrid-header-override', + renderCell: (params: GridRenderCellParams) => ( + + {params.value} + + ), + }, ]; const handlePageSize = (event: SelectChangeEvent) => { From 57d3d6fd0fe9d5f94da89df50a16007e49fb93f7 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 13:59:23 +0100 Subject: [PATCH 36/67] sdding version number on the gateways list and details --- explorer/src/pages/GatewayDetail/index.tsx | 6 ++++++ explorer/src/pages/Gateways/index.tsx | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/explorer/src/pages/GatewayDetail/index.tsx b/explorer/src/pages/GatewayDetail/index.tsx index 5fb7dd9c9f..3372ded2a7 100644 --- a/explorer/src/pages/GatewayDetail/index.tsx +++ b/explorer/src/pages/GatewayDetail/index.tsx @@ -58,6 +58,12 @@ const columns: ColumnsType[] = [ headerAlign: 'left', flex: 1, }, + { + field: 'version', + title: 'Version', + headerAlign: 'left', + flex: 1, + }, ]; /** diff --git a/explorer/src/pages/Gateways/index.tsx b/explorer/src/pages/Gateways/index.tsx index 60fdf28bd5..2edfe62527 100644 --- a/explorer/src/pages/Gateways/index.tsx +++ b/explorer/src/pages/Gateways/index.tsx @@ -129,7 +129,7 @@ export const PageGateways: React.FC = () => { field: 'owner', headerName: 'Owner', renderHeader: () => , - width: 380, + width: 180, headerAlign: 'left', headerClassName: 'MuiDataGrid-header-override', renderCell: (params: GridRenderCellParams) => ( @@ -143,7 +143,6 @@ export const PageGateways: React.FC = () => { ), }, - , { field: 'version', headerName: 'Version', From bd20fd0b1f239323013574024796478e61a0671b Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 14:01:53 +0100 Subject: [PATCH 37/67] remove console log --- explorer/src/pages/Gateways/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/explorer/src/pages/Gateways/index.tsx b/explorer/src/pages/Gateways/index.tsx index 2edfe62527..8e01fad54c 100644 --- a/explorer/src/pages/Gateways/index.tsx +++ b/explorer/src/pages/Gateways/index.tsx @@ -27,7 +27,6 @@ export const PageGateways: React.FC = () => { React.useEffect(() => { if (searchTerm === '' && gateways?.data) { - console.log('gateways?.data', gateways?.data); setFilteredGateways(gateways?.data); } else { const filtered = gateways?.data?.filter((g) => { From e0f2fa670578ecdca00637002b12f45165baaa90 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 14:45:14 +0100 Subject: [PATCH 38/67] fix indentation --- explorer/src/components/Gateways.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/explorer/src/components/Gateways.ts b/explorer/src/components/Gateways.ts index 6e6d08b1f9..aa055a71d0 100644 --- a/explorer/src/components/Gateways.ts +++ b/explorer/src/components/Gateways.ts @@ -21,14 +21,14 @@ export function gatewayToGridRow(arrayOfGateways: GatewayResponse): GatewayRowTy return !arrayOfGateways ? [] : arrayOfGateways.map((gw) => ({ - id: gw.owner, - owner: gw.owner, - identityKey: gw.gateway.identity_key || '', - location: gw?.gateway?.location || '', - bond: gw.pledge_amount.amount || 0, - host: gw.gateway.host || '', - version: gw.gateway.version || '', - })); + id: gw.owner, + owner: gw.owner, + identityKey: gw.gateway.identity_key || '', + location: gw?.gateway?.location || '', + bond: gw.pledge_amount.amount || 0, + host: gw.gateway.host || '', + version: gw.gateway.version || '', + })); } export function gatewayEnrichedToGridRow( From 52699d75983259acb0f8144a82e15973cb7f2f6b Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 15 Dec 2022 14:18:01 +0100 Subject: [PATCH 39/67] bond table changes --- .../src/components/Bonding/BondedMixnode.tsx | 70 +++++++++++++------ nym-wallet/src/components/IdentityKey.tsx | 18 ++--- .../general-settings/ParametersSettings.tsx | 2 +- nym-wallet/src/utils/index.ts | 2 + nym-wallet/src/utils/nextEpoch.ts | 23 ++++++ 5 files changed, 83 insertions(+), 32 deletions(-) create mode 100644 nym-wallet/src/utils/nextEpoch.ts diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 6ff0151b29..69b37b64f5 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Box, Button, Chip, Stack, Tooltip, Typography } from '@mui/material'; import { Link } from '@nymproject/react/link/Link'; @@ -11,6 +11,9 @@ import { Node as NodeIcon } from '../../svg-icons/node'; import { Cell, Header, NodeTable } from './NodeTable'; import { BondedMixnodeActions, TBondedMixnodeActions } from './BondedMixnodeActions'; import { NodeStats } from './NodeStats'; +import { getIntervalAsDate } from 'src/utils'; + +const textWhenNotName = 'This node has not yet set a name'; const headers: Header[] = [ { @@ -63,6 +66,7 @@ export const BondedMixnode = ({ network?: Network; onActionSelect: (action: TBondedMixnodeActions) => void; }) => { + const [nextEpoch, setNextEpoch] = useState(); const navigate = useNavigate(); const { name, @@ -78,6 +82,15 @@ export const BondedMixnode = ({ identityKey, host, } = mixnode; + + const getNextInterval = async () => { + try { + const { nextEpoch } = await getIntervalAsDate(); + setNextEpoch(nextEpoch); + } catch { + setNextEpoch(Error()); + } + }; const cells: Cell[] = [ { cell: `${stake.amount} ${stake.denom}`, @@ -121,6 +134,10 @@ export const BondedMixnode = ({ }, ]; + useEffect(() => { + getNextInterval(); + }, []); + return ( - {name && ( - - - {name} - - + {name?.includes(textWhenNotName) ? null : ( + + {name} + )} - + } Action={ - isMixnode(mixnode) && ( - - - - - - ) + + {isMixnode(mixnode) && ( + + + + + + )} + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} + } > diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index bca08ab68c..372a6bf40d 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,13 +1,15 @@ import React from 'react'; -import { Stack, Typography } from '@mui/material'; +import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - - - {splice(6, identityKey)} - - - +export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( + + + + {splice(6, identityKey)} + + + + ); diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index ec9269981c..96829fadae 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -15,7 +15,6 @@ import { import { useTheme } from '@mui/material/styles'; import { CurrencyDenom, MixNodeCostParams } from '@nymproject/types'; import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField'; -import { add, format, fromUnixTime } from 'date-fns'; import { isMixnode } from 'src/types'; import { getPendingIntervalEvents, @@ -28,6 +27,7 @@ import { TBondedMixnode } from 'src/context/bonding'; import { SimpleModal } from 'src/components/Modals/SimpleModal'; import { bondedNodeParametersValidationSchema } from 'src/components/Bonding/forms/mixnodeValidationSchema'; import { Console } from 'src/utils/console'; +import { getIntervalAsDate } from 'src/utils'; import { Alert } from 'src/components/Alert'; import { ChangeMixCostParams } from 'src/pages/bonding/types'; import { AppContext } from 'src/context'; diff --git a/nym-wallet/src/utils/index.ts b/nym-wallet/src/utils/index.ts index 10cae9455a..a7674d185b 100644 --- a/nym-wallet/src/utils/index.ts +++ b/nym-wallet/src/utils/index.ts @@ -14,6 +14,8 @@ import { } from '../requests'; import { Console } from './console'; +export * from './nextEpoch'; + export const validateKey = (key: string, bytesLength: number): boolean => { // it must be a valid base58 key try { diff --git a/nym-wallet/src/utils/nextEpoch.ts b/nym-wallet/src/utils/nextEpoch.ts new file mode 100644 index 0000000000..799cf635fd --- /dev/null +++ b/nym-wallet/src/utils/nextEpoch.ts @@ -0,0 +1,23 @@ +import { getCurrentInterval } from 'src/requests'; +import { add, format, fromUnixTime } from 'date-fns'; + +export const getIntervalAsDate = async () => { + const interval = await getCurrentInterval(); + const secondsToNextInterval = + Number(interval.epochs_in_interval - interval.current_epoch_id) * Number(interval.epoch_length_seconds); + + const intervalTime = format( + add(new Date(), { + seconds: secondsToNextInterval, + }), + 'MM/dd/yyyy HH:mm', + ); + const nextEpoch = format( + add(fromUnixTime(Number(interval.current_epoch_start_unix)), { + seconds: Number(interval.epoch_length_seconds), + }), + 'HH:mm', + ); + + return { intervalTime, nextEpoch }; +}; \ No newline at end of file From 11b1089d83707a265e724a1acac83aae6dd847dd Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 15 Dec 2022 15:22:44 +0100 Subject: [PATCH 40/67] removing epoch on settings and fixing divider position --- .../general-settings/ParametersSettings.tsx | 19 ++++++++++++------- nym-wallet/src/utils/nextEpoch.ts | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index 96829fadae..48c33ae71a 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -39,7 +39,6 @@ import { getIntervalAsDate } from 'src/utils'; export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }): JSX.Element => { const [openConfirmationModal, setOpenConfirmationModal] = useState(false); const [intervalTime, setIntervalTime] = useState(); - const [nextEpoch, setNextEpoch] = useState(); const [pendingUpdates, setPendingUpdates] = useState(); const { clientDetails } = useContext(AppContext); const theme = useTheme(); @@ -119,7 +118,16 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode }; return ( - + {fee && ( - - {`Next epoch ${nextEpoch}`} - {`Next interval: ${intervalTime}`} } @@ -188,7 +193,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode )} - + @@ -231,7 +236,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode - + + + {!!delegations?.length && ( + + )} + + + + + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} + )} {delegationsComponent(delegations)} From 9616c904332f000b314f2c29e78cb9001ffcc26d Mon Sep 17 00:00:00 2001 From: Gala Date: Fri, 16 Dec 2022 08:04:33 +0100 Subject: [PATCH 44/67] delegations layout and tooltip when delegate with vesting --- .../components/Delegation/DelegationItem.tsx | 20 +++--- nym-wallet/src/pages/delegation/index.tsx | 69 ++++++++++--------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index d800f9f487..8a3df8dc17 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,16 +28,20 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; + const usesVestingContractTokens = item.uses_vesting_contract_tokens; + + const tooltipText = () => { + if (nodeIsUnbonded) { + return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; + } else if (usesVestingContractTokens) { + return 'Delegation made with locked tockens'; + } else { + return ''; + } + }; return ( - + {nodeIsUnbonded ? ( diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 5f581dd967..8fb399c6a8 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -343,42 +343,45 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { <> - - Delegations - + + {' '} + + + Delegations + + {!!delegations?.length && ( + + )} + + {!!delegations?.length && ( + + )} + {!!delegations?.length && ( - - {!!delegations?.length && ( - - )} - - - - - {nextEpoch instanceof Error ? null : ( - - Next epoch starts at {nextEpoch} - - )} - + + {nextEpoch instanceof Error ? null : ( + + Next epoch starts at {nextEpoch} + + )} )} {delegationsComponent(delegations)} From b03a1f922d82a95887d0920b137006b25812bd00 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 10:37:04 +0100 Subject: [PATCH 45/67] refactor --- nym-wallet/src/components/Delegation/DelegationItem.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index 8a3df8dc17..1b4327621c 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,12 +28,11 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; - const usesVestingContractTokens = item.uses_vesting_contract_tokens; const tooltipText = () => { if (nodeIsUnbonded) { return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; - } else if (usesVestingContractTokens) { + } else if (item.uses_vesting_contract_tokens) { return 'Delegation made with locked tockens'; } else { return ''; From 46edca0bd418fbda7fe05a37b069500c6d090722 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 10:52:29 +0100 Subject: [PATCH 46/67] refactor --- nym-wallet/src/components/Bonding/BondedMixnode.tsx | 2 +- nym-wallet/src/pages/delegation/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 69b37b64f5..92b4bdb965 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -66,7 +66,7 @@ export const BondedMixnode = ({ network?: Network; onActionSelect: (action: TBondedMixnodeActions) => void; }) => { - const [nextEpoch, setNextEpoch] = useState(); + const [nextEpoch, setNextEpoch] = useState(); const navigate = useNavigate(); const { name, diff --git a/nym-wallet/src/pages/delegation/index.tsx b/nym-wallet/src/pages/delegation/index.tsx index 8fb399c6a8..50ac86b354 100644 --- a/nym-wallet/src/pages/delegation/index.tsx +++ b/nym-wallet/src/pages/delegation/index.tsx @@ -36,10 +36,9 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => { const [confirmationModalProps, setConfirmationModalProps] = useState(); const [currentDelegationListActionItem, setCurrentDelegationListActionItem] = useState(); const [saturationError, setSaturationError] = useState<{ action: 'compound' | 'delegate'; saturation: string }>(); - const [nextEpoch, setNextEpoch] = useState(); + const [nextEpoch, setNextEpoch] = useState(); const theme = useTheme(); - const { clientDetails, network, From 7c5c19986a5c9ca3616c97fd2e42e957b789e0a4 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:23:39 +0100 Subject: [PATCH 47/67] refactor from PR request --- .../src/components/Bonding/BondedMixnode.tsx | 6 +++++- nym-wallet/src/components/IdentityKey.tsx | 16 +++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/nym-wallet/src/components/Bonding/BondedMixnode.tsx b/nym-wallet/src/components/Bonding/BondedMixnode.tsx index 92b4bdb965..ae32fdefba 100644 --- a/nym-wallet/src/components/Bonding/BondedMixnode.tsx +++ b/nym-wallet/src/components/Bonding/BondedMixnode.tsx @@ -155,7 +155,11 @@ export const BondedMixnode = ({ {name} )} - + + + + + } Action={ diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index 372a6bf40d..acf4019ce7 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -3,13 +3,11 @@ import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( - - - - {splice(6, identityKey)} - - - - +export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( + + + {splice(6, identityKey)} + + + ); From 4654b360e0720ebd1362a66f6b79bed9d1fa5469 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:27:35 +0100 Subject: [PATCH 48/67] cleaning --- nym-wallet/src/components/IdentityKey.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index acf4019ce7..bca08ab68c 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { Stack, Typography, Tooltip } from '@mui/material'; +import { Stack, Typography } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - + {splice(6, identityKey)} From 63bfe4246f458d18e304be6694c5add8960885d8 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 12:41:12 +0100 Subject: [PATCH 49/67] fix parameters settings layout --- .../general-settings/ParametersSettings.tsx | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx index b271125a7f..f622de7e63 100644 --- a/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/settings-pages/general-settings/ParametersSettings.tsx @@ -157,7 +157,7 @@ export const ParametersSettings = ({ bondedNode }: { bondedNode: TBondedMixnode {isMixnode(bondedNode) && ( - + - - - { - setValue('operatorCost', newValue, { shouldValidate: true, shouldDirty: true }); - }} - validationError={errors.operatorCost?.amount?.message} - denom={clientDetails?.display_mix_denom || 'nym'} - initialValue={defaultValues.operatorCost.amount} - /> - {pendingUpdates && ( - - Your last change to{' '} - - {pendingUpdates.interval_operating_cost.amount}{' '} - {pendingUpdates?.interval_operating_cost.denom.toUpperCase()}{' '} - - will be applied in the next interval - - )} - + + { + setValue('operatorCost', newValue, { shouldValidate: true, shouldDirty: true }); + }} + validationError={errors.operatorCost?.amount?.message} + denom={clientDetails?.display_mix_denom || 'nym'} + initialValue={defaultValues.operatorCost.amount} + /> + {pendingUpdates && ( + + Your last change to{' '} + + {pendingUpdates.interval_operating_cost.amount}{' '} + {pendingUpdates?.interval_operating_cost.denom.toUpperCase()}{' '} + + will be applied in the next interval + + )} From 4995dde705dac1c1c84da4a2b03b81fa04f6fe7d Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 15 Dec 2022 14:18:01 +0100 Subject: [PATCH 50/67] bond table changes --- nym-wallet/src/components/IdentityKey.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index bca08ab68c..372a6bf40d 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,13 +1,15 @@ import React from 'react'; -import { Stack, Typography } from '@mui/material'; +import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - - - {splice(6, identityKey)} - - - +export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( + + + + {splice(6, identityKey)} + + + + ); From ddb7b0e872d770826e52beab71ed8dbbfe03fcf3 Mon Sep 17 00:00:00 2001 From: Gala Date: Fri, 16 Dec 2022 08:04:33 +0100 Subject: [PATCH 51/67] delegations layout and tooltip when delegate with vesting --- .../src/components/Delegation/DelegationItem.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index 1b4327621c..8cdbe90e0c 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,6 +28,17 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; + const usesVestingContractTokens = item.uses_vesting_contract_tokens; + + const tooltipText = () => { + if (nodeIsUnbonded) { + return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; + } else if (usesVestingContractTokens) { + return 'Delegation made with locked tockens'; + } else { + return ''; + } + }; const tooltipText = () => { if (nodeIsUnbonded) { From d6048fae524620d0f5d30cd7b29759b9cfd3aa74 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 10:37:04 +0100 Subject: [PATCH 52/67] refactor --- nym-wallet/src/components/Delegation/DelegationItem.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nym-wallet/src/components/Delegation/DelegationItem.tsx b/nym-wallet/src/components/Delegation/DelegationItem.tsx index 8cdbe90e0c..b1d68c8a83 100644 --- a/nym-wallet/src/components/Delegation/DelegationItem.tsx +++ b/nym-wallet/src/components/Delegation/DelegationItem.tsx @@ -28,12 +28,11 @@ export const DelegationItem = ({ onItemActionClick?: (item: DelegationWithEverything, action: DelegationListItemActions) => void; }) => { const operatingCost = isDelegation(item) && item.cost_params?.interval_operating_cost; - const usesVestingContractTokens = item.uses_vesting_contract_tokens; const tooltipText = () => { if (nodeIsUnbonded) { return 'This node has unbonded and it does not exist anymore. You need to undelegate from it to get your stake and outstanding rewards (if any) back.'; - } else if (usesVestingContractTokens) { + } else if (item.uses_vesting_contract_tokens) { return 'Delegation made with locked tockens'; } else { return ''; From 9d3c7c0be8ec8746566e8f1afc59e6017f816e5a Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:23:39 +0100 Subject: [PATCH 53/67] refactor from PR request --- nym-wallet/src/components/IdentityKey.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index 372a6bf40d..acf4019ce7 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -3,13 +3,11 @@ import { Stack, Typography, Tooltip } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; -export const IdentityKey = ({ identityKey, tooltipTitle }: { identityKey: string; tooltipTitle?: string }) => ( - - - - {splice(6, identityKey)} - - - - +export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( + + + {splice(6, identityKey)} + + + ); From 60c8185beadc4ebf920ef3ab8b8bdc2c3f584962 Mon Sep 17 00:00:00 2001 From: Gala Date: Mon, 19 Dec 2022 15:27:35 +0100 Subject: [PATCH 54/67] cleaning --- nym-wallet/src/components/IdentityKey.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nym-wallet/src/components/IdentityKey.tsx b/nym-wallet/src/components/IdentityKey.tsx index acf4019ce7..bca08ab68c 100644 --- a/nym-wallet/src/components/IdentityKey.tsx +++ b/nym-wallet/src/components/IdentityKey.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { Stack, Typography, Tooltip } from '@mui/material'; +import { Stack, Typography } from '@mui/material'; import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard'; import { splice } from 'src/utils'; export const IdentityKey = ({ identityKey }: { identityKey: string }) => ( - + {splice(6, identityKey)} From 80d6cb5c12dcdc9c592378ad7c6e252ab07683e9 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 21 Dec 2022 17:34:26 +0100 Subject: [PATCH 55/67] last small touch --- nym-wallet/src/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-wallet/src/utils/index.ts b/nym-wallet/src/utils/index.ts index a7674d185b..936a89e57d 100644 --- a/nym-wallet/src/utils/index.ts +++ b/nym-wallet/src/utils/index.ts @@ -217,7 +217,7 @@ export const getIntervalAsDate = async () => { add(new Date(), { seconds: secondsToNextInterval, }), - 'MM/dd/yyyy HH:mm', + 'dd/MM/yyyy, HH:mm', ); const nextEpoch = format( From 06ed8716a1e8e3498a7a7f66190bc22ed35ba3be Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 15:09:44 +0200 Subject: [PATCH 56/67] adding a switch between networks --- explorer/src/api/index.ts | 7 +++++++ explorer/src/components/Nav.tsx | 21 +++++++++++++++++++-- explorer/src/context/main.tsx | 11 +++++++++-- explorer/src/typeDefs/explorer-api.ts | 2 ++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/explorer/src/api/index.ts b/explorer/src/api/index.ts index 37e68b8096..be0af90cb6 100644 --- a/explorer/src/api/index.ts +++ b/explorer/src/api/index.ts @@ -1,4 +1,5 @@ import { + API_BASE_URL, BLOCK_API, COUNTRY_DATA_API, GATEWAYS_API, @@ -27,6 +28,7 @@ import { StatusResponse, SummaryOverviewResponse, ValidatorsResponse, + Environment, } from '../typeDefs/explorer-api'; function getFromCache(key: string) { @@ -143,3 +145,8 @@ export class Api { static fetchUptimeStoryById = async (id: string): Promise => (await fetch(`${UPTIME_STORY_API}/${id}/history`)).json(); } + +export const getEnvironment = (): Environment => { + const matchEnv = (env: Environment) => API_BASE_URL?.toLocaleLowerCase().includes(env) && env; + return matchEnv('sandbox') || matchEnv('qa') || 'mainnet'; +}; diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index e2808871a0..3a3d703446 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { ExpandLess, ExpandMore, Menu } from '@mui/icons-material'; import { CSSObject, styled, Theme, useTheme } from '@mui/material/styles'; +import Button from '@mui/material/Button'; import MuiLink from '@mui/material/Link'; import Box from '@mui/material/Box'; import ListItem from '@mui/material/ListItem'; @@ -231,13 +232,20 @@ ExpandableButton.defaultProps = { }; export const Nav: React.FC = ({ children }) => { - const { updateNavState, navState } = useMainContext(); + const { updateNavState, navState, environment } = useMainContext(); const [drawerIsOpen, setDrawerToOpen] = React.useState(false); const [fixedOpen, setFixedOpen] = React.useState(false); // Set maintenance banner to false by default to don't display it const [openMaintenance, setOpenMaintenance] = React.useState(false); const theme = useTheme(); + const explorerName = + `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; + + const switchNetworkText = environment === 'mainnet' ? 'Switch to Testnet' : 'Switch to Mainnet'; + const switchNetworkLink = + environment === 'mainnet' ? 'https://sandbox-explorer.nymtech.net' : 'https://explorer.nymtech.net'; + const setToActive = (id: number) => { updateNavState(id); }; @@ -302,8 +310,17 @@ export const Nav: React.FC = ({ children }) => { }} > - Network Explorer + {explorerName} + ; + environment?: Environment; } interface StateApi { @@ -47,6 +49,9 @@ export const MainContext = React.createContext({ export const useMainContext = (): React.ContextType => React.useContext(MainContext); export const MainContextProvider: React.FC = ({ children }) => { + // network explorer environment + const [environment, setEnvironment] = React.useState('mainnet'); + // light/dark mode const [mode, setMode] = React.useState('dark'); @@ -166,10 +171,12 @@ export const MainContextProvider: React.FC = ({ children }) => { React.useEffect(() => { Promise.all([fetchOverviewSummary(), fetchGateways(), fetchValidators(), fetchBlock(), fetchCountryData()]); + setEnvironment(getEnvironment()); }, []); const state = React.useMemo( () => ({ + environment, block, countryData, fetchMixnodes, @@ -184,7 +191,7 @@ export const MainContextProvider: React.FC = ({ children }) => { updateNavState, validators, }), - [block, countryData, gateways, globalError, mixnodes, mode, navState, summaryOverview, validators], + [environment, block, countryData, gateways, globalError, mixnodes, mode, navState, summaryOverview, validators], ); return {children}; diff --git a/explorer/src/typeDefs/explorer-api.ts b/explorer/src/typeDefs/explorer-api.ts index f8350775c4..0f832b9f59 100644 --- a/explorer/src/typeDefs/explorer-api.ts +++ b/explorer/src/typeDefs/explorer-api.ts @@ -224,3 +224,5 @@ export type MixNodeEconomicDynamicsStatsResponse = { estimated_delegators_reward: number; current_interval_uptime: number; }; + +export type Environment = 'mainnet' | 'sandbox' | 'qa'; From b9fbab60247ad1d150094a821a69cd9dcb8ec451 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 15:43:42 +0200 Subject: [PATCH 57/67] adding button on mov nav and make it smaller --- explorer/src/components/MobileNav.tsx | 22 ++++++++++++++++++++-- explorer/src/components/Nav.tsx | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/explorer/src/components/MobileNav.tsx b/explorer/src/components/MobileNav.tsx index cb44210e9d..2a808e3c91 100644 --- a/explorer/src/components/MobileNav.tsx +++ b/explorer/src/components/MobileNav.tsx @@ -31,11 +31,18 @@ type MobileNavProps = { export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: MobileNavProps) => { const theme = useTheme(); - const { navState, updateNavState } = useMainContext(); + const { navState, updateNavState, environment } = useMainContext(); const [drawerOpen, setDrawerOpen] = React.useState(false); // Set maintenance banner to false by default to don't display it const [openMaintenance, setOpenMaintenance] = React.useState(false); + const explorerName = + `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; + + const switchNetworkText = environment === 'mainnet' ? 'Switch to Testnet' : 'Switch to Mainnet'; + const switchNetworkLink = + environment === 'mainnet' ? 'https://sandbox-explorer.nymtech.net' : 'https://explorer.nymtech.net'; + const toggleDrawer = () => { setDrawerOpen(!drawerOpen); }; @@ -86,11 +93,22 @@ export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: fontSize: '18px', fontWeight: 600, ml: 2, + display: 'flex', + flexDirection: 'column', }} > - Network Explorer + {explorerName} + diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index 3a3d703446..d4aa202071 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -313,11 +313,11 @@ export const Nav: React.FC = ({ children }) => { {explorerName} From 75a726ebbec3881464c2360310a2f01ac2098d51 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 16:34:30 +0200 Subject: [PATCH 58/67] some styles --- explorer/src/components/MobileNav.tsx | 13 +++++-------- explorer/src/components/Nav.tsx | 2 +- explorer/src/components/Switch.tsx | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/explorer/src/components/MobileNav.tsx b/explorer/src/components/MobileNav.tsx index 2a808e3c91..e3515dff7f 100644 --- a/explorer/src/components/MobileNav.tsx +++ b/explorer/src/components/MobileNav.tsx @@ -83,7 +83,7 @@ export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: }} > - + = ({ children }: color: theme.palette.nym.networkExplorer.nav.text, fontSize: '18px', fontWeight: 600, - ml: 2, - display: 'flex', - flexDirection: 'column', }} > - + {explorerName} - + - diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index d4aa202071..93ea445a33 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -317,7 +317,7 @@ export const Nav: React.FC = ({ children }) => { variant="outlined" color="inherit" href={switchNetworkLink} - sx={{ textTransform: 'none', width: 150, ml: 4 }} + sx={{ borderRadius: 2, textTransform: 'none', width: 150, ml: 4, fontSize: 14, fontWeight: 600 }} > {switchNetworkText} diff --git a/explorer/src/components/Switch.tsx b/explorer/src/components/Switch.tsx index 835100a1db..25e76ccdfa 100644 --- a/explorer/src/components/Switch.tsx +++ b/explorer/src/components/Switch.tsx @@ -54,7 +54,7 @@ export const DarkLightSwitch = styled(Switch)(({ theme }) => ({ export const DarkLightSwitchMobile: React.FC = () => { const { toggleMode } = useMainContext(); return ( - ); From acd832d8e54c7b15ad5745db4cbabb7f90de86a6 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 10 Aug 2022 16:38:56 +0200 Subject: [PATCH 59/67] cleaning --- explorer/src/components/UptimeChart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorer/src/components/UptimeChart.tsx b/explorer/src/components/UptimeChart.tsx index 51f2c9b62b..c5b4c0a402 100644 --- a/explorer/src/components/UptimeChart.tsx +++ b/explorer/src/components/UptimeChart.tsx @@ -55,7 +55,7 @@ export const UptimeChart: React.FC = ({ title, xLabel, yLabel, uptim uptimeStory.data ? formattedChartData : [ - ['Date', 'Routing Score'], + ['Date', 'Uptime'], [format(new Date(Date.now()), 'MMM dd'), 0], ] } From 4120234155a1a738af8d6ccbadb8ff12742d0415 Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 22 Dec 2022 11:09:55 +0100 Subject: [PATCH 60/67] fix build problem --- explorer/src/components/MobileNav.tsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/explorer/src/components/MobileNav.tsx b/explorer/src/components/MobileNav.tsx index 26543b9ec3..e3515dff7f 100644 --- a/explorer/src/components/MobileNav.tsx +++ b/explorer/src/components/MobileNav.tsx @@ -36,13 +36,6 @@ export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: // Set maintenance banner to false by default to don't display it const [openMaintenance, setOpenMaintenance] = React.useState(false); - const explorerName = - `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; - - const switchNetworkText = environment === 'mainnet' ? 'Switch to Testnet' : 'Switch to Mainnet'; - const switchNetworkLink = - environment === 'mainnet' ? 'https://sandbox-explorer.nymtech.net' : 'https://explorer.nymtech.net'; - const explorerName = `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; From 4813cf6c18a1f02010ca12c78390c5f17137b457 Mon Sep 17 00:00:00 2001 From: farbanas Date: Thu, 22 Dec 2022 12:12:46 +0100 Subject: [PATCH 61/67] feat: release v1.1.5 of nym-wallet --- nym-wallet/CHANGELOG.md | 4 ++++ nym-wallet/package.json | 2 +- nym-wallet/src-tauri/Cargo.toml | 2 +- nym-wallet/src-tauri/tauri.conf.json | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nym-wallet/CHANGELOG.md b/nym-wallet/CHANGELOG.md index ae119b7749..4f6a5d089a 100644 --- a/nym-wallet/CHANGELOG.md +++ b/nym-wallet/CHANGELOG.md @@ -2,6 +2,10 @@ ## UNRELEASED +## [nym-wallet-v1.1.5](https://github.com/nymtech/nym/releases/tag/nym-wallet-v1.1.5) (2022-12-22) + +This release contains the APY calculator feature. + ## [nym-wallet-v1.1.4](https://github.com/nymtech/nym/releases/tag/nym-wallet-v1.1.4) (2022-12-20) This release contains a bugfix for hiding and displaying the mnemonic, and displays the Bity wallet address in the buy page, as well as better error handling. diff --git a/nym-wallet/package.json b/nym-wallet/package.json index f2f827c098..21f885b496 100644 --- a/nym-wallet/package.json +++ b/nym-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/nym-wallet-app", - "version": "1.1.4", + "version": "1.1.5", "main": "index.js", "license": "MIT", "scripts": { diff --git a/nym-wallet/src-tauri/Cargo.toml b/nym-wallet/src-tauri/Cargo.toml index edbe2592b7..2e03275a02 100644 --- a/nym-wallet/src-tauri/Cargo.toml +++ b/nym-wallet/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym_wallet" -version = "1.1.4" +version = "1.1.5" description = "Nym Native Wallet" authors = ["Nym Technologies SA"] license = "" diff --git a/nym-wallet/src-tauri/tauri.conf.json b/nym-wallet/src-tauri/tauri.conf.json index e6c2dad6b9..004dd66912 100644 --- a/nym-wallet/src-tauri/tauri.conf.json +++ b/nym-wallet/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "package": { "productName": "nym-wallet", - "version": "1.1.4" + "version": "1.1.5" }, "build": { "distDir": "../dist", From 9dd4c5d871d9a12abe0b5aa22eb595d84ce43265 Mon Sep 17 00:00:00 2001 From: Gala Date: Thu, 22 Dec 2022 14:20:21 +0100 Subject: [PATCH 62/67] Revert "NE: Switch button to change the explorer network" --- explorer/src/api/index.ts | 7 ------ explorer/src/components/MobileNav.tsx | 29 ++++++------------------- explorer/src/components/Nav.tsx | 21 ++---------------- explorer/src/components/Switch.tsx | 2 +- explorer/src/components/UptimeChart.tsx | 2 +- explorer/src/context/main.tsx | 11 ++-------- explorer/src/typeDefs/explorer-api.ts | 2 -- 7 files changed, 13 insertions(+), 61 deletions(-) diff --git a/explorer/src/api/index.ts b/explorer/src/api/index.ts index be0af90cb6..37e68b8096 100644 --- a/explorer/src/api/index.ts +++ b/explorer/src/api/index.ts @@ -1,5 +1,4 @@ import { - API_BASE_URL, BLOCK_API, COUNTRY_DATA_API, GATEWAYS_API, @@ -28,7 +27,6 @@ import { StatusResponse, SummaryOverviewResponse, ValidatorsResponse, - Environment, } from '../typeDefs/explorer-api'; function getFromCache(key: string) { @@ -145,8 +143,3 @@ export class Api { static fetchUptimeStoryById = async (id: string): Promise => (await fetch(`${UPTIME_STORY_API}/${id}/history`)).json(); } - -export const getEnvironment = (): Environment => { - const matchEnv = (env: Environment) => API_BASE_URL?.toLocaleLowerCase().includes(env) && env; - return matchEnv('sandbox') || matchEnv('qa') || 'mainnet'; -}; diff --git a/explorer/src/components/MobileNav.tsx b/explorer/src/components/MobileNav.tsx index e3515dff7f..cb44210e9d 100644 --- a/explorer/src/components/MobileNav.tsx +++ b/explorer/src/components/MobileNav.tsx @@ -31,18 +31,11 @@ type MobileNavProps = { export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: MobileNavProps) => { const theme = useTheme(); - const { navState, updateNavState, environment } = useMainContext(); + const { navState, updateNavState } = useMainContext(); const [drawerOpen, setDrawerOpen] = React.useState(false); // Set maintenance banner to false by default to don't display it const [openMaintenance, setOpenMaintenance] = React.useState(false); - const explorerName = - `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; - - const switchNetworkText = environment === 'mainnet' ? 'Switch to Testnet' : 'Switch to Mainnet'; - const switchNetworkLink = - environment === 'mainnet' ? 'https://sandbox-explorer.nymtech.net' : 'https://explorer.nymtech.net'; - const toggleDrawer = () => { setDrawerOpen(!drawerOpen); }; @@ -83,7 +76,7 @@ export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: }} > - + = ({ children }: color: theme.palette.nym.networkExplorer.nav.text, fontSize: '18px', fontWeight: 600, + ml: 2, }} > - - {explorerName} + + Network Explorer - - + - diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index 93ea445a33..e2808871a0 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { ExpandLess, ExpandMore, Menu } from '@mui/icons-material'; import { CSSObject, styled, Theme, useTheme } from '@mui/material/styles'; -import Button from '@mui/material/Button'; import MuiLink from '@mui/material/Link'; import Box from '@mui/material/Box'; import ListItem from '@mui/material/ListItem'; @@ -232,20 +231,13 @@ ExpandableButton.defaultProps = { }; export const Nav: React.FC = ({ children }) => { - const { updateNavState, navState, environment } = useMainContext(); + const { updateNavState, navState } = useMainContext(); const [drawerIsOpen, setDrawerToOpen] = React.useState(false); const [fixedOpen, setFixedOpen] = React.useState(false); // Set maintenance banner to false by default to don't display it const [openMaintenance, setOpenMaintenance] = React.useState(false); const theme = useTheme(); - const explorerName = - `${environment && environment.charAt(0).toUpperCase() + environment.slice(1)} Explorer` || 'Mainnet Explorer'; - - const switchNetworkText = environment === 'mainnet' ? 'Switch to Testnet' : 'Switch to Mainnet'; - const switchNetworkLink = - environment === 'mainnet' ? 'https://sandbox-explorer.nymtech.net' : 'https://explorer.nymtech.net'; - const setToActive = (id: number) => { updateNavState(id); }; @@ -310,17 +302,8 @@ export const Nav: React.FC = ({ children }) => { }} > - {explorerName} + Network Explorer - ({ export const DarkLightSwitchMobile: React.FC = () => { const { toggleMode } = useMainContext(); return ( - ); diff --git a/explorer/src/components/UptimeChart.tsx b/explorer/src/components/UptimeChart.tsx index c5b4c0a402..51f2c9b62b 100644 --- a/explorer/src/components/UptimeChart.tsx +++ b/explorer/src/components/UptimeChart.tsx @@ -55,7 +55,7 @@ export const UptimeChart: React.FC = ({ title, xLabel, yLabel, uptim uptimeStory.data ? formattedChartData : [ - ['Date', 'Uptime'], + ['Date', 'Routing Score'], [format(new Date(Date.now()), 'MMM dd'), 0], ] } diff --git a/explorer/src/context/main.tsx b/explorer/src/context/main.tsx index 7d9287d0bf..42e89b32ee 100644 --- a/explorer/src/context/main.tsx +++ b/explorer/src/context/main.tsx @@ -9,10 +9,9 @@ import { MixnodeStatus, SummaryOverviewResponse, ValidatorsResponse, - Environment, } from '../typeDefs/explorer-api'; import { EnumFilterKey } from '../typeDefs/filters'; -import { Api, getEnvironment } from '../api'; +import { Api } from '../api'; import { NavOptionType, originalNavOptions } from './nav'; interface StateData { @@ -25,7 +24,6 @@ interface StateData { mode: PaletteMode; navState: NavOptionType[]; validators?: ApiState; - environment?: Environment; } interface StateApi { @@ -49,9 +47,6 @@ export const MainContext = React.createContext({ export const useMainContext = (): React.ContextType => React.useContext(MainContext); export const MainContextProvider: React.FC = ({ children }) => { - // network explorer environment - const [environment, setEnvironment] = React.useState('mainnet'); - // light/dark mode const [mode, setMode] = React.useState('dark'); @@ -171,12 +166,10 @@ export const MainContextProvider: React.FC = ({ children }) => { React.useEffect(() => { Promise.all([fetchOverviewSummary(), fetchGateways(), fetchValidators(), fetchBlock(), fetchCountryData()]); - setEnvironment(getEnvironment()); }, []); const state = React.useMemo( () => ({ - environment, block, countryData, fetchMixnodes, @@ -191,7 +184,7 @@ export const MainContextProvider: React.FC = ({ children }) => { updateNavState, validators, }), - [environment, block, countryData, gateways, globalError, mixnodes, mode, navState, summaryOverview, validators], + [block, countryData, gateways, globalError, mixnodes, mode, navState, summaryOverview, validators], ); return {children}; diff --git a/explorer/src/typeDefs/explorer-api.ts b/explorer/src/typeDefs/explorer-api.ts index 0f832b9f59..f8350775c4 100644 --- a/explorer/src/typeDefs/explorer-api.ts +++ b/explorer/src/typeDefs/explorer-api.ts @@ -224,5 +224,3 @@ export type MixNodeEconomicDynamicsStatsResponse = { estimated_delegators_reward: number; current_interval_uptime: number; }; - -export type Environment = 'mainnet' | 'sandbox' | 'qa'; From 5b15ed6f15bef2df6e55f5288bf53d71bd7a61c2 Mon Sep 17 00:00:00 2001 From: Fouad Date: Wed, 21 Dec 2022 12:56:40 +0000 Subject: [PATCH 63/67] merge resolve --- nym-wallet/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index 4821268ecd..25e16a69a1 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -2876,7 +2876,7 @@ dependencies = [ [[package]] name = "nym_wallet" -version = "1.1.3" +version = "1.1.5" dependencies = [ "aes-gcm", "argon2 0.3.4", From fdbe3a1f6a987eb35eacdcc5544305a6b73b5174 Mon Sep 17 00:00:00 2001 From: Pierre Dommerc Date: Thu, 5 Jan 2023 15:53:15 +0100 Subject: [PATCH 64/67] fix(explorer,explorer-api): mixnode location (#2763) * chore(explorer-api): remove useless route (/terms) * feat(explorer-api-geoip): add coordinates lat&lon * fix(explorer): mixnode location * fix: typo * fix: clippy --- .env.sample-dev | 2 +- explorer-api/.env.sample | 2 +- explorer-api/README.md | 2 +- explorer-api/src/buy_terms/http.rs | 26 ---------------------- explorer-api/src/buy_terms/mod.rs | 1 - explorer-api/src/geo_ip/location.rs | 17 +++++++++----- explorer-api/src/http/mod.rs | 2 -- explorer-api/src/main.rs | 1 - explorer-api/src/mix_nodes/location.rs | 4 ++++ explorer/src/pages/MixnodeDetail/index.tsx | 4 ++-- explorer/src/typeDefs/explorer-api.ts | 4 ++-- 11 files changed, 22 insertions(+), 43 deletions(-) delete mode 100644 explorer-api/src/buy_terms/http.rs delete mode 100644 explorer-api/src/buy_terms/mod.rs diff --git a/.env.sample-dev b/.env.sample-dev index d77245ab12..3a48d8ebb0 100644 --- a/.env.sample-dev +++ b/.env.sample-dev @@ -14,7 +14,7 @@ GEOIPUPDATE_LICENSE_KEY=xxx # List of space-separated database edition IDs. Edition IDs may # consist of letters, digits, and dashes. For example, GeoIP2-City # would download the GeoIP2 City database (GeoIP2-City). -GEOIPUPDATE_EDITION_IDS=GeoLite2-Country +GEOIPUPDATE_EDITION_IDS=GeoLite2-City # The number of hours between geoipupdate runs. If this is not set # or is set to 0, geoipupdate will run once and exit. GEOIPUPDATE_FREQUENCY=72 diff --git a/explorer-api/.env.sample b/explorer-api/.env.sample index 1efd2de597..e5922f9cf0 100644 --- a/explorer-api/.env.sample +++ b/explorer-api/.env.sample @@ -1,2 +1,2 @@ # The path to the geoip database file -GEOIP_DB_PATH=./geo_ip/GeoLite2-Country.mmdb +GEOIP_DB_PATH=./geo_ip/GeoLite2-City.mmdb diff --git a/explorer-api/README.md b/explorer-api/README.md index d4e193dbb0..86e64e4c12 100644 --- a/explorer-api/README.md +++ b/explorer-api/README.md @@ -40,7 +40,7 @@ It should be previously installed thanks to `geoipupdate` service. For example: ```shell -GEOIP_DB_PATH=./geo_ip/GeoLite2-Country.mmdb cargo run +GEOIP_DB_PATH=./geo_ip/GeoLite2-City.mmdb cargo run ``` Note: explorer-api binary reads the provided `.env` file. diff --git a/explorer-api/src/buy_terms/http.rs b/explorer-api/src/buy_terms/http.rs deleted file mode 100644 index 5594a1a3be..0000000000 --- a/explorer-api/src/buy_terms/http.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 - Nym Technologies SA -// SPDX-License-Identifier: Apache-2.0 - -use crate::geo_ip::location::Location; -use crate::state::ExplorerApiStateContext; -use rocket::response::status; -use rocket::serde::json::Json; -use rocket::{Route, State}; -use rocket_okapi::okapi::openapi3::OpenApi; -use rocket_okapi::settings::OpenApiSettings; - -pub fn nym_terms_make_default_routes(settings: &OpenApiSettings) -> (Vec, OpenApi) { - openapi_get_routes_spec![settings: terms] -} - -#[openapi(tag = "terms")] -#[get("/")] -pub(crate) async fn terms( - _state: &State, - location: Location, -) -> Result, status::Forbidden> { - if location.iso_alpha2 == "US" { - return Err(status::Forbidden(Some("US government sucks".to_string()))); - } - Ok(Json("Nym Terms & Conditions: Welcome".to_string())) -} diff --git a/explorer-api/src/buy_terms/mod.rs b/explorer-api/src/buy_terms/mod.rs deleted file mode 100644 index d064c8bd6f..0000000000 --- a/explorer-api/src/buy_terms/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub(crate) mod http; diff --git a/explorer-api/src/geo_ip/location.rs b/explorer-api/src/geo_ip/location.rs index a1afec55d6..adbdb6cef3 100644 --- a/explorer-api/src/geo_ip/location.rs +++ b/explorer-api/src/geo_ip/location.rs @@ -3,14 +3,14 @@ use isocountry::CountryCode; use log::warn; -use maxminddb::{geoip2::Country, MaxMindDBError, Reader}; +use maxminddb::{geoip2::City, MaxMindDBError, Reader}; use std::{ net::{IpAddr, ToSocketAddrs}, str::FromStr, sync::Arc, }; -const DEFAULT_DATABASE_PATH: &str = "./geo_ip/GeoLite2-Country.mmdb"; +const DEFAULT_DATABASE_PATH: &str = "./geo_ip/GeoLite2-City.mmdb"; const FAKE_PORT: u16 = 1234; #[derive(Debug)] @@ -38,6 +38,8 @@ pub(crate) struct Location { pub(crate) iso_alpha3: String, /// English country short name (ISO 3166-1) pub(crate) name: String, + pub(crate) latitude: Option, + pub(crate) longitude: Option, } impl GeoIp { @@ -86,7 +88,7 @@ impl GeoIp { error!("No registered GeoIP database"); GeoIpError::InternalError })? - .lookup::(ip); + .lookup::(ip); match &result { Ok(v) => Ok(Some( Location::try_from(v).map_err(|_| GeoIpError::InternalError)?, @@ -99,11 +101,11 @@ impl GeoIp { } } -impl<'a> TryFrom<&Country<'a>> for Location { +impl<'a> TryFrom<&City<'a>> for Location { type Error = String; - fn try_from(country: &Country) -> Result { - let data = country.country.as_ref().ok_or_else(|| { + fn try_from(city: &City) -> Result { + let data = city.country.as_ref().ok_or_else(|| { warn!("No Country data found"); "No Country data found" })?; @@ -119,10 +121,13 @@ impl<'a> TryFrom<&Country<'a>> for Location { warn!("{}", &message); message })?; + Ok(Location { iso_alpha2, iso_alpha3: String::from(iso_codes.alpha3()), name: String::from(iso_codes.name()), + latitude: city.location.as_ref().and_then(|l| l.latitude), + longitude: city.location.as_ref().and_then(|l| l.longitude), }) } } diff --git a/explorer-api/src/http/mod.rs b/explorer-api/src/http/mod.rs index f5559124a5..31f638ee5f 100644 --- a/explorer-api/src/http/mod.rs +++ b/explorer-api/src/http/mod.rs @@ -5,7 +5,6 @@ use rocket::{Build, Request, Rocket}; use rocket_cors::{AllowedHeaders, AllowedOrigins}; use rocket_okapi::swagger_ui::make_swagger_ui; -use crate::buy_terms::http::nym_terms_make_default_routes; use crate::country_statistics::http::country_statistics_make_default_routes; use crate::gateways::http::gateways_make_default_routes; use crate::http::swagger::get_docs; @@ -57,7 +56,6 @@ fn configure_rocket(state: ExplorerApiStateContext) -> Rocket { "/overview" => overview_make_default_routes(&openapi_settings), "/ping" => ping_make_default_routes(&openapi_settings), "/validators" => validators_make_default_routes(&openapi_settings), - "/terms" => nym_terms_make_default_routes(&openapi_settings), }; building_rocket diff --git a/explorer-api/src/main.rs b/explorer-api/src/main.rs index e1a02c57ea..81478638d4 100644 --- a/explorer-api/src/main.rs +++ b/explorer-api/src/main.rs @@ -10,7 +10,6 @@ use logging::setup_logging; use network_defaults::setup_env; use task::TaskManager; -mod buy_terms; pub(crate) mod cache; mod client; pub(crate) mod commands; diff --git a/explorer-api/src/mix_nodes/location.rs b/explorer-api/src/mix_nodes/location.rs index d14eaf771e..51c46261c6 100644 --- a/explorer-api/src/mix_nodes/location.rs +++ b/explorer-api/src/mix_nodes/location.rs @@ -36,6 +36,8 @@ pub(crate) struct Location { pub(crate) two_letter_iso_country_code: String, pub(crate) three_letter_iso_country_code: String, pub(crate) country_name: String, + pub(crate) latitude: Option, + pub(crate) longitude: Option, } impl Location { @@ -44,6 +46,8 @@ impl Location { country_name: location.name, two_letter_iso_country_code: location.iso_alpha2, three_letter_iso_country_code: location.iso_alpha3, + latitude: location.latitude, + longitude: location.longitude, } } } diff --git a/explorer/src/pages/MixnodeDetail/index.tsx b/explorer/src/pages/MixnodeDetail/index.tsx index 1c38f69a53..95e18ea603 100644 --- a/explorer/src/pages/MixnodeDetail/index.tsx +++ b/explorer/src/pages/MixnodeDetail/index.tsx @@ -164,10 +164,10 @@ const PageMixnodeDetailWithState: React.FC = () => { {mixNode && ( {mixNode?.error && } - {mixNode.data && mixNode?.data?.location && ( + {mixNode?.data?.location?.latitude && mixNode?.data?.location?.longitude && ( )} diff --git a/explorer/src/typeDefs/explorer-api.ts b/explorer/src/typeDefs/explorer-api.ts index f8350775c4..188a0c3ac0 100644 --- a/explorer/src/typeDefs/explorer-api.ts +++ b/explorer/src/typeDefs/explorer-api.ts @@ -77,8 +77,8 @@ export interface MixNodeResponseItem { status: MixnodeStatus; location: { country_name: string; - lat: number; - lng: number; + latitude?: number; + longitude?: number; three_letter_iso_country_code: string; two_letter_iso_country_code: string; }; From e181a1cfb153ebb89d3ab34cd59a36876ce7fcba Mon Sep 17 00:00:00 2001 From: Pierre Dommerc Date: Fri, 6 Jan 2023 09:38:30 +0100 Subject: [PATCH 65/67] feat(wallet-buy): pass wallet address as url param (#2780) --- nym-wallet/src/components/Buy/Tutorial.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nym-wallet/src/components/Buy/Tutorial.tsx b/nym-wallet/src/components/Buy/Tutorial.tsx index 316f033347..8d403cb2e6 100644 --- a/nym-wallet/src/components/Buy/Tutorial.tsx +++ b/nym-wallet/src/components/Buy/Tutorial.tsx @@ -1,10 +1,11 @@ -import React, { useState } from 'react'; +import React, { useContext, useState } from 'react'; import { Button, Stack, Typography, Grid, useMediaQuery, useTheme } from '@mui/material'; -import { Tune as TuneIcon, BorderColor as BorderColorIcon, Paid as PaidIcon } from '@mui/icons-material'; +import { Tune as TuneIcon, BorderColor as BorderColorIcon } from '@mui/icons-material'; import { CoinMark } from '@nymproject/react/coins/CoinMark'; import { NymCard, ClientAddress } from '../../components'; import { SignMessageModal } from './SignMessageModal'; import { PoweredByBity } from 'src/svg-icons'; +import { AppContext } from 'src/context'; // TODO retrieve this value from env const EXCHANGE_URL = 'https://buy.nymtech.net'; @@ -51,6 +52,7 @@ const TutorialStep = ({ ); export const Tutorial = () => { + const { clientDetails } = useContext(AppContext); const [showSignModal, setShowSignModal] = useState(false); const theme = useTheme(); const showBorder = useMediaQuery(theme.breakpoints.up('md')); @@ -123,7 +125,12 @@ export const Tutorial = () => { - From 61bc74148ffffff84054241f002e2d2ee9aead93 Mon Sep 17 00:00:00 2001 From: farbanas Date: Tue, 10 Jan 2023 13:10:24 +0100 Subject: [PATCH 66/67] Update versions --- clients/client-core/Cargo.toml | 2 +- clients/native/Cargo.toml | 2 +- clients/socks5/Cargo.toml | 2 +- explorer-api/Cargo.toml | 2 +- explorer/package.json | 2 +- gateway/Cargo.toml | 2 +- mixnode/Cargo.toml | 2 +- nym-api/Cargo.toml | 2 +- nym-connect/package.json | 2 +- nym-connect/src-tauri/Cargo.toml | 2 +- nym-connect/src-tauri/tauri.conf.json | 2 +- nym-wallet/package.json | 2 +- nym-wallet/src-tauri/Cargo.toml | 2 +- nym-wallet/src-tauri/tauri.conf.json | 2 +- service-providers/network-requester/Cargo.toml | 2 +- service-providers/network-statistics/Cargo.toml | 2 +- tools/nym-cli/Cargo.toml | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/clients/client-core/Cargo.toml b/clients/client-core/Cargo.toml index 2c36fb892b..507552e887 100644 --- a/clients/client-core/Cargo.toml +++ b/clients/client-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "client-core" -version = "1.1.4" +version = "1.1.5" authors = ["Dave Hrycyszyn "] edition = "2021" rust-version = "1.66" diff --git a/clients/native/Cargo.toml b/clients/native/Cargo.toml index d97f7748fb..e669026fa2 100644 --- a/clients/native/Cargo.toml +++ b/clients/native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-client" -version = "1.1.4" +version = "1.1.5" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] description = "Implementation of the Nym Client" edition = "2021" diff --git a/clients/socks5/Cargo.toml b/clients/socks5/Cargo.toml index add5a3ee58..9d1762c8f3 100644 --- a/clients/socks5/Cargo.toml +++ b/clients/socks5/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-socks5-client" -version = "1.1.4" +version = "1.1.5" authors = ["Dave Hrycyszyn "] description = "A SOCKS5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address" edition = "2021" diff --git a/explorer-api/Cargo.toml b/explorer-api/Cargo.toml index cc665b1f83..b03926dfe6 100644 --- a/explorer-api/Cargo.toml +++ b/explorer-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "explorer-api" -version = "1.1.1" +version = "1.1.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/explorer/package.json b/explorer/package.json index b314878308..2478774987 100644 --- a/explorer/package.json +++ b/explorer/package.json @@ -1,6 +1,6 @@ { "name": "@nym/network-explorer", - "version": "1.0.0", + "version": "1.0.1", "private": true, "license": "Apache-2.0", "dependencies": { diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 81fdd10c8b..a1761a7e17 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-gateway" -version = "1.1.4" +version = "1.1.5" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index 776b7594f3..fbffe76322 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-mixnode" -version = "1.1.4" +version = "1.1.5" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/nym-api/Cargo.toml b/nym-api/Cargo.toml index 5ffa219513..960e0599f9 100644 --- a/nym-api/Cargo.toml +++ b/nym-api/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-validator-api" -version = "1.1.4" +version = "1.1.5" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/nym-connect/package.json b/nym-connect/package.json index bff93c5a67..f74779b2d4 100644 --- a/nym-connect/package.json +++ b/nym-connect/package.json @@ -1,6 +1,6 @@ { "name": "@nym/nym-connect", - "version": "1.1.4", + "version": "1.1.5", "main": "index.js", "license": "MIT", "scripts": { diff --git a/nym-connect/src-tauri/Cargo.toml b/nym-connect/src-tauri/Cargo.toml index 1ef082ea8d..0d7118b97a 100644 --- a/nym-connect/src-tauri/Cargo.toml +++ b/nym-connect/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-connect" -version = "1.1.4" +version = "1.1.5" description = "nym-connect" authors = ["Nym Technologies SA"] license = "" diff --git a/nym-connect/src-tauri/tauri.conf.json b/nym-connect/src-tauri/tauri.conf.json index 05d22942c4..0e11432d04 100644 --- a/nym-connect/src-tauri/tauri.conf.json +++ b/nym-connect/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "package": { "productName": "nym-connect", - "version": "1.1.4" + "version": "1.1.5" }, "build": { "distDir": "../dist", diff --git a/nym-wallet/package.json b/nym-wallet/package.json index 21f885b496..72a440d733 100644 --- a/nym-wallet/package.json +++ b/nym-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/nym-wallet-app", - "version": "1.1.5", + "version": "1.1.6", "main": "index.js", "license": "MIT", "scripts": { diff --git a/nym-wallet/src-tauri/Cargo.toml b/nym-wallet/src-tauri/Cargo.toml index 2e03275a02..b5540924d0 100644 --- a/nym-wallet/src-tauri/Cargo.toml +++ b/nym-wallet/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym_wallet" -version = "1.1.5" +version = "1.1.6" description = "Nym Native Wallet" authors = ["Nym Technologies SA"] license = "" diff --git a/nym-wallet/src-tauri/tauri.conf.json b/nym-wallet/src-tauri/tauri.conf.json index 004dd66912..722c0c1af3 100644 --- a/nym-wallet/src-tauri/tauri.conf.json +++ b/nym-wallet/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "package": { "productName": "nym-wallet", - "version": "1.1.5" + "version": "1.1.6" }, "build": { "distDir": "../dist", diff --git a/service-providers/network-requester/Cargo.toml b/service-providers/network-requester/Cargo.toml index d693ed4422..04f360d7dd 100644 --- a/service-providers/network-requester/Cargo.toml +++ b/service-providers/network-requester/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-network-requester" -version = "1.1.4" +version = "1.1.5" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2021" rust-version = "1.65" diff --git a/service-providers/network-statistics/Cargo.toml b/service-providers/network-statistics/Cargo.toml index 00b76f524e..251b1a34a9 100644 --- a/service-providers/network-statistics/Cargo.toml +++ b/service-providers/network-statistics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-network-statistics" -version = "1.1.4" +version = "1.1.5" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/tools/nym-cli/Cargo.toml b/tools/nym-cli/Cargo.toml index ddc21464ff..5813e903bb 100644 --- a/tools/nym-cli/Cargo.toml +++ b/tools/nym-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-cli" -version = "1.1.4" +version = "1.1.5" authors = ["Nym Technologies SA"] edition = "2021" From 273dc41559ab4f3ca4a20a8dd12da244e76d419a Mon Sep 17 00:00:00 2001 From: farbanas Date: Tue, 10 Jan 2023 13:43:09 +0100 Subject: [PATCH 67/67] feat: update changelogs --- CHANGELOG.md | 17 ++++++++++------- explorer/CHANGELOG.md | 8 ++++++++ nym-connect/CHANGELOG.md | 7 +++++++ nym-wallet/CHANGELOG.md | 8 +++++++- 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 explorer/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md index b55407afe4..02a8caa0b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,19 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// ### Added -- socks5: send status message for service ready, and network-requester error response +- socks5: send status message for service ready, and network-requester error response in https://github.com/nymtech/nym/pull/2715 ### Changed -- all-binaries: improved error logging ([#2686]) -- native client: bring shutdown logic up to the same level as socks5-client -- nym-api, coconut-dkg contract: automatic, time-based dkg epoch state advancement ([#2670]) - -[#2686]: https://github.com/nymtech/nym/pull/2686 -[#2670]: https://github.com/nymtech/nym/pull/2670 +- all-binaries: improved error logging in https://github.com/nymtech/nym/pull/2686 +- native client: bring shutdown logic up to the same level as socks5-client in https://github.com/nymtech/nym/pull/2695 +- nym-api, coconut-dkg contract: automatic, time-based dkg epoch state advancement in https://github.com/nymtech/nym/pull/2670 +- DKG resharing unit test by @neacsu in https://github.com/nymtech/nym/pull/2668 +- Renaming validator-api to nym-api by @futurechimp in https://github.com/nymtech/nym/pull/1863 +- Modify wasm specific make targets by @neacsu in https://github.com/nymtech/nym/pull/2693 +- client: create websocket handler builder by @octol in https://github.com/nymtech/nym/pull/2700 +- Outfox and Lion by @durch in https://github.com/nymtech/nym/pull/2730 +- Feature/multi surb transmission lanes by @jstuczyn in https://github.com/nymtech/nym/pull/2723 ## [v1.1.4] (2022-12-20) diff --git a/explorer/CHANGELOG.md b/explorer/CHANGELOG.md new file mode 100644 index 0000000000..e55425407b --- /dev/null +++ b/explorer/CHANGELOG.md @@ -0,0 +1,8 @@ +## UNRELEASED + +## [nym-explorer-v1.0.1](https://github.com/nymtech/nym/tree/nym-explorer-v1.0.1) (2023-01-10) + +- Feat/2161 ne gate version by @gala1234 in https://github.com/nymtech/nym/pull/2743 +- fix(explorer): set gateway bond 6 decimals by @doums in https://github.com/nymtech/nym/pull/2741 +- Feat/2130 tables update rebase by @gala1234 in https://github.com/nymtech/nym/pull/2742 +- fix(explorer,explorer-api): mixnode location by @doums in https://github.com/nymtech/nym-api diff --git a/nym-connect/CHANGELOG.md b/nym-connect/CHANGELOG.md index 8e6d4eb168..b515382104 100644 --- a/nym-connect/CHANGELOG.md +++ b/nym-connect/CHANGELOG.md @@ -1,5 +1,12 @@ ## UNRELEASED +## [nym-connect-v1.1.5](https://github.com/nymtech/nym/tree/nym-connect-v1.1.5) (2023-01-10) + +- get version number from tauri and display by @fmtabbara in https://github.com/nymtech/nym/pull/2684 +- Feature/nym connect experimental software text by @fmtabbara in https://github.com/nymtech/nym/pull/2692 +- NymConnect - Display service info in tooltip **1.1.5 Release** by @fmtabbara in https://github.com/nymtech/nym/pull/2704 +- Feat/2130 tables update rebase by @gala1234 in https://github.com/nymtech/nym/pull/2742 + ## [nym-connect-v1.1.4](https://github.com/nymtech/nym/tree/nym-connect-v1.1.4) (2022-12-20) This release contains the new opt-in Test & Earn program, and it uses a stress-tested directory of network requesters to improve reliability. It also has some bugfixes, performance improvements, and better error handling. diff --git a/nym-wallet/CHANGELOG.md b/nym-wallet/CHANGELOG.md index 4f6a5d089a..14103948e3 100644 --- a/nym-wallet/CHANGELOG.md +++ b/nym-wallet/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog -## UNRELEASED +## [nym-wallet-v1.1.6](https://github.com/nymtech/nym/releases/tag/nym-wallet-v1.1.6) (2023-01-10) + +- wallet: rewrite some abci errors on the fly by @octol in https://github.com/nymtech/nym/pull/2716 +- Feature/node settings apy playground by @fmtabbara in https://github.com/nymtech/nym/pull/1677 +- Fix param input layout **1.1.5 Release** by @fmtabbara in https://github.com/nymtech/nym/pull/2720 +- Add epoch info to unbond modal **1.1.5 Release** by @fmtabbara in https://github.com/nymtech/nym/pull/2718 +- Feat/2130 tables update rebase by @gala1234ss as url param by @doums in https://github.com/nymtech/nym/pull/2780 ## [nym-wallet-v1.1.5](https://github.com/nymtech/nym/releases/tag/nym-wallet-v1.1.5) (2022-12-22)