Skip to content

Commit

Permalink
chore: dry convertToMap
Browse files Browse the repository at this point in the history
  • Loading branch information
mfw78 committed Jan 18, 2024
1 parent 7730d96 commit e7bda59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export type OrderBookApi = string | undefined;
export * from "./model";
export * from "./generated";
export * from "./generated/ComposableCoW";
export type { Config } from "./types";
export type { Config, FilterAction } from "./types";
8 changes: 5 additions & 3 deletions src/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* and run json-schema-to-typescript to regenerate this file.
*/

export type FilterAction = "ACCEPT" | "DROP" | "SKIP";

export interface Config {
networks: {
name: string;
Expand All @@ -14,12 +16,12 @@ export interface Config {
orderBookApi?: string;
pageSize?: number;
filterPolicy: {
defaultAction: "ACCEPT" | "DROP" | "SKIP";
defaultAction: FilterAction;
owners?: {
[k: string]: "ACCEPT" | "DROP" | "SKIP";
[k: string]: FilterAction;
};
handlers?: {
[k: string]: "ACCEPT" | "DROP" | "SKIP";
[k: string]: FilterAction;
};
};
}[];
Expand Down
4 changes: 2 additions & 2 deletions src/utils/filterPolicy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConditionalOrderParams } from "@cowprotocol/cow-sdk";
import { Config } from "../types";
import { Config, FilterAction as FilterActionSchema } from "../types";

export enum FilterAction {
DROP = "DROP",
Expand Down Expand Up @@ -57,7 +57,7 @@ export class FilterPolicy {
}

private convertToMap(object?: {
[k: string]: "ACCEPT" | "DROP" | "SKIP";
[k: string]: FilterActionSchema;
}): Map<string, FilterAction> {
return object
? new Map(
Expand Down

0 comments on commit e7bda59

Please sign in to comment.