Skip to content

Commit

Permalink
Merge pull request #161 from enabledao/connectWallet-update
Browse files Browse the repository at this point in the history
update connect Wallet
  • Loading branch information
djuanit0x authored Oct 29, 2019
2 parents 10ed9ef + a27a2ab commit ac02f2f
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 375 deletions.
200 changes: 113 additions & 87 deletions src/components/pages/faucet/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Container } from '../../../styles/bases'
import { Margin, Padding } from '../../../styles/utils'
import { Row, Col, Button, Spinner } from '../../lib'
import { FaucetActionMobile, FaucetBox, FaucetWrapper } from './styled'
import RenderConnectWallet from '../renderConnectWallet'
import contractAddresses from '../../../config/ines.fund.js'
import { connectToWallet, prepBigNumber } from '../../../utils/web3Utils'
import { getDeployedFromConfig } from '../../../utils/getDeployed'
Expand Down Expand Up @@ -62,7 +63,7 @@ class Faucet extends React.Component<FaucetProps, FaucetState> {
}
}

componentDidMount = async () => {
loadFaucet = async () => {
try {
await connectToWallet()
const crowdloanInstance = await getDeployedFromConfig(
Expand Down Expand Up @@ -96,102 +97,127 @@ class Faucet extends React.Component<FaucetProps, FaucetState> {
}
}

componentDidMount = async () => await this.loadFaucet()

render() {
const { paymentToken, faucetBalance, transacting } = this.state
return (
<React.Fragment>
<FaucetWrapper>
{this.state.loaded ? (
<Container>
<Row justify="center">
<Col lg={10} md={12}>
<img
src={walletIcon}
alt="Icon - Wallet"
width={34}
style={{ position: 'absolute' }}
/>
<Padding left={48}>
<h2>Testnet Token Faucet</h2>
</Padding>
<p>
Lorem ipsum dolor sit amet consectetur
adipisicing elit.
</p>
<Margin vertical={48}>
<Row text="center">
<Col lg={4} md={4} sm={4} xs={4}>
<h4>
{!faucetBalance
? '0'
: prepBigNumber(
faucetBalance,
paymentToken.decimals,
true
)}{' '}
Dai
</h4>
<p>Faucet Balance</p>
</Col>
<Col lg={4} md={4} sm={4} xs={4}>
<h4>
{!(
paymentToken &&
paymentToken.balanceOf
)
? '0'
: prepBigNumber(
paymentToken.balanceOf,
paymentToken.decimals,
true
)}{' '}
Dai
</h4>
<p>Account Balance</p>
</Col>
</Row>
</Margin>
</Col>
</Row>
<Margin bottom={48}>
<RenderConnectWallet onConnect={this.loadFaucet}>
<FaucetWrapper>
{this.state.loaded ? (
<Container>
<Row justify="center">
<Col lg={10} md={12}>
<FaucetBox>
<Row justify="center" text="center">
<Col lg={4} md={6} sm="hidden">
<Button
color="green"
disabled={transacting}
onClick={this.onRequest}
>
Request
{transacting && (
<Spinner size="16" />
)}
</Button>
<img
src={walletIcon}
alt="Icon - Wallet"
width={34}
style={{ position: 'absolute' }}
/>
<Padding left={48}>
<h2>Testnet Token Faucet</h2>
</Padding>
<p>
Lorem ipsum dolor sit amet
consectetur adipisicing elit.
</p>
<Margin vertical={48}>
<Row text="center">
<Col
lg={4}
md={4}
sm={4}
xs={4}
>
<h4>
{!faucetBalance
? '0'
: prepBigNumber(
faucetBalance,
paymentToken.decimals,
true
)}{' '}
Dai
</h4>
<p>Faucet Balance</p>
</Col>
<Col
lg={4}
md={4}
sm={4}
xs={4}
>
<h4>
{!(
paymentToken &&
paymentToken.balanceOf
)
? '0'
: prepBigNumber(
paymentToken.balanceOf,
paymentToken.decimals,
true
)}{' '}
Dai
</h4>
<p>Account Balance</p>
</Col>
</Row>
</FaucetBox>
<FaucetActionMobile>
<Button
color="green"
disabled={transacting}
onClick={this.onRequest}
>
Request
{transacting && (
<Spinner size="16" />
)}
</Button>
</FaucetActionMobile>
</Margin>
</Col>
</Row>
</Margin>
</Container>
) : (
<ChasingDots />
)}
</FaucetWrapper>
<Margin bottom={48}>
<Row justify="center">
<Col lg={10} md={12}>
<FaucetBox>
<Row
justify="center"
text="center"
>
<Col
lg={4}
md={6}
sm="hidden"
>
<Button
color="green"
disabled={
transacting
}
onClick={
this.onRequest
}
>
Request
{transacting && (
<Spinner size="16" />
)}
</Button>
</Col>
</Row>
</FaucetBox>
<FaucetActionMobile>
<Button
color="green"
disabled={transacting}
onClick={this.onRequest}
>
Request
{transacting && (
<Spinner size="16" />
)}
</Button>
</FaucetActionMobile>
</Col>
</Row>
</Margin>
</Container>
) : (
<ChasingDots />
)}
</FaucetWrapper>
</RenderConnectWallet>
</React.Fragment>
)
}
Expand Down
Loading

0 comments on commit ac02f2f

Please sign in to comment.