connect if not connected on project create

This commit is contained in:
Barry Gitarts 2019-09-17 11:52:19 -04:00
parent 15372a3af8
commit 551f3108bc
3 changed files with 10 additions and 5 deletions

View File

@ -160,7 +160,7 @@ module.exports = {
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",

View File

@ -1,3 +1,4 @@
/*eslint complexity: ["error", 25]*/
import React, { createRef, useState, useContext } from 'react'
import { Formik } from 'formik'
import classnames from 'classnames'
@ -198,7 +199,7 @@ const addProjectSucessMsg = response => {
}
const SubmissionSection = ({ classes, history }) => {
const [uploads, setUploads] = useState({})
const { account, openSnackBar, prices } = useContext(FundingContext)
const { account, enableEthereum, openSnackBar, prices } = useContext(FundingContext)
const windowSize = useWindowSize()
const isSmall = windowSize.innerWidth < 800
return (
@ -219,15 +220,18 @@ const SubmissionSection = ({ classes, history }) => {
validationSchema={validationSchema}
onSubmit={async (values, { resetForm }) => {
const { title, commitTime } = values
let user = account;
if (!user) user = await enableEthereum()
const manifest = createJSON(values)
const contentHash = await uploadFilesToIpfs(uploads, manifest)
uploadFilesToIpfs(uploads, manifest, true)
const args = [title, contentHash, account, 0, hoursToSeconds(commitTime), ZERO_ADDRESS]
const args = [title, contentHash, user, 0, hoursToSeconds(commitTime), ZERO_ADDRESS]
console.log({args})
addProject(...args)
.estimateGas({ from: account })
.estimateGas({ from: user })
.then(async gas => {
addProject(...args)
.send({ from: account, gas: gas + 100 })
.send({ from: user, gas: gas + 100 })
.then(async res => {
pinToGateway(contentHash)
console.log({res})

View File

@ -80,6 +80,7 @@ const optimisticUpdate = (client, pledgesInfo, weiAmount) => {
}
})
}
const SubmissionSection = ({ classes, projectData, projectId, profileData, startPolling, client }) => {
const { account, enableEthereum, openSnackBar, prices } = useContext(FundingContext)
const [submissionState, setSubmissionState] = useState(NOT_SUBMITTED)