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