Skip to content
Draft
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
26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
npx --no -- commitlint --edit ${1}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Quote the path argument, use --no, and add a shebang for robustness

  • Quote $1 to handle paths with spaces.
  • Use --no to avoid network resolution.
  • Add a shebang and strict mode for consistency and portability.

Apply this diff:

-npx --no -- commitlint --edit ${1}
+#!/usr/bin/env sh
+set -euo pipefail
+npx --no -- commitlint --edit "$1"

Confirm the hook is executable and consistent with pre-commit:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Executable bit
if [ ! -x .husky/commit-msg ]; then
  echo "ERROR: .husky/commit-msg is not executable. Run: chmod +x .husky/commit-msg"
  exit 1
fi

# Check content
nl -ba .husky/commit-msg

Length of output: 175


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Listing .husky directory:"
ls -la .husky || true
echo

echo "Checking .husky/commit-msg permissions and content:"
ls -l .husky/commit-msg || true
echo "---- content ----"
head -n 200 .husky/commit-msg || cat .husky/commit-msg || true
echo

echo "First 2 lines of other .husky hooks (if any):"
for f in .husky/*; do
  [ -f "$f" ] || continue
  echo "== $f =="
  head -n 2 "$f" || true
done

Length of output: 1081


Add a shebang + strict mode and quote the commit message path in .husky/commit-msg

Short: .husky/commit-msg is executable and already uses --no, but it lacks a shebang/strict mode and uses an unquoted ${1}. .husky/pre-commit also lacks a shebang — make hooks consistent.

Files to update:

  • .husky/commit-msg — currently: npx --no -- commitlint --edit ${1} (executable). Apply below patch.
  • .husky/pre-commit — currently: npx lint-staged (executable). Consider adding the same shebang/strict-mode for consistency.

Apply this diff for .husky/commit-msg:

-npx --no -- commitlint --edit ${1}
+#!/usr/bin/env bash
+set -euo pipefail
+npx --no -- commitlint --edit "$1"

Optional, for consistency, update .husky/pre-commit similarly:

-npx lint-staged
+#!/usr/bin/env bash
+set -euo pipefail
+npx --no -- lint-staged
📝 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
npx --no -- commitlint --edit ${1}
#!/usr/bin/env bash
set -euo pipefail
npx --no -- commitlint --edit "$1"
🤖 Prompt for AI Agents
In .husky/commit-msg around line 1, the hook lacks a shebang and strict shell
settings and uses an unquoted ${1}; update the file to start with a POSIX sh
shebang (e.g. #!/usr/bin/env sh) and enable strict mode (set -euo pipefail or
set -e -u), and change the command to quote the commit message path as "${1}"
when invoking commitlint; also apply the same shebang/strict-mode header to
.husky/pre-commit for consistency.

5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
npx lint-staged
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Use npx with --no, add a shebang, and restore a trailing newline for portability and reliability

  • Without a shebang, hook execution can be shell-dependent.
  • Using --no prevents accidental remote installs and enforces local devDependency usage.
  • File currently lacks a trailing newline.

Apply this diff:

-npx lint-staged
+#!/usr/bin/env sh
+set -euo pipefail
+npx --no -- lint-staged

Run this to confirm hooks are executable and won’t hit the network:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Ensure the hook is executable
if [ ! -x .husky/pre-commit ]; then
  echo "ERROR: .husky/pre-commit is not executable. Run: chmod +x .husky/pre-commit"
  exit 1
fi

# 2) Verify lint-staged is a local devDependency (prevents npx from installing from the network)
jq -r '.devDependencies["lint-staged"] // empty' package.json | grep -qE '^[0-9]' \
  && echo "OK: lint-staged is in devDependencies" \
  || { echo "WARNING: lint-staged not found in devDependencies"; exit 1; }

# 3) Check the hook content
echo "Hook content:"
nl -ba .husky/pre-commit

Length of output: 256


Fix .husky/pre-commit: add shebang, safety flags, use npx --no --, and ensure lint-staged is a devDependency

Verification output: "WARNING: lint-staged not found in devDependencies" — using plain npx here can trigger a network install.

Files to change:

  • .husky/pre-commit — update hook content and ensure it ends with a trailing newline and is executable.
  • package.json — add lint-staged to devDependencies (or install it locally).

Suggested diff:

-npx lint-staged
+#!/usr/bin/env sh
+set -euo pipefail
+npx --no -- lint-staged

Actions:

  • Add lint-staged locally: npm install --save-dev lint-staged (or add to package.json).
  • Make hook executable: chmod +x .husky/pre-commit
  • Ensure the file ends with a newline.
📝 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
npx lint-staged
#!/usr/bin/env sh
set -euo pipefail
npx --no -- lint-staged
🤖 Prompt for AI Agents
In .husky/pre-commit around lines 1 to 1, the hook currently just runs "npx
lint-staged" which can trigger network installs and lacks a shebang, safety
flags, and a trailing newline; update the hook to start with a POSIX shebang
(#!/bin/sh), enable safe shell options (e.g., set -euo pipefail) and invoke the
local binary with npx --no -- lint-staged, ensure the file ends with a newline
and is chmod +x executable, and also add lint-staged to package.json
devDependencies (or run npm install --save-dev lint-staged) so the hook uses the
local package rather than fetching from the network.

1 change: 1 addition & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "*.ts": "yarn lint:fix" }
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Pattern will miss files in subfolders; include tsx and prefer direct eslint invocation

  • "*.ts" matches only TS files in repo root; it will skip src/**/*.ts. This effectively disables linting on most staged files.
  • Consider including tsx if present.
  • Calling ESLint directly avoids potential argument passthrough issues with yarn lint:fix scripts.

