diff --git a/client/.env.local.example b/client/.env.local.example index 16cf0cf..33d5f20 100644 --- a/client/.env.local.example +++ b/client/.env.local.example @@ -54,3 +54,4 @@ REACT_APP_BRIZO_ADDRESS="0x0474ed05ba757dde575dfaaaa267d9e7f3643abc" REACT_APP_REPORT_EMAIL="test@example.com" # REACT_APP_ALLOW_PRICING=true +# REACT_APP_SHOW_REQUEST_TOKENS_BUTTON=true diff --git a/client/src/config.ts b/client/src/config.ts index 3952878..d36f670 100644 --- a/client/src/config.ts +++ b/client/src/config.ts @@ -29,3 +29,4 @@ export const faucetUri = export const verbose = true export const analyticsId = 'UA-60614729-11' export const allowPricing = process.env.REACT_APP_ALLOW_PRICING || false +export const showRequestTokens = process.env.REACT_APP_SHOW_REQUEST_TOKENS_BUTTON || false diff --git a/client/src/routes/Faucet.tsx b/client/src/routes/Faucet.tsx index 3746e7b..3299f0c 100644 --- a/client/src/routes/Faucet.tsx +++ b/client/src/routes/Faucet.tsx @@ -8,6 +8,7 @@ import Web3message from '../components/organisms/Web3message' import styles from './Faucet.module.scss' import Content from '../components/atoms/Content' import withTracker from '../hoc/withTracker' +import { showRequestTokens } from '../config' interface FaucetState { isLoading: boolean @@ -26,7 +27,17 @@ class Faucet extends PureComponent<{}, FaucetState> { trxHash: undefined } - private getTokens = async ( + private getTokens = async () => { + + const { ocean } = this.context + const accounts = await ocean.accounts.list() + console.log(accounts) + const account = accounts[0] + console.log(account) + await ocean.accounts.requestTokens(account, 10) + } + + private getEther = async ( requestFromFaucet: () => Promise ) => { this.setState({ isLoading: true }) @@ -91,13 +102,13 @@ class Faucet extends PureComponent<{}, FaucetState> { ) - private Action = () => ( + private GetEther = () => ( <> @@ -107,6 +118,22 @@ class Faucet extends PureComponent<{}, FaucetState> { ) + private GetTokens = () => ( + <> + +

+ You can request tokens every once in a while. +

+ + ) + public render() { const { isLogged } = this.context const { isLoading, error, success } = this.state @@ -129,9 +156,25 @@ class Faucet extends PureComponent<{}, FaucetState> { ) : success ? ( ) : ( - isLogged && + isLogged && )} + + { + showRequestTokens ? +
+ {isLoading ? ( + + ) : error ? ( + + ) : success ? ( + + ) : ( + isLogged && + )} +
: null + } + )}