Skip to content

Commit

Permalink
faucet
Browse files Browse the repository at this point in the history
  • Loading branch information
adibas03 committed Nov 5, 2019
1 parent 0b5187e commit a5a9fa6
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/components/pages/faucet/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import React from 'react'
import { ChasingDots } from 'styled-spinkit'
import walletIcon from '../../../images/icons/wallet.svg'
import { RouteComponentProps, withRouter } from 'react-router-dom'
import { store } from '../../../store'
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 { networksExplorer } from '../../../utils/getWeb3'
import { connectToWallet, prepBigNumber } from '../../../utils/web3Utils'
import { getDeployedFromConfig } from '../../../utils/getDeployed'
import { request } from '../../../utils/tokenFaucet'
Expand Down Expand Up @@ -37,6 +39,31 @@ class Faucet extends React.Component<FaucetProps, FaucetState> {
loaded: false,
}

get txEvents() {
const { networkId, toastProvider } = store.getState()
return {
onTransactionHash: hash =>
toastProvider.addMessage('Processing request...', {
secondaryMessage: 'Check progress on Etherscan',
actionHref: `${networksExplorer[networkId]}/tx/${hash}`,
actionText: 'Check',
variant: 'processing',
}),
onReceipt: receipt =>
toastProvider.addMessage('Request successful...', {
secondaryMessage: 'View transaction Etherscan',
actionHref: `${networksExplorer[networkId]}/tx/${receipt.transactionHash}`,
actionText: 'View',
variant: 'success',
}),
onError: error =>
toastProvider.addMessage('Request failed...', {
secondaryMessage: `${error.message || error}`,
variant: 'failure',
}),
}
}

onRequest = async () => {
// const {history} = this.props;
const {
Expand All @@ -52,7 +79,9 @@ class Faucet extends React.Component<FaucetProps, FaucetState> {
try {
this.setState({ transacting: true })

const tx = await request(faucetInstance, address)
const tx = await request(faucetInstance, address, {
txEvents: this.txEvents,
})
console.log(tx)

this.setState({ transacting: false })
Expand Down

0 comments on commit a5a9fa6

Please sign in to comment.