Apply this diff:

-{ "*.ts": "yarn lint:fix" }
+{ "**/*.{ts,tsx}": "eslint --fix --max-warnings=0" }

If you must keep the script, at least fix the pattern:

-{ "*.ts": "yarn lint:fix" }
+{ "**/*.{ts,tsx}": "yarn lint:fix" }

Verify your lint script can accept file arguments (lint-staged appends them):


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the configured script
jq -r '.scripts["lint:fix"] // empty' package.json

# Heuristic check: ensure it calls eslint
jq -r '.scripts["lint:fix"] // empty' package.json | grep -qi 'eslint' \
  && echo "OK: lint:fix appears to run ESLint" \
  || echo "WARNING: lint:fix may not run ESLint; ensure it forwards file args"

Length of output: 283


Fix lint-staged pattern and ensure lint script accepts staged file args

Verified: package.json -> scripts.lint:fix = eslint --fix "src/**/*.ts" && prettier --write "src/**/*.ts" (it runs ESLint but hardcodes globs).

  • .lintstagedrc currently uses { "*.ts": "yarn lint:fix" }"*.ts" matches only root-level files and will skip staged files in subfolders.
  • Because lint:fix hardcodes src/**/*.ts, invoking it via yarn lint:fix from lint-staged may not correctly target only the staged files (the hardcoded glob can ignore/override file args). Prefer calling ESLint directly from lint-staged, or make the lint:fix script explicitly forward file arguments.

Files to change:

  • .lintstagedrc
  • package.json (scripts.lint:fix) if you plan to keep using the npm script

Recommended change (preferred: call eslint directly from lint-staged):

-{ "*.ts": "yarn lint:fix" }
+{ "**/*.{ts,tsx}": "eslint --fix --max-warnings=0" }

If you must keep the package script, at minimum fix the pattern so nested files are matched:

-{ "*.ts": "yarn lint:fix" }
+{ "**/*.{ts,tsx}": "yarn lint:fix" }

Also ensure lint:fix is updated to accept forwarded file args (or use a shell wrapper that forwards "$@") so lint-staged's file list is actually linted.

📝 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
{ "*.ts": "yarn lint:fix" }
{ "**/*.{ts,tsx}": "eslint --fix --max-warnings=0" }

11 changes: 11 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import tseslint from "typescript-eslint";

