parent
bd7d318ec2
commit
26f7c2bda6
|
@ -160,14 +160,14 @@ const Title = ({ className, manifest }) => (
|
||||||
)
|
)
|
||||||
|
|
||||||
const getSendFn = (pledgeType, filteredPledges) => {
|
const getSendFn = (pledgeType, filteredPledges) => {
|
||||||
if (pledgeType === PLEDGED) {
|
if (pledgeTypes[pledgeType] === PLEDGED) {
|
||||||
return filteredPledges.length > 1 ? mWithdraw : withdraw
|
return filteredPledges.length > 1 ? mWithdraw : withdraw
|
||||||
}
|
}
|
||||||
return confirmPayment
|
return confirmPayment
|
||||||
|
|
||||||
}
|
}
|
||||||
const getArgs = (pledgeType, filteredPledges) => {
|
const getArgs = (pledgeType, filteredPledges) => {
|
||||||
if (pledgeType === PLEDGED) {
|
if (pledgeTypes[pledgeType] === PLEDGED) {
|
||||||
const formattedPledges = filteredPledges.map(pledge => ({ amount: pledge.amount, id: pledge.idPledge }))
|
const formattedPledges = filteredPledges.map(pledge => ({ amount: pledge.amount, id: pledge.idPledge }))
|
||||||
const encodedPledges = encodePledges(formattedPledges)
|
const encodedPledges = encodePledges(formattedPledges)
|
||||||
const withdrawArgs = [filteredPledges[0].id, filteredPledges[0].amount]
|
const withdrawArgs = [filteredPledges[0].id, filteredPledges[0].amount]
|
||||||
|
@ -176,10 +176,10 @@ const getArgs = (pledgeType, filteredPledges) => {
|
||||||
const { idPayment } = filteredPledges[0].authorization.returnValues
|
const { idPayment } = filteredPledges[0].authorization.returnValues
|
||||||
return [idPayment]
|
return [idPayment]
|
||||||
}
|
}
|
||||||
const SubmissionSection = ({ classes, openSnackBar, pledges, pledgeType }) => {
|
const SubmissionSection = ({ classes, openSnackBar, syncWithRemote, pledges, pledgeType }) => {
|
||||||
return (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
onSubmit={async(values, { resetForm }) => {
|
onSubmit={async(values) => {
|
||||||
const { pledge } = values
|
const { pledge } = values
|
||||||
const filteredPledges = Object.keys(pledge)
|
const filteredPledges = Object.keys(pledge)
|
||||||
.filter(p => !!pledge[p])
|
.filter(p => !!pledge[p])
|
||||||
|
@ -199,7 +199,7 @@ const SubmissionSection = ({ classes, openSnackBar, pledges, pledgeType }) => {
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
openSnackBar('success', 'Withdraws initiated')
|
openSnackBar('success', 'Withdraws initiated')
|
||||||
resetForm()
|
syncWithRemote()
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -259,7 +259,7 @@ function CenteredTabs({ pledged, paying, paid, pledgeType, setPledgeType }) {
|
||||||
function ProjectPledges({classes, match, projectAddedEvents, pledges, authorizedPayments}) {
|
function ProjectPledges({classes, match, projectAddedEvents, pledges, authorizedPayments}) {
|
||||||
const [pledgeType, setPledgeType] = useState(0)
|
const [pledgeType, setPledgeType] = useState(0)
|
||||||
const projectId = match.params.id
|
const projectId = match.params.id
|
||||||
const { manifest, delegateProfiles, openSnackBar } = useProjectData(projectId, projectAddedEvents)
|
const { manifest, delegateProfiles, openSnackBar, syncWithRemote } = useProjectData(projectId, projectAddedEvents)
|
||||||
const delegatePledges = useProfileData(delegateProfiles)
|
const delegatePledges = useProfileData(delegateProfiles)
|
||||||
const enrichedPledges = usePledgesAuthorizations(pledges, authorizedPayments).filter(p => Number(p.amount) > 0)
|
const enrichedPledges = usePledgesAuthorizations(pledges, authorizedPayments).filter(p => Number(p.amount) > 0)
|
||||||
const pledged = enrichedPledges.filter(p => p.pledgeState === 0)
|
const pledged = enrichedPledges.filter(p => p.pledgeState === 0)
|
||||||
|
@ -286,6 +286,7 @@ function ProjectPledges({classes, match, projectAddedEvents, pledges, authorized
|
||||||
delegatePledges={delegatePledges}
|
delegatePledges={delegatePledges}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
openSnackBar={openSnackBar}
|
openSnackBar={openSnackBar}
|
||||||
|
syncWithRemote={syncWithRemote}
|
||||||
pledges={selectedPledges[pledgeType]}
|
pledges={selectedPledges[pledgeType]}
|
||||||
pledgeType={pledgeType}
|
pledgeType={pledgeType}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -105,7 +105,7 @@ export function useProjectData(projectId, projectAddedEvents) {
|
||||||
const [projectAssets, setAssets] = useState(null)
|
const [projectAssets, setAssets] = useState(null)
|
||||||
const [ipfsReady, setIpfsState] = useState(null)
|
const [ipfsReady, setIpfsState] = useState(null)
|
||||||
const [delegateProfiles, setDelegateProfiles] = useState(null)
|
const [delegateProfiles, setDelegateProfiles] = useState(null)
|
||||||
const { account, openSnackBar } = useContext(FundingContext)
|
const { account, openSnackBar, syncWithRemote } = useContext(FundingContext)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ipfs.on('ready', () => { setIpfsState(true) })
|
ipfs.on('ready', () => { setIpfsState(true) })
|
||||||
|
@ -130,7 +130,8 @@ export function useProjectData(projectId, projectAddedEvents) {
|
||||||
projectAssets,
|
projectAssets,
|
||||||
manifest,
|
manifest,
|
||||||
delegateProfiles,
|
delegateProfiles,
|
||||||
openSnackBar
|
openSnackBar,
|
||||||
|
syncWithRemote
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
src/dapp.js
19
src/dapp.js
|
@ -54,7 +54,8 @@ class App extends React.Component {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async syncWithRemote() {
|
syncWithRemote = async () => {
|
||||||
|
this.setState({ loading: true })
|
||||||
// not running in parallel due to possible metamask / infura limitation
|
// not running in parallel due to possible metamask / infura limitation
|
||||||
await getAndAddLpEvents()
|
await getAndAddLpEvents()
|
||||||
await getAndAddVaultEvents()
|
await getAndAddVaultEvents()
|
||||||
|
@ -82,8 +83,20 @@ class App extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar } = this.state
|
const { account, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar } = this.state
|
||||||
const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar } = this
|
const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar, syncWithRemote } = this
|
||||||
const fundingContext = { appendPledges, appendFundProfile, account, transferPledgeAmounts, authorizedPayments, needsInit, initVaultAndLP, standardTokenApproval, openSnackBar, closeSnackBar }
|
const fundingContext = {
|
||||||
|
appendPledges,
|
||||||
|
appendFundProfile,
|
||||||
|
account,
|
||||||
|
transferPledgeAmounts,
|
||||||
|
authorizedPayments,
|
||||||
|
needsInit,
|
||||||
|
initVaultAndLP,
|
||||||
|
standardTokenApproval,
|
||||||
|
openSnackBar,
|
||||||
|
closeSnackBar,
|
||||||
|
syncWithRemote
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<FundingContext.Provider value={fundingContext}>
|
<FundingContext.Provider value={fundingContext}>
|
||||||
<Router>
|
<Router>
|
||||||
|
|
Loading…
Reference in New Issue