Skip to content
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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions kleros-sdk/.gitignore
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
Expand Up @@ -18,7 +18,7 @@
"frontendUrl": "https://reality.eth.limo/app/#!/question/{{ realityAddress }}-{{ questionId }}",
"arbitrableChainID": "100",
"arbitrableAddress": "0x2e39b8f43d0870ba896f516f78f57cde773cf805",
"arbitratorChainID": "421613",
"arbitratorChainID": "421614",
"arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b",
"category": "Oracle",
"lang": "en_US",
Expand Down
26 changes: 21 additions & 5 deletions kleros-sdk/package.json
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"
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions kleros-sdk/src/dataMappings/actions/callAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseAbiItem } from "viem";
import { AbiCallMapping } from "src/dataMappings/utils/actionTypes";
import { createResultObject } from "src/dataMappings/utils/createResultObject";
import { configureSDK, getPublicClient } from "src/sdk";
import { AbiCallMapping } from "~src/dataMappings/utils/dataMappingTypes";
import { createResultObject } from "~src/dataMappings/utils/createResultObject";
import { configureSDK, getPublicClient } from "~src/sdk";

export const callAction = async (mapping: AbiCallMapping) => {
configureSDK({ apiKey: process.env.ALCHEMY_API_KEY });
Expand Down
6 changes: 3 additions & 3 deletions kleros-sdk/src/dataMappings/actions/eventAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseAbiItem } from "viem";
import { AbiEventMapping } from "src/dataMappings/utils/actionTypes";
import { createResultObject } from "src/dataMappings/utils/createResultObject";
import { configureSDK, getPublicClient } from "src/sdk";
import { AbiEventMapping } from "~src/dataMappings/utils/dataMappingTypes";
import { createResultObject } from "~src/dataMappings/utils/createResultObject";
import { configureSDK, getPublicClient } from "~src/sdk";