export default [
...tseslint.configs.recommended,
{
files: ["src/**/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
Comment on lines +6 to +9
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Widen file globs to include all TS/TSX files across the repo

The current files: ["src/**/*.ts"] will exclude TS files outside src and TSX files entirely. Prefer a broader glob unless intentionally scoped.

Apply this diff:

-    files: ["src/**/*.ts"],
+    files: ["**/*.{ts,tsx}"],

Optional: If you want to be explicit about parser options or ignore build artifacts, you can extend:

// Example additions (outside the changed lines)
languageOptions: {
  parserOptions: { ecmaVersion: "latest", sourceType: "module" },
},
ignores: ["dist/**"],

Please confirm you’re using ESLint v9+ and the typescript-eslint meta-package, which this flat config expects. If unsure, run:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# ESLint version
jq -r '.devDependencies.eslint // empty' package.json

# typescript-eslint meta package presence
jq -r '.devDependencies["typescript-eslint"] // empty' package.json

Length of output: 161


Widen ESLint file globs to include all .ts/.tsx files across the repo

The current files: ["src/**/*.ts"] excludes TS files outside src and all TSX files. Change to broaden the scope.

  • File: eslint.config.mjs — lines 6–9
-    files: ["src/**/*.ts"],
+    files: ["**/*.{ts,tsx}"],

Verified: ESLint v^9.33.0 and typescript-eslint meta-package v^8.39.1 are present — flat config is supported. Optional: add parser options / ignore patterns, e.g. languageOptions.parserOptions and ignores: ["dist/**"].

📝 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
files: ["src/**/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
files: ["**/*.{ts,tsx}"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
🤖 Prompt for AI Agents
In eslint.config.mjs around lines 6 to 9, the files glob is too narrow (only
"src/**/*.ts") and excludes TypeScript files outside src as well as TSX files;
update the files array to include all .ts and .tsx files across the repo (for
example use globs like "**/*.{ts,tsx}" and/or
["src/**/*.ts","src/**/*.tsx","**/*.ts","**/*.tsx"] as appropriate), and
optionally add ignores like "dist/**" and any needed
languageOptions.parserOptions for the TypeScript parser to ensure proper
parsing.

},
];
91 changes: 35 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,54 @@
},
"main": "dist/src/index.js",
"scripts": {
"build": "rm -rf dist && rm -rf src/types/generated && yarn typechain && tsc && cp ./src/types/config.schema.json dist/src/types/config.schema.json",
"build": "rimraf dist && rimraf src/types/generated && yarn typechain && tsc && cpx ./src/types/config.schema.json dist/src/types/config.schema.json",
"fmt": "prettier --write \"src/**/*.ts\"",
"lint": "eslint \"src/**/*.ts\" && prettier --check \"src/**/*.ts\"",
"lint:fix": "eslint --fix \"src/**/*.ts\" && prettier --write \"src/**/*.ts\"",
"test": "yarn build && jest ./dist",
"test": "node --require ts-node/register --test \"src/**/*.{spec,test}.ts\"",
"typechain": "typechain --target ethers-v5 --out-dir src/types/generated/ \"abi/*.json\"",
"configschema": "node ./src/types/build.js",
"prepare": "husky install && yarn typechain && yarn configschema",
"cli": "ts-node src/index.ts"
},
"devDependencies": {
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@typechain/ethers-v5": "^11.1.1",
"@types/ajv": "^1.0.0",
"@types/express": "^4.17.18",
"@types/jest": "^29.5.3",
"@types/node": "^18.16.3",
"@types/node-fetch": "^2.6.9",
"@types/node-slack": "^0.0.31",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"dotenv": "^16.3.1",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unused-imports": "^3.0.0",
"husky": "^8.0.3",
"jest": "^28.1.3",
"json-schema-to-typescript": "^13.1.2",
"lint-staged": "^14.0.1",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"typechain": "^8.3.1"
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@typechain/ethers-v5": "^11.1.2",
"@types/ajv": "^1.0.4",
"@types/express": "^5.0.3",
"@types/node": "^24.2.1",
"@types/node-slack": "^0.0.34",
"cpx": "^1.5.0",
"dotenv": "^17.2.1",
"eslint": "^9.33.0",
"husky": "^9.1.7",
"json-schema-to-typescript": "^15.0.4",
"lint-staged": "^16.1.5",
"prettier": "^3.6.2",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript-eslint": "^8.39.1"
},
"dependencies": {
"@commander-js/extra-typings": "^11.0.0",
"@cowprotocol/contracts": "^1.4.0",
"@cowprotocol/cow-sdk": "6.2.0-RC.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"chalk": "^4.1.2",
"@commander-js/extra-typings": "^14.0.0",
"@cowprotocol/contracts": "^1.8.0",
"@cowprotocol/cow-sdk": "6.2.0-lens-bsc.0",
"@typechain/ethers-v6": "^0.5.1",
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"chalk": "^5.5.0",
"ethers": "5.8.0",
"express": "^4.18.2",
"graphql-request": "^6.1.0",
"level": "^8.0.0",
"express": "^5.1.0",
"graphql-request": "^7.2.0",
"level": "^10.0.0",
"level-ts": "^2.1.0",
"loglevel": "^1.8.1",
"loglevel": "^1.9.2",
"loglevel-plugin-prefix": "^0.8.4",
"node-fetch": "2",
"node-slack": "^0.0.7",
"prom-client": "^14.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
},
"jest": {
"automock": false,
"resetMocks": false,
"collectCoverageFrom": [
"src/**/*.{ts,tsx}"
],
"coveragePathIgnorePatterns": [
"abi",
"types"
]
},
"lint-staged": {
"src/**/*.ts": [
"npm run lint:fix --"
]
"prom-client": "^15.1.3",
"ts-node": "^10.9.2",
"typescript": "^5.9.2"
}
}
}
4 changes: 2 additions & 2 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export async function run(options: RunOptions) {
...options,
...network,
},
storage
storage,
);
})
}),
);

