diff --git a/nym-browser-extension/.eslintrc b/nym-browser-extension/.eslintrc deleted file mode 100644 index 3ea1281af17..00000000000 --- a/nym-browser-extension/.eslintrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": [ - "@nymproject/eslint-config-react-typescript" - ], - "parserOptions": { - "project": "./tsconfig.eslint.json" - } -} diff --git a/nym-browser-extension/.prettierrc b/nym-browser-extension/.prettierrc deleted file mode 100644 index ccf75b89de0..00000000000 --- a/nym-browser-extension/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "trailingComma": "all", - "singleQuote": true, - "printWidth": 120, - "tabWidth": 2 -} diff --git a/nym-browser-extension/.sample.env b/nym-browser-extension/.sample.env deleted file mode 100644 index 85128503d8d..00000000000 --- a/nym-browser-extension/.sample.env +++ /dev/null @@ -1,7 +0,0 @@ -RPC_URL= -VALIDATOR_URL= -PREFIX= -MIXNET_CONTRACT_ADDRESS= -VESTING_CONTRACT_ADDRESS= -DENOM= -BLOCK_EXPLORER_URL= \ No newline at end of file diff --git a/nym-browser-extension/CHANGELOG.md b/nym-browser-extension/CHANGELOG.md deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/nym-browser-extension/README.md b/nym-browser-extension/README.md deleted file mode 100644 index a6ba4b6a974..00000000000 --- a/nym-browser-extension/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Nym Browser Extension - -The Nym browser extension lets you access your Nym wallet via the browser. - -## Getting started - -You will need: - -- NodeJS (use `nvm install` to automatically install the correct version) -- `npm` -- `yarn` - -> **Note**: This project is part of a mono repo, so you will need to build the shared packages before starting. And any time they change, you'll need to rebuild them. - -From the [root of the repository](../README.md) run the following to build shared packages: - -``` -yarn -yarn build -``` - -From the `nym-browser-extension` directory of the `nym` monorepo, run: - -`yarn dev` to run the extension in dev mode. - -You can then open a browser to http://localhost:9000 and start development. - -OR - -`yarn build` to build the extension. - -The extension will build to the `nym-browser-extension/dist` directory. - -## Load extension - -To load the extension into a Chrome browser - -- Go to `settings > extensions > manage extensions` -- Select `Load unpacked` -- Select the `nym-browser-extension/dist` diff --git a/nym-browser-extension/package.json b/nym-browser-extension/package.json deleted file mode 100644 index 08fdc6f39c5..00000000000 --- a/nym-browser-extension/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "name": "@nym/browser-extension", - "version": "0.1.0", - "main": "index.js", - "license": "MIT", - "scripts": { - "dev": "yarn webpack serve --config webpack.dev.js", - "build": "yarn preinstall && webpack build --progress --config webpack.prod.js", - "lint": "eslint src", - "lint:fix": "eslint src --fix", - "lint:ts": "tsc --noEmit", - "storybook": "start-storybook -p 6006", - "storybook:build": "build-storybook" - }, - "dependencies": { - "@emotion/react": "^11.7.0", - "@emotion/styled": "^11.7.0", - "@hookform/resolvers": "^3.1.0", - "@mui/icons-material": "^5.11.11", - "@mui/material": "^5.11.15", - "@mui/system": "^5.11.15", - "@nymproject/mui-theme": "^1.0.0", - "@nymproject/nym-validator-client": ">=1.2.0-rc.0 || 1", - "@nymproject/react": "^1.0.0", - "@nymproject/types": "^1.0.0", - "@nymproject/extension-storage": ">=1.2.0-rc.0 || 1", - "@storybook/react": "^6.5.16", - "big.js": "^6.2.1", - "crypto-js": "^4.1.1", - "qrcode.react": "^3.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-error-boundary": "^4.0.3", - "react-hook-form": "^7.43.9", - "react-router-dom": "^6.9.0", - "zod": "^3.21.4" - }, - "devDependencies": { - "@nymproject/eslint-config-react-typescript": "^1.0.0", - "@pmmmwh/react-refresh-webpack-plugin": "^0.5.4", - "@svgr/webpack": "^6.1.1", - "@testing-library/jest-dom": "^5.14.1", - "@testing-library/react": "^14.0.0", - "@types/big.js": "^6.1.6", - "@types/crypto-js": "4.1.1", - "@types/jest": "^27.0.1", - "@types/node": "^18.16.1", - "@types/react": "^18.0.26", - "@types/react-dom": "^18.0.10", - "@typescript-eslint/eslint-plugin": "^5.13.0", - "@typescript-eslint/parser": "^5.13.0", - "copy-webpack-plugin": "^11.0.0", - "dotenv-webpack": "^8.0.1", - "eslint": "^8.10.0", - "eslint-config-airbnb": "^19.0.4", - "eslint-config-airbnb-typescript": "^16.1.0", - "eslint-config-prettier": "^8.5.0", - "eslint-import-resolver-root-import": "^1.0.4", - "eslint-plugin-import": "^2.25.4", - "eslint-plugin-jest": "^26.1.1", - "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-react": "^7.29.2", - "eslint-plugin-react-hooks": "^4.3.0", - "eslint-plugin-storybook": "^0.5.12", - "favicons-webpack-plugin": "^5.0.2", - "html-webpack-plugin": "^5.3.2", - "jest": "^27.1.0", - "mini-css-extract-plugin": "^2.2.2", - "prettier": "^2.8.7", - "react-refresh": "^0.14.0", - "react-refresh-typescript": "^2.0.8", - "style-loader": "^3.3.1", - "ts-jest": "^27.0.5", - "ts-loader": "^9.4.2", - "tsconfig-paths-webpack-plugin": "^3.5.2", - "typescript": "^4.6.2", - "url-loader": "^4.1.1", - "util": "^0.12.5", - "webpack": "^5.75.0", - "webpack-cli": "^5.0.1", - "webpack-dev-server": "^4.5.0", - "webpack-favicons": "^1.3.8", - "webpack-merge": "^5.8.0" - } -} diff --git a/nym-browser-extension/src/App.tsx b/nym-browser-extension/src/App.tsx deleted file mode 100644 index a66ff64a2a5..00000000000 --- a/nym-browser-extension/src/App.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { NymBrowserExtThemeWithMode } from './theme/NymBrowserExtensionTheme'; -import { AppRoutes } from './routes'; -import { AppLayout } from './layouts/AppLayout'; -import { AppProvider } from './context'; - -export const App = () => ( - - - - - - - -); diff --git a/nym-browser-extension/src/components/accounts/Accounts.tsx b/nym-browser-extension/src/components/accounts/Accounts.tsx deleted file mode 100644 index d5bf72e3ce4..00000000000 --- a/nym-browser-extension/src/components/accounts/Accounts.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react'; -import { Avatar, ListItem, ListItemAvatar, ListItemButton, ListItemText } from '@mui/material'; -import { useNavigate } from 'react-router-dom'; -import { useAppContext } from 'src/context'; -import { AccountActions } from './Actions'; - -const AccountItem = ({ - accountName, - disabled, - onSelect, -}: { - accountName: string; - disabled: boolean; - onSelect: () => void; -}) => ( - } divider> - - - {accountName[0]} - - - - -); - -export const AccountList = () => { - const navigate = useNavigate(); - const { accounts, selectAccount, selectedAccount } = useAppContext(); - - const handleSelectAccount = async (accountName: string) => { - await selectAccount(accountName); - navigate('/user/balance'); - }; - - return ( - <> - {accounts.map((accountName) => ( - handleSelectAccount(accountName)} - /> - ))} - - ); -}; diff --git a/nym-browser-extension/src/components/accounts/Actions.tsx b/nym-browser-extension/src/components/accounts/Actions.tsx deleted file mode 100644 index 84d37881c1d..00000000000 --- a/nym-browser-extension/src/components/accounts/Actions.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import React from 'react'; -import { IconButton, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material'; -import { MoreVert, VisibilityOutlined } from '@mui/icons-material'; -import { useAppContext } from 'src/context'; - -type ActionType = { - title: string; - Icon: React.ReactNode; - onSelect: () => void; -}; - -const ActionItem = ({ action }: { action: ActionType }) => ( - - {action.Icon} - {action.title} - -); - -export const AccountActions = ({ accountName }: { accountName: string }) => { - const { setShowSeedForAccount } = useAppContext(); - - const [anchorEl, setAnchorEl] = React.useState(null); - - const open = Boolean(anchorEl); - - const handleClick = (event: React.MouseEvent) => { - setAnchorEl(event.currentTarget); - }; - const handleClose = () => { - setAnchorEl(null); - }; - - const actions: Array = [ - { - title: 'View seed phrase', - Icon: , - onSelect: () => { - setShowSeedForAccount(accountName); - }, - }, - ]; - - return ( - <> - - - - - {actions.map((action) => ( - - ))} - - - ); -}; diff --git a/nym-browser-extension/src/components/accounts/ViewSeedPhrase.tsx b/nym-browser-extension/src/components/accounts/ViewSeedPhrase.tsx deleted file mode 100644 index 372c770934a..00000000000 --- a/nym-browser-extension/src/components/accounts/ViewSeedPhrase.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import React, { useState } from 'react'; -import { Box, Card, CardContent, Typography } from '@mui/material'; -import { PasswordInput } from '@nymproject/react/textfields/Password'; -import { ExtensionStorage } from '@nymproject/extension-storage'; -import { Button, ConfirmationModal } from 'src/components/ui'; - -const ShowSeedButton = ({ handleShowSeedPhrase }: { handleShowSeedPhrase: () => void }) => ( - -); - -const DoneButton = ({ onDone }: { onDone: () => void }) => ( - -); - -const Seed = ({ seed }: { seed: string }) => ( - - - {seed} - - -); - -export const ViewSeedPhrase = ({ accountName, onDone }: { accountName: string; onDone: () => void }) => { - const [seed, setSeed] = useState(); - const [password, setPassword] = useState(''); - const [error, setError] = useState(); - - const handleShowSeedPhrase = async () => { - try { - const storage = await new ExtensionStorage(password); - const accountSeed = await storage.read_mnemonic(accountName); - setSeed(accountSeed); - } catch (e) { - setError('Could not retrieve seed phrase. Please check your password'); - } - }; - - return ( - : - } - > - {seed ? ( - - ) : ( - - { - setPassword(pw); - }} - /> - - )} - - ); -}; diff --git a/nym-browser-extension/src/components/accounts/index.tsx b/nym-browser-extension/src/components/accounts/index.tsx deleted file mode 100644 index 4cc1e418422..00000000000 --- a/nym-browser-extension/src/components/accounts/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Accounts'; -export * from './Actions'; -export * from './ViewSeedPhrase'; diff --git a/nym-browser-extension/src/components/address/index.tsx b/nym-browser-extension/src/components/address/index.tsx deleted file mode 100644 index 79230b74f6e..00000000000 --- a/nym-browser-extension/src/components/address/index.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { Typography } from '@mui/material'; -import { Stack } from '@mui/system'; -import { ClientAddress } from '@nymproject/react/client-address/ClientAddress'; -import { useAppContext } from 'src/context'; - -export const Address = () => { - const { client } = useAppContext(); - - return ( - - Address - - - ); -}; diff --git a/nym-browser-extension/src/components/balance/index.tsx b/nym-browser-extension/src/components/balance/index.tsx deleted file mode 100644 index a3b0391c228..00000000000 --- a/nym-browser-extension/src/components/balance/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React, { useEffect } from 'react'; -import { Stack, Typography } from '@mui/material'; -import { useAppContext } from 'src/context'; - -export const Balance = () => { - const { balance, fiatBalance, currency, getBalance } = useAppContext(); - - useEffect(() => { - getBalance(); - }, []); - - const fiat = fiatBalance ? `~ ${Intl.NumberFormat().format(fiatBalance)} ${currency.toUpperCase()}` : '-'; - - return ( - - Available - - {balance} NYM - - {fiat} - - ); -}; diff --git a/nym-browser-extension/src/components/index.ts b/nym-browser-extension/src/components/index.ts deleted file mode 100644 index 6838fdfd2b5..00000000000 --- a/nym-browser-extension/src/components/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './accounts'; -export * from './address'; -export * from './balance'; -export * from './receive'; -export * from './send'; -export * from './ui'; diff --git a/nym-browser-extension/src/components/receive/ReceiveModal.tsx b/nym-browser-extension/src/components/receive/ReceiveModal.tsx deleted file mode 100644 index dc84aa2a33b..00000000000 --- a/nym-browser-extension/src/components/receive/ReceiveModal.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import { Card, CardContent, Dialog, DialogContent, DialogTitle, IconButton, Stack, Typography } from '@mui/material'; -import { QRCodeSVG } from 'qrcode.react'; -import { useAppContext } from 'src/context'; -import { ClientAddress } from '@nymproject/react/client-address/ClientAddress'; -import { Close } from '@mui/icons-material'; - -export const ReceiveModal = ({ open, onClose }: { open: boolean; onClose: () => void }) => { - const { client } = useAppContext(); - return ( - - - - Receive - - - - - - - - - - - - - - Your Nym address - - - - - - ); -}; diff --git a/nym-browser-extension/src/components/receive/index.ts b/nym-browser-extension/src/components/receive/index.ts deleted file mode 100644 index 356034db064..00000000000 --- a/nym-browser-extension/src/components/receive/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ReceiveModal'; diff --git a/nym-browser-extension/src/components/send/SendConfirmationModal.tsx b/nym-browser-extension/src/components/send/SendConfirmationModal.tsx deleted file mode 100644 index 59acb9a1dc7..00000000000 --- a/nym-browser-extension/src/components/send/SendConfirmationModal.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { Box, Typography } from '@mui/material'; -import { Link } from '@nymproject/react/link/Link'; -import { ConfirmationModal, Button } from 'src/components/ui'; - -export const SendConfirmationModal = ({ - amount, - txUrl, - onConfirm, -}: { - amount: string; - txUrl: string; - onConfirm: () => void; -}) => ( - - Done - - } - > - - {amount} - - - -); diff --git a/nym-browser-extension/src/components/send/index.ts b/nym-browser-extension/src/components/send/index.ts deleted file mode 100644 index cb5dd64f446..00000000000 --- a/nym-browser-extension/src/components/send/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './SendConfirmationModal'; diff --git a/nym-browser-extension/src/components/ui/AppBar/index.tsx b/nym-browser-extension/src/components/ui/AppBar/index.tsx deleted file mode 100644 index b6543c2862a..00000000000 --- a/nym-browser-extension/src/components/ui/AppBar/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import * as React from 'react'; -import { AppBar as MUIAppBar } from '@mui/material/'; -import Box from '@mui/material/Box'; -import Toolbar from '@mui/material/Toolbar'; - -export const AppBar = ({ Action }: { Action: React.ReactNode }) => ( - - - {Action} - - -); - -export default AppBar; diff --git a/nym-browser-extension/src/components/ui/BackButton/index.tsx b/nym-browser-extension/src/components/ui/BackButton/index.tsx deleted file mode 100644 index 11594ab13e4..00000000000 --- a/nym-browser-extension/src/components/ui/BackButton/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { useNavigate } from 'react-router-dom'; -import { ArrowBackIosRounded } from '@mui/icons-material'; -import { IconButton } from '@mui/material'; - -export const BackButton = ({ onBack }: { onBack?: () => void }) => { - const navigate = useNavigate(); - - const handleClick = () => { - if (onBack) { - onBack(); - } else { - navigate(-1); - } - return undefined; - }; - - return ( - - - - ); -}; diff --git a/nym-browser-extension/src/components/ui/Button/index.tsx b/nym-browser-extension/src/components/ui/Button/index.tsx deleted file mode 100644 index e44aca5c61a..00000000000 --- a/nym-browser-extension/src/components/ui/Button/index.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react'; -import { Button as MUIButton, ButtonProps } from '@mui/material'; - -export const Button = (props: ButtonProps) => ( - -); diff --git a/nym-browser-extension/src/components/ui/Logo/index.tsx b/nym-browser-extension/src/components/ui/Logo/index.tsx deleted file mode 100644 index 9b3d4ae513c..00000000000 --- a/nym-browser-extension/src/components/ui/Logo/index.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react'; -import { NymLogoBW } from '@nymproject/react/logo/NymLogoBW'; - -export const Logo = ({ small }: { small?: boolean }) => ( - -); diff --git a/nym-browser-extension/src/components/ui/LogoWithText/index.tsx b/nym-browser-extension/src/components/ui/LogoWithText/index.tsx deleted file mode 100644 index 661cd0766d2..00000000000 --- a/nym-browser-extension/src/components/ui/LogoWithText/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import { Stack, Typography } from '@mui/material'; -import { Logo } from '../Logo'; -import { Title } from '../Title'; - -export const LogoWithText = ({ - logoSmall, - title, - description, -}: { - logoSmall?: boolean; - title: string; - description?: string; -}) => ( - - - {title} - {description} - -); diff --git a/nym-browser-extension/src/components/ui/MenuDrawer/index.tsx b/nym-browser-extension/src/components/ui/MenuDrawer/index.tsx deleted file mode 100644 index fcc0cafb954..00000000000 --- a/nym-browser-extension/src/components/ui/MenuDrawer/index.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import * as React from 'react'; -import Box from '@mui/material/Box'; -import Drawer from '@mui/material/Drawer'; -import List from '@mui/material/List'; -import ListItem from '@mui/material/ListItem'; -import ListItemButton from '@mui/material/ListItemButton'; -import ListItemIcon from '@mui/material/ListItemIcon'; -import ListItemText from '@mui/material/ListItemText'; -import { AccountBalanceWalletRounded, AccountCircleRounded, ArrowDownwardRounded } from '@mui/icons-material'; -import { Link } from 'react-router-dom'; - -const menuSchema = [ - { - title: 'Accounts', - Icon: , - path: '/user/accounts', - }, - { - title: 'Balance', - Icon: , - path: '/user/balance', - }, - { - title: 'Send', - Icon: , - path: '/user/send', - }, -]; - -export const MenuDrawer = ({ open, onClose }: { open: boolean; onClose: () => void }) => { - const list = () => ( - {}}> - - {menuSchema.map(({ title, Icon, path }) => ( - - - - {Icon} - - - - - ))} - - - ); - - return ( -
- - {list()} - -
- ); -}; diff --git a/nym-browser-extension/src/components/ui/Modal/ErrorModal.tsx b/nym-browser-extension/src/components/ui/Modal/ErrorModal.tsx deleted file mode 100644 index 713c83fdc9e..00000000000 --- a/nym-browser-extension/src/components/ui/Modal/ErrorModal.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import React from 'react'; -import { - Breakpoint, - Paper, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - SxProps, - Typography, -} from '@mui/material'; -import { Button } from '../Button'; - -export interface ErrorModalProps { - open: boolean; - children?: React.ReactNode; - title: React.ReactNode | string; - subtitle?: React.ReactNode | string; - sx?: SxProps; - fullWidth?: boolean; - maxWidth?: Breakpoint; - backdropProps?: object; - onClose?: () => void; -} - -export const ErrorModal = ({ - open, - onClose, - children, - title, - subtitle, - sx, - fullWidth, - maxWidth, - backdropProps, -}: ErrorModalProps) => { - const Title = ( - - - {title} - - {subtitle && - (typeof subtitle === 'string' ? ( - - {subtitle} - - ) : ( - subtitle - ))} - - ); - - return ( - - {Title} - {children} - - - - - ); -}; diff --git a/nym-browser-extension/src/components/ui/Modal/LoadingModal.tsx b/nym-browser-extension/src/components/ui/Modal/LoadingModal.tsx deleted file mode 100644 index 82b0301c0f6..00000000000 --- a/nym-browser-extension/src/components/ui/Modal/LoadingModal.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -import { Box, CircularProgress, Modal, Stack, Typography, SxProps } from '@mui/material'; - -const modalStyle: SxProps = { - position: 'absolute', - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - width: 300, - bgcolor: 'background.paper', - boxShadow: 24, - borderRadius: '16px', - p: 4, -}; - -export const LoadingModal = ({ sx, backdropProps }: { sx?: SxProps; backdropProps?: object }) => ( - - `1px solid ${t.palette.grey[500]}`, ...modalStyle, ...sx }} textAlign="center"> - - - Please wait... - - - -); diff --git a/nym-browser-extension/src/components/ui/Modal/Modal.tsx b/nym-browser-extension/src/components/ui/Modal/Modal.tsx deleted file mode 100644 index 18f88e28d06..00000000000 --- a/nym-browser-extension/src/components/ui/Modal/Modal.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -import { - Breakpoint, - Paper, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - SxProps, - Typography, -} from '@mui/material'; - -export interface ConfirmationModalProps { - open: boolean; - children?: React.ReactNode; - title: React.ReactNode | string; - subtitle?: React.ReactNode | string; - ConfirmButton: React.ReactNode; - sx?: SxProps; - fullWidth?: boolean; - maxWidth?: Breakpoint; - backdropProps?: object; - onClose?: () => void; -} - -export const ConfirmationModal = ({ - open, - onClose, - children, - title, - subtitle, - ConfirmButton, - sx, - fullWidth, - maxWidth, - backdropProps, -}: ConfirmationModalProps) => { - const Title = ( - - - {title} - - {subtitle && - (typeof subtitle === 'string' ? ( - - {subtitle} - - ) : ( - subtitle - ))} - - ); - - return ( - - {Title} - {children} - {ConfirmButton} - - ); -}; diff --git a/nym-browser-extension/src/components/ui/Modal/index.tsx b/nym-browser-extension/src/components/ui/Modal/index.tsx deleted file mode 100644 index 310ca4336cc..00000000000 --- a/nym-browser-extension/src/components/ui/Modal/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Modal'; -export * from './LoadingModal'; -export * from './ErrorModal'; diff --git a/nym-browser-extension/src/components/ui/Title/index.tsx b/nym-browser-extension/src/components/ui/Title/index.tsx deleted file mode 100644 index 1bc6036d6ed..00000000000 --- a/nym-browser-extension/src/components/ui/Title/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { Typography } from '@mui/material'; - -const FONT_WEIGHT = 400; - -export const Title = ({ children }: { children: string }) => ( - - {children} - -); diff --git a/nym-browser-extension/src/components/ui/index.ts b/nym-browser-extension/src/components/ui/index.ts deleted file mode 100644 index 5bee731a181..00000000000 --- a/nym-browser-extension/src/components/ui/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './AppBar'; -export * from './Button'; -export * from './BackButton'; -export * from './Logo'; -export * from './LogoWithText'; -export * from './MenuDrawer'; -export * from './Modal'; -export * from './Title'; diff --git a/nym-browser-extension/src/config.ts b/nym-browser-extension/src/config.ts deleted file mode 100644 index f66efff5455..00000000000 --- a/nym-browser-extension/src/config.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const config = { - rpcUrl: process.env.RPC_URL || '', - validatorUrl: process.env.VALIDATOR_URL || '', - prefix: process.env.PREFIX || '', - mixnetContractAddress: process.env.MIXNET_CONTRACT_ADDRESS || '', - vestingContractAddress: process.env.VESTING_CONTRACT_ADDRESS || '', - denom: process.env.DENOM || '', -}; diff --git a/nym-browser-extension/src/context/app.tsx b/nym-browser-extension/src/context/app.tsx deleted file mode 100644 index 9d052c1a604..00000000000 --- a/nym-browser-extension/src/context/app.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import React, { useEffect, useMemo, useState } from 'react'; -import ValidatorClient from '@nymproject/nym-validator-client'; -import { ExtensionStorage } from '@nymproject/extension-storage'; -import { connectToValidator } from 'src/validator-client'; -import { unymToNym } from 'src/utils/coin'; -import { Currency, getTokenPrice } from 'src/utils/price'; - -type TAppContext = { - client?: ValidatorClient; - accounts: string[]; - balance?: string; - fiatBalance?: number; - denom: 'NYM'; - minorDenom: 'unym'; - currency: Currency; - showSeedForAccount?: string; - selectedAccount: string; - storage?: ExtensionStorage; - selectAccount: (accountName: string) => Promise; - setAccounts: (accounts: string[]) => void; - setShowSeedForAccount: (accountName?: string) => void; - handleUnlockWallet: (password: string) => void; - getBalance: () => void; -}; - -type TBalanceInNYMs = string; - -const DEFAULT_ACCOUNT_NAME = 'Default account'; - -const AppContext = React.createContext({} as TAppContext); - -export const AppProvider = ({ children }: { children: React.ReactNode }) => { - const [client, setClient] = useState(); - const [selectedAccount, setSelected] = useState(DEFAULT_ACCOUNT_NAME); - const [balance, setBalance] = useState(); - const [fiatBalance, setFiatBalance] = useState(); - const [accounts, setAccounts] = useState([]); - const [showSeedForAccount, setShowSeedForAccount] = useState(); - const [storage, setStorage] = useState(); - - const denom = 'NYM'; - const minorDenom = 'unym'; - const currency = 'gbp'; - - const handleUnlockWallet = async (password: string) => { - const store = await new ExtensionStorage(password); - const mnemonic = await store.read_mnemonic(DEFAULT_ACCOUNT_NAME); - const userAccounts = await store.get_all_mnemonic_keys(); - const clientFromMnemonic = await connectToValidator(mnemonic); - - setStorage(store); - setAccounts(userAccounts); - setClient(clientFromMnemonic); - }; - - const selectAccount = async (accountName: string) => { - const mnemonic = await storage!.read_mnemonic(accountName); - const clientFromMnemonic = await connectToValidator(mnemonic); - setSelected(accountName); - setClient(clientFromMnemonic); - }; - - const getFiatBalance = async (bal: number) => { - const tokenPrice = await getTokenPrice('nym', currency); - const fiatBal = tokenPrice.nym.gbp * bal; - return fiatBal; - }; - - const getBalance = async () => { - const bal = await client?.getBalance(client.address); - if (bal) { - const nym = unymToNym(Number(bal.amount)); - const fiat = await getFiatBalance(nym); - setFiatBalance(fiat); - setBalance(nym.toString()); - } - }; - - useEffect(() => { - if (client) { - getBalance(); - } - }, [client]); - - const value = useMemo( - () => ({ - client, - accounts, - balance, - fiatBalance, - currency, - denom, - minorDenom, - selectedAccount, - storage, - handleUnlockWallet, - getBalance, - setShowSeedForAccount, - showSeedForAccount, - setAccounts, - selectAccount, - }), - [client, accounts, balance, fiatBalance, denom, minorDenom, selectedAccount, showSeedForAccount, storage], - ); - - return {children}; -}; - -export const useAppContext = () => React.useContext(AppContext); diff --git a/nym-browser-extension/src/context/index.tsx b/nym-browser-extension/src/context/index.tsx deleted file mode 100644 index 5bcd157c3cb..00000000000 --- a/nym-browser-extension/src/context/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export * from './app'; -export * from './send'; -export * from './register'; diff --git a/nym-browser-extension/src/context/register.tsx b/nym-browser-extension/src/context/register.tsx deleted file mode 100644 index 2204b07d0b9..00000000000 --- a/nym-browser-extension/src/context/register.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React, { useMemo, useState } from 'react'; -import { ExtensionStorage } from '@nymproject/extension-storage'; - -const RegisterContext = React.createContext({} as TRegisterContext); - -type TRegisterContext = { - userPassword: string; - userMnemonic: string; - accountName: string; - checkAccountName: () => Promise; - setUserPassword: (password: string) => void; - setUserMnemonic: (mnemonic: string) => void; - setAccountName: (name: string) => void; - createAccount: (args: { mnemonic: string; password: string; accName: string }) => Promise; - importAccount: () => Promise; - resetState: () => void; -}; - -export const RegisterContextProvider = ({ children }: { children: React.ReactNode }) => { - const [userPassword, setUserPassword] = useState(''); - const [userMnemonic, setUserMnemonic] = useState(''); - const [accountName, setAccountName] = useState(''); - - const resetState = () => { - setUserMnemonic(''); - setUserPassword(''); - setAccountName(''); - }; - - const createAccount = async ({ - mnemonic, - password, - accName, - }: { - mnemonic: string; - password: string; - accName: string; - }) => { - const storage = await new ExtensionStorage(password); - await storage.store_mnemonic(accName, mnemonic); - }; - - const importAccount = async () => { - const storage = await new ExtensionStorage(userPassword); - await storage.store_mnemonic(accountName, userMnemonic); - const accounts = await storage.get_all_mnemonic_keys(); - return accounts; - }; - - const checkAccountName = async () => true; - - const value = useMemo( - () => ({ - userPassword, - setUserPassword, - userMnemonic, - accountName, - setAccountName, - setUserMnemonic, - createAccount, - checkAccountName, - importAccount, - resetState, - }), - [userPassword, userMnemonic, accountName], - ); - - return {children}; -}; - -export const useRegisterContext = () => React.useContext(RegisterContext); diff --git a/nym-browser-extension/src/context/send.tsx b/nym-browser-extension/src/context/send.tsx deleted file mode 100644 index a5c4295ff86..00000000000 --- a/nym-browser-extension/src/context/send.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import React, { useMemo, useState } from 'react'; -import { DecCoin } from '@nymproject/types'; -import { useNavigate } from 'react-router-dom'; -import { nymToUnym } from 'src/utils/coin'; -import { TTransaction } from 'src/types'; -import { Fee, useGetFee } from 'src/hooks/useGetFee'; -import { createFeeObject } from 'src/utils/fee'; -import { useAppContext } from './app'; - -type TSendContext = { - address?: string; - amount?: DecCoin; - transaction?: TTransaction; - fee?: Fee; - handleChangeAddress: (address?: string) => void; - handleChangeAmount: (amount?: DecCoin) => void; - handleSend: () => void; - resetTx: () => void; - onDone: () => void; - handleGetFee: (address: string, amount: string) => Promise; -}; - -const SendContext = React.createContext({} as TSendContext); - -export const SendProvider = ({ children }: { children: React.ReactNode }) => { - const [address, setAddress] = useState(); - const [amount, setAmount] = useState(); - const [transaction, setTransaction] = useState(); - - const { client, minorDenom } = useAppContext(); - const navigate = useNavigate(); - - const handleChangeAddress = (_address?: string) => setAddress(_address); - - const handleChangeAmount = (_amount?: DecCoin) => setAmount(_amount); - - const { getFee, fee } = useGetFee(); - - const handleGetFee = async (addressVal: string, amountVal: string) => { - const unym = nymToUnym(Number(amountVal)); - - if (client) { - // client loses its 'this' context when passing the method - // TODO find a better way of doing this. - getFee(client.simulateSend.bind(client), { - signingAddress: client.address, - from: client.address, - to: addressVal, - amount: [{ amount: unym.toString(), denom: minorDenom }], - }); - } - }; - - const handleSend = async () => { - setTransaction({ status: 'loading', type: 'send' }); - let unyms; - - if (!Number(amount?.amount)) { - setTransaction({ status: 'error', type: 'send', message: 'Amount is not a valid number' }); - } - - if (amount) { - unyms = nymToUnym(Number(amount.amount)); - } - - if (client && address && unyms) { - try { - const response = await client.send( - address, - [{ amount: unyms.toString(), denom: minorDenom }], - createFeeObject(fee?.unym), - ); - - setTransaction({ status: 'success', type: 'send', txHash: response?.transactionHash }); - } catch (e) { - setTransaction({ - status: 'error', - type: 'send', - message: e instanceof Error ? e.message : 'Error making send transaction. Please try again', - }); - } - } - }; - - const resetTx = () => { - setTransaction(undefined); - }; - - const onDone = () => { - navigate('/user/balance'); - }; - - const value = useMemo( - () => ({ - address, - amount, - transaction, - fee, - handleChangeAddress, - handleChangeAmount, - handleSend, - resetTx, - onDone, - handleGetFee, - }), - [address, amount, transaction, fee], - ); - - return {children}; -}; - -export const useSendContext = () => React.useContext(SendContext); diff --git a/nym-browser-extension/src/hooks/useCreatePassword.tsx b/nym-browser-extension/src/hooks/useCreatePassword.tsx deleted file mode 100644 index 33aa94ca594..00000000000 --- a/nym-browser-extension/src/hooks/useCreatePassword.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useState } from 'react'; - -export const useCreatePassword = () => { - const [password, setPassword] = useState(''); - const [confirmPassword, setConfirmPassword] = useState(''); - const [isSafePassword, setIsSafePassword] = useState(false); - const [hasReadTerms, setHasReadTerms] = useState(false); - - const canProceed = isSafePassword && hasReadTerms && password === confirmPassword; - - return { - password, - setPassword, - confirmPassword, - setConfirmPassword, - setIsSafePassword, - canProceed, - setHasReadTerms, - hasReadTerms, - }; -}; diff --git a/nym-browser-extension/src/hooks/useGetFee.ts b/nym-browser-extension/src/hooks/useGetFee.ts deleted file mode 100644 index af6080a2f45..00000000000 --- a/nym-browser-extension/src/hooks/useGetFee.ts +++ /dev/null @@ -1,40 +0,0 @@ -import Big from 'big.js'; -import { useState } from 'react'; -import { unymToNym } from 'src/utils/coin'; - -export type Fee = { nym: number; unym: number }; - -export function useGetFee() { - const [fee, setFee] = useState(); - const [isLoading, setIsLoading] = useState(false); - const [error, setError] = useState(); - - async function getFee(txReq: (args: T) => Promise, args: T) { - setError(undefined); - setIsLoading(true); - - try { - const txFee = await txReq(args); - - if (txFee) { - const feeWithMultiplyer = Big(txFee).mul(1); - console.log(fee); - - const txFeeInNyms = unymToNym(feeWithMultiplyer); - - setFee({ nym: Number(txFeeInNyms), unym: Number(feeWithMultiplyer) }); - } - - if (!txFee) { - setError('Unable to calculate fee'); - } - } catch (e) { - console.error(e); - setError(`Unable to get estimated fee: ${e}`); - } finally { - setIsLoading(false); - } - } - - return { fee, getFee, isLoading, error }; -} diff --git a/nym-browser-extension/src/index.html b/nym-browser-extension/src/index.html deleted file mode 100644 index 5c2e4f5473e..00000000000 --- a/nym-browser-extension/src/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Nym browser extension - - -
- - diff --git a/nym-browser-extension/src/index.tsx b/nym-browser-extension/src/index.tsx deleted file mode 100644 index 56859d9574c..00000000000 --- a/nym-browser-extension/src/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { createRoot } from 'react-dom/client'; -import { App } from './App'; - -const rootDomElem = document.getElementById('root'); - -if (rootDomElem) { - const root = createRoot(rootDomElem); - root.render(); -} diff --git a/nym-browser-extension/src/layouts/AppLayout.tsx b/nym-browser-extension/src/layouts/AppLayout.tsx deleted file mode 100644 index be5a54398e9..00000000000 --- a/nym-browser-extension/src/layouts/AppLayout.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { Container } from '@mui/material'; -import React from 'react'; - -export const AppLayout = ({ children }: { children: React.ReactNode }) => ( - - {children} - -); diff --git a/nym-browser-extension/src/layouts/CenteredLogo.tsx b/nym-browser-extension/src/layouts/CenteredLogo.tsx deleted file mode 100644 index 5a59bd3673b..00000000000 --- a/nym-browser-extension/src/layouts/CenteredLogo.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import { Box } from '@mui/material'; -import { LogoWithText } from 'src/components/ui'; - -const layoutStyle = { - height: '100%', - display: 'grid', - gridTemplateColumns: '1fr', - gridTemplateRows: 'repeat(3, 1fr)', - gridColumnGap: '0px', - gridRowGap: '0px', - p: 2, -}; - -export const CenteredLogoLayout = ({ - title, - description, - Actions, -}: { - title: string; - description?: string; - Actions: React.ReactNode; -}) => ( - - - - {Actions} - -); diff --git a/nym-browser-extension/src/layouts/PageLayout.tsx b/nym-browser-extension/src/layouts/PageLayout.tsx deleted file mode 100644 index 07bd62797dd..00000000000 --- a/nym-browser-extension/src/layouts/PageLayout.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React, { useCallback, useState } from 'react'; -import { Box, IconButton } from '@mui/material'; -import MenuIcon from '@mui/icons-material/Menu'; -import { AppBar, BackButton, MenuDrawer } from 'src/components/ui'; -import { useLocation } from 'react-router-dom'; - -const layoutStyle = { - display: 'grid', - gridTemplateColumns: '1fr', - gridTemplateRows: '50px 1fr', - gridColumnGap: '0px', - gridRowGap: '0px', -}; - -export const PageLayout = ({ children, onBack }: { children: React.ReactNode; onBack?: () => void }) => { - const [menuOpen, setMenuOpen] = useState(false); - - const location = useLocation(); - - const MenuAction = useCallback( - () => ( - setMenuOpen(true)}> - - - ), - [], - ); - - const Action = location.pathname.includes('balance') ? MenuAction : BackButton; - - return ( - - } /> - setMenuOpen(false)} /> - {children} - - ); -}; diff --git a/nym-browser-extension/src/layouts/TopLogo.tsx b/nym-browser-extension/src/layouts/TopLogo.tsx deleted file mode 100644 index b8b9a75ccfb..00000000000 --- a/nym-browser-extension/src/layouts/TopLogo.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { Box } from '@mui/material'; -import { BackButton, LogoWithText } from 'src/components/ui'; - -const layoutStyle = { - height: '100%', - display: 'grid', - gridTemplateColumns: '1fr', - gridTemplaterows: '1fr 2fr 1fr', - gridColumnGap: '0px', - gridRowGap: '0px', - position: 'relative', - p: 2, -}; - -export const TopLogoLayout = ({ - title, - description, - children, - Actions, -}: { - title: string; - description?: string; - children: React.ReactNode; - Actions: React.ReactNode; -}) => ( - - - - - - - - {children} - {Actions} - -); diff --git a/nym-browser-extension/src/layouts/index.ts b/nym-browser-extension/src/layouts/index.ts deleted file mode 100644 index 11267509504..00000000000 --- a/nym-browser-extension/src/layouts/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './AppLayout'; -export * from './CenteredLogo'; -export * from './TopLogo'; diff --git a/nym-browser-extension/src/manifest.json b/nym-browser-extension/src/manifest.json deleted file mode 100644 index 47ced7fc78c..00000000000 --- a/nym-browser-extension/src/manifest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "Nym browser extension", - "description": "Nym browser extension - Wallet & credentials", - "version": "0.1.0", - "manifest_version": 3, - "action": { - "default_popup": "index.html", - "default_title": "Nym - Browser extension" - }, - "icons": { - "16": "favicon-16x16.png", - "32": "favicon-32x32.png", - "48": "favicon-48x48.png" - }, - "content_security_policy": { - "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'" - } -} diff --git a/nym-browser-extension/src/pages/accounts/Accounts.tsx b/nym-browser-extension/src/pages/accounts/Accounts.tsx deleted file mode 100644 index 00b8f065f20..00000000000 --- a/nym-browser-extension/src/pages/accounts/Accounts.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React, { useEffect } from 'react'; -import { PageLayout } from 'src/layouts/PageLayout'; -import { Stack } from '@mui/material'; -import { Add, ArrowDownward } from '@mui/icons-material'; -import { AccountList, Button } from 'src/components'; -import { ViewSeedPhrase } from 'src/components/accounts/ViewSeedPhrase'; -import { useAppContext, useRegisterContext } from 'src/context'; -import { useLocation, useNavigate } from 'react-router-dom'; - -export const Accounts = () => { - const { showSeedForAccount, setShowSeedForAccount } = useAppContext(); - const { resetState } = useRegisterContext(); - - useEffect(() => { - resetState(); - }, []); - - const location = useLocation(); - const navigate = useNavigate(); - - const handleAddAccount = () => navigate(`${location.pathname}/add-account`); - - const handleImportAccount = () => navigate(`${location.pathname}/import-account`); - - const onBack = () => navigate('/user/balance'); - - return ( - - {showSeedForAccount && ( - setShowSeedForAccount(undefined)} /> - )} - - - - - - - ); -}; diff --git a/nym-browser-extension/src/pages/accounts/AddAccount.tsx b/nym-browser-extension/src/pages/accounts/AddAccount.tsx deleted file mode 100644 index 50849ea9d3b..00000000000 --- a/nym-browser-extension/src/pages/accounts/AddAccount.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { useNavigate } from 'react-router-dom'; -import { useRegisterContext } from 'src/context'; -import { SeedPhraseTemplate } from 'src/pages/templates'; - -export const AddAccount = () => { - const { setUserMnemonic } = useRegisterContext(); - const navigate = useNavigate(); - - const onNext = (seedPhrase: string) => { - setUserMnemonic(seedPhrase); - navigate('/user/accounts/name-account'); - }; - - return ; -}; diff --git a/nym-browser-extension/src/pages/accounts/Complete.tsx b/nym-browser-extension/src/pages/accounts/Complete.tsx deleted file mode 100644 index b94616c531b..00000000000 --- a/nym-browser-extension/src/pages/accounts/Complete.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import { useNavigate } from 'react-router-dom'; -import { SetupCompleteTemplate } from 'src/pages/templates/Complete'; - -export const SetupComplete = () => { - const navigate = useNavigate(); - const handleOnDone = () => { - navigate('/user/accounts'); - }; - - return ( - - ); -}; diff --git a/nym-browser-extension/src/pages/accounts/ConfirmPassword.tsx b/nym-browser-extension/src/pages/accounts/ConfirmPassword.tsx deleted file mode 100644 index 10f3efd549f..00000000000 --- a/nym-browser-extension/src/pages/accounts/ConfirmPassword.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React, { useState } from 'react'; -import { PasswordInput } from '@nymproject/react/textfields/Password'; -import { Button } from 'src/components'; -import { useAppContext, useRegisterContext } from 'src/context'; -import { TopLogoLayout } from 'src/layouts'; -import { useNavigate } from 'react-router-dom'; - -export const ConfirmPassword = () => { - const { setAccounts } = useAppContext(); - const { userPassword, setUserPassword, importAccount } = useRegisterContext(); - const [error, setError] = useState(); - - const navigate = useNavigate(); - - const handleOnComplete = async () => { - try { - const accounts = await importAccount(); - setAccounts(accounts); - navigate('/user/accounts/complete'); - } catch (e) { - setError('Incorrect password. Please try again'); - } - }; - - const onChange = (password: string) => { - setError(undefined); - setUserPassword(password); - }; - - return ( - - Confirm - - } - > - - - ); -}; diff --git a/nym-browser-extension/src/pages/accounts/ImportAccount.tsx b/nym-browser-extension/src/pages/accounts/ImportAccount.tsx deleted file mode 100644 index b630eef9866..00000000000 --- a/nym-browser-extension/src/pages/accounts/ImportAccount.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { useNavigate } from 'react-router-dom'; -import { useRegisterContext } from 'src/context/register'; -import { ImportAccountTemplate } from '../templates'; - -export const ImportAccount = () => { - const { userMnemonic, setUserMnemonic } = useRegisterContext(); - const navigate = useNavigate(); - - const handleOnNext = () => { - navigate('/user/accounts/name-account'); - }; - - return ( - - ); -}; diff --git a/nym-browser-extension/src/pages/accounts/NameAccount.tsx b/nym-browser-extension/src/pages/accounts/NameAccount.tsx deleted file mode 100644 index 7cb2bc9b662..00000000000 --- a/nym-browser-extension/src/pages/accounts/NameAccount.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React, { useState } from 'react'; -import { TextField } from '@mui/material'; -import { Button } from 'src/components'; -import { useRegisterContext } from 'src/context/register'; -import { TopLogoLayout } from 'src/layouts'; -import { useNavigate } from 'react-router-dom'; -import { useAppContext } from 'src/context'; - -export const NameAccount = () => { - const { accountName, setAccountName } = useRegisterContext(); - const { storage } = useAppContext(); - const navigate = useNavigate(); - - const [error, setError] = useState(); - - const handleNext = async () => { - const accountNameExists = await storage?.has_mnemonic(accountName); - if (accountNameExists) { - setError('Account name already exists. Please choose another account name'); - } else { - navigate('/user/accounts/confirm-password'); - } - }; - - return ( - - Next - - } - > - { - setError(undefined); - setAccountName(e.target.value); - }} - error={!!error} - helperText={error} - /> - - ); -}; diff --git a/nym-browser-extension/src/pages/accounts/index.ts b/nym-browser-extension/src/pages/accounts/index.ts deleted file mode 100644 index ed37aac8adb..00000000000 --- a/nym-browser-extension/src/pages/accounts/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './Accounts'; -export * from './AddAccount'; -export * from './Complete'; -export * from './ConfirmPassword'; -export * from './ImportAccount'; -export * from './NameAccount'; diff --git a/nym-browser-extension/src/pages/auth/ForgotPassword.tsx b/nym-browser-extension/src/pages/auth/ForgotPassword.tsx deleted file mode 100644 index 5910a1d77fd..00000000000 --- a/nym-browser-extension/src/pages/auth/ForgotPassword.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -import { Typography } from '@mui/material'; -import { Box } from '@mui/system'; -import { TopLogoLayout } from 'src/layouts'; - -const steps = [ - 'Make sure you have your mnemonic saved', - 'Uninstal Nym extension wallet', - 'Reinstal Nym extension wallet', - 'Import your account using seed phrase', - 'Create new password', -]; - -export const ForgotPassword = () => ( - }> - - {steps.map((step, index) => ( - - {`${index + 1}. ${step}`} - - ))} - - -); diff --git a/nym-browser-extension/src/pages/auth/Login.tsx b/nym-browser-extension/src/pages/auth/Login.tsx deleted file mode 100644 index 11db476a559..00000000000 --- a/nym-browser-extension/src/pages/auth/Login.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import React from 'react'; -import { Stack, TextField } from '@mui/material'; -import { useLocation, useNavigate } from 'react-router-dom'; -import { Button } from 'src/components/ui'; -import { CenteredLogoLayout } from 'src/layouts/CenteredLogo'; -import { useAppContext } from 'src/context'; -import { useForm } from 'react-hook-form'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { validationSchema } from './validationSchema'; - -export const Login = () => { - const { handleUnlockWallet } = useAppContext(); - const navigate = useNavigate(); - const location = useLocation(); - - const { - register, - handleSubmit, - setError, - formState: { errors, isSubmitting }, - } = useForm({ resolver: zodResolver(validationSchema), defaultValues: { password: '' } }); - - const onSubmit = async (data: { password: string }) => { - try { - await handleUnlockWallet(data.password); - } catch (e) { - setError('password', { message: 'Incorrect password. Please try again.' }); - } - }; - - return ( - - - - - - - } - /> - ); -}; diff --git a/nym-browser-extension/src/pages/auth/index.tsx b/nym-browser-extension/src/pages/auth/index.tsx deleted file mode 100644 index 80aa38c3c1a..00000000000 --- a/nym-browser-extension/src/pages/auth/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Login'; -export * from './ForgotPassword'; diff --git a/nym-browser-extension/src/pages/auth/validationSchema.ts b/nym-browser-extension/src/pages/auth/validationSchema.ts deleted file mode 100644 index a24b838a9c2..00000000000 --- a/nym-browser-extension/src/pages/auth/validationSchema.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as z from 'zod'; - -export const validationSchema = z.object({ - password: z.string().min(1, { message: 'Required' }), -}); diff --git a/nym-browser-extension/src/pages/balance/index.tsx b/nym-browser-extension/src/pages/balance/index.tsx deleted file mode 100644 index a4fc0cd4e61..00000000000 --- a/nym-browser-extension/src/pages/balance/index.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React, { useState } from 'react'; -import { useNavigate } from 'react-router-dom'; -import { Box, Stack, IconButton, Typography } from '@mui/material'; -import { ArrowDownwardRounded, ArrowUpwardRounded, TollRounded } from '@mui/icons-material'; -import { PageLayout } from 'src/layouts/PageLayout'; -import { Address, Balance, ReceiveModal } from 'src/components'; - -type ActionsSchema = Array<{ - title: string; - Icon: React.ReactNode; - onClick: () => void; -}>; - -const Actions = ({ actionsSchema }: { actionsSchema: ActionsSchema }) => ( - - {actionsSchema.map(({ title, Icon, onClick }) => ( - - - {Icon} - - {title} - - ))} - -); - -export const BalancePage = () => { - const [showReceiveModal, setShowReceiveModal] = useState(false); - const navigate = useNavigate(); - - const actionsSchema = [ - { - title: 'Send', - Icon: , - onClick: () => navigate('/user/send'), - }, - { - title: 'Receive', - Icon: , - onClick: () => setShowReceiveModal(true), - }, - { - title: 'Buy', - Icon: , - onClick: () => navigate('/user/balance'), - }, - ]; - - return ( - - - setShowReceiveModal(false)} /> -
- - - - - ); -}; diff --git a/nym-browser-extension/src/pages/delegation/index.tsx b/nym-browser-extension/src/pages/delegation/index.tsx deleted file mode 100644 index 4e89134021e..00000000000 --- a/nym-browser-extension/src/pages/delegation/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import React from 'react'; - -export const Delegation = () =>

Delegation

; diff --git a/nym-browser-extension/src/pages/home/index.tsx b/nym-browser-extension/src/pages/home/index.tsx deleted file mode 100644 index 21cc23d9200..00000000000 --- a/nym-browser-extension/src/pages/home/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -import { Stack } from '@mui/system'; -import { Button } from 'src/components/ui'; -import { CenteredLogoLayout } from 'src/layouts'; -import { Link } from 'react-router-dom'; - -export const Home = () => ( - - - - - - - - - } - /> -); diff --git a/nym-browser-extension/src/pages/index.ts b/nym-browser-extension/src/pages/index.ts deleted file mode 100644 index 47c840f7525..00000000000 --- a/nym-browser-extension/src/pages/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './accounts'; -export * from './auth'; -export * from './balance'; -export * from './home'; -export * from './receive'; -export * from './send'; -export * from './settings'; -export * from './delegation'; diff --git a/nym-browser-extension/src/pages/receive/index.tsx b/nym-browser-extension/src/pages/receive/index.tsx deleted file mode 100644 index cdccb23d3e1..00000000000 --- a/nym-browser-extension/src/pages/receive/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import React from 'react'; - -export const Receive = () =>

Receive

; diff --git a/nym-browser-extension/src/pages/register/Complete.tsx b/nym-browser-extension/src/pages/register/Complete.tsx deleted file mode 100644 index 601e3559101..00000000000 --- a/nym-browser-extension/src/pages/register/Complete.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { SetupCompleteTemplate } from '../templates/Complete'; - -export const SetupComplete = ({ onDone }: { onDone: () => void }) => ( - -); diff --git a/nym-browser-extension/src/pages/register/CreatePasswordOnExistingAccount.tsx b/nym-browser-extension/src/pages/register/CreatePasswordOnExistingAccount.tsx deleted file mode 100644 index 77a19b7e5ec..00000000000 --- a/nym-browser-extension/src/pages/register/CreatePasswordOnExistingAccount.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { useCreatePassword } from 'src/hooks/useCreatePassword'; -import { useRegisterContext } from 'src/context/register'; -import { CreatePasswordTemplate } from 'src/pages/templates/CreatePassword'; - -export const CreatePasswordOnExistingAccount = ({ onComplete }: { onComplete: () => void }) => { - const passwordState = useCreatePassword(); - const { createAccount, userMnemonic } = useRegisterContext(); - - const handleOnComplete = async () => { - await createAccount({ mnemonic: userMnemonic, password: passwordState.password, accName: 'Default account' }); - onComplete(); - }; - - return ; -}; diff --git a/nym-browser-extension/src/pages/register/CreatePasswordOnNewAccount.tsx b/nym-browser-extension/src/pages/register/CreatePasswordOnNewAccount.tsx deleted file mode 100644 index 2a5190ac7cb..00000000000 --- a/nym-browser-extension/src/pages/register/CreatePasswordOnNewAccount.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { useCreatePassword } from 'src/hooks/useCreatePassword'; -import { useRegisterContext } from 'src/context/register'; -import { CreatePasswordTemplate } from 'src/pages/templates/CreatePassword'; - -export const CreatePasswordOnNewAccount = ({ onNext }: { onNext: () => void }) => { - const passwordState = useCreatePassword(); - const { setUserPassword } = useRegisterContext(); - - const handleCreateAccount = async () => { - await setUserPassword(passwordState.password); - onNext(); - }; - - return ; -}; diff --git a/nym-browser-extension/src/pages/register/ImportAccount.tsx b/nym-browser-extension/src/pages/register/ImportAccount.tsx deleted file mode 100644 index 76cf4204716..00000000000 --- a/nym-browser-extension/src/pages/register/ImportAccount.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import { useLocation, useNavigate } from 'react-router-dom'; -import { useRegisterContext } from 'src/context/register'; -import { ImportAccountTemplate } from '../templates/ImportAccount'; - -export const ImportAccount = () => { - const navigate = useNavigate(); - const location = useLocation(); - - const { setUserMnemonic, userMnemonic } = useRegisterContext(); - - const handleNext = async () => { - navigate(`${location.pathname}/create-password`); - }; - - return ( - - ); -}; diff --git a/nym-browser-extension/src/pages/register/SeedPhrase.tsx b/nym-browser-extension/src/pages/register/SeedPhrase.tsx deleted file mode 100644 index 7218aa8da7f..00000000000 --- a/nym-browser-extension/src/pages/register/SeedPhrase.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { useNavigate } from 'react-router-dom'; -import { useRegisterContext } from 'src/context/register'; -import { SeedPhraseTemplate } from '../templates/SeedPhrase'; - -export const SeedPhrase = () => { - const navigate = useNavigate(); - - const { createAccount, userPassword } = useRegisterContext(); - - const handleEncryptSeedPhrase = async (seedPhrase: string) => { - await createAccount({ mnemonic: seedPhrase, password: userPassword, accName: 'Default account' }); - navigate('/register/complete'); - }; - - return ; -}; diff --git a/nym-browser-extension/src/pages/register/index.ts b/nym-browser-extension/src/pages/register/index.ts deleted file mode 100644 index 691cc9ea35e..00000000000 --- a/nym-browser-extension/src/pages/register/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './Complete'; -export * from './CreatePasswordOnExistingAccount'; -export * from './CreatePasswordOnNewAccount'; -export * from './ImportAccount'; -export * from './SeedPhrase'; diff --git a/nym-browser-extension/src/pages/send/Confirmation.tsx b/nym-browser-extension/src/pages/send/Confirmation.tsx deleted file mode 100644 index 2e6d305f4c9..00000000000 --- a/nym-browser-extension/src/pages/send/Confirmation.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import React from 'react'; -import { Box, Divider, ListItem, ListItemText, Stack, Typography } from '@mui/material'; -import { Button } from 'src/components'; -import { PageLayout } from 'src/layouts/PageLayout'; -import { useAppContext, useSendContext } from 'src/context'; -import { ErrorModal, LoadingModal } from 'src/components/ui/Modal'; -import { SendConfirmationModal } from 'src/components/send/SendConfirmationModal'; -import { blockExplorerUrl } from 'src/urls'; - -const InfoItem = ({ label, value }: { label: string; value: string }) => ( - - - - {label} - - } - secondary={ - - {value} - - } - /> - - - -); - -export const SendConfirmationPage = ({ onCancel }: { onCancel: () => void }) => { - const { client, denom } = useAppContext(); - const { address, amount, fee, handleSend, transaction, resetTx, onDone } = useSendContext(); - - const calculateTotal = () => (Number(fee?.nym) + Number(amount?.amount)).toString(); - - return ( - - {transaction?.status === 'success' && ( - - )} - {transaction?.status === 'loading' && } - {transaction?.status === 'error' && ( - - {transaction.message} - - )} - - - - - - - - - - - - - ); -}; diff --git a/nym-browser-extension/src/pages/send/index.tsx b/nym-browser-extension/src/pages/send/index.tsx deleted file mode 100644 index c6aa42bbe47..00000000000 --- a/nym-browser-extension/src/pages/send/index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import React, { useState } from 'react'; -import { Box, Divider, Stack, Typography } from '@mui/material'; -import { WalletAddressFormField } from '@nymproject/react/account/WalletAddressFormField'; -import { CurrencyFormField } from '@nymproject/react/currency/CurrencyFormField'; -import { DecCoin } from '@nymproject/types'; -import { Address, Button } from 'src/components'; -import { PageLayout } from 'src/layouts/PageLayout'; -import { SendProvider, useAppContext, useSendContext } from 'src/context'; -import { SendConfirmationPage } from './Confirmation'; - -const SendPage = ({ onConfirm }: { onConfirm: () => void }) => { - const [isValidAddress, setIsValidAddress] = useState(false); - const [isValidAmount, setIsValidAmount] = useState(false); - - const { address, amount, handleChangeAddress, handleChangeAmount, handleGetFee } = useSendContext(); - const { balance } = useAppContext(); - - const handleNext = async () => { - if (address && amount) { - await handleGetFee(address, amount.amount); - onConfirm(); - } - }; - - return ( - - -
- handleChangeAddress(_address)} - onValidate={setIsValidAddress} - initialValue={address} - /> - handleChangeAmount(_amount)} - onValidate={(_: any, isValid: boolean) => setIsValidAmount(isValid)} - /> - - - Account balance - {balance} NYM - - - - Est. fee for this transaction will be calculated on the next page - - - - - - ); -}; - -export const Send = () => { - const [showConfirmation, setShowConfirmation] = useState(false); - - return ( - - {showConfirmation ? ( - setShowConfirmation(false)} /> - ) : ( - setShowConfirmation(true)} /> - )} - - ); -}; diff --git a/nym-browser-extension/src/pages/settings/index.tsx b/nym-browser-extension/src/pages/settings/index.tsx deleted file mode 100644 index 0beaaf3dc16..00000000000 --- a/nym-browser-extension/src/pages/settings/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import React from 'react'; - -export const Settings = () =>