export const eventAction = async (mapping: AbiEventMapping) => {
configureSDK({ apiKey: process.env.ALCHEMY_API_KEY });
Expand Down
6 changes: 3 additions & 3 deletions kleros-sdk/src/dataMappings/actions/fetchIpfsJsonAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fetch from "node-fetch";
import { FetchIpfsJsonMapping } from "src/dataMappings/utils/actionTypes";
import { createResultObject } from "src/dataMappings/utils/createResultObject";
import { MAX_BYTE_SIZE } from "src/consts";
import { FetchIpfsJsonMapping } from "~src/dataMappings/utils/dataMappingTypes";
Copy link
Contributor

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:

#!/bin/bash
# Description: Verify the usage of the new import path and check for any remaining old import paths.

# Test 1: Check for the new import path
echo "Occurrences of the new import path:"
rg --type typescript "from ['\"]~src/dataMappings/utils/dataMappingTypes['\"]"

# Test 2: Check for any remaining old import paths
echo "Occurrences of the old import path (if any):"
rg --type typescript "from ['\"]src/dataMappings/utils/actionTypes['\"]"

# Test 3: Check for consistency in using tilde prefix for src imports
echo "Inconsistent src imports without tilde prefix (if any):"
rg --type typescript "from ['\"]src/" | grep -v "from ['\"]~src/"

Length of output: 641


Script:

#!/bin/bash
# Description: Verify the usage of the new import path and check for any remaining old import paths.

# Test 1: Check for the new import path
echo "Occurrences of the new import path:"
rg "from ['\"]~src/dataMappings/utils/dataMappingTypes['\"]" --glob "*.ts" --glob "*.tsx"

# Test 2: Check for any remaining old import paths
echo "Occurrences of the old import path (if any):"
rg "from ['\"]src/dataMappings/utils/actionTypes['\"]" --glob "*.ts" --glob "*.tsx"

# Test 3: Check for consistency in using tilde prefix for src imports
echo "Inconsistent src imports without tilde prefix (if any):"
rg "from ['\"]src/" --glob "*.ts" --glob "*.tsx" | grep -v "from ['\"]~src/"

Length of output: 4386

import { createResultObject } from "~src/dataMappings/utils/createResultObject";
import { MAX_BYTE_SIZE } from "~src/consts";

export const fetchIpfsJsonAction = async (mapping: FetchIpfsJsonMapping) => {
const { ipfsUri, seek, populate } = mapping;
Expand Down
4 changes: 2 additions & 2 deletions kleros-sdk/src/dataMappings/actions/jsonAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonMapping } from "../utils/actionTypes";
import { createResultObject } from "src/dataMappings/utils/createResultObject";
import { JsonMapping } from "../utils/dataMappingTypes";
import { createResultObject } from "~src/dataMappings/utils/createResultObject";

export const jsonAction = (mapping: JsonMapping) => {
const { value: source, seek, populate } = mapping;
Expand Down
4 changes: 2 additions & 2 deletions kleros-sdk/src/dataMappings/actions/subgraphAction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from "node-fetch";
import { SubgraphMapping } from "../utils/actionTypes";
import { createResultObject } from "src/dataMappings/utils/createResultObject";
import { SubgraphMapping } from "../utils/dataMappingTypes";
import { createResultObject } from "~src/dataMappings/utils/createResultObject";

export const subgraphAction = async (mapping: SubgraphMapping) => {
const { endpoint, query, variables, seek, populate } = mapping;
Expand Down
29 changes: 14 additions & 15 deletions kleros-sdk/src/dataMappings/decoder.ts
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>) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Specify the type of the query parameter for better type safety

The graphqlQueryFnHelper function's query parameter is currently untyped. Explicitly specifying the type enhances type safety and code readability.

Consider adding a type annotation to query. If query is of type DocumentNode from the graphql module, you can update the function signature as follows:

+import { DocumentNode } from 'graphql';
 export const graphqlQueryFnHelper = async (url: string, query: DocumentNode, parametersObject: Record<string, any>) => {
   return request(url, query, parametersObject);
 };

Committable suggestion was skipped due to low confidence.

return request(url, query, parametersObject);
};

Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Incorrect Chain ID Detected

The chain ID 421614 used for Devnet and Testnet in kleros-sdk/src/dataMappings/decoder.ts is incorrect. Arbitrum Goerli should use chain ID 421613. Additionally, ensure that the Testnet address corresponds to the correct network.

  • kleros-sdk/src/dataMappings/decoder.ts (Lines 36-39)
🔗 Analysis chain

Verify that the chain IDs and addresses are correct

The switch cases for disputeTemplateRegistry use chain ID 421614 with specific addresses for Devnet and Testnet. Please verify that 421614 is the correct chain ID for the intended networks, as Arbitrum Goerli typically uses chain ID 421613. Additionally, ensure that the addresses correspond to the correct contracts on those networks.

You can run the following script to check the chain IDs and addresses in your codebase:

🏁 Scripts executed

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid leaving commented-out code and ensure genericDecoder is implemented

The switch statement for disputeTemplate.specification is commented out, and the function currently throws a generic "Not implemented" error. Consider the following:

  • Clean up commented-out code: If the code is obsolete, removing it keeps the codebase clean.
  • Implement pending functionality: If implementation is pending, add a TODO comment specifying the next steps.
  • Notify callers: Ensure that callers of genericDecoder are aware that it throws an error and handle it appropriately.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 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");
// TODO: Implement decoder logic based on disputeTemplate.specification
throw new Error("Not implemented");

};
15 changes: 9 additions & 6 deletions kleros-sdk/src/dataMappings/executeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import {
validateJsonMapping,
validateRealityMapping,
validateSubgraphMapping,
} from "./utils/actionTypeValidators";
import { ActionMapping } from "./utils/actionTypes";
} from "./utils/dataMappingValidators";
import { DataMapping } from "./utils/dataMappingTypes";
import { replacePlaceholdersWithValues } from "./utils/replacePlaceholdersWithValues";
import { DisputeRequest } from "./utils/disputeRequest";

