Merge branch 'master' into feature/remote-config

This commit is contained in:
Matthias Kretschmann 2019-04-02 13:06:52 +02:00 committed by GitHub
commit 717d67c619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 10 deletions

View File

@ -53,7 +53,7 @@ class App extends Component<{}, AppState> {
private requestFromFaucet = async () => {
if (this.state.account !== '') {
try {
await fetch(
const response = await fetch(
`${faucetScheme}://${faucetHost}:${faucetPort}/faucet`,
{
method: 'POST',
@ -67,6 +67,8 @@ class App extends Component<{}, AppState> {
})
}
)
return response.json()
} catch (error) {
Logger.log('requestFromFaucet', error)
}

View File

@ -13,3 +13,10 @@
.success {
color: $green;
}
.error {
&,
p {
color: $red;
}
}

View File

@ -21,16 +21,24 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
eth: 'xx'
}
private getTokens = async (requestFromFaucet: () => void) => {
private getTokens = async (requestFromFaucet: () => any) => {
this.setState({ isLoading: true })
try {
await requestFromFaucet()
const response = await requestFromFaucet()
if (response.error) {
this.setState({
isLoading: false,
error: response.error
})
return
}
this.setState({
isLoading: false,
success: `Successfully added ${
this.state.eth
} ETH to your account.`
success: `Successfully added ETH to your account.`
})
} catch (error) {
this.setState({ isLoading: false, error })
@ -56,10 +64,8 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
<Spinner message="Getting Ether..." />
) : this.state.error ? (
<div className={styles.error}>
{this.state.error}{' '}
<Button link onClick={this.reset}>
Try again
</Button>
<p>{this.state.error}</p>
<Button onClick={this.reset}>Try again</Button>
</div>
) : this.state.success ? (
<div className={styles.success}>{this.state.success}</div>