Skip to content

Commit

Permalink
fix calculator roundi d
Browse files Browse the repository at this point in the history
  • Loading branch information
boudra committed Mar 26, 2024
1 parent 8699219 commit 75146d0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/calculator/dataProvider/databaseDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import { parseAddress } from "../../address.js";
import { FileNotFoundError } from "../errors.js";
import { z } from "zod";

function parseRoundId(id: string): string {
if (id.startsWith("0x")) {
return parseAddress(id);
}

return id;
}

export class DatabaseDataProvider implements DataProvider {
#db: Database;

Expand Down Expand Up @@ -105,7 +113,7 @@ export class DatabaseDataProvider implements DataProvider {
segments[3] === "applications.json"
) {
const chainId = Number(segments[0]);
const roundId = segments[2];
const roundId = parseRoundId(segments[2]);

const applications = await this.#db.getAllRoundApplications(
chainId,
Expand All @@ -126,7 +134,7 @@ export class DatabaseDataProvider implements DataProvider {
segments[3] === "votes.json"
) {
const chainId = Number(segments[0]);
const roundId = segments[2];
const roundId = parseRoundId(segments[2]);

const donations = await this.#db.getAllRoundDonations(chainId, roundId);

Expand Down

0 comments on commit 75146d0

Please sign in to comment.