add addr index to GiverAdded to filter on client side

This commit is contained in:
Barry Gitarts 2018-12-01 18:32:56 -05:00
parent a64517e0b3
commit c46add12ed
3 changed files with 34 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import Button from '@material-ui/core/Button';
import AddFunder from './components/AddFunder';
import CreateFunding from './components/CreateFunding';
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval, getLpAllowance } from './utils/initialize'
import { getUserFundProfiles } from './utils/events';
const { getNetworkType } = web3.eth.net;
@ -21,13 +22,15 @@ class App extends React.Component {
EmbarkJS.onReady(async (err) => {
getNetworkType().then(async network => {
const { environment } = EmbarkJS
const needsInit = await vaultPledgingNeedsInit();
const lpAllowance = await getLpAllowance();
const needsInit = await vaultPledgingNeedsInit()
const lpAllowance = await getLpAllowance()
const fundProfiles = await getUserFundProfiles()
this.setState({
network,
environment,
needsInit: needsInit === 0,
lpAllowance
lpAllowance,
fundProfiles
})
});
});

25
app/utils/events.js Normal file
View File

@ -0,0 +1,25 @@
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock'
import web3 from 'Embark/web3'
const { getPledgeAdmin } = LiquidPledgingMock.methods
const formatFundProfileEvent = async event => {
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
}

View File

@ -28,7 +28,7 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
uint constant MAX_INTERPROJECT_LEVEL = 20;
// Events
event GiverAdded(uint64 indexed idGiver, string url);
event GiverAdded(uint64 indexed idGiver, address indexed addr, string url);
event GiverUpdated(uint64 indexed idGiver, string url);
event DelegateAdded(uint64 indexed idDelegate, string url);
event DelegateUpdated(uint64 indexed idDelegate, string url);
@ -88,7 +88,7 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
url)
);
GiverAdded(idGiver, url);
GiverAdded(idGiver, addr, url);
}
/// @notice Updates a Giver's info to change the address, name, url, or
@ -356,4 +356,4 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
PledgeAdmin storage parent = _findAdmin(a.parentProject);
return _getProjectLevel(parent) + 1;
}
}
}