Skip to content

Commit

Permalink
chore: fix npm scripts, linting and bump lint packages
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRAG committed Jan 30, 2025
1 parent 3fbbf60 commit d2beb68
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 877 deletions.
10 changes: 5 additions & 5 deletions cdp-agentkit-core/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
],
"scripts": {
"build": "tsc",
"lint": "npx --yes eslint -c .eslintrc.json src/**/*.ts",
"lint:fix": "npx --yes eslint -c .eslintrc.json src/**/*.ts --fix",
"format": "npx --yes prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format-check": "npx --yes prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
"lint": "eslint -c .eslintrc.json \"src/**/*.ts\"",
"lint:fix": "eslint -c .eslintrc.json \"src/**/*.ts\" --fix",
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
"check": "tsc --noEmit",
"test": "npx jest --no-cache --testMatch='**/*_test.ts'",
"test:dry-run": "npm install && npm ci && npm publish --dry-run",
"test:e2e": "npx jest --no-cache --testMatch=**/e2e.ts --coverageThreshold '{}'",
"test:types": "tsd --files src/tests/types.test-d.ts",
"clean": "rm -rf dist/*",
"prepack": "tsc",
"docs": "npx --yes typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
"docs": "typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
"docs:serve": "http-server ./docs",
"dev": "tsc --watch"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import { z } from "zod";
import { ActionProvider } from "../action_provider";
import { Network } from "../../wallet_providers/wallet_provider";
import { CreateAction } from "../action_decorator";
import { PythFetchPriceFeedIDSchema, PythFetchPriceSchema } from "./schemas";

/**
* PythActionProvider is an action provider for Pyth.
*/
export class PythActionProvider extends ActionProvider {
/**
* Constructs a new PythActionProvider.
*/
constructor() {
super("pyth", []);
}

/**
* Checks if the Pyth action provider supports the given network.
*
* @param network - The network to check.
* @returns True if the Pyth action provider supports the network, false otherwise.
*/
supportsNetwork = (_: Network) => true;

/**
* Fetch the price feed ID for a given token symbol from Pyth.
*
Expand All @@ -46,6 +40,7 @@ export class PythActionProvider extends ActionProvider {
}

const filteredData = data.filter(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(item: any) => item.attributes.base.toLowerCase() === args.tokenSymbol.toLowerCase(),
);

Expand Down Expand Up @@ -75,7 +70,7 @@ Important notes:
- If you are asked to fetch the price from Pyth for a ticker symbol such as BTC, you must first use the pyth_fetch_price_feed_id
action to retrieve the price feed ID before invoking the pyth_Fetch_price action
`,
schema: PythFetchPriceSchema
schema: PythFetchPriceSchema,
})
async fetchPrice(args: z.infer<typeof PythFetchPriceSchema>): Promise<string> {
const url = `https://hermes.pyth.network/v2/updates/price/latest?ids[]=${args.priceFeedID}`;
Expand Down Expand Up @@ -108,6 +103,13 @@ action to retrieve the price feed ID before invoking the pyth_Fetch_price action
const scaledPrice = price / BigInt(10) ** BigInt(exponent);
return scaledPrice.toString();
}

/**
* Checks if the Pyth action provider supports the given network.
*
* @returns True if the Pyth action provider supports the network, false otherwise.
*/
supportsNetwork = () => true;
}

export const pythActionProvider = () => new PythActionProvider();
16 changes: 10 additions & 6 deletions cdp-agentkit-core/typescript/src/action_providers/pyth/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { z } from "zod";
/**
* Input schema for Pyth fetch price feed ID action.
*/
export const PythFetchPriceFeedIDSchema = z.object({
tokenSymbol: z.string().describe("The token symbol to fetch the price feed ID for"),
}).strict();
export const PythFetchPriceFeedIDSchema = z
.object({
tokenSymbol: z.string().describe("The token symbol to fetch the price feed ID for"),
})
.strict();

/**
* Input schema for Pyth fetch price action.
*/
export const PythFetchPriceSchema = z.object({
priceFeedID: z.string().describe("The price feed ID to fetch the price for"),
}).strict();
export const PythFetchPriceSchema = z
.object({
priceFeedID: z.string().describe("The price feed ID to fetch the price for"),
})
.strict();
3 changes: 3 additions & 0 deletions cdp-agentkit-core/typescript/src/agentkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export class AgentKit {
this.actions = config.actions || [];
}

/**
* Returns the actions available to the AgentKit.
*/
public getActions(): Action[] {
// TODO: Implement
throw Error("Unimplemented");
Expand Down
4 changes: 2 additions & 2 deletions cdp-langchain/examples/chatbot-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scripts": {
"start": "NODE_OPTIONS='--no-warnings' ts-node ./chatbot.ts",
"dev": "nodemon ./chatbot.ts",
"lint": "eslint -c .eslintrc.json *.ts",
"lint:fix": "eslint -c .eslintrc.json *.ts --fix",
"lint": "eslint -c .eslintrc.json \"*.ts\"",
"lint:fix": "eslint -c .eslintrc.json \"*.ts\" --fix",
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\""
},
Expand Down
10 changes: 5 additions & 5 deletions cdp-langchain/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
"files": ["dist"],
"scripts": {
"build": "tsc",
"lint": "npx --yes eslint -c .eslintrc.json src/**/*.ts",
"lint:fix": "npx --yes eslint -c .eslintrc.json src/**/*.ts --fix",
"format": "npx --yes prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format-check": "npx --yes prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
"lint": "eslint -c .eslintrc.json \"src/**/*.ts\"",
"lint:fix": "eslint -c .eslintrc.json \"src/**/*.ts\" --fix",
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
"check": "tsc --noEmit",
"test": "npx jest --no-cache --testMatch='**/*_test.ts'",
"test:dry-run": "npm install && npm ci && npm publish --dry-run",
"test:e2e": "npx jest --no-cache --testMatch=**/e2e.ts --coverageThreshold '{}'",
"test:types": "tsd --files src/tests/types.test-d.ts",
"clean": "rm -rf dist/*",
"prepack": "tsc",
"docs": "npx --yes typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
"docs": "typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
"docs:serve": "http-server ./docs",
"dev": "tsc --watch"
},
Expand Down
2 changes: 1 addition & 1 deletion cdp-langchain/typescript/src/tools/cdp_tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class CdpTool<TActionSchema extends CdpActionSchemaAny> extends Structure
try {
const validatedInput = this.schema.parse(input);
args = validatedInput;
} catch (validationError) {
} catch {
// If schema validation fails, fall back to instructions-only mode
args = input;
}
Expand Down
4 changes: 2 additions & 2 deletions farcaster-langchain/examples/chatbot-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"start": "NODE_OPTIONS='--no-warnings' ts-node ./chatbot.ts",
"dev": "nodemon ./chatbot.ts",
"lint": "eslint -c .eslintrc.json *.ts",
"lint:fix": "eslint -c .eslintrc.json *.ts --fix",
"lint": "eslint -c .eslintrc.json \"*.ts\"",
"lint:fix": "eslint -c .eslintrc.json \"*.ts\" --fix",
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\""
},
Expand Down
14 changes: 7 additions & 7 deletions farcaster-langchain/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
"files": ["dist"],
"scripts": {
"build": "tsc",
"lint": "npx --yes eslint -c .eslintrc.json src/**/*.ts",
"lint:fix": "npx --yes eslint -c .eslintrc.json src/**/*.ts --fix",
"format": "npx --yes prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format-check": "npx --yes prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
"lint": "eslint -c .eslintrc.json \"src/**/*.ts\"",
"lint:fix": "eslint -c .eslintrc.json \"src/**/*.ts\" --fix",
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
"check": "tsc --noEmit",
"test": "npx jest --no-cache --testMatch='**/*_test.ts'",
"test": "jest --no-cache --testMatch='**/*_test.ts'",
"test:dry-run": "npm install && npm ci && npm publish --dry-run",
"test:e2e": "npx jest --no-cache --testMatch=**/e2e.ts --coverageThreshold '{}'",
"test:e2e": "jest --no-cache --testMatch=**/e2e.ts --coverageThreshold '{}'",
"test:types": "tsd --files src/tests/types.test-d.ts",
"clean": "rm -rf dist/*",
"prepack": "tsc",
"docs": "npx --yes typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
"docs": "typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
"docs:serve": "http-server ./docs",
"dev": "tsc --watch"
},
Expand Down
Loading

0 comments on commit d2beb68

Please sign in to comment.