Skip to content
Open
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
40 changes: 40 additions & 0 deletions front/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "ubj_scoreboard",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4",
"web3": "^4.16.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
}
}
10 changes: 10 additions & 0 deletions front/public/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:root{

}

body {
background-color: black;
color: aliceblue;
margin: 0;
height: 100vh;
}
12 changes: 12 additions & 0 deletions front/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="./index.css" />
<title>Score Board</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
77 changes: 77 additions & 0 deletions front/src/Main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Component } from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { useParams } from 'react-router-dom';

import HomePage from './pages/HomePage';
import IssueToken from './pages/IssueToken';
import TradeToken from './pages/TradeToken';
import TradeNFT from './pages/TradeNFT';
import MintNFT from './pages/MintNFT';

import Web3 from 'web3';

function DynamicComponent() {
const { menu } = useParams();

if (menu === "토큰발행") {
return <IssueToken />;
} else if (menu === "토큰거래") {
return <TradeToken />;
} else if (menu === "NFT발행") {
return <MintNFT />;
} else if (menu === "NFT거래") {
return <TradeNFT />;
}
return <div>Not Found</div>;
}

class Main extends Component {
constructor(props) {
super(props);
this.state = {
account: "0x0",
balance: 0,
};
}

async componentDidMount() {
await this.loadWeb3();
await this.loadBlockchainData();
}

async loadWeb3() {
if (window.ethereum) {
window.web3 = new Web3(window.ethereum);
await window.ethereum.enable();
} else if (window.web3) {
window.web3 = new Web3(window.web3.currentProvider);
} else {
window.alert("No ethereum browser detected. You can check out MetaMask!");
}
}

async loadBlockchainData() {
const web3 = window.web3;
const accounts = await web3.eth.getAccounts();
this.setState({ account: accounts[0] });
console.log("Current Account:", accounts[0]);
const balance = await web3.eth.getBalance(accounts[0]);

//잔액을 이더로 변환
const balanceEther = web3.utils.fromWei(balance,'ether');
this.setState({balance: balanceEther})
}

render() {
return (
<BrowserRouter>
<Routes>
<Route index element={<HomePage account={this.state.account} balance={this.state.balance}/>} />
<Route path=":menu" element={<DynamicComponent/>} />
</Routes>
</BrowserRouter>
);
}
}

export default Main;
Binary file added front/src/assets/tokenus_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions front/src/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Outlet } from 'react-router-dom';

function App() {
return (
<>
<div><Outlet /></div>
</>
);

}

export default App;
11 changes: 11 additions & 0 deletions front/src/components/Container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import './styles/Container.css';

function Container({children }) {
return (
<div className="container-col">
{children}
</div>
);
}

export default Container;
13 changes: 13 additions & 0 deletions front/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import './styles/Header.css';

function Header({ menu }) {
return (
<>
<div className="header">
<p className='menu'>{menu}</p>
</div>
</>
);
}

export default Header;
12 changes: 12 additions & 0 deletions front/src/components/MenuButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "./styles/MenuButton.css"

function MenuButton({menu}) {
return (
<>
<div className="menu-btn">
<p>{menu}</p>
</div>
</>
);
}
export default MenuButton;
38 changes: 38 additions & 0 deletions front/src/components/styles/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.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;
}

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

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
13 changes: 13 additions & 0 deletions front/src/components/styles/Container.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.container-col {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.container-row {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
31 changes: 31 additions & 0 deletions front/src/components/styles/Header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.header {
width: 100%;
height: 10vh;
display: flex;
align-items: center;
background-color: rgb(255, 255, 255);
}

.header img {
width: 3.2vw;
}

.header p {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
white-space: nowrap;
}

.logo {
flex: 1;
}


.menu {
flex: 1;
font-size: 3.2vw;
font-weight: 900;
color: black;
}
18 changes: 18 additions & 0 deletions front/src/components/styles/MenuButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.menu-btn {
display: flex;
justify-content: center;
align-items: center;

height: 4.5rem;

font-size: 2vw;

border-radius: 10px;
background-color: #D9D9D9;
color: black;
}

.menu-btn:hover {
background-color:tomato;
color:aliceblue;
}
6 changes: 6 additions & 0 deletions front/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Main from './Main';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Main />);
44 changes: 44 additions & 0 deletions front/src/pages/HomePage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

import { Link } from 'react-router-dom';
import Container from '../components/Container';
import MenuButton from '../components/MenuButton';
import logo from '../assets/tokenus_logo.png';
import './styles/HomePage.css'


function MenuButtons() {
const menus = ['토큰발행', '토큰거래', 'NFT발행', 'NFT거래'];
return (
<ul className='buttons'>
{menus.map((menu) => (
<li key={menu} className='btn'>
<Link to={`/${menu}`}>
<MenuButton menu={menu} />
</Link>
</li>
))}
</ul>
);
}


function HomePage({ account, balance }) {

return (
<>
<div>
<Container>
<div className='title align-col'>
<p>TokenUs</p>
<Link to={"/"}><img src={logo} alt="로고" style={{ padding: "10px", width: "200px", height: "auto" }} /></Link>
</div>
<p className='account'>Connected Account : {account}</p>
<p className='balance'>잔액 : {balance} ETH</p>
<MenuButtons />
</Container>
</div>
</>
);
}

export default HomePage;
Loading