Skip to content

Commit 34fb467

Browse files
committed
fix: many type fixes, eslint bump and config migration
1 parent f897258 commit 34fb467

15 files changed

+816
-458
lines changed

eslint-config/package.json

+12-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
"main": ".eslintrc.js",
66
"license": "MIT",
77
"dependencies": {
8-
"@typescript-eslint/eslint-plugin": "^5.62.0",
9-
"@typescript-eslint/parser": "^5.62.0",
10-
"@typescript-eslint/utils": "^5.62.0",
11-
"eslint-config-prettier": "^8.10.0",
12-
"eslint-config-standard": "^16.0.3",
13-
"eslint-plugin-import": "^2.29.1",
8+
"@typescript-eslint/eslint-plugin": "^8.8.1",
9+
"@typescript-eslint/parser": "^8.8.1",
10+
"@typescript-eslint/utils": "^8.8.1",
11+
"eslint-config-prettier": "^9.1.0",
12+
"eslint-config-standard": "^17.1.0",
13+
"eslint-plugin-import": "^2.31.0",
1414
"eslint-plugin-node": "^11.1.0",
15-
"eslint-plugin-prettier": "^4.2.1",
16-
"eslint-plugin-promise": "^5.2.0",
17-
"eslint-plugin-security": "^1.7.1",
15+
"eslint-plugin-prettier": "^5.2.1",
16+
"eslint-plugin-promise": "^6.0.0",
17+
"eslint-plugin-security": "^3.0.1",
1818
"eslint-utils": "^3.0.0"
1919
},
2020
"devDependencies": {
21+
"@eslint/eslintrc": "^3.1.0",
22+
"@eslint/js": "^9.12.0",
23+
"globals": "^15.11.0",
2124
"typescript": "^5.3.3"
2225
},
2326
"peerDependencies": {

kleros-sdk/src/dataMappings/actions/callAction.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const callAction = async (mapping: AbiCallMapping, alchemyApiKey: string)
1313
const data = await publicClient.readContract({
1414
address,
1515
abi: [parsedAbi],
16+
functionName: "TODO: FIX ME",
1617
args,
1718
});
1819

kleros-sdk/src/dataMappings/actions/eventAction.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { parseAbiItem } from "viem";
2+
import { type AbiEvent } from "abitype";
23
import { AbiEventMapping } from "src/dataMappings/utils/actionTypes";
34
import { createResultObject } from "src/dataMappings/utils/createResultObject";
45
import { configureSDK, getPublicClient } from "src/sdk";
@@ -8,17 +9,17 @@ export const eventAction = async (mapping: AbiEventMapping, alchemyApiKey: strin
89
const publicClient = getPublicClient();
910

1011
const { abi: source, address, eventFilter, seek, populate } = mapping;
11-
const parsedAbi = typeof source === "string" ? parseAbiItem(source) : source;
12+
const parsedAbi = parseAbiItem(source) as AbiEvent;
1213

1314
const filter = await publicClient.createEventFilter({
1415
address,
1516
event: parsedAbi,
1617
args: eventFilter.args,
17-
fromBlock: eventFilter.fromBlock,
18-
toBlock: eventFilter.toBlock,
18+
fromBlock: eventFilter.fromBlock ? BigInt(eventFilter.fromBlock.toString()) : undefined,
19+
toBlock: eventFilter.toBlock ? BigInt(eventFilter.toBlock.toString()) : undefined,
1920
});
2021

21-
const contractEvent = await publicClient.getFilterLogs({ filter: filter as any });
22+
const contractEvent = await publicClient.getFilterLogs({ filter });
2223
const eventData = contractEvent[0].args;
2324

2425
return createResultObject(eventData, seek, populate);

kleros-sdk/src/dataMappings/executeActions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const executeAction = async (
2424
mapping: ActionMapping,
2525
context: Record<string, unknown> = {}
2626
): Promise<ActionResult> => {
27-
mapping = replacePlaceholdersWithValues(mapping, context);
27+
mapping = replacePlaceholdersWithValues(mapping, context) as ActionMapping;
2828

2929
switch (mapping.type) {
3030
case "graphql":

kleros-sdk/src/dataMappings/utils/actionTypes.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { type Address } from "viem";
2+
13
export type JsonMapping = {
24
type: string;
35
value: object;
@@ -17,7 +19,7 @@ export interface SubgraphMapping {
1719
export type AbiCallMapping = {
1820
type: string;
1921
abi: string;
20-
address: string;
22+
address: Address;
2123
args: any[];
2224
seek: string[];
2325
populate: string[];
@@ -26,7 +28,7 @@ export type AbiCallMapping = {
2628
export type AbiEventMapping = {
2729
type: string;
2830
abi: string;
29-
address: string;
31+
address: Address;
3032
eventFilter: {
3133
fromBlock: BigInt | string;
3234
toBlock: BigInt | string;

kleros-sdk/src/dataMappings/utils/disputeDetailsSchema.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { z } from "zod";
22
import { isAddress } from "viem";
33
import { normalize } from "viem/ens";
44

5-
const isHexAddress = (str: string): boolean => /^0x[a-fA-F0-9]{40}$/.test(str);
6-
const isHexId = (str: string): boolean => /^0x[a-fA-F0-9]{1,64}$/.test(str);
7-
const isMultiaddr = (str: string): boolean =>
5+
export const isHexAddress = (str: string): boolean => /^0x[a-fA-F0-9]{40}$/.test(str);
6+
export const isHexId = (str: string): boolean => /^0x[a-fA-F0-9]{1,64}$/.test(str);
7+
export const isMultiaddr = (str: string): boolean =>
88
/^\/(?:ip4|ip6|dns4|dns6|dnsaddr|tcp|udp|utp|tls|ws|wss|p2p-circuit|p2p-webrtc-star|p2p-webrtc-direct|p2p-websocket-star|onion|ipfs)(\/[^\s\/]+)+$|^ipfs:\/\/[a-zA-Z0-9]+\/[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)?$/.test(
99
str
1010
);
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import mustache from "mustache";
2+
import { ActionMapping } from "./actionTypes";
23

3-
export const replacePlaceholdersWithValues = (mapping: any, context: Record<string, unknown>) => {
4-
const replace = (obj) => {
4+
export function replacePlaceholdersWithValues(
5+
mapping: ActionMapping,
6+
context: Record<string, unknown>
7+
): ActionMapping | ActionMapping[] {
8+
function replace(obj: ActionMapping): ActionMapping | ActionMapping[] {
59
if (typeof obj === "string") {
6-
return mustache.render(obj, context);
10+
return mustache.render(obj, context) as unknown as ActionMapping;
711
} else if (Array.isArray(obj)) {
8-
return obj.map(replace);
12+
return obj.map(replace) as unknown as ActionMapping[];
913
} else if (typeof obj === "object" && obj !== null) {
10-
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, replace(value)]));
14+
return Object.fromEntries(
15+
Object.entries(obj).map(([key, value]) => [key, replace(value)])
16+
) as unknown as ActionMapping[];
1117
} else {
1218
return obj;
1319
}
14-
};
20+
}
1521

1622
return replace(mapping);
17-
};
23+
}

kleros-sdk/src/sdk.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { createPublicClient, webSocket } from "viem";
1+
import { createPublicClient, webSocket, type PublicClient } from "viem";
22
import { arbitrumSepolia } from "viem/chains";
33

4-
let publicClient;
4+
let publicClient: PublicClient | undefined;
55

66
export const configureSDK = (config: { apiKey?: string }) => {
77
if (config.apiKey) {
@@ -14,7 +14,7 @@ export const configureSDK = (config: { apiKey?: string }) => {
1414
}
1515
};
1616

17-
export const getPublicClient = () => {
17+
export const getPublicClient = (): PublicClient => {
1818
if (!publicClient) {
1919
throw new Error("SDK not configured. Please call `configureSDK` before using.");
2020
}

prettier-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"eslint": "^8.56.0",
7+
"eslint": "^8.57.1",
88
"prettier": "^2.8.8",
99
"prettier-plugin-solidity": "^1.3.1"
1010
},

web-devtools/.eslintignore

-3
This file was deleted.

web-devtools/.eslintrc.json

-166
This file was deleted.

0 commit comments

Comments
 (0)