Skip to content

Conversation

@fadeev
Copy link
Member

@fadeev fadeev commented Aug 18, 2025

Right now when deploying contracts on ZetaChain, the RPC doesn't send a correct response, so commands like forge create throw an error. Even though forge create actually deploys a contract it doesn't return contract address and it looks like it's broken, so we're switching to commands instead to:

  • pre-compute contract address
  • handle RPC response to make it look like it's not broken
npx tsx commands deploy --private-key $PRIVATE_KEY
UNIVERSAL=$(npx tsx commands deploy --private-key $PRIVATE_KEY | jq -r .contractAddress) && echo $UNIVERSAL

Related: zeta-chain/docs#703

Summary by CodeRabbit

  • New Features

    • Added deploy CLI commands to Hello and Call examples to deploy contracts and output JSON summaries (predicted address, deployer, network, tx hash).
    • Swap deploy updated to deterministic, nonce-based flow and adds a --tx-gas-limit option (default 4,000,000).
  • Refactor

    • Replaced the Hello Hardhat deploy task with the new CLI deployment workflow.
  • Chores

    • Added/updated tsx dev dependency across examples; loosened zetachain version constraint.
    • CI: pinned Foundry toolchain version and added a pre-flight runtime check.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 18, 2025

📝 Walkthrough

Walkthrough

Adds new deploy CLI commands for call, hello, and swap using ethers; introduces getAbi helpers and replaces artifact loaders; rewrites swap deploy to deterministic nonce-based implementation+proxy deployment with --tx-gas-limit; removes the Hardhat deploy task; wires commands into indices; bumps tsx and updates zetachain version in example packages.

Changes

Cohort / File(s) Summary
Hello CLI: ABI helper + deploy
examples/hello/commands/common.ts, examples/hello/commands/deploy.ts, examples/hello/commands/index.ts
New getAbi(name) helper reads compiled artifact JSON. Adds a Commander deploy command that uses ethers to deploy and prints JSON (contractAddress, deployer, network, transactionHash). CLI entry wired.
Call CLI: deploy command
examples/call/commands/deploy.ts, examples/call/commands/index.ts
Adds deploy command: builds provider and signer, loads artifact via getAbi, deploys, predicts address (nonce-based), and logs JSON. Registers command in CLI index.
Swap: artifact API and deterministic deployment
examples/swap/commands/common.ts, examples/swap/commands/deploy.ts
Replaces loadContractArtifacts with getAbi(name) returning parsed artifact. Deployment rewritten to compute pending nonce, predict implementation and proxy addresses, deploy implementation (nonce N) and proxy (nonce N+1) with explicit nonces and configurable --tx-gas-limit (default 4,000,000). Logs predicted addresses and TX hashes.
Hardhat task removal
examples/hello/hardhat.config.ts, examples/hello/tasks/deploy.ts
Removed import of local Hardhat deploy task from Hardhat config and deleted the Hardhat tasks/deploy.ts file (task no longer registered).
Dev tooling updates
examples/call/package.json, examples/messaging/package.json, examples/swap/package.json
Added or updated devDependency tsx to ^4.20.4 across example packages.
Hello package dependency bump
examples/hello/package.json
Updated zetachain from 6.0.1 to ^6.2.0 (looser semver allowing newer 6.x releases).

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant Provider
  participant Signer
  participant ContractFactory

  User->>CLI: run deploy --rpc --private-key --name --gateway
  CLI->>Provider: new JsonRpcProvider(rpc)
  CLI->>Signer: new Wallet(privateKey, Provider)
  CLI->>CLI: getAbi(name) → artifact {abi, bytecode}
  CLI->>ContractFactory: new ContractFactory(abi, bytecode, Signer)
  ContractFactory->>Provider: deploy(gateway)
  Provider-->>CLI: deployment tx
  CLI->>CLI: predict address via getContractAddress({from, nonce})
  CLI-->>User: print {contractAddress, deployer, network, transactionHash}
Loading
sequenceDiagram
  participant User
  participant CLI
  participant Provider
  participant Signer
  participant ImplFactory
  participant ProxyFactory

  User->>CLI: run swap deploy --rpc --private-key --name --gateway [--tx-gas-limit]
  CLI->>Provider: connect
  CLI->>Signer: connect
  CLI->>CLI: baseNonce = Signer.getTransactionCount("pending")
  CLI->>CLI: predict implAddress = getContractAddress({from, nonce: baseNonce})
  CLI->>ImplFactory: deploy(...){nonce: baseNonce}
  ImplFactory-->>CLI: implTx.hash
  CLI->>CLI: predict proxyAddress = getContractAddress({from, nonce: baseNonce+1})
  CLI->>ProxyFactory: deploy(implAddress, initData){nonce: baseNonce+1, gasLimit}
  ProxyFactory-->>CLI: proxyTx.hash
  CLI-->>User: print {contractAddress: proxyAddress, implementationAddress: implAddress, transactionHash: proxyTx.hash, implementationTransactionHash: implTx.hash}
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • feat: Swap commands #278 — Overlapping migration of example deploy tooling and artifact-loading helpers (same CLI/task changes and artifact API updates).

Suggested reviewers

  • s2imonovic

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch deploy-commands

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fadeev fadeev marked this pull request as ready for review August 18, 2025 12:06
@fadeev fadeev requested a review from a team as a code owner August 18, 2025 12:06
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: 0

♻️ Duplicate comments (6)
examples/swap/commands/deploy.ts (2)

13-14: Confirm artifact shape includes bytecode

getAbi must return a bytecode string compatible with ethers.ContractFactory. If artifacts come from Hardhat, bytecode can live under evm.bytecode.object. Ensure getAbi normalizes this (see common.ts comment).


28-33: ERC1967Proxy artifact lookup may fail with current getAbi

If ERC1967Proxy’s artifact is nested under a dependency path, getAbi("ERC1967Proxy") will not find it. The robust lookup proposed in common.ts resolves this.

examples/call/commands/deploy.ts (4)

12-17: Same suggestions as in hello deploy

  • Validate and normalize gateway address before deployment.
  • Consider normalizing artifact.bytecode in the helper.

18-21: Same nit: prefer tx.from for prediction

Mirror the small resilience improvement suggested in the hello deploy.


42-46: Same nit: use option instead of requiredOption with default

For consistency and clearer help text.


1-8: Confirm ethers major version usage

Replicating the ethers v5 API check across packages to avoid runtime surprises.

🧹 Nitpick comments (12)
examples/swap/package.json (1)

64-64: Nit: ensure swap package exposes a CLI script (optional)

Given new commands exist under examples/swap/commands, consider adding a convenience script to run them via tsx for parity with other packages.

Apply this diff if you want a yarn script:

   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "lint:fix": "npx eslint . --ext .js,.ts --fix",
     "lint": "npx eslint . --ext .js,.ts",
-    "deploy:localnet": "npx hardhat compile --force && npx hardhat deploy --network localhost --gateway 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"
+    "deploy:localnet": "npx hardhat compile --force && npx hardhat deploy --network localhost --gateway 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
+    "cli": "tsx commands/index.ts"
   },
examples/swap/commands/common.ts (1)

4-9: Optional: rename for clarity and add types

The function returns more than an ABI. Consider renaming to getArtifact and adding a minimal return type to aid callers.

examples/swap/commands/deploy.ts (4)

3-3: Use local import path

The file resides in the same folder as common.ts. Simplify the import path to avoid brittle ../../ segments.

Apply:

-import { getAbi } from "../../swap/commands/common";
+import { getAbi } from "./common";

39-47: Apply tx gas limit consistently to both deployments

You set gasLimit for the proxy deploy but not for the implementation. Apply the same override to avoid OOG on the first transaction and for consistency.

Apply:

-    const implementation = await factory.deploy({ nonce: baseNonce });
+    const implementation = await factory.deploy({
+      nonce: baseNonce,
+      gasLimit: ethers.BigNumber.from(opts.txGasLimit || 4000000),
+    });

88-92: CLI option naming: potential confusion with --gas-limit

You now have --gas-limit (contract initialization parameter) and --tx-gas-limit (transaction gas). Consider renaming the latter to --deploy-gas-limit for clarity. No functional change required.


93-96: Early validate user-supplied addresses

Fail fast on invalid addresses to prevent opaque RPC errors later.

Apply:

   .action((opts) => {
     opts.gasLimit = Number(opts.gasLimit);
     if (opts.txGasLimit) opts.txGasLimit = Number(opts.txGasLimit);
+    if (!ethers.utils.isAddress(opts.gateway)) {
+      throw new Error(`Invalid --gateway address: ${opts.gateway}`);
+    }
+    if (!ethers.utils.isAddress(opts.uniswapRouter)) {
+      throw new Error(`Invalid --uniswap-router address: ${opts.uniswapRouter}`);
+    }
     main(opts).catch((err) => {
       console.error("Unhandled error:", err);
       process.exit(1);
     });
   });
examples/hello/commands/index.ts (2)

1-1: Shebang should use env -S for multiple arguments

On many systems, using multiple arguments in a shebang via env requires -S. This avoids brittle behavior across shells/OSes.

Apply:

-#!/usr/bin/env npx tsx
+#!/usr/bin/env -S npx tsx

6-8: Guard CLI execution and export the program for composability

Align with the pattern used in examples/call/commands/index.ts to avoid auto-parsing when imported and to enable reuse in tests or other scripts.

-const program = new Command().addCommand(deploy);
-
-program.parse();
+const program = new Command().addCommand(deploy);
+
+if (require.main === module) program.parse();
+
+export default program;
examples/hello/commands/deploy.ts (4)

12-17: Validate gateway address before deploying

Normalize and validate the gateway address to fail fast with a clear error if it’s invalid.

-    const { abi, bytecode } = getAbi(opts.name);
-    const factory = new ethers.ContractFactory(abi, bytecode, signer);
-
-    const contract = await factory.deploy(opts.gateway);
+    const { abi, bytecode } = getAbi(opts.name);
+    const factory = new ethers.ContractFactory(abi, bytecode, signer);
+
+    // Validate/normalize address (throws if invalid)
+    const gateway = ethers.utils.getAddress(opts.gateway);
+
+    const contract = await factory.deploy(gateway);

18-21: Use transaction sender when predicting contract address

Using tx.from (fallback to signer.address) makes the prediction resilient to wrappers/middleware that may alter the from field.

-    const predictedAddress = ethers.utils.getContractAddress({
-      from: signer.address,
-      nonce: tx.nonce,
-    });
+    const predictedAddress = ethers.utils.getContractAddress({
+      from: tx.from ?? signer.address,
+      nonce: tx.nonce,
+    });

42-46: Do not mark an option with a default as required

requiredOption with a default is misleading in help text. Use option for the RPC URL since a sensible default is provided.

-  .requiredOption(
+  .option(
     "-r, --rpc <url>",
     "RPC URL (default: testnet)",
     "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"
   )

23-30: Optional: add a confirmations flag for users who want to wait

Some users may prefer a wait for N confirmations when the RPC behaves correctly. Consider adding a --confirmations option (default 0) and, when >0, await tx.wait(n) while still printing the predicted address immediately.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0f79a and 4060fec.

⛔ Files ignored due to path filters (3)
  • examples/call/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • examples/messaging/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • examples/swap/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (12)
  • examples/call/commands/deploy.ts (1 hunks)
  • examples/call/commands/index.ts (1 hunks)
  • examples/call/package.json (1 hunks)
  • examples/hello/commands/common.ts (1 hunks)
  • examples/hello/commands/deploy.ts (1 hunks)
  • examples/hello/commands/index.ts (1 hunks)
  • examples/hello/hardhat.config.ts (0 hunks)
  • examples/hello/tasks/deploy.ts (0 hunks)
  • examples/messaging/package.json (1 hunks)
  • examples/swap/commands/common.ts (1 hunks)
  • examples/swap/commands/deploy.ts (3 hunks)
  • examples/swap/package.json (2 hunks)
💤 Files with no reviewable changes (2)
  • examples/hello/tasks/deploy.ts
  • examples/hello/hardhat.config.ts
🧰 Additional context used
🧬 Code Graph Analysis (4)
examples/hello/commands/index.ts (1)
examples/hello/commands/deploy.ts (1)
  • deploy (40-59)
examples/call/commands/deploy.ts (1)
examples/hello/commands/common.ts (1)
  • getAbi (4-10)
examples/hello/commands/deploy.ts (3)
examples/hello/commands/common.ts (1)
  • getAbi (4-10)
examples/call/commands/deploy.ts (1)
  • deploy (40-59)
examples/swap/commands/deploy.ts (1)
  • deploy (68-100)
examples/swap/commands/deploy.ts (1)
examples/swap/commands/common.ts (1)
  • getAbi (4-10)
⏰ 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). (11)
  • GitHub Check: slither (examples/swap, swap.sarif)
  • GitHub Check: slither (examples/call, call.sarif)
  • GitHub Check: slither (examples/hello, hello.sarif)
  • GitHub Check: test (examples/hello)
  • GitHub Check: test (examples/nft)
  • GitHub Check: test (examples/token)
  • GitHub Check: test (examples/call)
  • GitHub Check: test (examples/swap)
  • GitHub Check: slither (examples/hello, hello.sarif)
  • GitHub Check: slither (examples/call, call.sarif)
  • GitHub Check: slither (examples/swap, swap.sarif)
