add addr index to GiverAdded to filter on client side
This commit is contained in:
parent
a64517e0b3
commit
c46add12ed
|
@ -8,6 +8,7 @@ import Button from '@material-ui/core/Button';
|
||||||
import AddFunder from './components/AddFunder';
|
import AddFunder from './components/AddFunder';
|
||||||
import CreateFunding from './components/CreateFunding';
|
import CreateFunding from './components/CreateFunding';
|
||||||
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval, getLpAllowance } from './utils/initialize'
|
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval, getLpAllowance } from './utils/initialize'
|
||||||
|
import { getUserFundProfiles } from './utils/events';
|
||||||
|
|
||||||
const { getNetworkType } = web3.eth.net;
|
const { getNetworkType } = web3.eth.net;
|
||||||
|
|
||||||
|
@ -21,13 +22,15 @@ class App extends React.Component {
|
||||||
EmbarkJS.onReady(async (err) => {
|
EmbarkJS.onReady(async (err) => {
|
||||||
getNetworkType().then(async network => {
|
getNetworkType().then(async network => {
|
||||||
const { environment } = EmbarkJS
|
const { environment } = EmbarkJS
|
||||||
const needsInit = await vaultPledgingNeedsInit();
|
const needsInit = await vaultPledgingNeedsInit()
|
||||||
const lpAllowance = await getLpAllowance();
|
const lpAllowance = await getLpAllowance()
|
||||||
|
const fundProfiles = await getUserFundProfiles()
|
||||||
this.setState({
|
this.setState({
|
||||||
network,
|
network,
|
||||||
environment,
|
environment,
|
||||||
needsInit: needsInit === 0,
|
needsInit: needsInit === 0,
|
||||||
lpAllowance
|
lpAllowance,
|
||||||
|
fundProfiles
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -28,7 +28,7 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
|
||||||
uint constant MAX_INTERPROJECT_LEVEL = 20;
|
uint constant MAX_INTERPROJECT_LEVEL = 20;
|
||||||
|
|
||||||
// Events
|
// 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 GiverUpdated(uint64 indexed idGiver, string url);
|
||||||
event DelegateAdded(uint64 indexed idDelegate, string url);
|
event DelegateAdded(uint64 indexed idDelegate, string url);
|
||||||
event DelegateUpdated(uint64 indexed idDelegate, string url);
|
event DelegateUpdated(uint64 indexed idDelegate, string url);
|
||||||
|
@ -88,7 +88,7 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
|
||||||
url)
|
url)
|
||||||
);
|
);
|
||||||
|
|
||||||
GiverAdded(idGiver, url);
|
GiverAdded(idGiver, addr, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Updates a Giver's info to change the address, name, url, or
|
/// @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);
|
PledgeAdmin storage parent = _findAdmin(a.parentProject);
|
||||||
return _getProjectLevel(parent) + 1;
|
return _getProjectLevel(parent) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue