fix encoding of withdraw tx
This commit is contained in:
parent
762e74db03
commit
5718523669
|
@ -141,7 +141,7 @@ const Title = ({ className, manifest }) => (
|
||||||
<Divider />
|
<Divider />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
const SubmissionSection = ({ classes, delegatePledges, projectId, openSnackBar, pledges }) => {
|
const SubmissionSection = ({ classes, projectId, openSnackBar, pledges }) => {
|
||||||
return (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
onSubmit={async(values, { resetForm }) => {
|
onSubmit={async(values, { resetForm }) => {
|
||||||
|
@ -152,10 +152,12 @@ const SubmissionSection = ({ classes, delegatePledges, projectId, openSnackBar,
|
||||||
.map(pledge => ({ amount: pledge.amount, id: pledge.idPledge }))
|
.map(pledge => ({ amount: pledge.amount, id: pledge.idPledge }))
|
||||||
const encodedPledges = encodePledges(filteredPledges)
|
const encodedPledges = encodePledges(filteredPledges)
|
||||||
console.log({openSnackBar, resetForm, values, projectId, filteredPledges, encodePledges, pledges, mWithdraw})
|
console.log({openSnackBar, resetForm, values, projectId, filteredPledges, encodePledges, pledges, mWithdraw})
|
||||||
const toSend = filteredPledges.length > 1 ? mWithdraw(encodedPledges) : withdraw(filteredPledges[0].id, filteredPledges[0].amount)
|
const args = filteredPledges.length > 1 ? [encodedPledges] : [filteredPledges[0].id, filteredPledges[0].amount]
|
||||||
|
const sendFn = filteredPledges.length > 1 ? mWithdraw : withdraw
|
||||||
|
const toSend = sendFn(...args)
|
||||||
const estimatedGas = await toSend.estimateGas()
|
const estimatedGas = await toSend.estimateGas()
|
||||||
console.log({estimatedGas})
|
console.log({estimatedGas})
|
||||||
toSend().send({gas: estimatedGas})
|
toSend.send({gas: estimatedGas})
|
||||||
.then(async res => {
|
.then(async res => {
|
||||||
console.log({res})
|
console.log({res})
|
||||||
})
|
})
|
||||||
|
@ -176,17 +178,11 @@ const SubmissionSection = ({ classes, delegatePledges, projectId, openSnackBar,
|
||||||
errors: _errors,
|
errors: _errors,
|
||||||
touched: _touched,
|
touched: _touched,
|
||||||
handleChange,
|
handleChange,
|
||||||
//handleBlur,
|
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
setFieldValue: _setFieldValue,
|
setFieldValue: _setFieldValue,
|
||||||
setStatus: _setStatus,
|
setStatus: _setStatus,
|
||||||
status: _status
|
status: _status
|
||||||
}) => {
|
}) => {
|
||||||
const filterPledges = delegateProfile => delegatePledges.filter(
|
|
||||||
d => d.profile.id === delegateProfile.id && d.pledgeData.amount !== '0' && d.pledgeData.pledgeState === 0 && d.pledgeData.intendedProject === 0
|
|
||||||
)
|
|
||||||
const filteredPledges = values.delegateProfile ? filterPledges(values.delegateProfile) : null
|
|
||||||
console.log({filteredPledges})
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className={classes.submissionRoot}>
|
<form onSubmit={handleSubmit} className={classes.submissionRoot}>
|
||||||
{pledges.map(pledge => <PledgeInfo key={pledge.id} pledge={pledge} values={values} handleChange={handleChange} />)}
|
{pledges.map(pledge => <PledgeInfo key={pledge.id} pledge={pledge} values={values} handleChange={handleChange} />)}
|
||||||
|
|
Loading…
Reference in New Issue