// Set the chain contexts on the API server
Expand Down
26 changes: 13 additions & 13 deletions src/domain/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const composableCow = ComposableCoW__factory.createInterface();
*/
export async function processNewOrderEvent(
context: ChainContext,
event: ConditionalOrderCreatedEvent
event: ConditionalOrderCreatedEvent,
) {
const { chainId, registry } = context;

Expand All @@ -60,7 +60,7 @@ export async function processNewOrderEvent(
numContractsAdded++;
} else {
log.error(
`Failed to register Smart Order from tx ${tx} on block ${blockNumber}. Error: ${error}`
`Failed to register Smart Order from tx ${tx} on block ${blockNumber}. Error: ${error}`,
);
}

Expand All @@ -78,7 +78,7 @@ export async function processNewOrderEvent(
}
} else {
log.info(
`No conditional order added for tx ${tx} on block ${blockNumber}`
`No conditional order added for tx ${tx} on block ${blockNumber}`,
);
}
};
Expand All @@ -95,7 +95,7 @@ export async function processNewOrderEvent(

async function decodeAndAddOrder(
event: ConditionalOrderCreatedEvent | MerkleRootSetEvent,
context: ChainContext
context: ChainContext,
): Promise<{ error: boolean; added: boolean }> {
const { chainId, registry } = context;
const log = getLogger({
Expand All @@ -117,7 +117,7 @@ async function decodeAndAddOrder(
const [owner, params] = composableCow.decodeEventLog(
"ConditionalOrderCreated",
eventLog.data,
eventLog.topics
eventLog.topics,
) as [string, IConditionalOrder.ConditionalOrderParamsStruct];

// Attempt to add the conditional order to the registry
Expand All @@ -128,7 +128,7 @@ async function decodeAndAddOrder(
null,
eventLog.address,
event.blockNumber,
context
context,
);
if (added) {
metrics.singleOrdersTotal.labels(network).inc();
Expand All @@ -140,7 +140,7 @@ async function decodeAndAddOrder(
const [owner, root, proof] = composableCow.decodeEventLog(
"MerkleRootSet",
eventLog.data,
eventLog.topics
eventLog.topics,
) as [string, BytesLike, ComposableCoW.ProofStruct];

// First need to flush the owner's conditional orders that do not have the merkle root set
Expand All @@ -151,7 +151,7 @@ async function decodeAndAddOrder(
// Decode the proof.data
const proofData = ethers.utils.defaultAbiCoder.decode(
["bytes[]"],
proof.data as BytesLike
proof.data as BytesLike,
);

for (const order of proofData) {
Expand All @@ -161,7 +161,7 @@ async function decodeAndAddOrder(
"bytes32[]",
"tuple(address handler, bytes32 salt, bytes staticInput)",
],
order as BytesLike
order as BytesLike,
);
// Attempt to add the conditional order to the registry

Expand All @@ -172,7 +172,7 @@ async function decodeAndAddOrder(
{ merkleRoot: root, path: decodedOrder[0] },
eventLog.address,
event.blockNumber,
context
context,
);
if (added) {
metrics.merkleRootTotal.labels(network).inc();
Expand All @@ -183,7 +183,7 @@ async function decodeAndAddOrder(
} catch (err) {
log.error(
`Error handling ConditionalOrderCreated/MerkleRootSet event for tx: ${tx}` +
err
err,
);
return { error: true, added };
}
Expand All @@ -208,7 +208,7 @@ function addOrder(
proof: Proof | null,
composableCow: string,
blockNumber: number,
context: ChainContext
context: ChainContext,
): boolean {
const { chainId, registry, filterPolicy } = context;
const log = getLogger({ name: "addOrder", chainId, blockNumber });
Expand Down Expand Up @@ -290,7 +290,7 @@ function addOrder(
orders: new Map(),
composableCow,
},
])
]),
);

metrics.activeOwnersTotal.labels(network).inc();
Expand Down
2 changes: 1 addition & 1 deletion src/domain/polling/filtering/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class FilterPolicy {
Object.entries(object).map(([key, value]) => [
key,
FilterAction[value],
])
]),
)
: new Map<string, FilterAction>();
}
Expand Down
Loading
Loading