Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed Jun 20, 2024
1 parent 853c91b commit e9d57a2
Showing 1 changed file with 6 additions and 106 deletions.
112 changes: 6 additions & 106 deletions src/indexer/allo/v2/handleEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ import {
ProjectTable,
} from "../../../database/schema.js";
import type { Indexer } from "../../indexer.js";
import {
DGApplicationData,
DGTimeStampUpdatedData,
DVMDApplicationData,
DVMDTimeStampUpdatedData,
MACIApplicationData,
} from "../../types.js";
import { MACIApplicationData } from "../../types.js";
import { fetchPoolMetadata } from "./poolMetadata.js";
import roleGranted from "./roleGranted.js";
import roleRevoked from "./roleRevoked.js";
Expand All @@ -37,14 +31,12 @@ import {
ProjectMetadata,
ProjectMetadataSchema,
} from "../../projectMetadata.js";
import StatusesBitmap from "statuses-bitmap";
import { updateApplicationStatus } from "../application.js";
import { convertFromUSD, convertToUSD } from "../../../prices/provider.js";
import { RoundMetadataSchema } from "../roundMetadata.js";
import { getTokenForChain } from "../../../config.js";
import { ethers } from "ethers";
import { UnknownTokenError } from "../../../prices/common.js";
import { ApplicationMetadataSchema } from "../../applicationMetadata.js";
import { randomUUID } from "crypto";

const ALLO_NATIVE_TOKEN = parseAddress(
Expand Down Expand Up @@ -79,76 +71,6 @@ function getProjectTypeFromMetadata(metadata: ProjectMetadata) {
return "canonical";
}

// Decode the application data from DonationVotingMerkleDistribution
function decodeDVMDApplicationData(encodedData: Hex): DVMDApplicationData {
const values = decodeAbiParameters(
[
{ name: "data", type: "bytes" },
{ name: "recipientsCounter", type: "uint256" },
],
encodedData
);

const decodedData = decodeAbiParameters(
[
{ name: "registryAnchor", type: "address" },
{ name: "recipientAddress", type: "address" },
{
name: "metadata",
type: "tuple",
components: [
{ name: "protocol", type: "uint256" },
{ name: "pointer", type: "string" },
],
},
],
values[0]
);

const results: DVMDApplicationData = {
recipientsCounter: values[1].toString(),
anchorAddress: decodedData[0],
recipientAddress: decodedData[1],
metadata: {
protocol: Number(decodedData[2].protocol),
pointer: decodedData[2].pointer,
},
};

return results;
}

function decodeDGApplicationData(encodedData: Hex) {
const decodedData = decodeAbiParameters(
[
{ name: "recipientId", type: "address" },
{ name: "registryAnchor", type: "address" },
{ name: "grantAmount", type: "uint256" },
{
name: "metadata",
type: "tuple",
components: [
{ name: "protocol", type: "uint256" },
{ name: "pointer", type: "string" },
],
},
],
encodedData
);

const results: DGApplicationData = {
recipientAddress: decodedData[0],
anchorAddress: decodedData[1],
grantAmount: decodedData[2],
metadata: {
protocol: Number(decodedData[3].protocol),
pointer: decodedData[3].pointer,
},
};

return results;
}

// Decode the application data from MACIQF
function decodeMACIApplicationData(encodedData: Hex): MACIApplicationData {
const decodedData = decodeAbiParameters(
Expand Down Expand Up @@ -193,15 +115,6 @@ type ParamsWithoutRowIndex = {

type EventParams = ParamsWithRowIndex | ParamsWithoutRowIndex;

const isParamsWithRowIndexAndFullRow = (
params: EventParams
): params is ParamsWithRowIndex => {
return (
(params as ParamsWithRowIndex).rowIndex !== undefined &&
(params as ParamsWithRowIndex).fullRow !== undefined
);
};

const isParamsWithRecipientIdAndStatus = (
params: EventParams
): params is ParamsWithoutRowIndex => {
Expand All @@ -220,14 +133,7 @@ export async function handleEvent(
subscribeToContract,
readContract,
getBlock,
context: {
db,
rpcClient,
ipfsGet,
logger,
priceProvider,
blockTimestampInMs,
},
context: { db, rpcClient, ipfsGet, logger, priceProvider },
} = args;

switch (event.name) {
Expand Down Expand Up @@ -436,10 +342,6 @@ export async function handleEvent(
).amount;
}
} else {
logger.warn({
msg: `Unsupported strategy ${strategy?.name}`,
event,
});
throw new Error("Unsupported strategy");
}
const fundedAmount = event.params.amount;
Expand Down Expand Up @@ -874,12 +776,10 @@ export async function handleEvent(
throw new Error("Round not found");
}

let applicationsStartTime: Date | null = null;
let applicationsEndTime: Date | null = null;
let donationsStartTime: Date | null = null;
let donationsEndTime: Date | null = null;
let params;

const applicationsStartTime: Date | null = null;
const applicationsEndTime: Date | null = null;
const donationsStartTime: Date | null = null;
const donationsEndTime: Date | null = null;

return [
{
Expand Down

0 comments on commit e9d57a2

Please sign in to comment.