Settings

; diff --git a/nym-browser-extension/src/pages/templates/Complete.tsx b/nym-browser-extension/src/pages/templates/Complete.tsx deleted file mode 100644 index a774516d4c1..00000000000 --- a/nym-browser-extension/src/pages/templates/Complete.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; -import { Box } from '@mui/material'; -import { Button } from 'src/components/ui'; -import { CenteredLogoLayout } from 'src/layouts'; - -export const SetupCompleteTemplate = ({ - title, - description, - onDone, -}: { - title: string; - description: string; - onDone: () => void; -}) => ( - - - - } - /> -); diff --git a/nym-browser-extension/src/pages/templates/CreatePassword.tsx b/nym-browser-extension/src/pages/templates/CreatePassword.tsx deleted file mode 100644 index cb866d545b8..00000000000 --- a/nym-browser-extension/src/pages/templates/CreatePassword.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React from 'react'; -import { FormControlLabel, Checkbox, Stack, Typography, Box } from '@mui/material'; -import { TopLogoLayout } from 'src/layouts/TopLogo'; -import { PasswordInput } from '@nymproject/react/textfields/Password'; -import { PasswordStrength } from '@nymproject/react/password-strength/PasswordStrength'; -import { Button } from 'src/components/ui'; - -type TCreatePassword = { - canProceed: boolean; - password: string; - confirmPassword: string; - hasReadTerms: boolean; - setHasReadTerms: (hasReadTerms: boolean) => void; - setIsSafePassword: (isSafe: boolean) => void; - setConfirmPassword: (password: string) => void; - onNext: () => void; - setPassword: (password: string) => void; -}; - -export const CreatePasswordTemplate = ({ - canProceed, - onNext, - password, - setPassword, - confirmPassword, - setIsSafePassword, - setConfirmPassword, - setHasReadTerms, - hasReadTerms, -}: TCreatePassword) => ( - - Next - - } - > - - setPassword(_password)} - label="Password" - /> - - setIsSafePassword(isSafe)} /> - - - - setConfirmPassword(_password)} - label="Confirm password" - /> - - - I have read and agree with the Terms of use} - control={ setHasReadTerms(checked)} />} - /> - -); diff --git a/nym-browser-extension/src/pages/templates/ImportAccount.tsx b/nym-browser-extension/src/pages/templates/ImportAccount.tsx deleted file mode 100644 index 03a560f7e3a..00000000000 --- a/nym-browser-extension/src/pages/templates/ImportAccount.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import { TextField } from '@mui/material'; -import { Button } from 'src/components'; -import { TopLogoLayout } from 'src/layouts'; - -export const ImportAccountTemplate = ({ - userMnemonic, - onChangeUserMnemonic, - onNext, -}: { - userMnemonic: string; - onChangeUserMnemonic: (mnemonic: string) => void; - onNext: () => void; -}) => ( - - Next - - } - > - onChangeUserMnemonic(e.target.value)} - multiline - autoFocus={false} - fullWidth - inputProps={{ - style: { - height: '160px', - }, - }} - InputLabelProps={{ shrink: true }} - sx={{ - 'input::-webkit-textfield-decoration-container': { - alignItems: 'start', - }, - }} - /> - -); diff --git a/nym-browser-extension/src/pages/templates/SeedPhrase.tsx b/nym-browser-extension/src/pages/templates/SeedPhrase.tsx deleted file mode 100644 index f8c47150a87..00000000000 --- a/nym-browser-extension/src/pages/templates/SeedPhrase.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import React, { useRef, useState } from 'react'; -import { Checkbox, FormControlLabel, Stack, TextField, Typography } from '@mui/material'; -import { TopLogoLayout } from 'src/layouts/TopLogo'; -import { Button } from 'src/components/ui'; -import { generateMnemonmic } from 'src/validator-client'; - -export const SeedPhraseTemplate = ({ onNext }: { onNext: (seedPhrase: string) => void }) => { - const [isConfirmed, setIsconfirmed] = useState(false); - - const seedPhrase = useRef(generateMnemonmic()); - - return ( - onNext(seedPhrase.current)} - > - Next - - } - > - - - Below is your 24 word mnemonic, make sure to store it in a safe place for accessing your wallet in the future - - - - - setIsconfirmed(checked)} />} - /> - - - ); -}; diff --git a/nym-browser-extension/src/pages/templates/index.ts b/nym-browser-extension/src/pages/templates/index.ts deleted file mode 100644 index b7c8c43756a..00000000000 --- a/nym-browser-extension/src/pages/templates/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './Complete'; -export * from './CreatePassword'; -export * from './ImportAccount'; -export * from './SeedPhrase'; diff --git a/nym-browser-extension/src/routes/index.tsx b/nym-browser-extension/src/routes/index.tsx deleted file mode 100644 index a6cd93be4f1..00000000000 --- a/nym-browser-extension/src/routes/index.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { BrowserRouter, MemoryRouter, Route, Routes } from 'react-router-dom'; -import { Home } from 'src/pages'; -import { ExtensionStorage } from '@nymproject/extension-storage'; -import { RegisterRoutes } from './register'; -import { UserRoutes } from './user'; -import { LoginRoutes } from './login'; - -const Router = process.env.NODE_ENV === 'development' ? BrowserRouter : MemoryRouter; - -export const AppRoutes = () => { - const [userHasAccount, setUserHasAccount] = useState(null); - - useEffect(() => { - const checkUserHasAccount = async () => { - const hasAccount = await ExtensionStorage.exists(); - setUserHasAccount(hasAccount); - }; - - checkUserHasAccount(); - }, []); - - if (userHasAccount === null) return null; - - return ( - - - : } /> - } /> - } /> - } /> - - - ); -}; diff --git a/nym-browser-extension/src/routes/login/index.tsx b/nym-browser-extension/src/routes/login/index.tsx deleted file mode 100644 index c61c45c0955..00000000000 --- a/nym-browser-extension/src/routes/login/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React, { useEffect } from 'react'; -import { Route, Routes, useNavigate } from 'react-router-dom'; -import { useAppContext } from 'src/context'; -import { ForgotPassword, Login } from 'src/pages/auth'; - -export const LoginRoutes = () => { - const { client } = useAppContext(); - const navigate = useNavigate(); - - useEffect(() => { - let route = '/login'; - - if (client) { - route = '/user/balance'; - } - - navigate(route); - }, [client]); - - return ( - - } /> - } /> - - ); -}; diff --git a/nym-browser-extension/src/routes/register/index.tsx b/nym-browser-extension/src/routes/register/index.tsx deleted file mode 100644 index 27210900e62..00000000000 --- a/nym-browser-extension/src/routes/register/index.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; -import { Route, Routes, useNavigate } from 'react-router-dom'; -import { RegisterContextProvider } from 'src/context/register'; -import { ImportAccount, SeedPhrase, SetupComplete } from 'src/pages/register'; -import { CreatePasswordOnExistingAccount } from 'src/pages/register/CreatePasswordOnExistingAccount'; -import { CreatePasswordOnNewAccount } from 'src/pages/register/CreatePasswordOnNewAccount'; - -export const RegisterRoutes = () => { - const navigate = useNavigate(); - - const handleSetUpComplete = () => { - navigate('/login'); - }; - - return ( - - - navigate('/register/seed-phrase')} />} - /> - } /> - } /> - { - navigate('/register/complete'); - }} - /> - } - /> - } /> - - - ); -}; diff --git a/nym-browser-extension/src/routes/user/accounts/accounts.tsx b/nym-browser-extension/src/routes/user/accounts/accounts.tsx deleted file mode 100644 index 63ef6e2abf4..00000000000 --- a/nym-browser-extension/src/routes/user/accounts/accounts.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { Route, Routes } from 'react-router-dom'; -import { RegisterContextProvider } from 'src/context/register'; -import { Accounts, AddAccount, ConfirmPassword, ImportAccount, NameAccount, SetupComplete } from 'src/pages'; - -export const AccountRoutes = () => ( - - - } /> - } /> - } /> - } /> - } /> - } /> - - -); diff --git a/nym-browser-extension/src/routes/user/index.tsx b/nym-browser-extension/src/routes/user/index.tsx deleted file mode 100644 index 30e9ea1e117..00000000000 --- a/nym-browser-extension/src/routes/user/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React, { useEffect } from 'react'; -import { Route, Routes, useNavigate } from 'react-router-dom'; -import { useAppContext } from 'src/context'; -import { Delegation, BalancePage, Receive, Send, Settings } from 'src/pages'; -import { AccountRoutes } from './accounts/accounts'; - -export const UserRoutes = () => { - const { client } = useAppContext(); - const navigate = useNavigate(); - - useEffect(() => { - if (!client) navigate('/login'); - }, [client]); - - return ( - - } /> - } /> - } /> - } /> - } /> - } /> - - ); -}; diff --git a/nym-browser-extension/src/theme/NymBrowserExtensionTheme.tsx b/nym-browser-extension/src/theme/NymBrowserExtensionTheme.tsx deleted file mode 100644 index dfde09cbc00..00000000000 --- a/nym-browser-extension/src/theme/NymBrowserExtensionTheme.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { CssBaseline, PaletteMode } from '@mui/material'; -import { createTheme, ThemeProvider } from '@mui/material/styles'; -import { getDesignTokens } from './theme'; -import '@assets/fonts/non-variable/fonts.css'; - -type TNymBrowserExtThemeProps = { mode: PaletteMode; children: React.ReactNode }; - -export const NymBrowserExtThemeWithMode = ({ mode, children }: TNymBrowserExtThemeProps) => { - const theme = React.useMemo(() => createTheme(getDesignTokens(mode)), [mode]); - - return ( - - - {children} - - ); -}; diff --git a/nym-browser-extension/src/theme/mui-theme.d.ts b/nym-browser-extension/src/theme/mui-theme.d.ts deleted file mode 100644 index 6145e0d3309..00000000000 --- a/nym-browser-extension/src/theme/mui-theme.d.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* eslint-disable no-shadow,@typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-interface */ -import { Theme, ThemeOptions, Palette, PaletteOptions } from '@mui/material/styles'; -import { PaletteMode } from '@mui/material'; - -/** - * If you are unfamiliar with Material UI theming, please read the following first: - * - https://mui.com/customization/theming/ - * - https://mui.com/customization/palette/ - * - https://mui.com/customization/dark-mode/#dark-mode-with-custom-palette - * - * This file adds typings to the theme using Typescript's module augmentation. - * - * Read the following if you are unfamiliar with module augmentation and declaration merging. Then - * look at the recommendations from Material UI docs for implementation: - * - https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation - * - https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces - * - https://mui.com/customization/palette/#adding-new-colors - * - * - * IMPORTANT: - * - * The type augmentation must match MUI's definitions. So, notice the use of `interface` rather than - * `type Foo = { ... }` - this is necessary to merge the definitions. - */ - -declare module '@mui/material/styles' { - /** - * This interface defines a palette used across Nym for branding - */ - interface NymPalette { - background: { light: string; dark: string }; - } - - interface NymPaletteVariant { - mode: PaletteMode; - } - - /** - * A palette definition only for the Nym Browser Extension that extends the Nym palette - */ - interface NymBrowserExtPalette { - nymBrowserExt: NymPaletteVariant; - } - - interface NymPaletteAndNymBrowserExtPalette { - nym: NymPalette & NymBrowserExtPalette; - } - - type NymPaletteAndNymBrowserExtPaletteOptions = Partial; - - /** - * Add anything not palette related to the theme here - */ - interface NymTheme {} - - /** - * This augments the definitions of the MUI Theme with the Nym theme, as well as - * a partial `ThemeOptions` type used by `createTheme` - * - * IMPORTANT: only add extensions to the interfaces above, do not modify the lines below - */ - interface Theme extends NymTheme {} - interface ThemeOptions extends Partial {} - interface Palette extends NymPaletteAndNymBrowserExtPalette {} - interface PaletteOptions extends NymPaletteAndNymBrowserExtPaletteOptions {} -} diff --git a/nym-browser-extension/src/theme/theme.ts b/nym-browser-extension/src/theme/theme.ts deleted file mode 100644 index b4ab3ee20e0..00000000000 --- a/nym-browser-extension/src/theme/theme.ts +++ /dev/null @@ -1,138 +0,0 @@ -import { PaletteMode } from '@mui/material'; -import { - PaletteOptions, - NymPalette, - NymBrowserExtPalette, - ThemeOptions, - createTheme, - NymPaletteVariant, -} from '@mui/material/styles'; - -//----------------------------------------------------------------------------------------------- -// Nym palette type definitions -// - -/** - * The Nym palette. - * - * IMPORTANT: do not export this constant, always use the MUI `useTheme` hook to get the correct - * colours for dark/light mode. - */ -const nymPalette: NymPalette = { - /** emphasises important elements */ - background: { light: '#F4F6F8', dark: '#1D2125' }, -}; - -const darkMode: NymPaletteVariant = { - mode: 'dark', -}; - -const lightMode: NymPaletteVariant = { - mode: 'light', -}; - -/** - * Nym palette specific to the Nym Wallet - * - * IMPORTANT: do not export this constant, always use the MUI `useTheme` hook to get the correct - * colours for dark/light mode. - */ -const nymBrowserExtPalette = (variant: NymPaletteVariant): NymBrowserExtPalette => ({ - nymBrowserExt: variant, -}); - -//----------------------------------------------------------------------------------------------- -// Nym palettes for light and dark mode -// - -/** - * Map a Nym palette variant onto the MUI palette - */ -const variantToMUIPalette = (_: NymPaletteVariant): PaletteOptions => ({ - primary: { - main: '#6750A4', - }, -}); - -/** - * Returns the Network Explorer palette for light mode. - */ -const createLightModePalette = (): PaletteOptions => ({ - nym: { - ...nymPalette, - ...nymBrowserExtPalette(lightMode), - }, - ...variantToMUIPalette(lightMode), -}); - -/** - * Returns the Network Explorer palette for dark mode. - */ -const createDarkModePalette = (): PaletteOptions => ({ - nym: { - ...nymPalette, - ...nymBrowserExtPalette(darkMode), - }, - ...variantToMUIPalette(darkMode), -}); - -/** - * IMPORANT: if you need to get the default MUI theme, use the following - * - * import { createTheme as systemCreateTheme } from '@mui/system'; - * - * // get the MUI system defaults for light mode - * const systemTheme = systemCreateTheme({ palette: { mode: 'light' } }); - * - * - * return { - * // change `primary` to default MUI `success` - * primary: { - * main: systemTheme.palette.success.main, - * }, - * nym: { - * ...nymPalette, - * ...nymWalletPalette, - * }, - * }; - */ - -//----------------------------------------------------------------------------------------------- -// Nym theme overrides -// - -/** - * Gets the theme options to be passed to `createTheme`. - * - * Based on pattern from https://mui.com/customization/dark-mode/#dark-mode-with-custom-palette. - * - * @param mode The theme mode: 'light' or 'dark' - */ -export const getDesignTokens = (mode: PaletteMode): ThemeOptions => { - // first, create the palette from user's choice of light or dark mode - const { palette } = createTheme({ - palette: { - mode, - ...(mode === 'light' ? createLightModePalette() : createDarkModePalette()), - }, - }); - - // then customise theme and components - return { - typography: { - fontFamily: [ - 'Open Sans', - 'sans-serif', - 'BlinkMacSystemFont', - 'Roboto', - 'Oxygen', - 'Ubuntu', - 'Helvetica Neue', - ].join(','), - }, - shape: { - borderRadius: 8, - }, - palette, - }; -}; diff --git a/nym-browser-extension/src/types/global.ts b/nym-browser-extension/src/types/global.ts deleted file mode 100644 index 370aa18e22e..00000000000 --- a/nym-browser-extension/src/types/global.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare namespace NodeJS { - interface ProcessEnv { - development: string; - } -} diff --git a/nym-browser-extension/src/types/index.ts b/nym-browser-extension/src/types/index.ts deleted file mode 100644 index cbb355622fc..00000000000 --- a/nym-browser-extension/src/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './tx'; diff --git a/nym-browser-extension/src/types/tx.ts b/nym-browser-extension/src/types/tx.ts deleted file mode 100644 index afe264e119c..00000000000 --- a/nym-browser-extension/src/types/tx.ts +++ /dev/null @@ -1,9 +0,0 @@ -// TODO Add other transaction types later -type TTransactionType = 'send'; - -export type TTransaction = { - type: TTransactionType; - txHash?: string; - status: 'loading' | 'success' | 'error'; - message?: string; -}; diff --git a/nym-browser-extension/src/typings/jpeg.d.ts b/nym-browser-extension/src/typings/jpeg.d.ts deleted file mode 100644 index cfe3695fd53..00000000000 --- a/nym-browser-extension/src/typings/jpeg.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.jpeg' { - const value: any; - export default value; -} diff --git a/nym-browser-extension/src/typings/json.d.ts b/nym-browser-extension/src/typings/json.d.ts deleted file mode 100644 index b72dd46ee5d..00000000000 --- a/nym-browser-extension/src/typings/json.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.json' { - const content: any; - export default content; -} diff --git a/nym-browser-extension/src/typings/png.d.ts b/nym-browser-extension/src/typings/png.d.ts deleted file mode 100644 index dd84df40a48..00000000000 --- a/nym-browser-extension/src/typings/png.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.png' { - const content: any; - export default content; -} diff --git a/nym-browser-extension/src/typings/svg.d.ts b/nym-browser-extension/src/typings/svg.d.ts deleted file mode 100644 index 091d25e2101..00000000000 --- a/nym-browser-extension/src/typings/svg.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.svg' { - const content: any; - export default content; -} diff --git a/nym-browser-extension/src/urls/index.ts b/nym-browser-extension/src/urls/index.ts deleted file mode 100644 index 10ab2d6aaba..00000000000 --- a/nym-browser-extension/src/urls/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const blockExplorerUrl = process.env.BLOCK_EXPLORER_URL; -export const coinGeckoPriceAPI = 'https://api.coingecko.com/api/v3/simple/price?'; diff --git a/nym-browser-extension/src/utils/coin.ts b/nym-browser-extension/src/utils/coin.ts deleted file mode 100644 index 6b46d9b56e9..00000000000 --- a/nym-browser-extension/src/utils/coin.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Big from 'big.js'; - -export const unymToNym = (unym: number | Big, dp = 4) => { - let nym; - try { - nym = Big(unym).div(1_000_000).toFixed(dp); - } catch (e: any) { - console.warn(`${unym} not a valid decimal number: ${e}`); - } - return Number(nym); -}; - -export const nymToUnym = (nym: number) => { - let unym; - try { - unym = Big(nym).mul(1_000_000); - } catch (e: any) { - console.warn(`unable to convert nym to unym: ${e}`); - } - return Number(unym); -}; diff --git a/nym-browser-extension/src/utils/crypto.ts b/nym-browser-extension/src/utils/crypto.ts deleted file mode 100644 index 122149ac60b..00000000000 --- a/nym-browser-extension/src/utils/crypto.ts +++ /dev/null @@ -1,8 +0,0 @@ -import cryptojs from 'crypto-js'; - -const encrypt = (mnemonic: string, password: string) => cryptojs.AES.encrypt(mnemonic, password).toString(); - -const decrypt = (cipher: string, password: string) => - cryptojs.AES.decrypt(cipher, password).toString(cryptojs.enc.Utf8); - -export { encrypt, decrypt }; diff --git a/nym-browser-extension/src/utils/fee.ts b/nym-browser-extension/src/utils/fee.ts deleted file mode 100644 index 7357c6181fe..00000000000 --- a/nym-browser-extension/src/utils/fee.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const createFeeObject = (feeInUnyms?: number) => { - if (!feeInUnyms) return undefined; - - return { - amount: [{ amount: feeInUnyms.toString(), denom: 'unym' }], - gas: '100000', - }; -}; diff --git a/nym-browser-extension/src/utils/price.ts b/nym-browser-extension/src/utils/price.ts deleted file mode 100644 index 8f38ca18dbe..00000000000 --- a/nym-browser-extension/src/utils/price.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { coinGeckoPriceAPI } from 'src/urls'; - -export type Currency = 'gbp' | 'usd'; -export type TokenId = 'nym'; - -type ResponseMap = { [token in T]: { [currency in C]: number } }; - -const constructUrl = (tokenId: TokenId, currency: Currency) => - `${coinGeckoPriceAPI}ids=${tokenId}&vs_currencies=${currency}`; - -export async function getTokenPrice( - tokenId: T, - currency: C, -): Promise> { - const response = await fetch(constructUrl(tokenId, currency)); - const json = await response.json(); - return json; -} diff --git a/nym-browser-extension/src/validator-client/index.tsx b/nym-browser-extension/src/validator-client/index.tsx deleted file mode 100644 index 0e007e3c266..00000000000 --- a/nym-browser-extension/src/validator-client/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import ValidatorClient from '@nymproject/nym-validator-client'; -import { config } from 'src/config'; - -export const generateMnemonmic = () => ValidatorClient.randomMnemonic(); - -export const connectToValidator = async (mnemonic: string) => - ValidatorClient.connect( - mnemonic, - config.rpcUrl, - config.validatorUrl, - config.prefix, - config.mixnetContractAddress, - config.vestingContractAddress, - config.denom, - ); diff --git a/nym-browser-extension/storage/internal-dev/index.js b/nym-browser-extension/storage/internal-dev/index.js deleted file mode 100644 index ab69f6e686f..00000000000 --- a/nym-browser-extension/storage/internal-dev/index.js +++ /dev/null @@ -1,73 +0,0 @@ - -import { - ExtensionStorage, - set_panic_hook -} from "@nymproject/storage-extension" - -// // current limitation of rust-wasm for async stuff : ( -// let client = null - -async function main() { - // // sets up better stack traces in case of in-rust panics - set_panic_hook(); - - let storage = await new ExtensionStorage("my super duper password"); - - const goodMnemonic = "figure aspect pill salute review sponsor army city muffin engine army kid rival chunk unit insect blouse paddle velvet shallow box crawl grace never" - const badMnemonic = "foomp" - - let readEmpty = await storage.read_mnemonic("my-mnemonic1") - console.log("value initial:", readEmpty); - - try { - await storage.store_mnemonic("my-mnemonic1", badMnemonic); - } catch (e) { - console.log("store error: ",e) - } - - let anotherRead = await storage.read_mnemonic("my-mnemonic1") - console.log("value bad store:", anotherRead); - - await storage.store_mnemonic("my-mnemonic1", goodMnemonic) - - let yetAnotherRead = await storage.read_mnemonic("my-mnemonic1") - console.log("value good store:", yetAnotherRead); - - await storage.remove_mnemonic("my-mnemonic1") - - let finalRead = await storage.read_mnemonic("my-mnemonic1") - console.log("value removed:", finalRead); - - const anotherMnemonic = "salmon picture danger pill tomato hour hand chaos tray bargain frequent fuel scheme coil divert season lucky ginger mom stem mistake blanket lake suffer"; - const oneMore = "cat quiz circle letter trade unhappy quarter garlic sting gravity zone stock scatter merge account barrel forward fame club chest camp under crop connect" - - const key1 = "my-amazing-mnemonic" - const key2 = "my-other-mnemonic" - - await storage.store_mnemonic(key1, anotherMnemonic) - await storage.store_mnemonic(key2, oneMore) - - let allKeys = await storage.get_all_mnemonic_keys() - console.log("keys:", allKeys) - - const anotherOne = "mammal fashion rice two marble high brain achieve first harsh infant timber flush cloud hunt address brand immune tip identify aspect call beyond once" - const anotherKey = "some-mnemonic" - - let isPresent = await storage.has_mnemonic(anotherKey); - console.log("has mnemonic: ", isPresent) - - await storage.store_mnemonic(anotherKey, anotherOne) - - let isPresentNew = await storage.has_mnemonic(anotherKey); - console.log("has mnemonic: ", isPresentNew) - - await storage.remove_mnemonic(anotherKey) - - let isPresentEvenNewer = await storage.has_mnemonic(anotherKey); - console.log("has mnemonic: ", isPresentEvenNewer) - -} - - -// Let's get started! -main(); \ No newline at end of file diff --git a/nym-browser-extension/tsconfig.eslint.json b/nym-browser-extension/tsconfig.eslint.json deleted file mode 100644 index d1da615e581..00000000000 --- a/nym-browser-extension/tsconfig.eslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "jsx": "react-jsx", - "noEmit": true - }, - "include": [ - ".storybook/*.js", - "webpack.*.js", - "src/**/*.js", - "src/**/*.jsx", - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.stories.*" - ], - "exclude": ["node_modules", "dist"] -} diff --git a/nym-browser-extension/tsconfig.json b/nym-browser-extension/tsconfig.json deleted file mode 100644 index 213619ac536..00000000000 --- a/nym-browser-extension/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "noFallthroughCasesInSwitch": true, - "skipLibCheck": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": false, - "jsx": "react-jsx", - "sourceMap": true, - "baseUrl": ".", - "paths": { - "@assets/*": ["../assets/*"] - }, - "noEmit": true - }, - "exclude": [ - "node_modules", - "dist", - "jest.config.js", - "webpack.config.js", - "webpack.prod.js", - "webpack.common.js", - "tsconfig.json" - ] -} diff --git a/nym-browser-extension/webpack.common.js b/nym-browser-extension/webpack.common.js deleted file mode 100644 index 3ca6344af89..00000000000 --- a/nym-browser-extension/webpack.common.js +++ /dev/null @@ -1,26 +0,0 @@ -const path = require('path'); -const { mergeWithRules } = require('webpack-merge'); -const { webpackCommon } = require('@nymproject/webpack'); - -module.exports = mergeWithRules({ - module: { - rules: { - test: 'match', - use: 'replace', - }, - }, -})(webpackCommon(__dirname), { - entry: path.resolve(__dirname, 'src/index.tsx'), - output: { - clean: true, - path: path.resolve(__dirname, 'dist'), - publicPath: '/', - }, - resolve: { - fallback: { - crypto: 'crypto-browserify', - stream: 'stream-browserify', - }, - }, - experiments: { asyncWebAssembly: true }, -}); diff --git a/nym-browser-extension/webpack.dev.js b/nym-browser-extension/webpack.dev.js deleted file mode 100644 index 4554968e159..00000000000 --- a/nym-browser-extension/webpack.dev.js +++ /dev/null @@ -1,68 +0,0 @@ -const { mergeWithRules } = require('webpack-merge'); -const webpack = require('webpack'); -const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); -const ReactRefreshTypeScript = require('react-refresh-typescript'); -const Dotenv = require('dotenv-webpack'); -const commonConfig = require('./webpack.common'); - -module.exports = mergeWithRules({ - module: { - rules: { - test: 'match', - use: 'replace', - }, - }, -})(commonConfig, { - mode: 'development', - devtool: 'inline-source-map', - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/, - options: { - getCustomTransformers: () => ({ - before: [ReactRefreshTypeScript()], - }), - // `ts-loader` does not work with HMR unless `transpileOnly` is used. - // If you need type checking, `ForkTsCheckerWebpackPlugin` is an alternative. - transpileOnly: true, - }, - }, - ], - }, - plugins: [ - new ReactRefreshWebpackPlugin(), - - // this can be included automatically by the dev server, however build mode fails if missing - new webpack.HotModuleReplacementPlugin(), - new Dotenv({ path: './env.dev' }), - ], - - // recommended for faster rebuild - optimization: { - runtimeChunk: true, - removeAvailableModules: false, - removeEmptyChunks: false, - splitChunks: false, - }, - - cache: { - type: 'filesystem', - buildDependencies: { - // restart on config change - config: ['./webpack.dev.js'], - }, - }, - - devServer: { - port: 9000, - compress: true, - historyApiFallback: true, - hot: true, - client: { - overlay: false, - }, - }, -}); diff --git a/nym-browser-extension/webpack.prod.js b/nym-browser-extension/webpack.prod.js deleted file mode 100644 index 359dc9f9a51..00000000000 --- a/nym-browser-extension/webpack.prod.js +++ /dev/null @@ -1,21 +0,0 @@ -const path = require('path'); -const { default: merge } = require('webpack-merge'); -const common = require('./webpack.common'); -const CopyPlugin = require('copy-webpack-plugin'); -const Dotenv = require('dotenv-webpack'); - -module.exports = merge(common, { - mode: 'production', - entry: path.resolve(__dirname, 'src/index.tsx'), - plugins: [ - new CopyPlugin({ - patterns: [ - { - from: './src/manifest.json', - to: './', - }, - ], - }), - new Dotenv({ path: './.env' }), - ], -});