Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a86cb74
add dowgo balance and usdc allowance
antoine-dowgo Jun 3, 2022
c3a861a
add sell button
antoine-dowgo Jun 7, 2022
26a59e9
add button compo
antoine-dowgo Jun 13, 2022
277b8ac
add boostrap to navbar
antoine-dowgo Jun 13, 2022
ef054c5
view components for balance and buy sell
antoine-dowgo Jun 13, 2022
82e9f94
add approve modal
antoine-dowgo Jun 15, 2022
03d85ac
lint
antoine-dowgo Jun 15, 2022
e260851
adapt to usdc 5 digits
antoine-dowgo Oct 14, 2022
7f35249
more usdc decimal fixes
antoine-dowgo Oct 14, 2022
6c7381e
add transaction status
antoine-dowgo Oct 14, 2022
a9afb22
error handling and dwg info
antoine-dowgo Oct 14, 2022
3ee2458
fix function input and update info
antoine-dowgo Oct 14, 2022
e36144b
publish on dowgo.io
antoine-dowgo Oct 15, 2022
a650a55
adapt to mainnet deployement
antoine-dowgo Oct 17, 2022
ac59924
iterate on demo feedback
antoine-dowgo Oct 18, 2022
4a41071
Update index.html
oscar-dowgo Oct 18, 2022
04cd1c5
add detailed calculus
antoine-dowgo Oct 18, 2022
f427917
solved merge conflicts
antoine-dowgo Nov 2, 2022
72a7044
update ui with new alpha version
antoine-dowgo Dec 6, 2022
6920090
Merge pull request #11 from DOWGO/update-alpha-with-goerli
antoine-dowgo Dec 6, 2022
02d6b97
update addresses
antoine-dowgo Dec 6, 2022
966baf0
fetch latest deplyment for goerli
antoine-dowgo Dec 8, 2022
73e6cd6
homepage: modified UI of components and added new library antd
Tris92 Dec 9, 2022
e3c4b45
remove comment
antoine-dowgo Dec 12, 2022
b54c374
Merge pull request #13 from DOWGO/add-latest-deployment-api
antoine-dowgo Dec 13, 2022
9f00f67
fix contract addresses dependency
antoine-dowgo Dec 13, 2022
6198105
Merge pull request #15 from DOWGO/dev
antoine-dowgo Dec 13, 2022
8edf18f
sync with main and solve conflicts
antoine-dowgo Dec 13, 2022
bde5967
added react-router-dom to project including routing component in App.…
Tris92 Jan 23, 2023
a442fdf
Merge pull request #14 from DOWGO/tristan
oscar-dowgo Jan 23, 2023
080db73
dowgo.io
oscar-dowgo Jan 23, 2023
8563f2a
interface
oscar-dowgo Jan 23, 2023
c9000c2
interface
oscar-dowgo Jan 24, 2023
8867052
fixed header menu item + updated home page and removed the title of t…
Tris92 Jan 25, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
.DS_Store
build
.env
/build
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# web3-react-template

Template to make a DApp with React, typescript and ethers.js.

- Button to Connect to MetaMask
- Display Account
- Display Network
- Display Dai Balance

Made using the create-react-app typescript template, MetaMask recommandation to connect, ethers.js library and types generated by Typechain in a separate repo.

To launch, run `npm run start`
To launch, run `npm run start`

## TODO

