import React from 'react'; import { Formik } from 'formik'; import EmbarkJS from 'Embark/EmbarkJS'; import LPVault from 'Embark/contracts/LPVault'; import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock'; import Button from '@material-ui/core/Button'; import TextField from '@material-ui/core/TextField'; import Snackbar from '@material-ui/core/Snackbar'; import MenuItem from '@material-ui/core/MenuItem'; import web3 from 'Embark/web3'; import { MySnackbarContentWrapper } from './base/SnackBars'; import { currencies, TOKEN_ICON_API, getTokenLabel } from '../utils/currencies' const { donate } = LiquidPledgingMock.methods const hoursToSeconds = hours => hours * 60 * 60 const addFunderSucessMsg = response => { const { events: { GiverAdded: { returnValues: { idGiver } } } } = response return `Funder created with ID of ${idGiver}` } const CreateFunding = ({ refreshTable }) => ( { const { funderId, receiverId, tokenAddress, amount } = values const account = await web3.eth.getCoinbase() const args = [funderId, receiverId, tokenAddress, web3.utils.toWei(amount, 'ether')] donate(...args) .send({ from: account }) .then(res => { console.log({res}) setStatus({ snackbar: { variant: 'success', message: 'funding provided!' } }) refreshTable() }) .catch(e => { console.log({e}) setStatus({ snackbar: { variant: 'error', message: 'There was an error' } }) }) }} > {({ values, errors, touched, handleChange, handleBlur, handleSubmit, setFieldValue, setStatus, status }) => (
{currencies.map(option => ( {option.icon || } {option.label} ))} {status && setStatus(null)} > setStatus(null)} variant={status.snackbar.variant} message={status.snackbar.message} /> } )}
) export default CreateFunding