From 8e0ae253845ca2e6e18ccf84a57eaa391c917e59 Mon Sep 17 00:00:00 2001 From: "phat.itern" Date: Sun, 22 Aug 2021 12:52:46 +0700 Subject: [PATCH 1/3] chore: adapt to newer version of material ui --- dapp/package.json | 2 ++ dapp/src/components/Card/index.js | 7 ++++--- dapp/src/components/Contract.js | 2 +- dapp/src/components/MetaMask/MetaMask.js | 9 +++++---- dapp/src/components/NiftyAlert/index.js | 4 ++-- dapp/src/components/Top/Title.js | 2 +- dapp/src/components/Top/Top.js | 4 ++-- dapp/src/components/Warning/Warning.js | 2 +- dapp/src/lib/web3Service.js | 20 ++++++-------------- 9 files changed, 24 insertions(+), 28 deletions(-) diff --git a/dapp/package.json b/dapp/package.json index e725c9e..7771937 100644 --- a/dapp/package.json +++ b/dapp/package.json @@ -3,6 +3,8 @@ "version": "0.1.0", "author": "PhyrexTsai", "dependencies": { + "@babel/runtime": "^7.15.3", + "@material-ui/core": "^4.12.3", "autoprefixer": "7.1.6", "babel-cli": "^6.26.0", "babel-core": "6.26.0", diff --git a/dapp/src/components/Card/index.js b/dapp/src/components/Card/index.js index f201e85..5d1516f 100644 --- a/dapp/src/components/Card/index.js +++ b/dapp/src/components/Card/index.js @@ -5,13 +5,14 @@ import style from './Card.css'; import { getCryptoHerosTokenAddress } from '../../lib/web3Service'; import axios from 'axios'; import LoadingCoin from '../LoadingCoin'; -import Button from 'material-ui/Button'; +import Button from '@material-ui/core/Button'; -import Dialog, { +import { + Dialog, DialogActions, DialogContent, DialogContentText, -} from 'material-ui/Dialog'; +} from '@material-ui/core'; const cx = classnames.bind(style); diff --git a/dapp/src/components/Contract.js b/dapp/src/components/Contract.js index 5acff00..a005be4 100644 --- a/dapp/src/components/Contract.js +++ b/dapp/src/components/Contract.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { LinearProgress } from 'material-ui/Progress'; +import { LinearProgress } from '@material-ui/core/Progress'; import './Contract.css'; export default class Contract extends Component { // 將 read contract method 透過 redux 儲存與 saga 非同步呼叫,將 web3 當成 API 使用 diff --git a/dapp/src/components/MetaMask/MetaMask.js b/dapp/src/components/MetaMask/MetaMask.js index a41032c..0de507e 100644 --- a/dapp/src/components/MetaMask/MetaMask.js +++ b/dapp/src/components/MetaMask/MetaMask.js @@ -1,13 +1,14 @@ import React, {Component} from 'react'; import Web3 from 'web3'; -import Button from 'material-ui/Button'; -import Dialog, { +import {Button} from '@material-ui/core'; +import { + Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, -} from 'material-ui/Dialog'; -import Slide from 'material-ui/transitions/Slide'; + Slide, +} from '@material-ui/core'; const messages = { 'LOAD_MATAMASK_WALLET_ERROR': 'Load metamask wallet error, maybe try Metamask later, or upload a wallet json file.', diff --git a/dapp/src/components/NiftyAlert/index.js b/dapp/src/components/NiftyAlert/index.js index 2e5ea1e..65e60b4 100644 --- a/dapp/src/components/NiftyAlert/index.js +++ b/dapp/src/components/NiftyAlert/index.js @@ -1,10 +1,10 @@ import React, { Component } from 'react'; -import Button from 'material-ui/Button'; +import Button from '@material-ui/core/Button'; import Dialog, { DialogActions, DialogContent, DialogContentText, -} from 'material-ui/Dialog'; +} from '@material-ui/core/Dialog'; export default class extends Component{ diff --git a/dapp/src/components/Top/Title.js b/dapp/src/components/Top/Title.js index 0de43e3..36f58eb 100644 --- a/dapp/src/components/Top/Title.js +++ b/dapp/src/components/Top/Title.js @@ -1,5 +1,5 @@ import React from 'react'; -import Typography from 'material-ui/Typography'; +import Typography from '@material-ui/core/Typography'; export const Title = (props) => ( diff --git a/dapp/src/components/Top/Top.js b/dapp/src/components/Top/Top.js index 6fc0d83..b61029e 100644 --- a/dapp/src/components/Top/Top.js +++ b/dapp/src/components/Top/Top.js @@ -1,6 +1,6 @@ import React from 'react'; -import AppBar from 'material-ui/AppBar'; -import Toolbar from 'material-ui/Toolbar'; +import AppBar from '@material-ui/core/AppBar'; +import Toolbar from '@material-ui/core/Toolbar'; import {Title} from './Title'; export const Top = (props) => ( diff --git a/dapp/src/components/Warning/Warning.js b/dapp/src/components/Warning/Warning.js index a581560..e85a26a 100644 --- a/dapp/src/components/Warning/Warning.js +++ b/dapp/src/components/Warning/Warning.js @@ -1,5 +1,5 @@ import React from 'react'; -import Snackbar from 'material-ui/Snackbar'; +import Snackbar from '@material-ui/core/Snackbar'; export const Warning = (props) => ( { } } -export const getSimpleTokenAddress = (networkId) => { - switch (networkId) { - case '1': - return '0x0'; - case '3': - return '0x131855dda0aaff096f6854854c55a4debf61077a'; - case '4': - return '0x0'; - case '42': - return '0x0'; - default: - return '0x0'; - } -} +// Heros Token deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +// Heros Game deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 export const getCryptoHerosTokenAddress = (networkId) => { switch (networkId) { @@ -38,6 +26,8 @@ export const getCryptoHerosTokenAddress = (networkId) => { return '0x0'; case '42': return '0x0'; + case '1337': + return '0x5FbDB2315678afecb367f032d93F642f64180aa3'; default: return '0x0'; } @@ -53,6 +43,8 @@ export const getCryptoHerosGameAddress = (networkId) => { return '0x0'; case '42': return '0x0'; + case '1337': + return '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512'; default: return '0x0'; } From 44f811eb56786529077971fe8ddcaa62e871dcad Mon Sep 17 00:00:00 2001 From: "phat.itern" Date: Sun, 22 Aug 2021 13:20:19 +0700 Subject: [PATCH 2/3] chore: adapt to newer version of material ui --- dapp/src/components/NiftyAlert/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dapp/src/components/NiftyAlert/index.js b/dapp/src/components/NiftyAlert/index.js index 65e60b4..ef327b9 100644 --- a/dapp/src/components/NiftyAlert/index.js +++ b/dapp/src/components/NiftyAlert/index.js @@ -1,10 +1,11 @@ import React, { Component } from 'react'; import Button from '@material-ui/core/Button'; -import Dialog, { +import { + Dialog, DialogActions, DialogContent, DialogContentText, -} from '@material-ui/core/Dialog'; +} from '@material-ui/core'; export default class extends Component{ From 3b93b350cbc53f07dcd2edf01f0cb096b9805ad1 Mon Sep 17 00:00:00 2001 From: "phat.itern" Date: Sun, 22 Aug 2021 13:26:29 +0700 Subject: [PATCH 3/3] doc: add annotation to hint dev to start repo locally --- dapp/package.json | 1 - dapp/src/lib/web3Service.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dapp/package.json b/dapp/package.json index 7771937..0179bf1 100644 --- a/dapp/package.json +++ b/dapp/package.json @@ -3,7 +3,6 @@ "version": "0.1.0", "author": "PhyrexTsai", "dependencies": { - "@babel/runtime": "^7.15.3", "@material-ui/core": "^4.12.3", "autoprefixer": "7.1.6", "babel-cli": "^6.26.0", diff --git a/dapp/src/lib/web3Service.js b/dapp/src/lib/web3Service.js index 332329d..e9404fb 100644 --- a/dapp/src/lib/web3Service.js +++ b/dapp/src/lib/web3Service.js @@ -2,6 +2,7 @@ export const getProvider = (networkId) => { switch (networkId) { case '1': return 'https://mainnet.infura.io/'; + //! This currently need a project Id in order to access, please run locally if you can case '3': return 'https://ropsten.infura.io/'; case '4': @@ -13,9 +14,6 @@ export const getProvider = (networkId) => { } } -// Heros Token deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -// Heros Game deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 - export const getCryptoHerosTokenAddress = (networkId) => { switch (networkId) { case '1': @@ -27,6 +25,7 @@ export const getCryptoHerosTokenAddress = (networkId) => { case '42': return '0x0'; case '1337': + //* development at local, please update your local contract's address here return '0x5FbDB2315678afecb367f032d93F642f64180aa3'; default: return '0x0'; @@ -44,6 +43,7 @@ export const getCryptoHerosGameAddress = (networkId) => { case '42': return '0x0'; case '1337': + //* development at local, please update your local contract's address here return '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512'; default: return '0x0';