- handle errors
- only allow buy if allowance
- sell
- check non -zero
12,309 changes: 7,658 additions & 4,651 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "web3-react-template",
"version": "0.1.0",
"private": true,
"homepage": "https://dowgo.io",
"dependencies": {
"@metamask/detect-provider": "^1.2.0",
"@metamask/providers": "^8.1.1",
Expand All @@ -12,10 +13,15 @@
"@types/node": "^16.11.38",
"@types/react": "^18.0.10",
"@types/react-dom": "^18.0.5",
"antd": "^4.24.1",
"axios": "^1.2.1",
"ethers": "^5.6.8",
"jquery": "^3.6.1",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router-dom": "^6.4.3",
"react-scripts": "5.0.1",
"sass": "^1.56.0",
"typescript": "^4.7.2",
"web-vitals": "^2.1.4"
},
Expand All @@ -24,7 +30,9 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "npx prettier -w ."
"lint": "npx prettier -w src && npx prettier -w public",
"predeploy": "npm run build",
"deploy": "echo 'dowgo.io' > ./build/CNAME && gh-pages -d build"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -52,5 +60,10 @@
"license": "ISC",
"bugs": {
"url": "https://github.com/joelamouche/web3-react-template/issues"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"gh-pages": "^4.0.0"
}
}
Binary file modified public/favicon.ico
Binary file not shown.
14 changes: 12 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;500;600;700;800&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.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/
Expand All @@ -24,7 +34,7 @@
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>React App</title>
<title>dowgo interface</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file added public/logo.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 removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"type": "image/x-icon"
},
{
"src": "logo192.png",
"src": "logo.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"src": "logo.png",
"type": "image/png",
"sizes": "512x512"
}
Expand Down
51 changes: 27 additions & 24 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
.App {
.app-container {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
.app-header {
position: fixed;
z-index: 999;
width: 100%;
padding: 0;
height: 100px;
margin-bottom: 200px;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
.dowgo-logo-container {
top: 0;
position: absolute;
z-index: 1000;
margin-left: 20px;
margin-top: 10px;
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
.dowgo-logo-menu {
height: 80px;
width: auto;
}



.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}

.ant-layout {
background: black !important;
}

.ant-layout-footer {
background: black !important;
height: 50vh;
}
12 changes: 9 additions & 3 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import App from "./App";
import ReactDOM from "react-dom";

test("renders learn react link", () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
// render(<App />);
// const linkElement = screen.getByText(/learn react/i);
// expect(linkElement).toBeInTheDocument();

// renders without crashing
const div = document.createElement("div");
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
97 changes: 75 additions & 22 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,83 @@
import React from "react";
import "./App.css";
import ConnectMetaMask from "./components/ConnectMetaMask";
import DaiBalance from "./components/DaiBalance";
import { Address } from "./types/types";
import React, { useEffect } from 'react';
import {Routes, Route, Navigate} from "react-router-dom";

import DowgoDApp from './pages/home/home';
import Funds from './pages/funds/funds';
import ConnectMetaMask from './components/ConnectMetaMask/ConnectMetaMask';
import Profile from './pages/profile/profile';

import { Layout } from "antd";
import { EthAddress, ChainId, ContractAddresses} from "./types/types";
import { providers } from "ethers";

function App() {
const [provider, setProvider] = React.useState<providers.Web3Provider|undefined>(undefined);
const [currentAccount, setCurrentAccount] = React.useState<Address>("0x");
//@ts-ignore
import DowgoLogo from "./assets/header/dowgo-logo.png";

import { getContractAddresses } from "./constants/contractAddresses";

import "./App.css";

function App () {

const { Header } = Layout;
const [currentAccount, setCurrentAccount] = React.useState<EthAddress>("0x");
const [provider, setProvider] = React.useState<
providers.Web3Provider | undefined
>(undefined);
const [chainId, setChainId] = React.useState<ChainId | undefined>(undefined);

// Contract addresses
const [contractAddresses, setContractAddresses] = React.useState<
ContractAddresses | undefined
>(undefined);
async function getAddresses(chainId: ChainId | undefined) {
if (chainId) {
let addresses = await getContractAddresses(chainId);
setContractAddresses(addresses);
}
}
useEffect(() => {
getAddresses(chainId);
}, [chainId]);


return (
<div className="App">
<header className="App-header">
{ConnectMetaMask(
provider,
setProvider,
currentAccount,
setCurrentAccount
)}
{DaiBalance(
provider,
currentAccount
)}
</header>
<div>
<Layout>
<Header className="app-header">
{ConnectMetaMask(
provider,
setProvider,
currentAccount,
setCurrentAccount,
chainId,
setChainId
)}
<div className="dowgo-logo-container">
<a href="https://dowgo.io/" rel="noopener noreferrer">
<img
src={DowgoLogo}
alt="dowgo-logo"
className="dowgo-logo-menu"
/>
</a>
</div>
</Header>

<Routes>
{currentAccount !== "0x"
?
<Route path='/' element={<Navigate to='/profile' />} />
:
<Route path="/" element={<DowgoDApp />} />
}
<Route path="/profile" element={<Profile />} />
<Route path="/dowgo-funds" element={<Funds />} />
<Route path='*' element={<Navigate to='/' />} />
</Routes>
</Layout>
</div>
);
)
}

export default App;
1 change: 1 addition & 0 deletions src/assets/balance/usdc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/dowgo-funds/alpha.svg
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 src/assets/header/dowgo-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/header/metamask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading