Add SwapProxy to fund project

handle projects that are only a manifest
This commit is contained in:
Barry Gitarts 2019-10-18 14:37:50 -04:00 committed by Barry G
parent 97e62c862d
commit 394cad5e83
6 changed files with 19 additions and 4 deletions

View File

@ -173,6 +173,10 @@ module.exports = {
},
strategy: 'explicit',
contracts: {
DAI: {
instanceOf: "StandardToken",
address: "0xaD6D458402F60fD3Bd25163575031ACDce07538D"
},
LPVault: {},
LiquidPledging: {},
StandardToken: {},

View File

@ -20,6 +20,10 @@
"0xb573e81b6da869674bb2d8448581ed758b9dbf7e72b0879087d49620167778d4": {
"name": "SwapProxy",
"address": "0x46A30Bf6D0E438E7EeaabD6c4B5fEBf481267722"
},
"0xd9d749fb529af69819711faec78815efe4334ea74c7785ece18e3f276d845934": {
"name": "DAI",
"address": "0xaD6D458402F60fD3Bd25163575031ACDce07538D"
}
}
}

View File

@ -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 (
<Formik
initialValues={{

View File

@ -55,7 +55,7 @@ export const currencies = [
chainReadibleFn: toWei
},
{
value: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
value: DAI._address,
label: 'DAI',
img: `${TOKEN_API}/0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359.png`,
width: '2rem',

View File

@ -1,6 +1,7 @@
/*global web3, BigInt*/
import LiquidPledging from '../embarkArtifacts/contracts/LiquidPledging'
import { getTokenLabel, getTokenByAddress } from './currencies'
import { toEther } from './conversions'
const { getPledgeDelegate, numberOfPledges, getPledge } = LiquidPledging.methods
const { utils } = web3
@ -98,7 +99,9 @@ export function getAmountsPledged(pledges){
export function getAmountFromPledgesInfo(info){
if (!info) return 0
const { token, lifetimeReceived } = info
const { humanReadibleFn } = getTokenByAddress(token)
const res = getTokenByAddress(token)
if (!res) return toEther(lifetimeReceived)
const { humanReadibleFn } = res
return humanReadibleFn(lifetimeReceived)
}

View File

@ -25,8 +25,9 @@ export function getNumberOfBackers(pledges){
return length(uniqBy(p => 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) {