Skip to content

Commit

Permalink
copy pasta client code
Browse files Browse the repository at this point in the history
  • Loading branch information
fede-rodes committed Nov 28, 2021
1 parent 53e062d commit 7b20791
Show file tree
Hide file tree
Showing 63 changed files with 15,232 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_CHAIN_ID=42
REACT_APP_INFURA_PROJECT_ID=XXX
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
settings: {
react: {
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
extends: [
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. '@typescript-eslint/explicit-function-return-type': 'off',
semi: ['error', 'never'],
indent: [2, 2, { SwitchCase: 1 }],
quotes: ['error', 'single'],
},
overrides: [
{
'files': ['**/*.tsx'],
'rules': {
'react/prop-types': 'off'
}
}
]
}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
.env.kovan
.env.dev

npm-debug.log*
yarn-debug.log*
yarn-error.log*

/.netlify
1 change: 1 addition & 0 deletions _redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
23 changes: 23 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
// The root of your source code, typically /src
// `<rootDir>` is a token Jest substitutes
roots: ['<rootDir>/src'],
// Jest transformations -- this adds support for TypeScript
// using ts-jest
transform: {
'^.+\\.tsx?$': 'ts-jest'
},
// Runs special logic, such as cleaning up components
// when using React Testing Library and adds special
// extended assertions to Jest
setupFilesAfterEnv: [
'@testing-library/react/cleanup-after-each',
'@testing-library/jest-dom/extend-expect'
],
// Test spec file resolution pattern
// Look for tests inside the `src` folder and filename
// should contain `test` or `spec`.
testRegex: '(/**/.*|(\\.|/)(test|spec))\\.tsx?$',
// Module file extensions for importing
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
82 changes: 82 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test:watch": "yarn run test --watch",
"eject": "react-scripts eject",
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"setEnv:dev": "cp .env.dev .env",
"setEnv:kovan": "cp .env.kovan .env",
"setEnv:rinkeby": "cp .env.rinkeby .env",
"deploy": "yarn run build && cp ./_redirects ./build && netlify deploy --dir build --prod"
},
"dependencies": {
"renpool-contracts": "https://github.com/renpool/renpool-contracts",
"@ethersproject/address": "^5.4.0",
"@ethersproject/bignumber": "^5.4.0",
"@ethersproject/contracts": "^5.4.0",
"@ethersproject/providers": "^5.4.1",
"@ethersproject/strings": "^5.4.0",
"@ethersproject/units": "^5.4.0",
"@renproject/react-components": "^1.0.0-alpha.10",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/bs58": "^4.0.1",
"@types/jest": "^26.0.15",
"@types/lodash": "^4.14.170",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/styled-components": "^5.1.11",
"@web3-react/core": "^6.1.9",
"@web3-react/injected-connector": "^6.0.7",
"@web3-react/network-connector": "^6.1.9",
"bs58": "^4.0.1",
"lodash": "^4.17.21",
"react": "^17.0.2",
"react-device-detect": "^1.17.0",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rimble-ui": "^0.14.0",
"styled-components": "^5.3.0",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"testMatch": [
"**/?(*.)(spec|test).ts?(x)"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"<rootDir>/Tests/Setup.js",
"<rootDir>/Tests/Mocks/*"
]
}
}
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="RenPool"
content="Ren community pool"
/>
<!-- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> -->
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>RenPool</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "RenPool",
"name": "RenPool",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
91 changes: 91 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React, { useContext, useState } from 'react'
import { Flex, Box } from 'rimble-ui'
import { RenPoolContext } from './context/RenPoolProvider'
import { useActiveWeb3React } from './hooks/useActiveWeb3React'
import { DepositScreen } from './screens/DepositScreen'
import { WithdrawScreen } from './screens/WithdrawScreen'
import { AdminScreen } from './screens/AdminScreen'
import { StatsSection } from './sections/StatsSection'
import { AddressesSection } from './sections/AddressesSection'
import { Header } from './components/Header'
import { Banners } from './components/Banners'
import { NavLink } from './components/NavLink'
// import { Instructions } from './components/Instructions'
import { Footer } from './components/Footer'

enum Views {
DEPOSIT = 'DEPOSIT',
WITHDRAW = 'WITHDRAW',
ADMIN = 'ADMIN',
}

export const App = (): JSX.Element => {
const { account } = useActiveWeb3React()
const { owner, nodeOperator } = useContext(RenPoolContext)
const [view, setView] = useState<Views>(Views.DEPOSIT)

// TODO: display darknodeUrl once registered

return (
<>
<Header />

<div className="App">
<Banners />

<Box p={2} />

<Flex justifyContent="center" alignItems="center">
<NavLink
label="Deposit"
disabled={view === Views.DEPOSIT}
onClick={() => { setView(Views.DEPOSIT) }}
/>
<Box p={3}>|</Box>
<NavLink
label="Withdraw"
disabled={view === Views.WITHDRAW}
onClick={() => { setView(Views.WITHDRAW) }}
/>
{account != null && [owner, nodeOperator].includes(account) && (
<>
<Box p={3}>|</Box>
<NavLink
label="Admin"
disabled={view === Views.ADMIN}
onClick={() => { setView(Views.ADMIN) }}
/>
</>
)}
</Flex>

<Box p={2} />

{view === Views.DEPOSIT && (
<DepositScreen />
)}

{view === Views.WITHDRAW && (
<WithdrawScreen />
)}

{view === Views.ADMIN && (
<AdminScreen />
)}

{[Views.DEPOSIT, Views.WITHDRAW].includes(view) && (
<>
<Box p={3} />
<StatsSection />
<Box p={2} />
<AddressesSection />
<Box p={2} />
{/* <Instructions /> */}
</>
)}

<Footer />
</div>
</>
)
}
Loading

0 comments on commit 7b20791

Please sign in to comment.