Skip to content

Conversation

@jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Jan 9, 2026

PR-Codex overview

This PR introduces support for syncing and tagging contracts with the Tenderly platform. It adds a new script for synchronization and enhances the configuration for managing deployments.

Detailed summary

  • Added hardhat-deploy-tenderly import in contracts/hardhat.config.ts.
  • Introduced sync-tenderly script in contracts/package.json.
  • Created syncToTenderly.ts script with:
    • Type definitions for deployment and Tenderly API.
    • Functions for reading deployments, syncing contracts, and tagging.
    • CLI entry point for executing sync and tag operations.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Introduced Tenderly contract synchronization with CLI support for syncing deployed contracts, applying tags, and removing tags across networks.
    • Added "sync-tenderly" npm script with dry-run capability and flexible argument parsing for contract management operations.
  • Chores

    • Added missing import in configuration file.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Jan 9, 2026

Deploy Preview for kleros-v2-testnet-devtools failed. Why did it fail? →

Name Link
🔨 Latest commit 46dd2ec
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/69604cec5d6b210008bbba18

@netlify
Copy link

netlify bot commented Jan 9, 2026

Deploy Preview for kleros-v2-neo failed. Why did it fail? →

Name Link
🔨 Latest commit 46dd2ec
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/69604cecd1d8b90007eca711

@netlify
Copy link

netlify bot commented Jan 9, 2026

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 46dd2ec
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/69604cec8a94cf000815e6c6
😎 Deploy Preview https://deploy-preview-2214--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

Walkthrough

The pull request adds contract synchronization capabilities with Tenderly by introducing a new TypeScript script that reads deployment artifacts, syncs contracts to Tenderly via API calls, and supports tagging/untagging workflows. Configuration updates include a new npm script and a duplicate Tenderly plugin import in Hardhat config.

Changes

Cohort / File(s) Summary
Configuration & Setup
contracts/hardhat.config.ts, contracts/package.json
Adds duplicate import of hardhat-deploy-tenderly; introduces new npm script sync-tenderly executing ts-node ./scripts/syncToTenderly.ts with NODE_NO_WARNINGS=1 flag
Contract Sync Script
contracts/scripts/syncToTenderly.ts
Implements comprehensive Tenderly contract synchronization with three operational modes: sync (read deployments and add contracts to Tenderly), tag (apply labels to non-implementation contracts), and untag (remove labels). Includes Tenderly API integration, file I/O for reading deployment artifacts, dry-run support, error handling, rate-limiting pauses, and detailed result aggregation

Sequence Diagram(s)

sequenceDiagram
    actor CLI as CLI User
    participant Script as syncToTenderly Script
    participant FS as Filesystem
    participant API as Tenderly API
    
    CLI->>Script: yarn sync-tenderly --network=X [--dry-run]
    
    rect rgb(200, 220, 255)
    note over Script,FS: Sync Mode
    Script->>FS: Read deployment artifacts
    FS-->>Script: Contract list (main + implementations)
    Script->>API: Add contracts (bulk)
    API-->>Script: 200/409/error responses
    Script->>Script: Aggregate results (succeeded, failed, exists)
    end
    
    CLI->>Script: yarn sync-tenderly --network=X --tag=T [--dry-run]
    
    rect rgb(220, 200, 255)
    note over Script,API: Tag Mode
    Script->>Script: Filter non-implementation contracts
    loop Per Contract
        Script->>API: POST tag to contract
        API-->>Script: Success/failure
        Script->>Script: Rate-limit pause
    end
    Script->>Script: Return tag results
    end
    
    Script-->>CLI: Structured results + logs
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A script hops into the fold,
Tenderly contracts to behold,
Sync, tag, untag—the trio dance,
With API calls and dry-run chance,
Artifacts bundled, results so bold!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Tenderly tooling' is vague and generic, failing to convey the specific functionality or purpose of the changes. Consider using a more descriptive title such as 'Add Tenderly contract synchronization script' or 'Add Tenderly sync and tagging CLI tools' to better communicate the main changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@jaybuidl jaybuidl added Type: Enhancement ✨ Type: Toolchain ⚒️ Build tools configuration, CI/CD Package: Contracts Court smart contracts labels Jan 9, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @contracts/hardhat.config.ts:
- Line 12: Remove the duplicate import of "hardhat-deploy-tenderly" — there are
two identical import statements for that module (one at the top and the
duplicate shown in the diff); delete the redundant import so only a single
import of "hardhat-deploy-tenderly" remains in contracts/hardhat.config.ts.
🧹 Nitpick comments (3)
contracts/scripts/syncToTenderly.ts (3)

