Skip to content

Commit

Permalink
Make separate slot ranges for specified and not specified address
Browse files Browse the repository at this point in the history
  • Loading branch information
gostkin committed Dec 19, 2023
1 parent c5b9f69 commit 156a74d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
32 changes: 22 additions & 10 deletions webserver/server/app/controllers/ProjectedNftRangeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,32 @@ export class ProjectedNftRangeController extends Controller {
>
): Promise<EndpointTypes[typeof route]['response']> {
const slotRangeSize = requestBody.range.maxSlot - requestBody.range.minSlot;
if (slotRangeSize > PROJECTED_NFT_LIMIT.SLOT_RANGE) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return errorResponse(
StatusCodes.BAD_REQUEST,
genErrorMessage(Errors.SlotRangeLimitExceeded, {
limit: PROJECTED_NFT_LIMIT.SLOT_RANGE,
found: slotRangeSize,
})
);
}

if (requestBody.address !== undefined) {
if (slotRangeSize > PROJECTED_NFT_LIMIT.SINGLE_USER_SLOT_RANGE) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return errorResponse(
StatusCodes.BAD_REQUEST,
genErrorMessage(Errors.SlotRangeLimitExceeded, {
limit: PROJECTED_NFT_LIMIT.SINGLE_USER_SLOT_RANGE,
found: slotRangeSize,
})
);
}

return await this.handle_by_address_query(requestBody.address, requestBody);
} else {
if (slotRangeSize > PROJECTED_NFT_LIMIT.SLOT_RANGE) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return errorResponse(
StatusCodes.BAD_REQUEST,
genErrorMessage(Errors.SlotRangeLimitExceeded, {
limit: PROJECTED_NFT_LIMIT.SLOT_RANGE,
found: slotRangeSize,
})
);
}

return await this.handle_general_query(requestBody);
}
}
Expand Down
1 change: 1 addition & 0 deletions webserver/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export const POOL_DELEGATION_LIMIT = {

export const PROJECTED_NFT_LIMIT = {
SLOT_RANGE: 100000,
SINGLE_USER_SLOT_RANGE: 10000000000,
};

0 comments on commit 156a74d

Please sign in to comment.