set allowance to use proper token

This commit is contained in:
Barry Gitarts 2019-12-12 14:45:02 -05:00 committed by Barry G
parent d63cf60770
commit 37c3b73e94
1 changed files with 5 additions and 2 deletions

View File

@ -137,10 +137,11 @@ const SubmissionSection = ({ classes, projectData, projectId, profileData, start
if (!activeStep) return enableEthereum()
const { amount, fundToken } = values
const { goalToken } = manifest
const { chainReadibleFn, setAllowance } = getTokenByAddress(goalToken, currencies)
const { chainReadibleFn } = getTokenByAddress(goalToken, currencies)
const userAccount = account ? account : await enableEthereum()
const weiAmount = chainReadibleFn(amount)
if (activeStep === NOT_APPROVED) {
const { setAllowance } = getTokenByAddress(fundToken, currencies)
const toSend = goalToken === fundToken ? setAllowance(weiAmount, LiquidPledging) : setAllowance(weiAmount)
setSubmissionState(AUTHORIZATION_SUBMITTED)
return toSend
@ -152,7 +153,9 @@ const SubmissionSection = ({ classes, projectData, projectId, profileData, start
.catch(e => console.log({e})).finally(() => resetForm())
}
const send = generateSend(projectId, goalToken, fundToken, weiAmount, userAccount)
const args = [projectId, goalToken, fundToken, weiAmount, userAccount]
console.log({args})
const send = generateSend(...args)
send
.on('transactionHash', (hash) => {
optimisticUpdate(client, pledgesInfo, weiAmount)