Skip to content

Commit 4286bec

Browse files
authored
Merge pull request #14 from gitcoinco/validate-eligibility-updates
feat: add signature validation on update round voters
2 parents 3da895c + 4b94a91 commit 4286bec

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/controllers/poolController.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ interface CreatePoolRequest extends PoolIdChainId {
3636
}
3737

3838
interface EligibilityCriteriaRequest extends PoolIdChainId {
39+
signature: Hex;
3940
eligibilityType: EligibilityType;
4041
data: object;
4142
}
4243

4344
interface SetCustomDistributionRequest extends PoolIdChainId {
4445
signature: Hex;
45-
sender: Hex;
4646
distribution: Distribution[];
4747
}
4848

@@ -222,14 +222,26 @@ export const calculateDistribution = async (req, res): Promise<void> => {
222222
};
223223

224224
export const updateEligibilityCriteria = async (req, res): Promise<void> => {
225-
const { eligibilityType, alloPoolId, chainId, data } =
225+
const { signature, eligibilityType, alloPoolId, chainId, data } =
226226
req.body as EligibilityCriteriaRequest;
227227

228228
// Log the receipt of the update request
229229
logger.info(
230230
`Received update eligibility criteria request for chainId: ${chainId}, alloPoolId: ${alloPoolId}`
231231
);
232232

233+
if (
234+
!(await isPoolManager(
235+
{ alloPoolId, chainId },
236+
signature,
237+
chainId,
238+
alloPoolId
239+
))
240+
) {
241+
res.status(401).json({ message: 'Not Authorzied' });
242+
throw new BadRequestError('Not Authorzied');
243+
}
244+
233245
const [error] = await catchError(
234246
eligibilityCriteriaService.saveEligibilityCriteria({
235247
chainId,

src/routes/poolRoutes.ts

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ router.post('/calculate', calculateDistribution);
163163
* schema:
164164
* type: object
165165
* properties:
166+
* signature:
167+
* type: string
168+
* description: Signature of the sender which should be a manager of the pool
169+
* example: "0xdeadbeef"
166170
* alloPoolId:
167171
* type: string
168172
* description: The ID of the pool

0 commit comments

Comments
 (0)