Open chrishol opened 3 years ago
Yeah I'm looking for that to
Probably you need to find them off-chain but that may be a bit daunting. hardhat test example:
async function getWinningIndices(address) {
const indices = [];
for (let i = 0; i < availableSupply; i++) {
const entryAddress = await raffleContract.raffleEntries(i);
if (entryAddress === address) {
indices.push(i);
}
}
return indices;
}
Thanks for sharing this @Anish-Agnihotri - really great ideas and helpful examples.
My question: The design of the
claimRaffle
function seems to require the caller to know where their entry lies in theraffleEntries
array. Is the idea that the results could be indexed once and then provided to customers via a frontend UI?Ideally you'd have some way of quickly finding the indices by address, but storing that might get expensive quickly.
https://github.com/Anish-Agnihotri/MultiRaffle/blob/a468d0029138ec0166e9e43697c4053c340d7e13/src/MultiRaffle.sol#L195