201-209: Consider adding a request timeout.

The fetch call has no timeout, which could cause the script to hang indefinitely on network issues. Consider using AbortController with a timeout.

Example implementation
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 30000); // 30s timeout

try {
  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Accept: "application/json",
      "X-Access-Key": config.accessKey,
    },
    body: JSON.stringify(payload),
    signal: controller.signal,
  });
  // ... rest of logic
} finally {
  clearTimeout(timeoutId);
}

504-507: Clarify 404 handling behavior.

When a contract doesn't have the tag (404), it's counted as a failure. If this is intentional for reporting purposes, consider using logger.debug instead of incrementing failed count since the tag removal goal is effectively achieved (tag doesn't exist).

Alternative: treat 404 as success
     // 404 might mean contract doesn't have the tag - treat as warning, not error
     if (response.status === 404) {
-      return { success: false, error: "Tag not found on contract" };
+      return { success: true, alreadyRemoved: true };
     }

536-538: Guard against flags being parsed as values.

If a user runs yarn sync-tenderly --network --dry-run, the code would parse --dry-run as the network value. Consider validating that the value doesn't start with --.

Suggested fix
   } else if (networkSpaceIndex !== -1 && args[networkSpaceIndex + 1]) {
-    network = args[networkSpaceIndex + 1];
+    const value = args[networkSpaceIndex + 1];
+    if (!value.startsWith("--")) {
+      network = value;
+    }
   }

Apply similar logic for --tag and --untag parsing.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12b8303 and 46dd2ec.

📒 Files selected for processing (3)
  • contracts/hardhat.config.ts
  • contracts/package.json
  • contracts/scripts/syncToTenderly.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet-devtools
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-testnet-devtools
  • GitHub Check: Analyze (javascript)
  • GitHub Check: SonarCloud
  • GitHub Check: hardhat-tests
🔇 Additional comments (4)
contracts/scripts/syncToTenderly.ts (3)

110-167: LGTM!

The deployment reading logic correctly handles missing directories, validates .chainId, filters deployment artifacts appropriately, and handles parse errors gracefully without failing the entire operation.


249-292: LGTM!

The sync logic correctly aggregates results, handles rate limiting with a delay, and provides clear logging for each contract status.


309-406: LGTM!

The tagging function correctly filters contracts, builds the contract ID format expected by Tenderly, and handles both success and failure cases appropriately.

contracts/package.json (1)

70-70: LGTM!

The new npm script is consistent with the project's existing patterns and correctly invokes the new Tenderly sync script.

import "solidity-coverage";
import "hardhat-deploy";
import "hardhat-deploy-ethers";
import "hardhat-deploy-tenderly";
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 | 🟡 Minor

Remove duplicate import.

hardhat-deploy-tenderly is already imported at line 7.

Suggested fix
-import "hardhat-deploy-tenderly";
📝 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
import "hardhat-deploy-tenderly";
🤖 Prompt for AI Agents
In @contracts/hardhat.config.ts at line 12, Remove the duplicate import of
"hardhat-deploy-tenderly" — there are two identical import statements for that
module (one at the top and the duplicate shown in the diff); delete the
redundant import so only a single import of "hardhat-deploy-tenderly" remains in
contracts/hardhat.config.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Package: Contracts Court smart contracts Type: Enhancement ✨ Type: Toolchain ⚒️ Build tools configuration, CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants