Skip to content

Commit

Permalink
import ABIs statically
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast committed Jul 20, 2023
1 parent 4cdb86b commit c0337ef
Show file tree
Hide file tree
Showing 11 changed files with 1,954 additions and 80 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"main": "dist/src/indexer/index.js",
"types": "dist/src/indexer/index.d.ts",
"scripts": {
"start": "node dist/src/index.js --chains=mainnet,optimism,goerli,fantom,pgn-testnet,pgn-mainnet",
"start": "node dist/src/index.js --chains=optimism,pgn-testnet",
"dev": "nodemon --delay 2 --watch dist --exec 'npm run start'",
"build": "tsc",
"build:watch": "tsc --watch",
"lint": "eslint src",
"format": "prettier --write src",
"test": "vitest run --reporter verbose",
"test:watch": "vitest watch --reporter verbose",
"deploy:staging": "docker buildx build . -t registry.fly.io/indexer-staging:latest && docker push registry.fly.io/indexer-staging:latest && flyctl -c fly.staging.toml --app indexer-staging deploy -i registry.fly.io/indexer-staging:latest"
"deploy:staging": "docker buildx build . -t registry.fly.io/indexer-staging:latest && docker push registry.fly.io/indexer-staging:latest && flyctl -c fly.staging.toml --app indexer-staging deploy -i registry.fly.io/indexer-staging:latest"
},
"imports": {
"#abis/*": {
Expand Down
44 changes: 23 additions & 21 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "dotenv/config";
import { ethers } from "ethers";
import { parseArgs } from "node:util";
import { ToBlock } from "chainsauce";
import path from "node:path";
import * as abis from "./indexer/abis/index.js";

type ChainId = number;

Expand All @@ -14,7 +16,7 @@ export type Token = {

export type Subscription = {
address: string;
abi: string;
abi: ethers.ContractInterface;
fromBlock?: number;
events?: Record<string, string>;
};
Expand Down Expand Up @@ -64,16 +66,16 @@ export const CHAINS: Chain[] = [
subscriptions: [
{
address: "0x03506eD3f57892C85DB20C36846e9c808aFe9ef4",
abi: "#abis/v2/ProjectRegistry.json",
abi: abis.ProjectRegistryV2,
},
{
address: "0x9Cb7f434aD3250d1656854A9eC7A71EceC6eE1EF",
abi: "#abis/v2/RoundFactory.json",
abi: abis.RoundFactoryV2,
fromBlock: 16994474,
},
{
address: "0x4a850F463D1C4842937c5Bc9540dBc803D744c9F",
abi: "#abis/v2/QuadraticFundingVotingStrategyFactory.json",
abi: abis.QuadraticFundingVotingStrategyFactoryV2,
fromBlock: 16994526,
},
],
Expand Down Expand Up @@ -132,28 +134,28 @@ export const CHAINS: Chain[] = [
subscriptions: [
{
address: "0x832c5391dc7931312CbdBc1046669c9c3A4A28d5",
abi: "#abis/v1/ProjectRegistry.json",
abi: abis.ProjectRegistryV1,
},
{
address: "0x5770b7a57BD252FC4bB28c9a70C9572aE6400E48",
abi: "#abis/v1/RoundFactory.json",
abi: abis.RoundFactoryV1,
events: {
RoundCreated: "RoundCreatedV1",
},
},
{
address: "0xa71864fAd36439C50924359ECfF23Bb185FFDf21",
abi: "#abis/v2/ProjectRegistry.json",
abi: abis.ProjectRegistryV2,
fromBlock: 8738420,
},
{
address: "0x24F9EBFAdf095e0afe3d98635ee83CD72e49B5B0",
abi: "#abis/v2/RoundFactory.json",
abi: abis.RoundFactoryV2,
fromBlock: 8738430,
},
{
address: "0x06A6Cc566c5A88E77B1353Cdc3110C2e6c828e38",
abi: "#abis/v2/QuadraticFundingVotingStrategyFactory.json",
abi: abis.QuadraticFundingVotingStrategyFactoryV2,
fromBlock: 8790265,
},
],
Expand Down Expand Up @@ -196,16 +198,16 @@ export const CHAINS: Chain[] = [
subscriptions: [
{
address: "0x8e1bD5Da87C14dd8e08F7ecc2aBf9D1d558ea174",
abi: "#abis/v2/ProjectRegistry.json",
abi: abis.ProjectRegistryV2,
},
{
address: "0x04E753cFB8c8D1D7f776f7d7A033740961b6AEC2",
abi: "#abis/v2/RoundFactory.json",
abi: abis.RoundFactoryV2,
fromBlock: 87169287,
},
{
address: "0x838C5e10dcc1e54d62761d994722367BA167AC22",
abi: "#abis/v2/QuadraticFundingVotingStrategyFactory.json",
abi: abis.QuadraticFundingVotingStrategyFactoryV2,
fromBlock: 87168143,
},
],
Expand Down Expand Up @@ -246,19 +248,19 @@ export const CHAINS: Chain[] = [
subscriptions: [
{
address: "0x8e1bD5Da87C14dd8e08F7ecc2aBf9D1d558ea174",
abi: "#abis/v1/ProjectRegistry.json",
abi: abis.ProjectRegistryV1,
},
{
address: "0x3e7f72DFeDF6ba1BcBFE77A94a752C529Bb4429E",
abi: "#abis/v1/RoundFactory.json",
abi: abis.RoundFactoryV1,
events: {
RoundCreated: "RoundCreatedV1",
},
fromBlock: 55528191,
},
{
address: "0x06A6Cc566c5A88E77B1353Cdc3110C2e6c828e38",
abi: "#abis/v1/QuadraticFundingVotingStrategyFactory.json",
abi: abis.QuadraticFundingVotingStrategyFactoryV1,
fromBlock: 55528191,
},
],
Expand All @@ -281,16 +283,16 @@ export const CHAINS: Chain[] = [
subscriptions: [
{
address: "0x6294bed5B884Ae18bf737793Ef9415069Bf4bc11",
abi: "#abis/v2/ProjectRegistry.json",
abi: abis.ProjectRegistryV2,
},
{
address: "0x0479b9DA9f287539FEBd597350B1eBaEBF7479ac",
abi: "#abis/v2/RoundFactory.json",
abi: abis.RoundFactoryV2,
fromBlock: 0,
},
{
address: "0xE8027a807Bb85e57da4B7A5ecE65b0aBDf231ce8",
abi: "#abis/v2/QuadraticFundingVotingStrategyFactory.json",
abi: abis.QuadraticFundingVotingStrategyFactoryV2,
fromBlock: 0,
},
],
Expand All @@ -313,16 +315,16 @@ export const CHAINS: Chain[] = [
subscriptions: [
{
address: "0xDF9BF58Aa1A1B73F0e214d79C652a7dd37a6074e",
abi: "#abis/v2/ProjectRegistry.json",
abi: abis.ProjectRegistryV2,
},
{
address: "0x8AdFcF226dfb2fA73788Ad711C958Ba251369cb3",
abi: "#abis/v2/RoundFactory.json",
abi: abis.RoundFactoryV2,
fromBlock: 0,
},
{
address: "0x2AFA4bE0f2468347A2F086c2167630fb1E58b725",
abi: "#abis/v2/QuadraticFundingVotingStrategyFactory.json",
abi: abis.QuadraticFundingVotingStrategyFactoryV2,
fromBlock: 0,
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async function catchupAndWatchChain(
for (const subscription of config.chain.subscriptions) {
indexer.subscribe(
subscription.address,
await importAbi(subscription.abi),
subscription.abi,
Math.max(subscription.fromBlock || 0, config.fromBlock)
);
}
Expand Down
22 changes: 22 additions & 0 deletions src/indexer/abis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export { default as ProjectRegistryV1 } from "./v1/ProjectRegistry.json" assert { type: "json" };
export { default as QuadraticFundingVotingStrategyFactoryV1 } from "./v1/QuadraticFundingVotingStrategyFactory.json" assert { type: "json" };
export { default as QuadraticFundingVotingStrategyImplementationV1 } from "./v1/QuadraticFundingVotingStrategyImplementation.json" assert { type: "json" };
export { default as RoundFactoryV1 } from "./v1/RoundFactory.json" assert { type: "json" };
export { default as RoundImplementationV1 } from "./v1/RoundImplementation.json" assert { type: "json" };

import { default as QuadraticFundingVotingStrategyImplementationV2 } from "./v2/QuadraticFundingVotingStrategyImplementation.json" assert { type: "json" };
export { default as ProjectRegistryV2 } from "./v2/ProjectRegistry.json" assert { type: "json" };
export { default as QuadraticFundingVotingStrategyFactoryV2 } from "./v2/QuadraticFundingVotingStrategyFactory.json" assert { type: "json" };
export { QuadraticFundingVotingStrategyImplementationV2 };
export { default as RoundFactoryV2 } from "./v2/RoundFactory.json" assert { type: "json" };
export { default as RoundImplementationV2 } from "./v2/RoundImplementation.json" assert { type: "json" };

import { default as QuadraticFundingVotingStrategyImplementationV3 } from "./v3/QuadraticFundingVotingStrategyImplementation.json" assert { type: "json" };
export { default as ProjectRegistryV3 } from "./v3/ProjectRegistry.json" assert { type: "json" };
export { default as QuadraticFundingVotingStrategyFactoryV3 } from "./v3/QuadraticFundingVotingStrategyFactory.json" assert { type: "json" };
export { QuadraticFundingVotingStrategyImplementationV3 };
export { default as RoundFactoryV3 } from "./v3/RoundFactory.json" assert { type: "json" };
export { default as RoundImplementationV3 } from "./v3/RoundImplementation.json" assert { type: "json" };

export const QuadraticFundingVotingStrategyImplementationV2WithAIP13 =
QuadraticFundingVotingStrategyImplementationV2;
Original file line number Diff line number Diff line change
Expand Up @@ -61,61 +61,6 @@
"name": "Voted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "voter",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "grantAddress",
"type": "address"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "projectId",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "applicationIndex",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "roundAddress",
"type": "address"
}
],
"name": "Voted",
"type": "event"
},
{
"inputs": [],
"name": "VERSION",
Expand Down
Loading

0 comments on commit c0337ef

Please sign in to comment.