feat: remove roud number check in routes part as well to change repo to time-based repo

This commit is contained in:
2025-05-01 11:39:25 -03:00
parent c22f1d9d49
commit dfa38ae5ff

View File

@ -58,7 +58,7 @@ export async function routes() {
app.post("/add-todo-pr", async (req, res) => { app.post("/add-todo-pr", async (req, res) => {
const signature = req.body.signature; const signature = req.body.signature;
const prUrl = req.body.prUrl; const prUrl = req.body.prUrl;
const roundNumber = Number(req.body.roundNumber); const roundNumber = await namespaceWrapper.getRound();
const success = req.body.success; const success = req.body.success;
const message = req.body.message; const message = req.body.message;
console.log("[TASK] req.body", req.body); console.log("[TASK] req.body", req.body);
@ -68,17 +68,17 @@ export async function routes() {
console.error("[TASK] Error summarizing repository:", message); console.error("[TASK] Error summarizing repository:", message);
return; return;
} }
const uuid = await namespaceWrapper.storeGet(`uuid-${roundNumber}`); // const uuid = await namespaceWrapper.storeGet(`uuid-${roundNumber}`);
console.log("[TASK] uuid: ", uuid); // console.log("[TASK] uuid: ", uuid);
if (!uuid) { // if (!uuid) {
throw new Error("No uuid found"); // throw new Error("No uuid found");
} // }
const currentRound = await namespaceWrapper.getRound(); // const currentRound = await namespaceWrapper.getRound();
if (roundNumber !== currentRound) { // if (roundNumber !== currentRound) {
throw new Error(`Invalid round number: ${roundNumber}. Current round: ${currentRound}.`); // throw new Error(`Invalid round number: ${roundNumber}. Current round: ${currentRound}.`);
} // }
const publicKey = await namespaceWrapper.getMainAccountPubkey(); const publicKey = await namespaceWrapper.getMainAccountPubkey();
const stakingKeypair = await namespaceWrapper.getSubmitterAccount(); const stakingKeypair = await namespaceWrapper.getSubmitterAccount();
@ -105,14 +105,14 @@ export async function routes() {
if (jsonData.taskId !== TASK_ID) { if (jsonData.taskId !== TASK_ID) {
throw new Error(`Invalid task ID from signature: ${jsonData.taskId}. Actual task ID: ${TASK_ID}`); throw new Error(`Invalid task ID from signature: ${jsonData.taskId}. Actual task ID: ${TASK_ID}`);
} }
if (jsonData.roundNumber !== currentRound) { // if (jsonData.roundNumber !== currentRound) {
throw new Error( // throw new Error(
`Invalid round number from signature: ${jsonData.roundNumber}. Current round: ${currentRound}.`, // `Invalid round number from signature: ${jsonData.roundNumber}. Current round: ${currentRound}.`,
); // );
} // }
if (jsonData.uuid !== uuid) { // if (jsonData.uuid !== uuid) {
throw new Error(`Invalid uuid from signature: ${jsonData.uuid}. Actual uuid: ${uuid}`); // throw new Error(`Invalid uuid from signature: ${jsonData.uuid}. Actual uuid: ${uuid}`);
} // }
const middleServerPayload = { const middleServerPayload = {
taskId: jsonData.taskId, taskId: jsonData.taskId,
roundNumber, roundNumber,