Skip to content

Commit

Permalink
fix: match the validator key type from oss-directory networks (#1584)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryscheng authored Jun 4, 2024
1 parent 981401d commit 08f8a06
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions ops/external-prs/src/ossd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { Argv } from "yargs";
import { handleError } from "../utils/error.js";
import { logger } from "../utils/logger.js";
import { BaseArgs, CommmentCommandHandler } from "../base.js";
import { loadData, Project, Collection } from "oss-directory";
import {
loadData,
Project,
Collection,
BlockchainAddress,
} from "oss-directory";
import duckdb from "duckdb";
import _ from "lodash";
import * as util from "util";
Expand All @@ -24,6 +29,15 @@ import {
import { GithubOutput } from "../github.js";
import { CheckConclusion, CheckStatus } from "../checks.js";

// This is only used to get the type of `networks`
const EXAMPLE_ADDRESS: BlockchainAddress = {
address: "0x123",
networks: ["mainnet"],
tags: ["eoa"],
};
type NetworkTuple = typeof EXAMPLE_ADDRESS.networks;
type Network = NetworkTuple[number];

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Should map to the tables field in ./metadata/databases/databases.yaml
Expand Down Expand Up @@ -307,7 +321,7 @@ class OSSDirectoryPullRequest {
private db: duckdb.Database;
private args: OSSDirectoryPullRequestArgs;
private changes: ChangeSummary;
private validators: Record<string, EVMNetworkValidator>;
private validators: Partial<Record<Network, EVMNetworkValidator>>;

static async init(args: OSSDirectoryPullRequestArgs) {
const pr = new OSSDirectoryPullRequest(args);
Expand All @@ -329,7 +343,7 @@ class OSSDirectoryPullRequest {
rpcUrl: urls.mainnetRpcUrl,
});

this.validators["arbitrum"] = ArbitrumValidator({
this.validators["arbitrum_one"] = ArbitrumValidator({
rpcUrl: urls.arbitrumRpcUrl,
});

Expand Down Expand Up @@ -636,7 +650,7 @@ class OSSDirectoryPullRequest {
for (const item of this.changes.artifacts.toValidate.blockchain) {
const address = item.address;
for (const network of item.networks) {
const validator = this.validators[network];
const validator = this.validators[network as Network];
if (!validator) {
logger.error({
message: "no validator found for network",
Expand Down

0 comments on commit 08f8a06

Please sign in to comment.