diff --git a/src/components/projects/FundProject.jsx b/src/components/projects/FundProject.jsx
index cb2f443..142bbcc 100644
--- a/src/components/projects/FundProject.jsx
+++ b/src/components/projects/FundProject.jsx
@@ -6,9 +6,6 @@ import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
import Button from '@material-ui/core/Button'
import Typography from '@material-ui/core/Typography'
import { withStyles } from '@material-ui/core/styles'
-import withObservables from '@nozbe/with-observables'
-import { Q } from '@nozbe/watermelondb'
-import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'
import { FundingContext } from '../../context'
import TextDisplay from '../base/TextDisplay'
import Icon from '../base/icons/IconByName'
@@ -173,19 +170,17 @@ const SubmissionSection = ({ classes, projectData, projectId, commitTime, profil
)
}
-function FundProject({ classes, match, history, projectAddedEvents }) {
+function FundProject({ classes, match, history }) {
const projectId = match.params.id
const { loading, error, data } = useQuery(getProfileById, {
variables: { id: formatProjectId(projectId) }
});
- const projectData = useProjectData(projectId, projectAddedEvents, data)
+ const projectData = useProjectData(projectId, data)
if (loading) return
if (error) return
{`Error! ${error.message}`}
if(!data.profile) return Project Not Found
- console.log({loading,error,data})
-
const commitTime = convertToHours(data.profile.commitTime)
return (
@@ -201,12 +196,4 @@ function FundProject({ classes, match, history, projectAddedEvents }) {
)
}
-const StyledProject = withStyles(styles)(FundProject)
-export default withDatabase(withObservables(['match'], ({ database }) => ({
- transfers: database.collections.get('lp_events').query(
- Q.where('event', 'Transfer')
- ).observe(),
- projectAddedEvents: database.collections.get('lp_events').query(
- Q.where('event', 'ProjectAdded')
- ).observe()
-}))(StyledProject))
+export default withStyles(styles)(FundProject)
diff --git a/src/components/projects/hooks.js b/src/components/projects/hooks.js
index 8ecd352..be4c899 100644
--- a/src/components/projects/hooks.js
+++ b/src/components/projects/hooks.js
@@ -1,4 +1,3 @@
-/*global web3*/
import { useState, useEffect, useMemo, useContext } from 'react'
import { unnest } from 'ramda'
import { timeSinceBlock } from '../../utils/dates'
@@ -9,22 +8,18 @@ import { FundingContext } from '../../context'
import { getDelegateProfiles } from '../../actions/profiles'
import { getDelegatePledgesByProfile } from '../../actions/delegates'
-async function getProjectAge(id, events, setState){
- const event = events.find(e => e.returnValues.idProject === id)
- if (event) {
- const { timestamp } = await web3.eth.getBlock(event.blockNumber)
- setState(timeSinceBlock(timestamp, 'days'))
+async function getProjectAge(data, setState){
+ if (data.profile) {
+ setState(timeSinceBlock(data.profile.creationTime, 'days'))
} else {
setState(timeSinceBlock(false, 'days'))
}
}
-async function getProjectCreator(id, events, setState){
- const event = events.find(e => e.returnValues.idProject === id)
- if (event) {
- const { address } = event
- setState(address)
- }
+async function getProjectCreator(data, setState){
+ if (!data.profile) return
+ const { addr } = data.profile
+ setState(addr)
}
async function getProjectAssets(data, setState, debug=false){
@@ -109,7 +104,7 @@ const getProjectManifest = assets => {
}
}
-export function useProjectData(projectId, projectAddedEvents, data) {
+export function useProjectData(projectId, data) {
const [projectAge, setAge] = useState(null)
const [creator, setCreator] = useState(null)
const [projectAssets, setAssets] = useState(null)
@@ -126,12 +121,12 @@ export function useProjectData(projectId, projectAddedEvents, data) {
}, [account])
useEffect(() => {
- getProjectAge(projectId, projectAddedEvents, setAge)
- }, [projectAddedEvents, projectId])
+ getProjectAge(data, setAge)
+ }, [data, projectId])
useEffect(() => {
- getProjectCreator(projectId, projectAddedEvents, setCreator)
- }, [projectAddedEvents, projectId])
+ getProjectCreator(data, setCreator)
+ }, [data, projectId])
useEffect(() => {
getProjectAssets(data, setAssets)
diff --git a/src/components/projects/queries.js b/src/components/projects/queries.js
index 4725315..4530f65 100644
--- a/src/components/projects/queries.js
+++ b/src/components/projects/queries.js
@@ -9,7 +9,8 @@ query Profile($id: ID!){
url,
profileId,
type,
- name
+ name,
+ creationTime,
pledgesInfos {
id
token