🔇 Additional comments (10)
examples/swap/package.json (1)

50-50: Dev dependency bump to tsx v4.20.4 looks good

No compatibility concerns from this change; aligns with other packages in the repo.

examples/messaging/package.json (1)

50-50: Dev dependency addition to tsx v4.20.4 approved

Consistent with repo-wide updates; no risk.

examples/call/package.json (1)

50-50: Dev dependency bump to tsx v4.20.4 approved

Matches other example packages. No further action required.

examples/swap/commands/common.ts (1)

4-9: Couldn’t locate any compiled JSON artifacts in the examples/swap directory tree. Since the repo doesn’t include built outputs, please verify in your local build wherever contract JSONs actually land (e.g., Foundry’s out/<Contract>.sol/<Contract>.json, Hardhat’s artifacts/contracts/..., or a custom path). Ensure that getAbi searches all relevant directories and normalizes both the abi and bytecode fields across toolchains.

examples/swap/commands/deploy.ts (2)

15-22: Deterministic address precomputation via explicit nonces: good

Using pending nonce and explicit nonces ensures predictable implementation/proxy addresses and aligns with the PR objective of surfacing the address despite RPC quirks.


49-57: Output format aligns with goals

Logging predicted addresses and tx hashes as JSON meets the UX requirement to extract contractAddress even when RPC responses are unreliable.

examples/call/commands/index.ts (1)

6-12: LGTM: clean wiring of the new deploy subcommand

The new deploy command is registered cleanly and ordering with existing subcommands is consistent. The guarded parse keeps this module import-friendly.

examples/hello/commands/common.ts (1)

4-10: Normalize artifact shape and improve error messages

I wasn’t able to inspect the compiled JSON artifacts (they’re not checked into the repo), so please manually verify that your bytecode‐normalization covers all expected formats (plain string, .bytecode.object, .evm.bytecode.object) and that missing/invalid artifacts fail fast with clear messaging. Consider adding a small unit test for getAbi in examples/hello/commands/common.ts to guard against future regressions.

File: examples/hello/commands/common.ts

-export const getAbi = (name: string) => {
-  const abiPath = path.resolve(
-    __dirname,
-    path.join("..", "out", `${name}.sol`, `${name}.json`)
-  );
-  return JSON.parse(fs.readFileSync(abiPath, "utf8"));
-};
+export const getAbi = (name: string) => {
+  const abiPath = path.resolve(
+    __dirname,
+    path.join("..", "out", `${name}.sol`, `${name}.json`)
+  );
+  if (!fs.existsSync(abiPath)) {
+    throw new Error(`Artifact not found for ${name}: ${abiPath}`);
+  }
+  let artifact: any;
+  try {
+    artifact = JSON.parse(fs.readFileSync(abiPath, "utf8"));
+  } catch (e) {
+    throw new Error(`Invalid JSON in artifact for ${name}: ${abiPath}`);
+  }
+  const bytecode =
+    typeof artifact.bytecode === "string"
+      ? artifact.bytecode
+      : artifact.bytecode?.object ??
+        artifact.evm?.bytecode?.object ??
+        undefined;
+  if (!artifact?.abi || !bytecode) {
+    throw new Error(
+      `Artifact for ${name} missing abi/bytecode (checked: bytecode, bytecode.object, evm.bytecode.object).`
+    );
+  }
+  return { ...artifact, bytecode };
+};
examples/hello/commands/deploy.ts (1)

1-8: Ethers version usage in deploy.ts matches v5 declaration
The CLI commands under examples/hello are pinned to ethers ^5.4.7 (v5) in examples/hello/package.json, so the v5 API calls in deploy.ts are correct. The frontend at examples/hello/frontend uses ethers ^6.13.2 in isolation. No changes required.

examples/call/commands/deploy.ts (1)

3-3: Import path for getAbi verified
The file examples/call/commands/common.ts exists and exports getAbi at line 8. No further changes needed.

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: 0

🧹 Nitpick comments (1)
examples/hello/package.json (1)

6-11: Align scripts with new deploy CLI (Hardhat deploy task likely removed).

Given the PR migrates to custom tsx commands and removes the Hardhat deploy task, the current "deploy:localnet" script will likely fail. Recommend adding a build step for Foundry artifacts and a deploy script that uses the new CLI.

Apply this diff to replace the legacy Hardhat deploy with the new flow:

   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "lint:fix": "npx eslint . --ext .js,.ts --fix",
     "lint": "npx eslint . --ext .js,.ts",
-    "deploy:localnet": "npx hardhat compile --force && npx hardhat deploy --network localhost --gateway 0x9A676e781A523b5d0C0e43731313A708CB607508 && npx hardhat deploy --name Echo --network localhost --gateway 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
+    "build": "forge build",
+    "deploy": "yarn build && npx tsx commands deploy --private-key $PRIVATE_KEY"
   },

Verification checklist:

  • Ensure Foundry is available in CI/dev environments so "forge build" succeeds.
  • Confirm commands/ contains the new deploy CLI and that it reads artifacts from out/.
  • Optionally keep a separate legacy script if you still need local Hardhat-based flows.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4060fec and cb23e0d.

⛔ Files ignored due to path filters (1)
  • examples/hello/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • examples/hello/package.json (1 hunks)
⏰ 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). (13)
  • GitHub Check: test (examples/nft)
  • GitHub Check: test (examples/token)
  • GitHub Check: test (examples/hello)
  • GitHub Check: test (examples/swap)
  • GitHub Check: test (examples/call)
  • GitHub Check: test (examples/swap)
  • GitHub Check: test (examples/token)
  • GitHub Check: test (examples/nft)
  • GitHub Check: test (examples/hello)
  • GitHub Check: test (examples/call)
  • GitHub Check: slither (examples/hello, hello.sarif)
  • GitHub Check: slither (examples/swap, swap.sarif)
  • GitHub Check: slither (examples/call, call.sarif)
🔇 Additional comments (1)
examples/hello/package.json (1)

60-60: Refresh the Hello example lockfile
Run yarn install in examples/hello to update its yarn.lock after bumping "zetachain": "^6.2.0". Commit the updated lockfile to lock in the new version.

Note: All other examples (token, messaging, swap, nft, call) are self-contained projects with their own Zetachain versions; no cross-project dependency drift will occur.

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: 0

🧹 Nitpick comments (2)
.github/workflows/localnet.yaml (2)

40-41: Pin looks fine; confirm Foundry 1.2.3 supports forge soldeer and add a brief toolchain assertion.

You’re pinning Foundry to 1.2.3, which is good for reproducibility. Given the later step uses forge soldeer update, please confirm this Foundry version includes Soldeer support. If not, bump to a version that does, or add a short assertion step to fail fast.

If Soldeer is supported, consider adding a quick verification step right after installing Foundry:

- name: Verify Foundry toolchain
  run: |
    forge --version
    cast --version
    anvil --version

