Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

feat: fetch TVL for all chains #32

Draft
wants to merge 2 commits into
base: refactor/bundler
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VITE_SUBGRAPH_MARKETS_URL_ETHEREUM=
VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_ONE=
VITE_SUBGRAPH_MARKETS_URL_BSC_MAINNET=
VITE_SUBGRAPH_MARKETS_URL_OPBNB_MAINNET=
8 changes: 1 addition & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.stories.tsx',
'**/*.stories.ts',
'src/stories/**',
'**/*.spec.tsx',
'src/setupTests.ts',
],
devDependencies: true,
},
],
// Custom
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env
.idea

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

# Generated subgraph (GraphQL) client
src/subgraph/client
61 changes: 32 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
# Getting Started with Create React App
# Venus Protocol Landing Page

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
<p align="center">
<img src="https://venus.io/share.png">
</p>

## Available Scripts
Official repository for the [Venus protocol](https://venus.io) landing page.

In the project directory, you can run:
## Getting started

### `yarn start`
Install dependencies with yarn

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
```ssh
yarn
```

The page will reload if you make edits.\
You will also see any lint errors in the console.
Define environment variables by making a copy of `.env.example` and renaming it to `.env` (make sure to add values for each environment variable).

### `yarn test`
Start the development server

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
```ssh
yarn start
```

### `yarn build`
## Useful commands

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
Check Typescript code

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
```ssh
yarn tsc
```

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
Lint code

### `yarn eject`
```ssh
yarn lint
```

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
Generate production build

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
```ssh
yarn build
```

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
Start application with production build

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
```ssh
yarn preview
```
52 changes: 27 additions & 25 deletions public/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="https://venus.io/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#3A78FF" />
<meta
Expand All @@ -13,40 +13,40 @@
rel="icon"
type="image/png"
sizes="192x192"
href="https://venus.io/android-chrome-192x192.png"
href="/android-chrome-192x192.png"
/>
<link rel="icon" type="image/png" sizes="32x32" href="https://venus.io/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="https://venus.io/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />

<meta name="msapplication-square70x70logo" content="https://venus.io/70x70.png" />
<meta name="msapplication-square144x144logo" content="https://venus.io/144x144.png" />
<meta name="msapplication-square150x150logo" content="https://venus.io/150x150.png" />
<meta name="msapplication-square310x310logo" content="https://venus.io/310x310.png" />
<meta name="msapplication-wide310x150logo" content="https://venus.io/310x150.png" />
<meta name="msapplication-TileImage" content="https://venus.io/144x144.png" />
<meta name="msapplication-square70x70logo" content="/70x70.png" />
<meta name="msapplication-square144x144logo" content="/144x144.png" />
<meta name="msapplication-square150x150logo" content="/150x150.png" />
<meta name="msapplication-square310x310logo" content="/310x310.png" />
<meta name="msapplication-wide310x150logo" content="/310x150.png" />
<meta name="msapplication-TileImage" content="/144x144.png" />
<meta name="msapplication-TileColor" content="#3A78FF" />

<link rel="apple-touch-icon" type="image/png" href="https://venus.io/apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="57x57" href="https://venus.io/57x57.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="https://venus.io/60x60.png" />
<link rel="apple-touch-icon" type="image/png" sizes="72x72" href="https://venus.io/72x72.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="https://venus.io/76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="114x114" href="https://venus.io/114x114.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="https://venus.io/120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="144x144" href="https://venus.io/144x144.png" />
<link rel="apple-touch-icon" type="image/png" sizes="152x152" href="https://venus.io/152x152.png" />
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="https://venus.io/180x180.png" />
<link rel="apple-touch-icon" type="image/png" href="/apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="57x57" href="/57x57.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="/60x60.png" />
<link rel="apple-touch-icon" type="image/png" sizes="72x72" href="/72x72.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="/76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="114x114" href="/114x114.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="/120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="144x144" href="/144x144.png" />
<link rel="apple-touch-icon" type="image/png" sizes="152x152" href="/152x152.png" />
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="/180x180.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="https://venus.io/manifest.json" />
<link rel="manifest" href="/manifest.json" />
<!--
Notice the use of https://venus.io in the tags above.
Notice the use of 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", "https://venus.io/favicon.ico" will
Unlike "/favicon.ico" or "favicon.ico", "/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`.
-->
Expand All @@ -67,13 +67,13 @@
content="Venus is a decentralized finance (DeFi) algorithmic money market protocol on BNB Chain."
/>
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://venus.io/share.png" />
<meta name="twitter:image" content="/share.png" />
<meta name="theme-color" content="#3A78FF" />

<meta property="og:title" content="Venus Protocol" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://venus.io/" />
<meta property="og:image" content="https://venus.io/share.png" />
<meta property="og:image" content="/share.png" />
<meta
property="og:description"
content="Venus is a decentralized finance (DeFi) algorithmic money market protocol on BNB Chain."
Expand All @@ -94,5 +94,7 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->

<script type="module" src="/src/index.tsx"></script>
</body>
</html>
53 changes: 34 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,34 @@
"homepage": "https://venus.io/",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"@tanstack/react-query": "^5.40.0",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.1",
"@types/node": "^16.7.13",
"@types/react": "^17.0.40",
"@types/react-dom": "^17.0.13",
"axios": "^0.26.1",
"classnames": "^2.3.1",
"graphql": "^16.8.1",
"graphql-request": "^7.0.1",
"normalize.css": "^8.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-particles": "2.9.3",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.0",
"react-scrolllock": "^5.0.1",
"tsparticles": "2.9.3",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-app-rewired start",
"predeploy": "npm run build",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"start": "vite",
"build": "vite build",
"preview": "vite preview",
"lint:fix": "yarn lint --fix && yarn pretty --write",
"lint": "eslint .",
"pretty": "yarn prettier \"src/**/*.{js,jsx,ts,tsx,html,json,md}\" public/**/*.html --check"
"lint": "yarn run eslint .",
"pretty": "yarn prettier \"src/**/*.{js,jsx,ts,tsx,html,json,md}\" public/**/*.html --check",
"generate-subgraph-types": "dotenv -- graphql-codegen --config src/subgraph/codegen.ts",
"postinstall": "yarn run generate-subgraph-types"
},
"browserslist": {
"production": [
Expand All @@ -46,12 +45,25 @@
]
},
"devDependencies": {
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/client-preset": "4.2.6",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^9.0.0",
"dotenv-cli": "^7.4.2",
"eslint": "^8",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.2",
"husky": "^7.0.4",
"lint-staged": "^12.3.5",
"postcss": "^8.4.8",
Expand All @@ -64,7 +76,10 @@
"react-app-rewire-postcss": "^3.0.2",
"react-app-rewired": "^2.2.1",
"react-snap": "^1.23.0",
"typescript": "^4.6.2"
"typescript": "^5.4.5",
"vite": "^5.3.1",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.3.2"
},
"resolutions": {
"postcss": "^8.4.8"
Expand Down
2 changes: 1 addition & 1 deletion src/api/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const getTokenPublicUrl = (filePath: string) =>
`${process.env.PUBLIC_URL}/coins/${filePath}`;
new URL(`/coins/${filePath}`, import.meta.url).href;

export const tokenIconUrls = {
UNI: getTokenPublicUrl('uni.svg'),
Expand Down
36 changes: 6 additions & 30 deletions src/api/hooks/useProposals.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
import { useEffect, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { fetchProposalCount } from '../index';

export const useProposalsCountFromApi = () => {
const [data, setData] = useState<number>();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<Error | undefined>();

const fetchData = () => {
fetchProposalCount()
.then(res => {
setData(res);
setIsLoading(false);
})
.catch(e => {
setError(e);
setIsLoading(false);
});
};

useEffect(() => {
setIsLoading(true);
fetchData();
}, []);

return {
data,
isLoading,
error,
fetchData,
};
};
export const useProposalsCountFromApi = () =>
useQuery({
queryKey: ['proposalCount'],
queryFn: fetchProposalCount,
});
Loading