diff --git a/package.json b/package.json index b5cb81dd1..5a7b6aaf5 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "0.1.0", "private": true, "dependencies": { + "@burner-wallet/assets": "0.0.4", + "@burner-wallet/core": "0.0.6", "autolinker": "^2.2.1", "axios": "^0.18.0", "base64url": "^3.0.1", diff --git a/src/App.js b/src/App.js index b29759fd0..b204714db 100644 --- a/src/App.js +++ b/src/App.js @@ -3,8 +3,10 @@ import { ContractLoader, Dapparatus, Transactions, Gas, Address, Events } from " import Web3 from 'web3'; import axios from 'axios'; import { I18nextProvider } from 'react-i18next'; -import i18n from './i18n'; import gasless from 'tabookey-gasless'; +import { eth, dai, xdai } from '@burner-wallet/assets'; + +import i18n from './i18n'; import './App.scss'; import Header from './components/Header'; import NavCard from './components/NavCard'; @@ -47,9 +49,9 @@ import RNMessageChannel from 'react-native-webview-messaging'; import bufficorn from './bufficorn.png'; import cypherpunk from './cypherpunk.png'; -import eth from './ethereum.png'; -import dai from './dai.jpg'; -import xdai from './xdai.jpg'; +import ethImg from './images/ethereum.png'; +import daiImg from './images/dai.jpg'; +import xdaiImg from './images/xdai.jpg'; import Wyre from './services/wyre'; let base64url = require('base64url') @@ -537,34 +539,17 @@ class App extends Component { if(this.state.account){ - let ethBalance = 0.00 - let daiBalance = 0.00 - let xdaiBalance = 0.00 - - if(this.state.mainnetweb3){ - - try{ - ethBalance = await this.state.mainnetweb3.eth.getBalance(this.state.account) - ethBalance = this.state.mainnetweb3.utils.fromWei(""+ethBalance,'ether') - - if(this.state.daiContract){ - daiBalance = await this.state.daiContract.methods.balanceOf(this.state.account).call() - daiBalance = this.state.mainnetweb3.utils.fromWei(""+daiBalance,'ether') - } - }catch(e){ - console.log(e) - this.connectToRPC() - } - - - - } - if(this.state.xdaiweb3){ - xdaiBalance = await this.state.xdaiweb3.eth.getBalance(this.state.account) - xdaiBalance = this.state.xdaiweb3.utils.fromWei(""+xdaiBalance,'ether') - } - - this.setState({ethBalance,daiBalance,xdaiBalance,badgeBalance,hasUpdateOnce:true}) + const ethBalance = await eth.getDisplayBalance(this.state.account, 20); + const daiBalance = await dai.getDisplayBalance(this.state.account, 20); + const xdaiBalance = await xdai.getDisplayBalance(this.state.account, 20); + + this.setState({ + ethBalance, + daiBalance, + xdaiBalance, + badgeBalance, + hasUpdateOnce:true + }); if(xdaiBalance < 0.01 && singleBadgeId && !this.state.switchedToSingleBadge){ this.setState({switchedToSingleBadge:true}) @@ -1352,7 +1337,14 @@ render() { let defaultBalanceDisplay = (
- +
) @@ -1391,11 +1383,32 @@ render() { {extraTokens} - + - + - + {badgeDisplay} @@ -1835,9 +1848,6 @@ render() { + ) if(window.location.hostname.indexOf("xdai") >= 0 || window.location.hostname.indexOf("localhost") >= 0){ moneytype="$" diff --git a/src/components/Exchange.js b/src/components/Exchange.js index 4060ecd34..88f9e1ba9 100644 --- a/src/components/Exchange.js +++ b/src/components/Exchange.js @@ -13,6 +13,9 @@ import i18n from '../i18n'; import Wyre from '../services/wyre'; import wyrelogo from '../wyre.png'; +import ethImg from '../images/ethereum.png'; +import daiImg from '../images/dai.jpg'; +import xdaiImg from '../images/xdai.jpg'; import InputRange from 'react-input-range'; import 'react-input-range/lib/css/index.css'; @@ -2224,7 +2227,7 @@ export default class Exchange extends React.Component {
- +
xDai @@ -2249,7 +2252,7 @@ export default class Exchange extends React.Component {
- +
DAI @@ -2273,7 +2276,7 @@ export default class Exchange extends React.Component {
- +
ETH diff --git a/src/core.js b/src/core.js new file mode 100644 index 000000000..c5c6538ce --- /dev/null +++ b/src/core.js @@ -0,0 +1,19 @@ +import BurnerCore from '@burner-wallet/core'; +import { InjectedSigner, LocalSigner } from '@burner-wallet/core/src/signers'; +import { InfuraGateway, InjectedGateway, XDaiGateway } from '@burner-wallet/core/src/gateways'; +import { eth, dai, xdai } from '@burner-wallet/assets'; + +// TODO: Move all keys to env variable +const infuraKey = 'e0ea6e73570246bbb3d4bd042c4b5dac'; + +const core = new BurnerCore({ + signers: [new InjectedSigner(), new LocalSigner()], + gateways: [ + new InjectedGateway(), + new InfuraGateway(infuraKey), + new XDaiGateway(), + ], + assets: [xdai, dai, eth], +}); + +export default core; diff --git a/src/dai.jpg b/src/images/dai.jpg similarity index 100% rename from src/dai.jpg rename to src/images/dai.jpg diff --git a/src/ethereum.png b/src/images/ethereum.png similarity index 100% rename from src/ethereum.png rename to src/images/ethereum.png diff --git a/src/xdai.jpg b/src/images/xdai.jpg similarity index 100% rename from src/xdai.jpg rename to src/images/xdai.jpg diff --git a/src/index.js b/src/index.js index b8a4727c5..2c4cb94be 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import 'bootstrap/dist/css/bootstrap.min.css'; import './index.scss'; +import './core'; import App from './App';