export const executeAction = async (mapping: ActionMapping, context = {}) => {
export const executeAction = async (mapping: DataMapping<any>, context?: DisputeRequest) => {
mapping = replacePlaceholdersWithValues(mapping, context);

switch (mapping.type) {
Expand All @@ -31,15 +32,17 @@ export const executeAction = async (mapping: ActionMapping, context = {}) => {
return await fetchIpfsJsonAction(validateFetchIpfsJsonMapping(mapping));
case "reality":
mapping = validateRealityMapping(mapping);
if (!context?.arbitrable) {
throw new Error("Arbitrable address is required for reality action");
}
return await retrieveRealityData(mapping.realityQuestionID, context.arbitrable);
default:
throw new Error(`Unsupported action type: ${mapping.type}`);
}
};

export const executeActions = async (mappings, initialContext = {}) => {
const context = { ...initialContext };

export const executeActions = async (mappings, initialContext?: DisputeRequest) => {
const context = Object.assign({}, initialContext);
for (const mapping of mappings) {
const actionResult = await executeAction(mapping, context);
if (actionResult) {
Expand Down
13 changes: 5 additions & 8 deletions kleros-sdk/src/dataMappings/retrieveRealityData.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { executeAction } from "./executeActions";
import { AbiEventMapping } from "./utils/actionTypes";
import { AbiEventMapping, DataMapping } from "./utils/dataMappingTypes";
import { Answer } from "./utils/disputeDetailsTypes";

export const retrieveRealityData = async (realityQuestionID: string, arbitrable?: `0x${string}`) => {
if (!arbitrable) {
throw new Error("No arbitrable address provided");
}
const questionMapping: AbiEventMapping = {
const questionMapping: DataMapping<AbiEventMapping> = {
type: "abi/event",
abi: "event LogNewQuestion(bytes32 indexed question_id, address indexed user, uint256 template_id, string question, bytes32 indexed content_hash, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 created)",
address: arbitrable,
Expand Down Expand Up @@ -43,7 +44,7 @@ export const retrieveRealityData = async (realityQuestionID: string, arbitrable?
const questionData = await executeAction(questionMapping);
console.log("questionData", questionData);

const templateMapping: AbiEventMapping = {
const templateMapping: DataMapping<AbiEventMapping> = {
type: "abi/event",
abi: "event LogNewTemplate(uint256 indexed template_id, address indexed user, string question_text)",
address: arbitrable,
Expand All @@ -67,7 +68,7 @@ export const retrieveRealityData = async (realityQuestionID: string, arbitrable?

console.log("populatedTemplate", populatedTemplate);

let answers = [];
let answers: Answer[] = [];
if (populatedTemplate.type === "bool") {
answers = [
{
Expand All @@ -92,10 +93,6 @@ export const retrieveRealityData = async (realityQuestionID: string, arbitrable?
reserved: true,
});

for (let i = 0; i < answers.length; i++) {
answers[i].last = i === answers.length - 1;
}

return {
question: questionData.realityQuestion,
type: populatedTemplate.type,
Expand Down
57 changes: 0 additions & 57 deletions kleros-sdk/src/dataMappings/utils/actionTypes.ts

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider specifying a more precise type for variables instead of using any.

Using a more specific type for variables enhances type safety and code clarity.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider specifying a more precise type for args in AbiCallMapping.

Defining a specific type for args improves type safety and helps prevent runtime errors.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace BigInt with bigint in type annotations.

According to TypeScript conventions, use the lowercase primitive type bigint instead of the object type BigInt for consistency.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
🧰 Tools
🪛 Biome

[error] 28-28: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 29-29: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

args: any; // Event parameter value to filter on
args?: any; // Event parameter value to filter on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider specifying a precise type for args in eventFilter.

Using a specific type for args enhances type safety and readability.

};
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider refining the type property in DataMapping to use literal types.

Defining type as a union of specific string literals can restrict it to known mapping types, enhancing type safety.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export type DataMapping<
T extends SubgraphMapping | AbiEventMapping | AbiCallMapping | JsonMapping | FetchIpfsJsonMapping | RealityMapping
> = {
type: string;
} & T;
export type DataMapping<
T extends SubgraphMapping | AbiEventMapping | AbiCallMapping | JsonMapping | FetchIpfsJsonMapping | RealityMapping
> = {
type: 'Subgraph' | 'AbiEvent' | 'AbiCall' | 'Json' | 'FetchIpfsJson' | 'Reality';
} & T;


const subgraphMappingExample: SubgraphMapping = {
endpoint: "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2",
query: `
Expand Down
Loading