2018-12-01 23:32:56 +00:00
|
|
|
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock'
|
|
|
|
import web3 from 'Embark/web3'
|
|
|
|
|
|
|
|
const { getPledgeAdmin } = LiquidPledgingMock.methods
|
2018-12-02 14:46:20 +00:00
|
|
|
export const formatFundProfileEvent = async event => {
|
2018-12-01 23:32:56 +00:00
|
|
|
const { returnValues: { idGiver, url } } = event
|
|
|
|
const { commitTime, name, canceled } = await getPledgeAdmin(idGiver).call()
|
|
|
|
return {
|
|
|
|
idGiver,
|
|
|
|
url,
|
|
|
|
commitTime,
|
|
|
|
name,
|
|
|
|
canceled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getUserFundProfiles = async () => {
|
|
|
|
const events = await LiquidPledgingMock.getPastEvents('GiverAdded', {
|
|
|
|
addr: await web3.eth.getCoinbase(),
|
|
|
|
fromBlock: 0,
|
|
|
|
toBlock: 'latest'
|
|
|
|
})
|
|
|
|
const formattedEvents = await Promise.all(events.map(formatFundProfileEvent))
|
|
|
|
return formattedEvents
|
|
|
|
}
|