-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kleros SDK publication config #1704
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib | ||
dist | ||
node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
{ | ||
"name": "@kleros/kleros-sdk", | ||
"version": "0.1.0", | ||
"version": "2.0.1-3", | ||
"description": "SDK for Kleros version 2", | ||
"main": "index.ts", | ||
"repository": "[email protected]:kleros/kleros-v2.git", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://[email protected]/kleros/kleros-v2.git" | ||
}, | ||
"author": "Kleros", | ||
"license": "MIT", | ||
"main": "./lib/src/index.js", | ||
"types": "./lib/src/index.d.ts", | ||
"module": "./lib/src/index.js", | ||
"files": [ | ||
"lib/**/*", | ||
"!lib/**/test/*" | ||
], | ||
"alias": { | ||
"src": "./src", | ||
"dataMappings": "./src/dataMappings" | ||
|
@@ -18,17 +27,24 @@ | |
"volta": { | ||
"node": "20.11.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"tag": "latest" | ||
}, | ||
"scripts": { | ||
"build": "your-build-script", | ||
"clean": "rimraf lib", | ||
"build": "yarn clean && tsc", | ||
"test": "vitest", | ||
"test:ui": "vitest --ui", | ||
"test:run": "vitest run" | ||
"test:run": "vitest run", | ||
"publish": "yarn npm publish" | ||
}, | ||
"devDependencies": { | ||
"@types/mustache": "^4.2.5", | ||
"@vitest/ui": "^1.1.3", | ||
"dotenv": "^16.3.1", | ||
"mocha": "^10.2.0", | ||
"rimraf": "^5.0.5", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.1.3" | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,18 +1,15 @@ | ||||||||||||||||||||
import request from "graphql-request"; | ||||||||||||||||||||
import { TypedDocumentNode } from "@graphql-typed-document-node/core"; | ||||||||||||||||||||
import { DisputeDetails } from "./disputeDetails"; | ||||||||||||||||||||
import { graphql } from "~src/graphql"; | ||||||||||||||||||||
import { DisputeDetailsQuery } from "~src/graphql/graphql"; | ||||||||||||||||||||
export type { DisputeDetailsQuery }; | ||||||||||||||||||||
|
||||||||||||||||||||
export type Decoder = (externalDisputeID: string, disputeTemplate: Partial<DisputeDetails>) => Promise<DisputeDetails>; | ||||||||||||||||||||
|
||||||||||||||||||||
// https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md | ||||||||||||||||||||
export type CAIP10 = `eip155:${number}:0x${string}`; | ||||||||||||||||||||
|
||||||||||||||||||||
export const graphqlQueryFnHelper = async ( | ||||||||||||||||||||
url: string, | ||||||||||||||||||||
query: TypedDocumentNode<any, any>, | ||||||||||||||||||||
parametersObject: Record<string, any>, | ||||||||||||||||||||
chainId = 421613 | ||||||||||||||||||||
) => { | ||||||||||||||||||||
export const graphqlQueryFnHelper = async (url: string, query, parametersObject: Record<string, any>) => { | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify the type of the The Consider adding a type annotation to +import { DocumentNode } from 'graphql';
export const graphqlQueryFnHelper = async (url: string, query: DocumentNode, parametersObject: Record<string, any>) => {
return request(url, query, parametersObject);
};
|
||||||||||||||||||||
return request(url, query, parametersObject); | ||||||||||||||||||||
}; | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -36,20 +33,22 @@ export const genericDecoder = async ( | |||||||||||||||||||
): Promise<DisputeDetails> => { | ||||||||||||||||||||
let subgraphUrl; | ||||||||||||||||||||
switch (disputeTemplateRegistry) { | ||||||||||||||||||||
case "eip155:421613:0x22A58a17F12A718d18C9B6Acca3E311Da1b00A04": // Devnet | ||||||||||||||||||||
case "eip155:421614:0x22A58a17F12A718d18C9B6Acca3E311Da1b00A04": // Devnet | ||||||||||||||||||||
subgraphUrl = process.env.REACT_APP_DISPUTE_TEMPLATE_ARBGOERLI_SUBGRAPH_DEVNET; | ||||||||||||||||||||
break; | ||||||||||||||||||||
case "eip155:421613:0xA55D4b90c1F8D1fD0408232bF6FA498dD6786385": // Testnet | ||||||||||||||||||||
case "eip155:421614:0xA55D4b90c1F8D1fD0408232bF6FA498dD6786385": // Testnet | ||||||||||||||||||||
Comment on lines
+36
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Incorrect Chain ID Detected The chain ID
🔗 Analysis chainVerify that the chain IDs and addresses are correct The switch cases for You can run the following script to check the chain IDs and addresses in your codebase: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify chain IDs and addresses in the codebase.
# Search for occurrences of chain IDs 421613 and 421614
rg --type js --type ts 'eip155:42161[34]'
# Search for Devnet and Testnet addresses in the codebase
rg --type js --type ts '0x22A58a17F12A718d18C9B6Acca3E311Da1b00A04|0xA55D4b90c1F8D1fD0408232bF6FA498dD6786385'
# Confirm the correct chain IDs and addresses as per official documentation or configuration files.
Length of output: 1251 |
||||||||||||||||||||
subgraphUrl = process.env.REACT_APP_DISPUTE_TEMPLATE_ARBGOERLI_SUBGRAPH_TESTNET; | ||||||||||||||||||||
break; | ||||||||||||||||||||
default: | ||||||||||||||||||||
throw new Error(`Unsupported dispute template registry: ${disputeTemplateRegistry}`); | ||||||||||||||||||||
} | ||||||||||||||||||||
const { disputeTemplate } = await request(subgraphUrl, disputeTemplateQuery, { id: disputeTemplateID.toString() }); | ||||||||||||||||||||
switch (disputeTemplate.specification) { | ||||||||||||||||||||
case "KIP99": | ||||||||||||||||||||
return await kip99Decoder(externalDisputeID, disputeTemplate); | ||||||||||||||||||||
default: | ||||||||||||||||||||
throw new Error(`Unsupported dispute template specification: ${disputeTemplate.specification}`); | ||||||||||||||||||||
} | ||||||||||||||||||||
if (!disputeTemplate) throw new Error(`Dispute template not found: ${disputeTemplateID}`); | ||||||||||||||||||||
// switch (disputeTemplate.specification) { | ||||||||||||||||||||
// case "KIP99": | ||||||||||||||||||||
// return await kip99Decoder(externalDisputeID, disputeTemplate); | ||||||||||||||||||||
// default: | ||||||||||||||||||||
// throw new Error(`Unsupported dispute template specification: ${disputeTemplate.specification}`); | ||||||||||||||||||||
// } | ||||||||||||||||||||
throw new Error("Not implemented"); | ||||||||||||||||||||
Comment on lines
+47
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid leaving commented-out code and ensure The switch statement for
Consider updating the code as follows: - // switch (disputeTemplate.specification) {
- // case "KIP99":
- // return await kip99Decoder(externalDisputeID, disputeTemplate);
- // default:
- // throw new Error(`Unsupported dispute template specification: ${disputeTemplate.specification}`);
- // }
+// TODO: Implement decoder logic based on disputeTemplate.specification
throw new Error("Not implemented"); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,43 +1,54 @@ | ||||||||||||||||||||||
export type JsonMapping = { | ||||||||||||||||||||||
value: object; // Hardcoded object, to be stringified. | ||||||||||||||||||||||
seek: string[]; // JSON keys used to populate the template variables | ||||||||||||||||||||||
populate: string[]; // Populated template variables | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type SubgraphMapping = { | ||||||||||||||||||||||
endpoint: string; // Subgraph endpoint | ||||||||||||||||||||||
query: string; // Subgraph query | ||||||||||||||||||||||
variables?: { [k: string]: any }; // Subgraph query variables | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider specifying a more precise type for Using a more specific type for |
||||||||||||||||||||||
seek: string[]; // Subgraph query parameters value used to populate the template variables | ||||||||||||||||||||||
populate: string[]; // Populated template variables | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type AbiCallMapping = { | ||||||||||||||||||||||
abi: string; // ABI of the contract emitting the event | ||||||||||||||||||||||
address: string; // Address of the contract emitting the event | ||||||||||||||||||||||
args: any[]; // Function arguments | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider specifying a more precise type for Defining a specific type for |
||||||||||||||||||||||
seek: string[]; // Call return parameters used to populate the template variables | ||||||||||||||||||||||
populate: string[]; // Populated template variables | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type AbiEventMapping = { | ||||||||||||||||||||||
abi: string; // ABI of the contract emitting the event | ||||||||||||||||||||||
address: string; // Address of the contract emitting the event | ||||||||||||||||||||||
eventFilter: { | ||||||||||||||||||||||
// Event filter (eg. specific parameter value, block number range, event index) | ||||||||||||||||||||||
fromBlock: BigInt | string; // Block number range start | ||||||||||||||||||||||
toBlock: BigInt | string; // Block number range end | ||||||||||||||||||||||
Comment on lines
28
to
29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace According to TypeScript conventions, use the lowercase primitive type Apply this diff to fix the issue: - fromBlock: BigInt | string; // Block number range start
- toBlock: BigInt | string; // Block number range end
+ fromBlock: bigint | string; // Block number range start
+ toBlock: bigint | string; // Block number range end 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||||
args: any; // Event parameter value to filter on | ||||||||||||||||||||||
args?: any; // Event parameter value to filter on | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider specifying a precise type for Using a specific type for |
||||||||||||||||||||||
}; | ||||||||||||||||||||||
seek: string[]; // Event parameters value used to populate the template variables | ||||||||||||||||||||||
populate: string[]; // Populated template variables | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type AbiCallMapping = { | ||||||||||||||||||||||
abi: string; // ABI of the contract emitting the event | ||||||||||||||||||||||
address: string; // Address of the contract emitting the event | ||||||||||||||||||||||
args: any[]; // Function arguments | ||||||||||||||||||||||
seek: string[]; // Call return parameters used to populate the template variables | ||||||||||||||||||||||
populate: string[]; // Populated template variables | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type JsonMapping = { | ||||||||||||||||||||||
value: object; // Hardcoded object, to be stringified. | ||||||||||||||||||||||
seek: string[]; // JSON keys used to populate the template variables | ||||||||||||||||||||||
populate: string[]; // Populated template variables | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type FetchIpfsJsonMapping = { | ||||||||||||||||||||||
ipfsUri: string; // IPFS URL | ||||||||||||||||||||||
seek: string[]; // JSON keys used to populate the template variables | ||||||||||||||||||||||
populate: string[]; // Populated template variables | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type RealityMapping = { | ||||||||||||||||||||||
realityQuestionID: string; | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export type DataMapping< | ||||||||||||||||||||||
T extends SubgraphMapping | AbiEventMapping | AbiCallMapping | JsonMapping | FetchIpfsJsonMapping | RealityMapping | ||||||||||||||||||||||
> = { | ||||||||||||||||||||||
type: string; | ||||||||||||||||||||||
} & T; | ||||||||||||||||||||||
Comment on lines
+46
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider refining the Defining Apply this diff to implement the suggestion: -export type DataMapping<
+export type DataMapping<
T extends SubgraphMapping | AbiEventMapping | AbiCallMapping | JsonMapping | FetchIpfsJsonMapping | RealityMapping
> = {
- type: string;
+ type: 'Subgraph' | 'AbiEvent' | 'AbiCall' | 'Json' | 'FetchIpfsJson' | 'Reality';
} & T; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
const subgraphMappingExample: SubgraphMapping = { | ||||||||||||||||||||||
endpoint: "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2", | ||||||||||||||||||||||
query: ` | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistent usage of
src
imports without tilde prefix detected.Several files are still using
src/...
without the tilde prefix. Please update these import paths to maintain consistency across the codebase:web/src/hooks/queries/useVotingHistory.ts
web/src/hooks/queries/useUser.ts
web/src/hooks/queries/useTopUsersByCoherenceScore.ts
web/src/pages/Dashboard/index.tsx
web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx
web/src/pages/Cases/CasesFetcher.tsx
web/src/utils/uri.ts
web/src/hooks/queries/useJurorStakeDetailsQuery.ts
web/src/hooks/queries/useHomePageQuery.ts
web/src/hooks/queries/useEvidences.ts
web/src/hooks/queries/useDrawQuery.ts
web/src/hooks/queries/useDisputeTemplate.ts
web/src/hooks/queries/useDisputeDetailsQuery.ts
web/src/hooks/queries/useCourtTree.ts
web/src/hooks/queries/useCourtPolicyURI.ts
web/src/hooks/queries/useCourtDetails.ts
web/src/hooks/queries/useClassicAppealQuery.ts
web/src/hooks/queries/useCasesQuery.ts
web/src/hooks/queries/useCounter.ts
web/src/hooks/queries/useAllCasesQuery.ts
web/src/components/Verdict/DisputeTimeline.tsx
🔗 Analysis chain
Verify the consistency of import path changes.
The import path for
FetchIpfsJsonMapping
has been updated to use a tilde prefix and now points to a different file. This change appears to be part of a larger refactoring effort to standardize import paths and possibly reorganize types.To ensure consistency across the codebase, please run the following script:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 641
Script:
Length of output: 4386