diff --git a/src/components/AddFunder.jsx b/src/components/AddFunder.jsx index c7d8fcd..8c9d611 100644 --- a/src/components/AddFunder.jsx +++ b/src/components/AddFunder.jsx @@ -7,6 +7,7 @@ import CloudUpload from '@material-ui/icons/CloudUpload' import { MySnackbarContentWrapper } from './base/SnackBars' import { captureFile } from '../utils/ipfs' import ImageViewer from './image/ImageViewer' +import {ZERO_ADDRESS} from '../utils/address' const { addGiver, addDelegate, addProject } = LiquidPledging.methods const FUNDER = 'FUNDER' @@ -60,7 +61,7 @@ const AddFunder = ({ appendFundProfile }) => ( const { adminType, funderName, funderDescription, commitTime } = values const account = await web3.eth.getCoinbase() //TODO add field for parent project - const args = adminType === PROJECT ? [funderName, funderDescription, account, 0, hoursToSeconds(commitTime), 0] : [funderName, funderDescription, hoursToSeconds(commitTime), 0] + const args = adminType === PROJECT ? [funderName, funderDescription, account, 0, hoursToSeconds(commitTime), 0] : [funderName, funderDescription, hoursToSeconds(commitTime), ZERO_ADDRESS] const isFunder = adminType === FUNDER const sendFn = sendFns[adminType] sendFn(...args) diff --git a/src/components/projects/BackProject.jsx b/src/components/projects/BackProject.jsx index 6fa3cd9..8418f53 100644 --- a/src/components/projects/BackProject.jsx +++ b/src/components/projects/BackProject.jsx @@ -123,8 +123,8 @@ const SubmissionSection = ({ classes, profiles, delegatePledges, projectId, open disabled={!profiles || profiles.length === 0} value={values.delegateProfile || ''} > - {profiles && profiles.map(profile => ( - + {profiles && profiles.map((profile, index) => ( + {profile.name} ))} diff --git a/src/components/projects/CreateProject.jsx b/src/components/projects/CreateProject.jsx index e1cdd3c..fa94559 100644 --- a/src/components/projects/CreateProject.jsx +++ b/src/components/projects/CreateProject.jsx @@ -12,11 +12,11 @@ import CloudUpload from '@material-ui/icons/CloudUpload' import { withStyles } from '@material-ui/core/styles' import { formatForIpfs, uploadToIpfs, formatMedia, isWeb } from '../../utils/ipfs' import { FundingContext } from '../../context' +import {ZERO_ADDRESS} from '../../utils/address' const { addProject } = LiquidPledging.methods -const zeroAddress = '0x0000000000000000000000000000000000000000' const hoursToSeconds = hours => hours * 60 * 60 const helperText = 'The length of time the Project has to veto when the project delegates to another delegate and they pledge those funds to a project' @@ -144,7 +144,7 @@ const SubmissionSection = ({ classes, history }) => { path: '/root/manifest.json', content: Buffer.from(manifest) }) const contentHash = await uploadToIpfs(fileLists) - const args = [title, contentHash, account, 0, hoursToSeconds(commitTime), zeroAddress] + const args = [title, contentHash, account, 0, hoursToSeconds(commitTime), ZERO_ADDRESS] addProject(...args) .estimateGas({ from: account }) .then(async gas => { diff --git a/src/components/projects/hooks.js b/src/components/projects/hooks.js index fede98f..7bdc407 100644 --- a/src/components/projects/hooks.js +++ b/src/components/projects/hooks.js @@ -62,6 +62,9 @@ async function fetchAndAddDelegateProfiles(account, setState) { async function fetchAndAddDelegatePledges(profiles, setState) { const dPledges = [] + if (!profiles || !profiles.length) { + return setState(dPledges) + } profiles.forEach(profile => { const delegatePledges = getDelegatePledgesByProfile(profile) dPledges.push(delegatePledges) @@ -82,7 +85,18 @@ export function useProfileData(profiles) { } const getProjectManifest = assets => { - return assets ? JSON.parse(assets.find(a => a.name.toLowerCase() === 'manifest.json').content) : null + if (!assets) { + return null; + } + const manifest = assets.find(a => a.name.toLowerCase() === 'manifest.json'); + if (!manifest) { + return null; + } + try { + return JSON.parse(manifest.content) + } catch (e) { + return null; + } } export function useProjectData(projectId, profile, projectAddedEvents) { diff --git a/src/dapp.js b/src/dapp.js index a0fbf8a..b1d5989 100644 --- a/src/dapp.js +++ b/src/dapp.js @@ -75,6 +75,11 @@ class App extends React.Component { this.setState({ snackbar: null }) } + appendPledges = () => { + // TODO check if this is correct + getAndAddPledges() + } + render() { const { account, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar } = this.state const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar } = this diff --git a/src/utils/address.js b/src/utils/address.js new file mode 100644 index 0000000..e1118ce --- /dev/null +++ b/src/utils/address.js @@ -0,0 +1 @@ +export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'