Commit aa1f2e57 authored by Hayden Adams's avatar Hayden Adams

get Account balance at start

parent e90423d5
...@@ -85,7 +85,8 @@ class App extends Component { ...@@ -85,7 +85,8 @@ class App extends Component {
uniAdded: cookie.load('uniAdded') || false, uniAdded: cookie.load('uniAdded') || false,
transactions: cookie.load('transactions') || [], transactions: cookie.load('transactions') || [],
}) })
this.getContracts(); this.getInfoFirstTime();
// this.getContracts();
this.getUserAddress(); this.getUserAddress();
this.checkNetwork(); this.checkNetwork();
this.getBlock(); this.getBlock();
...@@ -109,6 +110,15 @@ class App extends Component { ...@@ -109,6 +110,15 @@ class App extends Component {
console.log(nextProps) console.log(nextProps)
} }
getInfoFirstTime = () => {
localweb3.eth.getAccounts((error, result) => {
if(result.length > 0)
this.setState({currentMaskAddress: result[0], locked: false, connected: true}, this.getContracts)
else
this.setState({locked: true, connected: false, interaction: 'locked'})
})
}
getContracts() { getContracts() {
const uniExchangeAddress = '0xcDc30C3b02c5776495298198377D2Fc0fd6B1F1C'; const uniExchangeAddress = '0xcDc30C3b02c5776495298198377D2Fc0fd6B1F1C';
const uniExchangeContract = new localweb3.eth.Contract(exchangeABI, uniExchangeAddress); const uniExchangeContract = new localweb3.eth.Contract(exchangeABI, uniExchangeAddress);
...@@ -136,7 +146,7 @@ class App extends Component { ...@@ -136,7 +146,7 @@ class App extends Component {
swapExchange: swapExchangeContract, swapExchange: swapExchangeContract,
swapToken: swapTokenContract, swapToken: swapTokenContract,
factory: factoryContract, factory: factoryContract,
}, this.getMarketInfo) }, this.getInfo)
} }
...@@ -657,7 +667,7 @@ class App extends Component { ...@@ -657,7 +667,7 @@ class App extends Component {
{this.state.interaction === 'input' ? {this.state.interaction === 'input' ?
<section className="swap grey-bg border pa2"> <section className="swap grey-bg border pa2">
<a role="button" onClick={() => {this.purchaseTokens()}}> <a role="button" onClick={() => {this.purchaseTokens()}}>
<b>{"I want to swap " + this.state.input + " " + this.state.inputToken.value + " for " + this.state.output/10**18 + " " + this.state.outputToken.value}</b> <b>{"I want to swap " + this.state.input + " " + this.state.inputToken.value + " for " + (this.state.output/10**18).toFixed(5) + " " + this.state.outputToken.value}</b>
</a> </a>
{/* <button> Approve </button> */} {/* <button> Approve </button> */}
</section> </section>
......
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