52-60: Strengthen the runtime check: verify all Foundry tools and fail fast.

anvil --version is a good sanity check. Make the step more robust by failing fast on errors and logging all tool versions to aid debugging.

Apply this diff to the step body:

       - name: Run Test Script
         run: |
-          cd "${{ matrix.example-dir }}"
-          yarn
-          forge soldeer update
-          anvil --version
-          chmod +x ./scripts/localnet.sh
-          ./scripts/localnet.sh start
+          set -euxo pipefail
+          cd "${{ matrix.example-dir }}"
+          # Ensure Yarn is available if the runner image changes
+          corepack enable || true
+          # Capture tool versions in the job summary for easier debugging
+          forge --version | tee -a "$GITHUB_STEP_SUMMARY"
+          cast --version  | tee -a "$GITHUB_STEP_SUMMARY"
+          anvil --version | tee -a "$GITHUB_STEP_SUMMARY"
+          yarn
+          forge soldeer update
+          chmod +x ./scripts/localnet.sh
+          ./scripts/localnet.sh start

Optionally, cache Yarn dependencies to speed up the matrix:

- name: Setup Node.js
  uses: actions/setup-node@v4
  with:
    node-version: "22"
    registry-url: "https://registry.npmjs.org"
    cache: yarn
    cache-dependency-path: "**/yarn.lock"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cb23e0d and cc3c755.

📒 Files selected for processing (1)
  • .github/workflows/localnet.yaml (2 hunks)
⏰ 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). (8)
  • GitHub Check: test (examples/swap)
  • GitHub Check: test (examples/nft)
  • GitHub Check: test (examples/call)
  • GitHub Check: test (examples/token)
  • GitHub Check: test (examples/hello)
  • GitHub Check: slither (examples/call, call.sarif)
  • GitHub Check: slither (examples/hello, hello.sarif)
  • GitHub Check: slither (examples/swap, swap.sarif)

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: 0

🧹 Nitpick comments (2)
.github/workflows/localnet.yaml (2)

40-41: Pinning Foundry is good; centralize the version to ease future bumps.

Using a hardcoded Foundry version improves reproducibility. To avoid touching multiple places when upgrading, reference an env variable instead of an inline literal.

Apply this diff within this step:

 with:
-  version: v1.2.3
+  version: ${{ env.FOUNDRY_VERSION }}

And add this near the top-level of the workflow (outside this hunk) to define the version once:

env:
  FOUNDRY_VERSION: v1.2.3

57-57: Good pre-flight; also validate Forge and consider a dedicated step for clearer logs.

Running anvil --version early is a helpful sanity check. Add forge --version alongside it to verify both tools, or split these into a small “Check Foundry versions” step for visibility.

Minimal inline addition:

-          anvil --version
+          anvil --version
+          forge --version

Alternatively, a separate step (outside this hunk) for clearer CI output:

- name: Check Foundry versions
  run: |
    anvil --version
    forge --version
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cc3c755 and bc15501.

📒 Files selected for processing (1)
  • .github/workflows/localnet.yaml (2 hunks)
⏰ 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). (8)
  • GitHub Check: test (examples/nft)
  • GitHub Check: test (examples/call)
  • GitHub Check: test (examples/swap)
  • GitHub Check: test (examples/hello)
  • GitHub Check: test (examples/token)
  • GitHub Check: slither (examples/hello, hello.sarif)
  • GitHub Check: slither (examples/call, call.sarif)
  • GitHub Check: slither (examples/swap, swap.sarif)

@fadeev
Copy link
Member Author

fadeev commented Aug 19, 2025

This PR also fixes CI by specifying Anvil version 1.2.3, because Localnet does not work with 1.3.0: zeta-chain/localnet#229

Copy link

@s2imonovic s2imonovic left a comment

Choose a reason for hiding this comment

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

Ran it locally and looks good.

from: signer.address,
nonce: tx.nonce,
});

Choose a reason for hiding this comment

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

maybe to add check that contract.address == predictedAddress

@fadeev fadeev merged commit dc02b57 into main Aug 20, 2025
20 checks passed
@fadeev fadeev deleted the deploy-commands branch August 20, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants