From 394cad5e83bcf1d2bb4beffd1f65d58f0e5f5261 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 18 Oct 2019 14:37:50 -0400 Subject: [PATCH] Add SwapProxy to fund project handle projects that are only a manifest --- embarkConfig/contracts.js | 4 ++++ ropsten.chains.json | 4 ++++ src/components/projects/FundProject.jsx | 3 +++ src/utils/currencies.js | 2 +- src/utils/pledges.js | 5 ++++- src/utils/project.js | 5 +++-- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/embarkConfig/contracts.js b/embarkConfig/contracts.js index d73ef6e..3d3fe01 100644 --- a/embarkConfig/contracts.js +++ b/embarkConfig/contracts.js @@ -173,6 +173,10 @@ module.exports = { }, strategy: 'explicit', contracts: { + DAI: { + instanceOf: "StandardToken", + address: "0xaD6D458402F60fD3Bd25163575031ACDce07538D" + }, LPVault: {}, LiquidPledging: {}, StandardToken: {}, diff --git a/ropsten.chains.json b/ropsten.chains.json index de0b853..41fb56b 100644 --- a/ropsten.chains.json +++ b/ropsten.chains.json @@ -20,6 +20,10 @@ "0xb573e81b6da869674bb2d8448581ed758b9dbf7e72b0879087d49620167778d4": { "name": "SwapProxy", "address": "0x46A30Bf6D0E438E7EeaabD6c4B5fEBf481267722" + }, + "0xd9d749fb529af69819711faec78815efe4334ea74c7785ece18e3f276d845934": { + "name": "DAI", + "address": "0xaD6D458402F60fD3Bd25163575031ACDce07538D" } } } diff --git a/src/components/projects/FundProject.jsx b/src/components/projects/FundProject.jsx index c1155d4..1ac8875 100644 --- a/src/components/projects/FundProject.jsx +++ b/src/components/projects/FundProject.jsx @@ -4,6 +4,7 @@ import { makeStyles } from '@material-ui/core/styles' import classnames from 'classnames' import { useQuery } from '@apollo/react-hooks' import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging' +import SwapProxy from '../../embarkArtifacts/contracts/SwapProxy' import Typography from '@material-ui/core/Typography' import { FundingContext } from '../../context' import TextDisplay from '../base/TextDisplay' @@ -89,6 +90,7 @@ const SubmissionSection = ({ classes, projectData, projectId, profileData, start const { projectAge, projectAssets, manifest } = projectData const { pledgesInfos, projectInfo } = profileData const pledgesInfo = pledgesInfos[0] + console.log({projectInfo}) const tokenLabel = getTokenLabel(projectInfo.goalToken) const totalPledged = getAmountFromPledgesInfo(pledgesInfo) const isVideo = useMemo(() => getMediaType(projectAssets), [projectAssets, projectId]) @@ -96,6 +98,7 @@ const SubmissionSection = ({ classes, projectData, projectId, profileData, start const createdDate = getDateCreated(projectAge) const percentToGoal = manifest ? formatPercent(Number(totalPledged) / Number(manifest.goal)) : formatPercent(0) const isCreator = projectData.creator === account + console.log({SwapProxy}) return ( p.owner, pledges)) } +const hasManifest = assets => !!assets.find(isManifest) export const getMediaType = assets => { - if (!assets) return false + if (!assets || !hasManifest(assets)) return false const { media } = getProjectManifest(assets) if (media.type.toLowerCase().includes('video')) return true } @@ -37,7 +38,7 @@ export function setMediaType(url) { } export const getMediaSrc = assets => { - if (!assets) return null + if (!assets || !hasManifest(assets)) return null const { media } = getProjectManifest(assets) const validMedia = media.type.includes('video') || media.type.includes('image') if (validMedia) {