Merge pull request #25 from status-im/fix/projects-page

Fix projects page error
This commit is contained in:
Iuri Matias 2019-05-03 16:40:00 -04:00 committed by GitHub
commit 41a5826632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 6 deletions

View File

@ -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)

View File

@ -123,8 +123,8 @@ const SubmissionSection = ({ classes, profiles, delegatePledges, projectId, open
disabled={!profiles || profiles.length === 0}
value={values.delegateProfile || ''}
>
{profiles && profiles.map(profile => (
<MenuItem style={{display: 'flex', alignItems: 'center'}} key={profile.name} value={profile}>
{profiles && profiles.map((profile, index) => (
<MenuItem style={{display: 'flex', alignItems: 'center'}} key={`profile-${index}`} value={profile}>
{profile.name}
</MenuItem>
))}

View File

@ -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 => {

View File

@ -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) {

View File

@ -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

1
src/utils/address.js Normal file
View File

@ -0,0 +1 @@
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'