Commit 2e3b8b6e authored by Hayden Adams's avatar Hayden Adams

minor fixes

parent 005538b6
...@@ -227,7 +227,8 @@ input[type=number]::-webkit-outer-spin-button { ...@@ -227,7 +227,8 @@ input[type=number]::-webkit-outer-spin-button {
} }
.red-bg{ .red-bg{
background-color: red; /* background-color: red; */
background-color: #d73a49;
} }
.blue-bg{ .blue-bg{
...@@ -235,7 +236,8 @@ input[type=number]::-webkit-outer-spin-button { ...@@ -235,7 +236,8 @@ input[type=number]::-webkit-outer-spin-button {
} }
.red{ .red{
color: red; /* color: red; */
color: #d73a49;
} }
.green{ .green{
......
...@@ -15,7 +15,7 @@ import About from './components/About'; ...@@ -15,7 +15,7 @@ import About from './components/About';
import Links from './components/Links'; import Links from './components/Links';
import SharePurchase from './components/SharePurchase'; import SharePurchase from './components/SharePurchase';
// import Transactions from './components/Transactions'; // import Transactions from './components/Transactions';
// import Visualization from './components/Visualization'; import Visualization from './components/Visualization';
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { subscribe } from 'redux-subscriber'; import { subscribe } from 'redux-subscriber';
...@@ -59,13 +59,8 @@ class App extends Component { ...@@ -59,13 +59,8 @@ class App extends Component {
} else { } else {
web3 = 'undefined' web3 = 'undefined'
} }
this.state = {
transactions: []
}
} }
// TODO: get rid of redundant web3 === 'undefined' checks in componentWill/DidMount // TODO: get rid of redundant web3 === 'undefined' checks in componentWill/DidMount
// STATUS: kind of done
componentWillMount() { componentWillMount() {
//console.log('props', this.props); //console.log('props', this.props);
if(web3 === 'undefined') { if(web3 === 'undefined') {
...@@ -228,37 +223,39 @@ class App extends Component { ...@@ -228,37 +223,39 @@ class App extends Component {
getInvestInfo = () => { getInvestInfo = () => {
var symbol = this.props.exchange.investToken.value; var symbol = this.props.exchange.investToken.value;
var exchange = this.symbolToExchangeContract(symbol); if (symbol != "ETH") {
var token = this.symbolToTokenContract(symbol); var exchange = this.symbolToExchangeContract(symbol);
var exchangeAddress = this.symbolToExchangeAddress(symbol); var token = this.symbolToTokenContract(symbol);
var exchangeAddress = this.symbolToExchangeAddress(symbol);
exchange.methods.ethPool().call().then((result, error) => { exchange.methods.ethPool().call().then((result, error) => {
this.props.setInvestEthPool(result); this.props.setInvestEthPool(result);
}); });
exchange.methods.tokenPool().call().then((result, error) => { exchange.methods.tokenPool().call().then((result, error) => {
this.props.setInvestTokenPool(result); this.props.setInvestTokenPool(result);
}); });
exchange.methods.totalShares().call().then((result, error) => { exchange.methods.totalShares().call().then((result, error) => {
this.props.setInvestShares(result); this.props.setInvestShares(result);
}); });
exchange.methods.getShares(this.props.web3Store.currentMaskAddress).call().then((result, error) => { exchange.methods.getShares(this.props.web3Store.currentMaskAddress).call().then((result, error) => {
this.props.setUserShares(result); this.props.setUserShares(result);
}); });
token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, balance) => { token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, result) => {
this.props.setInvestTokenBalance(balance); this.props.setInvestTokenBalance(result);
}); });
token.methods.allowance(this.props.web3Store.currentMaskAddress, exchangeAddress).call((error, balance) => { token.methods.allowance(this.props.web3Store.currentMaskAddress, exchangeAddress).call((error, result) => {
this.props.setInvestTokenAllowance(balance); this.props.setInvestTokenAllowance(result);
}); });
this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, balance) => { this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, result) => {
this.props.setInvestEthBalance(balance); this.props.setInvestEthBalance(result);
}); });
}
} }
getExchangeState = (type) => { getExchangeState = (type) => {
...@@ -268,12 +265,10 @@ class App extends Component { ...@@ -268,12 +265,10 @@ class App extends Component {
exchange.methods.ethPool().call().then((result, error) => { exchange.methods.ethPool().call().then((result, error) => {
this.props.setEthPool1(result); this.props.setEthPool1(result);
// console.log('Input Market ETH: ' + result);
}); });
exchange.methods.tokenPool().call().then((result, error) => { exchange.methods.tokenPool().call().then((result, error) => {
this.props.setTokenPool1(result); this.props.setTokenPool1(result);
// console.log('Input Market Tokens: ' + result);
}); });
} else if (type === 'output') { } else if (type === 'output') {
...@@ -281,26 +276,22 @@ class App extends Component { ...@@ -281,26 +276,22 @@ class App extends Component {
exchange.methods.ethPool().call().then((result, error) => { exchange.methods.ethPool().call().then((result, error) => {
this.props.setEthPool2(result); this.props.setEthPool2(result);
// console.log('Output Market ETH: ' + result);
}); });
exchange.methods.tokenPool().call().then((result, error) => { exchange.methods.tokenPool().call().then((result, error) => {
this.props.setTokenPool2(result); this.props.setTokenPool2(result);
// console.log('Output Market Tokens: ' + result);
}); });
} }
} }
getEthBalance = (type) => { getEthBalance = (type) => {
if (type === 'input') { if (type === 'input') {
this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, balance) => { this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, result) => {
this.props.setInputBalance(balance); this.props.setInputBalance(result);
// console.log('ETH Balance: ' + balance);
}); });
} else if (type === 'output') { } else if (type === 'output') {
this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, balance) => { this.props.web3Store.web3.eth.getBalance(this.props.web3Store.currentMaskAddress, (error, result) => {
this.props.setOutputBalance(balance); this.props.setOutputBalance(result);
// console.log('ETH Balance: ' + balance);
}); });
} }
} }
...@@ -309,15 +300,13 @@ class App extends Component { ...@@ -309,15 +300,13 @@ class App extends Component {
var token; var token;
if (type === 'input') { if (type === 'input') {
token = this.symbolToTokenContract(this.props.exchange.inputToken.value); token = this.symbolToTokenContract(this.props.exchange.inputToken.value);
token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, balance) => { token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, result) => {
this.props.setInputBalance(balance); this.props.setInputBalance(result);
// console.log(this.props.exchange.inputToken.value + ' Balance: ' + balance);
}); });
} else if (type === 'output') { } else if (type === 'output') {
token = this.symbolToTokenContract(this.props.exchange.outputToken.value); token = this.symbolToTokenContract(this.props.exchange.outputToken.value);
token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, balance) => { token.methods.balanceOf(this.props.web3Store.currentMaskAddress).call((error, result) => {
this.props.setOutputBalance(balance); this.props.setOutputBalance(result);
// console.log(this.props.exchange.outputToken.value + ' Balance: ' + balance);
}); });
} }
} }
......
...@@ -24,6 +24,7 @@ class Invest extends Component { ...@@ -24,6 +24,7 @@ class Invest extends Component {
this.getInvestExchangeState(); this.getInvestExchangeState();
this.getInvestBalance(); this.getInvestBalance();
} else { } else {
await this.props.setInvestToken(selected);
this.props.setInvestTokenPool(0); this.props.setInvestTokenPool(0);
this.props.setInvestEthPool(0); this.props.setInvestEthPool(0);
this.props.setInvestTokenBalance(0); this.props.setInvestTokenBalance(0);
...@@ -35,9 +36,11 @@ class Invest extends Component { ...@@ -35,9 +36,11 @@ class Invest extends Component {
} }
onInputChange = async (event) => { onInputChange = async (event) => {
var inputValue = event.target.value; if (this.props.exchange.investToken.value != "ETH") {
await this.props.setInvestSharesInput(inputValue); await this.props.setInvestSharesInput(event.target.value);
this.getInvestOutput(); this.getInvestOutput();
console.log('investToken', this.props.exchange.investToken.value)
}
} }
toggleCheck = () => { toggleCheck = () => {
......
...@@ -77,10 +77,13 @@ class Purchase extends Component { ...@@ -77,10 +77,13 @@ class Purchase extends Component {
} }
render() { render() {
if (this.props.exchange.investToken.value == "ETH") { if(this.props.web3Store.investToggle == true && this.props.exchange.investSharesInput > 0) {
return (<a className="swap grey-bg hidden border pa2"></a>) // Doesn't work
} else if(this.props.web3Store.investToggle == true && this.props.exchange.investSharesInput > 0) { if (this.props.exchange.investToken.value == "ETH") {
if(this.props.exchange.investTokenAllowance == 0) { <div className="swap border pa2 red-bg">
<b><p>Please select a token other than ETH.</p></b>
</div>
} else if(this.props.exchange.investTokenAllowance == 0) {
return ( return (
<div className="swap border pa2 blue-bg" role="button" onClick={() => {this.approveInvestAllowance()}}> <div className="swap border pa2 blue-bg" role="button" onClick={() => {this.approveInvestAllowance()}}>
<b><p>Click to approve {this.props.exchange.investToken.value} spending</p></b> <b><p>Click to approve {this.props.exchange.investToken.value} spending</p></b>
...@@ -90,7 +93,7 @@ class Purchase extends Component { ...@@ -90,7 +93,7 @@ class Purchase extends Component {
if(this.props.exchange.investEthRequired > this.props.exchange.investEthBalance) { if(this.props.exchange.investEthRequired > this.props.exchange.investEthBalance) {
return ( return (
<div className="swap border pa2 red-bg"> <div className="swap border pa2 red-bg">
<b><p>You can't afford to invest {(this.props.exchange.investEthRequired/10**18).toFixed(4)} ETH and {(this.props.exchange.investTokensRequired/10**18).toFixed(4)} {this.props.exchange.investToken.value} for {this.props.exchange.investSharesInput} shares</p></b> <b><p>😭 You can't afford to invest {(this.props.exchange.investEthRequired/10**18).toFixed(4)} ETH and {(this.props.exchange.investTokensRequired/10**18).toFixed(4)} {this.props.exchange.investToken.value} for {this.props.exchange.investSharesInput} shares 😭</p></b>
</div> </div>
) )
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment