Skip to content

fix: template various fixes [skip-line-limit]#1434

Merged
ctrlc03 merged 3 commits into
mainfrom
fix/template
Mar 17, 2026
Merged

fix: template various fixes [skip-line-limit]#1434
ctrlc03 merged 3 commits into
mainfrom
fix/template

Conversation

@ctrlc03

@ctrlc03 ctrlc03 commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator

fix #1209 and ensure template client works with the latest enclave changes

Summary by CodeRabbit

  • New Features

    • Added visual progress tracker during computation showing inputs submitted, FHE computation, and decryption phases
    • Added copy-to-clipboard functionality for result fields (E3 ID, transaction hash, raw output)
    • Added expiration warnings with ability to start new computations when input window expires
  • Improvements

    • Simplified wizard workflow by consolidating steps (now 5 steps instead of 6)
    • Extended input submission window from 1 minute to 10 minutes
    • Enhanced accessibility with alert role for error notifications
    • Integrated wallet-based input publishing
  • Documentation

    • Updated API documentation removing deprecated activation functionality

@ctrlc03 ctrlc03 requested a review from cedoor March 16, 2026 21:42
@vercel

vercel Bot commented Mar 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Mar 17, 2026 3:14pm
enclave-docs Ready Ready Preview, Comment Mar 17, 2026 3:14pm

Request Review

@ctrlc03 ctrlc03 requested a review from 0xjei March 16, 2026 21:42
@coderabbitai

coderabbitai Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR removes the ACTIVATE_E3 step from the wizard workflow and introduces fee token approval before E3 requests. It adds wallet-based input publishing, enhances progress tracking in the encryption step, and updates context state from isActivated to isCiphertextPublished. Configuration and deployment block values are incremented.

Changes

Cohort / File(s) Summary
Wizard Flow Restructuring
packages/enclave-react/README.md, templates/default/client/src/context/WizardContext.tsx, templates/default/client/src/pages/WizardRoutes.tsx, templates/default/client/src/pages/steps/ActivateE3.tsx
Removed ACTIVATE_E3 step, reindexed subsequent steps; updated WizardStep enum and E3State interface, replacing isActivated with isCiphertextPublished; deleted ActivateE3 component entirely; updated public API documentation.
E3 Request & Fee Approval
templates/default/client/src/pages/steps/RequestComputation.tsx
Added fee token approval and quote fetching before E3 request; refactored to use requestParams object; updated auto-advance to ENTER_INPUTS step; added expiresAt tracking; increased inputWindow from 60 to 600 seconds; updated UI text from "Activation" to "Input".
Wallet-based Input Publishing
templates/default/client/src/pages/steps/EnterInputs.tsx, templates/default/client/src/utils/input.ts
Introduced wallet client integration for input publishing; updated publishInput signature to accept WalletClient, address, and contract address; created new input.ts utility with ABI definition and writeContract invocation.
Computation Progress Tracking
templates/default/client/src/pages/steps/EncryptSubmit.tsx
Added expiration checking with 5-second polling; introduced isCiphertextPublished state tracking; added visual three-step progress tracker showing "Inputs submitted", "FHE computation complete", and "Committee decryption"; enhanced UI with expiration warning and dynamic status indicators.
Results Display Improvements
templates/default/client/src/pages/steps/Results.tsx
Added clipboard copy functionality for E3 ID, transaction hash, and raw output; updated step numbering from 6 to 5; refactored final button to use handleReset; improved result display formatting with monospace styling.
Accessibility & Error Handling
templates/default/client/src/pages/components/ErrorDisplay.tsx, templates/default/client/src/utils/error-formatting.ts
Added role='alert' accessibility attribute to ErrorDisplay root element; removed "activate" error mapping from contractErrors.
Configuration & Deployment
templates/default/deployed_contracts.json, templates/default/enclave.config.yaml
Incremented blockNumber and deploy_block values by 1 across all contracts and services to align with updated deployment state.
Development Environment
templates/default/scripts/dev_all_concurrently.sh, templates/default/scripts/dev_frontend.sh
Replaced "pnpm dev:evm" with direct anvil command in dev_all_concurrently.sh; updated environment configuration from "anvil" to "localhost" in dev_frontend.sh.

Sequence Diagram

sequenceDiagram
    actor User
    participant Client as Client
    participant RequestComp as RequestComputation
    participant EnterInput as EnterInputs
    participant EncryptSubmit as EncryptSubmit
    participant Wallet as Wallet/Contract
    participant E3Service as E3 Service
    participant Results as Results

    User->>Client: Start wizard
    Client->>RequestComp: Request E3 computation
    RequestComp->>E3Service: getE3Quote(requestParams)
    E3Service-->>RequestComp: fee amount
    RequestComp->>Wallet: approveFeeToken(fee)
    Wallet-->>RequestComp: approval confirmed
    RequestComp->>E3Service: requestE3(requestParams)
    E3Service-->>RequestComp: E3_REQUESTED event (expiresAt)
    RequestComp->>EnterInput: Auto-advance to ENTER_INPUTS
    User->>EnterInput: Enter two numbers
    EnterInput->>Wallet: walletClient.writeContract(publishInput)
    Wallet-->>EnterInput: transaction hash (isCiphertextPublished=false)
    EnterInput->>EncryptSubmit: Auto-advance to ENCRYPT_SUBMIT
    EncryptSubmit->>E3Service: Subscribe to encryption events
    E3Service-->>EncryptSubmit: E3_CIPHERTEXT_PUBLISHED (isCiphertextPublished=true)
    EncryptSubmit->>EncryptSubmit: Poll expiration every 5s
    E3Service-->>EncryptSubmit: E3_PLAINTEXT_OUTPUT (hasPlaintextOutput=true)
    EncryptSubmit->>Results: Auto-advance with results
    Results->>User: Display E3 ID, hash, output with copy buttons
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • cedoor
  • 0xjei

Poem

🐰 Hoppy hops through the workflow stream,
No more activation in our dream!
Fee approvals, wallet calls so bright,
Progress tracked through encrypt's flight,
Results copied—a cleaner sight!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Most changes align with #1209 objectives, but the PR includes substantial out-of-scope refactoring: removal of entire ActivateE3 step, state interface redesign (isActivated→isCiphertextPublished), and EncryptSubmit enhancements beyond token approval requirements. Clarify scope: either document why ActivateE3 removal and state restructuring are necessary for #1209, or defer non-approval-related changes to a separate PR focused on wizard flow refactoring.
Title check ❓ Inconclusive The title is vague and generic, using the phrase 'various fixes' without specifying what was actually fixed. Replace 'various fixes' with a specific description of the main change, such as 'Remove E3 activation step and update template wizard flow' or similar.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR addresses the primary requirement from #1209: adding token approval before requests. Changes include approveFeeToken call in RequestComputation.tsx, wallet-based publishing flow in EnterInputs.tsx, and related state updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/template
📝 Coding Plan
  • Generate coding plan for human review comments

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

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

@ctrlc03 ctrlc03 changed the title fix: template various fixes to work with latest enclave changes fix: template various fixes to work with latest enclave changes [skip-line-length] Mar 16, 2026
@ctrlc03 ctrlc03 changed the title fix: template various fixes to work with latest enclave changes [skip-line-length] fix: template various fixes to work with latest enclave changes [skip-line-limit] Mar 16, 2026
@ctrlc03 ctrlc03 changed the title fix: template various fixes to work with latest enclave changes [skip-line-limit] fix: template various fixes to work with latest changes [skip-line-limit] Mar 16, 2026
@ctrlc03 ctrlc03 changed the title fix: template various fixes to work with latest changes [skip-line-limit] fix: template various fixes [skip-line-limit] Mar 16, 2026
@vercel vercel Bot temporarily deployed to Preview – enclave-docs March 16, 2026 21:44 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp March 16, 2026 21:44 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
templates/default/client/src/pages/steps/RequestComputation.tsx (2)

224-230: ⚠️ Potential issue | 🟡 Minor

Update the idle CTA to reference the fee token.

The request flow now quotes and approves feeToken (MockUSDC in this template), but the idle label still says 0.001 ETH. That points users at the wrong asset.

💡 Suggested fix
-              : 'Request E3 Computation (0.001 ETH)'}
+              : 'Request E3 Computation (fee token required)'}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/client/src/pages/steps/RequestComputation.tsx` around lines
224 - 230, The idle CTA still shows the hardcoded string 'Request E3 Computation
(0.001 ETH)'; update the JSX fallback branch so it references the dynamic fee
token and amount instead of ETH — use the existing feeToken value (and the fee
amount variable available in scope, e.g., fee/quotedFee/feeAmount) in the string
returned by the tertiary expression that renders when !isRequesting &&
!e3State.isRequested, e.g. build a label like `Request E3 Computation
(${feeAmount} ${feeToken.symbol || feeToken})` so the CTA reflects the actual
token being quoted/approved.

126-130: ⚠️ Potential issue | 🟠 Major

Wait for transaction confirmation before marking the request as successful.

requestE3() returns the submitted tx hash immediately without waiting for confirmation. If requestSuccess is set true at that point, the CTA becomes clickable again (when isRequesting clears in finally) before e3State.isRequested updates via the E3Requested event. This leaves a window for duplicate-request submissions.

💡 Suggested fix
      const hash = await requestE3(requestParams)
+     await publicClient.waitForTransactionReceipt({ hash })

      setLocalTransactionHash(hash)
      setLastTransactionHash(hash)
      setRequestSuccess(true)

This follows the same pattern already used for the approval transaction above.

🧹 Nitpick comments (4)
templates/default/enclave.config.yaml (1)

7-22: Reduce drift risk between template sources of truth.

deploy_block here and blockNumber in templates/default/deployed_contracts.json must stay in lockstep. Consider generating one from the other during template generation to avoid future off-by-one regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/enclave.config.yaml` around lines 7 - 22, The template
currently duplicates deployment heights: deploy_block fields in
enclave.config.yaml and blockNumber fields in
templates/default/deployed_contracts.json, risking drift; update the template
generation pipeline so one canonical value is used and the other derived (e.g.,
when creating deployed_contracts.json set blockNumber = deploy_block from the
enclave.config.yaml source, or vice versa), and modify the template generator
code that emits the deploy_block and blockNumber values to read the canonical
field (either "deploy_block" or "blockNumber") and compute the other to keep
them in lockstep (referencing the deploy_block keys in enclave.config.yaml and
the blockNumber keys in deployed_contracts.json).
templates/default/client/src/pages/steps/Results.tsx (1)

22-29: Don’t silently swallow clipboard failures.

Line 27 currently ignores copy errors. Add a small user-visible fallback/error state so failed copy attempts are actionable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/client/src/pages/steps/Results.tsx` around lines 22 - 29,
The catch block in copyToClipboard silently swallows failures; update the catch
to set a user-visible error state instead of doing nothing — for example, call
setCopiedField with an error sentinel (e.g., 'copy-error') or trigger your
existing toast/notification helper so the UI shows "Copy failed" and optionally
include the error message, and ensure the temporary reset logic (setTimeout that
clears setCopiedField) still runs for the error state; locate this behavior in
the copyToClipboard function and adjust the catch to surface the failure to the
user.
templates/default/client/src/pages/steps/EncryptSubmit.tsx (1)

34-45: Use typed enclave event payloads instead of any.

Using any here removes compile-time guarantees for event.data.e3Id / plaintextOutput and makes event-shape regressions harder to catch.

🔧 Proposed change
+type CiphertextOutputEvent = { data: { e3Id: bigint } }
+type PlaintextOutputEvent = { data: { e3Id: bigint; plaintextOutput: string } }

-const handleCiphertextOutput = (event: any) => {
+const handleCiphertextOutput = (event: CiphertextOutputEvent) => {

-const handlePlaintextOutput = (event: any) => {
+const handlePlaintextOutput = (event: PlaintextOutputEvent) => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/client/src/pages/steps/EncryptSubmit.tsx` around lines 34 -
45, The handlers handleCiphertextOutput and handlePlaintextOutput currently
accept event: any; define a typed payload interface (e.g., { e3Id: string;
plaintextOutput?: string; /* other fields */ }) and change the parameter types
to MessageEvent<YourPayload> (or the appropriate event type) for both
handleCiphertextOutput and handlePlaintextOutput so event.data.e3Id and
event.data.plaintextOutput are type-checked; update any places that read other
fields on event.data to match the new interface.
templates/default/scripts/dev_all_concurrently.sh (1)

18-18: Add a preflight check for anvil before launching concurrent services.

Line 18 introduces a hard dependency on anvil, but the script only validates pnpm. Failing fast keeps startup behavior predictable.

🔧 Proposed change
 # Check if pnpm is available
 if ! command -v pnpm &> /dev/null; then
     echo "ERROR: pnpm is not installed or not in PATH"
     echo "Please install pnpm or tmux to run this script"
     exit 1
 fi
+
+# Check if anvil is available
+if ! command -v anvil &> /dev/null; then
+    echo "ERROR: anvil is not installed or not in PATH"
+    echo "Please install Foundry (anvil) to run this script"
+    exit 1
+fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/scripts/dev_all_concurrently.sh` at line 18, Add a
preflight check to ensure the anvil binary is available before trying to run the
"anvil --host 0.0.0.0 --chain-id 31337 --block-time 1 --mnemonic 'test test test
test test test test test test test test junk' --silent" command; implement this
by testing command availability (e.g., using command -v or which) early in the
script alongside the existing pnpm check and if not found print a clear error
like "anvil not found, please install anvil" and exit with non-zero status so
the concurrent startup fails fast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@templates/default/client/src/pages/steps/EnterInputs.tsx`:
- Around line 139-146: The CTA label doesn't reflect that the button is disabled
due to missing wallet; update the conditional rendering that produces the button
text (the block referencing input1, input2, e3State.isCommitteePublished,
e3State.publicKey) to first check walletClient and address and return a
wallet-specific label (e.g., "Connect Wallet" or "Reconnect Wallet") when either
is missing, otherwise preserve the existing "Waiting for Committee Key...",
"Enter Both Numbers", and "Proceed to Encryption" branches so users know they
must connect their wallet before proceeding.

In `@templates/default/client/src/pages/steps/RequestComputation.tsx`:
- Around line 122-124: Before calling approveFeeToken, ensure the wallet has
sufficient MockUSDC balance for the quoted fee: after computing fee via
sdk.sdk.getE3Quote(requestParams) and before sdk.sdk.approveFeeToken(fee), query
the fee-token balance (MockUSDC) for the signer using your token contract's
balanceOf or publicClient.getBalance equivalent, compare against fee.amount, and
if insufficient either trigger the dev faucet/mint flow for MockUSDC or throw a
clear error; keep the subsequent approveTx and
publicClient.waitForTransactionReceipt calls unchanged and only execute them
once the balance check/mint has succeeded so requestE3 will not fail due to
insufficient funds.

In `@templates/default/scripts/dev_frontend.sh`:
- Line 11: Capture the output of "enclave print-env --vite --chain localhost"
into a variable instead of using unquoted export $(...), check that variable is
non-empty and exit or warn if it is empty, and then safely export each key=value
pair (e.g., reading lines and export "$line") before running "pnpm dev"; replace
the current unquoted "$(enclave print-env ...)" usage with a quoted variable
reference and an explicit empty-check around that variable to prevent
word-splitting (SC2046) and silent continuation on empty output while preserving
the call to "pnpm dev".

---

Outside diff comments:
In `@templates/default/client/src/pages/steps/RequestComputation.tsx`:
- Around line 224-230: The idle CTA still shows the hardcoded string 'Request E3
Computation (0.001 ETH)'; update the JSX fallback branch so it references the
dynamic fee token and amount instead of ETH — use the existing feeToken value
(and the fee amount variable available in scope, e.g., fee/quotedFee/feeAmount)
in the string returned by the tertiary expression that renders when
!isRequesting && !e3State.isRequested, e.g. build a label like `Request E3
Computation (${feeAmount} ${feeToken.symbol || feeToken})` so the CTA reflects
the actual token being quoted/approved.

---

Nitpick comments:
In `@templates/default/client/src/pages/steps/EncryptSubmit.tsx`:
- Around line 34-45: The handlers handleCiphertextOutput and
handlePlaintextOutput currently accept event: any; define a typed payload
interface (e.g., { e3Id: string; plaintextOutput?: string; /* other fields */ })
and change the parameter types to MessageEvent<YourPayload> (or the appropriate
event type) for both handleCiphertextOutput and handlePlaintextOutput so
event.data.e3Id and event.data.plaintextOutput are type-checked; update any
places that read other fields on event.data to match the new interface.

In `@templates/default/client/src/pages/steps/Results.tsx`:
- Around line 22-29: The catch block in copyToClipboard silently swallows
failures; update the catch to set a user-visible error state instead of doing
nothing — for example, call setCopiedField with an error sentinel (e.g.,
'copy-error') or trigger your existing toast/notification helper so the UI shows
"Copy failed" and optionally include the error message, and ensure the temporary
reset logic (setTimeout that clears setCopiedField) still runs for the error
state; locate this behavior in the copyToClipboard function and adjust the catch
to surface the failure to the user.

In `@templates/default/enclave.config.yaml`:
- Around line 7-22: The template currently duplicates deployment heights:
deploy_block fields in enclave.config.yaml and blockNumber fields in
templates/default/deployed_contracts.json, risking drift; update the template
generation pipeline so one canonical value is used and the other derived (e.g.,
when creating deployed_contracts.json set blockNumber = deploy_block from the
enclave.config.yaml source, or vice versa), and modify the template generator
code that emits the deploy_block and blockNumber values to read the canonical
field (either "deploy_block" or "blockNumber") and compute the other to keep
them in lockstep (referencing the deploy_block keys in enclave.config.yaml and
the blockNumber keys in deployed_contracts.json).

In `@templates/default/scripts/dev_all_concurrently.sh`:
- Line 18: Add a preflight check to ensure the anvil binary is available before
trying to run the "anvil --host 0.0.0.0 --chain-id 31337 --block-time 1
--mnemonic 'test test test test test test test test test test test junk'
--silent" command; implement this by testing command availability (e.g., using
command -v or which) early in the script alongside the existing pnpm check and
if not found print a clear error like "anvil not found, please install anvil"
and exit with non-zero status so the concurrent startup fails fast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: efb9e50d-3c95-4cf0-9d5f-b9d8d7e5ca64

📥 Commits

Reviewing files that changed from the base of the PR and between be5a732 and c5ce039.

📒 Files selected for processing (27)
  • docs/pages/ciphernode-operators/index.mdx
  • packages/enclave-contracts/contracts/verifier/RecursiveAggregationFoldVerifier.sol
  • packages/enclave-contracts/contracts/verifier/ThresholdDecryptedSharesAggregationBnVerifier.sol
  • packages/enclave-contracts/contracts/verifier/ThresholdDecryptedSharesAggregationModVerifier.sol
  • packages/enclave-contracts/contracts/verifier/ThresholdPkAggregationVerifier.sol
  • packages/enclave-contracts/ignition/modules/recursiveAggregationFoldVerifier.ts
  • packages/enclave-contracts/ignition/modules/thresholdDecryptedSharesAggregationBnVerifier.ts
  • packages/enclave-contracts/ignition/modules/thresholdDecryptedSharesAggregationModVerifier.ts
  • packages/enclave-contracts/ignition/modules/thresholdPkAggregationVerifier.ts
  • packages/enclave-contracts/test/fixtures/attestation.ts
  • packages/enclave-contracts/test/fixtures/operators.ts
  • packages/enclave-react/README.md
  • scripts/README.md
  • templates/default/client/src/context/WizardContext.tsx
  • templates/default/client/src/pages/WizardRoutes.tsx
  • templates/default/client/src/pages/components/ErrorDisplay.tsx
  • templates/default/client/src/pages/steps/ActivateE3.tsx
  • templates/default/client/src/pages/steps/EncryptSubmit.tsx
  • templates/default/client/src/pages/steps/EnterInputs.tsx
  • templates/default/client/src/pages/steps/RequestComputation.tsx
  • templates/default/client/src/pages/steps/Results.tsx
  • templates/default/client/src/utils/error-formatting.ts
  • templates/default/client/src/utils/input.ts
  • templates/default/deployed_contracts.json
  • templates/default/enclave.config.yaml
  • templates/default/scripts/dev_all_concurrently.sh
  • templates/default/scripts/dev_frontend.sh
💤 Files with no reviewable changes (5)
  • packages/enclave-contracts/test/fixtures/operators.ts
  • packages/enclave-react/README.md
  • packages/enclave-contracts/test/fixtures/attestation.ts
  • templates/default/client/src/pages/steps/ActivateE3.tsx
  • templates/default/client/src/utils/error-formatting.ts

Comment thread templates/default/client/src/pages/steps/EnterInputs.tsx
Comment thread templates/default/client/src/pages/steps/RequestComputation.tsx
Comment thread templates/default/scripts/dev_frontend.sh
@vercel vercel Bot temporarily deployed to Preview – crisp March 17, 2026 09:23 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs March 17, 2026 09:23 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
templates/default/scripts/dev_frontend.sh (1)

11-11: ⚠️ Potential issue | 🟠 Major

Fix unsafe export $(...) usage on Line 11 (still unresolved).

This still has SC2046 word-splitting risk and can silently proceed if print-env is empty. This is the same issue already flagged earlier and should be fixed before merge.

🔧 Proposed fix
-cd client && (export $(enclave print-env --vite --chain localhost) && pnpm dev)
+ENV_VARS="$(enclave print-env --vite --chain localhost)"
+if [ -z "${ENV_VARS}" ]; then
+  echo "ERROR: no Vite env vars found for chain 'localhost'" >&2
+  exit 1
+fi
+
+cd client && (
+  while IFS= read -r kv; do
+    export "$kv"
+  done < <(printf '%s\n' "${ENV_VARS}" | tr ' ' '\n')
+  pnpm dev
+)
#!/bin/bash
# Verify SC2046 is gone and the line was updated safely.
shellcheck -f gcc templates/default/scripts/dev_frontend.sh | rg -n 'SC2046|dev_frontend.sh:11' || true
nl -ba templates/default/scripts/dev_frontend.sh | sed -n '8,20p'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/scripts/dev_frontend.sh` at line 11, The current subshell
uses unsafe export $(enclave print-env ...) which causes SC2046 word-splitting
and will silently proceed if output is empty; replace that pattern by capturing
the output of enclave print-env --vite --chain localhost into a variable, check
it’s non-empty, and then safely export each KEY=VALUE line (e.g., echo "$env" |
while IFS= read -r line; do export "$line"; done) before running pnpm dev so you
avoid word-splitting and handle empty output; update the pipeline that runs
enclave print-env, the export logic, and the subsequent pnpm dev invocation in
the dev_frontend.sh script.
🧹 Nitpick comments (3)
templates/default/client/src/pages/steps/Results.tsx (1)

22-30: Consider providing user feedback when clipboard copy fails.

The empty catch block silently swallows clipboard errors. Users won't know if the copy failed. Consider showing a brief error indicator or logging for debugging.

💡 Suggested improvement
   const copyToClipboard = async (text: string, field: string) => {
     try {
       await navigator.clipboard.writeText(text)
       setCopiedField(field)
       setTimeout(() => setCopiedField(null), 2000)
     } catch {
-      // Fallback for environments without clipboard API
+      // Fallback for environments without clipboard API
+      console.warn('Clipboard API unavailable')
+      // Optionally show a brief error state
+      setCopiedField(null)
     }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/client/src/pages/steps/Results.tsx` around lines 22 - 30,
The catch block in copyToClipboard silently swallows failures; update
copyToClipboard to handle errors by (1) logging the error (console.error or
processLogger) including the caught error and context (text/field), (2)
providing user feedback such as setting an error state (e.g., setCopiedField to
'error' or a new setCopyError state) that the UI can render briefly, and (3)
optionally falling back to document.execCommand('copy') if available; reference
copyToClipboard, navigator.clipboard.writeText, and setCopiedField when adding
the error handling and UI state updates.
templates/default/client/src/pages/steps/EnterInputs.tsx (2)

63-68: First publishInput transaction is not awaited for confirmation before the second.

Both inputs are published sequentially, but if the first transaction fails after being submitted (e.g., reverts on-chain), the second will still be attempted. Consider either:

  1. Awaiting transaction receipts between calls, or
  2. Documenting that partial failure is acceptable for this flow.
💡 Suggested improvement for robustness
+      const publicClient = sdk.sdk?.getPublicClient()
+      
       // Publish first input
-      await publishInput(walletClient, e3State.id, toHex(encryptedInput1), address, contracts.e3Program)
+      const hash1 = await publishInput(walletClient, e3State.id, toHex(encryptedInput1), address, contracts.e3Program)
+      if (publicClient) {
+        await publicClient.waitForTransactionReceipt({ hash: hash1 })
+      }

       // Publish second input
       const hash2 = await publishInput(walletClient, e3State.id, toHex(encryptedInput2), address, contracts.e3Program)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/client/src/pages/steps/EnterInputs.tsx` around lines 63 -
68, The first publishInput call is not confirmed before sending the second,
risking partial failure; modify the flow in EnterInputs.tsx to wait for the
first transaction to be mined/confirmed (use the wallet client's
transaction-wait/receipt mechanism) after calling publishInput(walletClient,
e3State.id, toHex(encryptedInput1), address, contracts.e3Program) and before
invoking publishInput for encryptedInput2 (whose return value is currently
assigned to hash2), and handle errors/retries so you don't proceed to the second
publish if the first failed.

61-61: Consider using viem's built-in toHex utility.

Viem provides a toHex function that handles byte array conversion. This would reduce custom code and leverage the well-tested library implementation.

💡 Suggested change
-import { hexToBytes } from 'viem'
+import { hexToBytes, toHex } from 'viem'
 ...
-      const toHex = (bytes: Uint8Array): `0x${string}` => `0x${Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('')}`
+      // Use viem's toHex directly on encryptedInput1 and encryptedInput2
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/client/src/pages/steps/EnterInputs.tsx` at line 61, Replace
the custom toHex implementation in EnterInputs.tsx with viem's built-in toHex:
import toHex from 'viem' (or named import per viem version) and use that
function wherever the local toHex const is referenced (remove the const toHex =
... declaration). Ensure the types expected by callers (Uint8Array input and
`0x${string}` return) align with viem's toHex signature and adjust any local
type annotations if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@templates/default/scripts/dev_frontend.sh`:
- Line 11: The current subshell uses unsafe export $(enclave print-env ...)
which causes SC2046 word-splitting and will silently proceed if output is empty;
replace that pattern by capturing the output of enclave print-env --vite --chain
localhost into a variable, check it’s non-empty, and then safely export each
KEY=VALUE line (e.g., echo "$env" | while IFS= read -r line; do export "$line";
done) before running pnpm dev so you avoid word-splitting and handle empty
output; update the pipeline that runs enclave print-env, the export logic, and
the subsequent pnpm dev invocation in the dev_frontend.sh script.

---

Nitpick comments:
In `@templates/default/client/src/pages/steps/EnterInputs.tsx`:
- Around line 63-68: The first publishInput call is not confirmed before sending
the second, risking partial failure; modify the flow in EnterInputs.tsx to wait
for the first transaction to be mined/confirmed (use the wallet client's
transaction-wait/receipt mechanism) after calling publishInput(walletClient,
e3State.id, toHex(encryptedInput1), address, contracts.e3Program) and before
invoking publishInput for encryptedInput2 (whose return value is currently
assigned to hash2), and handle errors/retries so you don't proceed to the second
publish if the first failed.
- Line 61: Replace the custom toHex implementation in EnterInputs.tsx with
viem's built-in toHex: import toHex from 'viem' (or named import per viem
version) and use that function wherever the local toHex const is referenced
(remove the const toHex = ... declaration). Ensure the types expected by callers
(Uint8Array input and `0x${string}` return) align with viem's toHex signature
and adjust any local type annotations if needed.

In `@templates/default/client/src/pages/steps/Results.tsx`:
- Around line 22-30: The catch block in copyToClipboard silently swallows
failures; update copyToClipboard to handle errors by (1) logging the error
(console.error or processLogger) including the caught error and context
(text/field), (2) providing user feedback such as setting an error state (e.g.,
setCopiedField to 'error' or a new setCopyError state) that the UI can render
briefly, and (3) optionally falling back to document.execCommand('copy') if
available; reference copyToClipboard, navigator.clipboard.writeText, and
setCopiedField when adding the error handling and UI state updates.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: df88df95-b179-4690-99d6-b9a80e590ee2

📥 Commits

Reviewing files that changed from the base of the PR and between c5ce039 and 95add68.

📒 Files selected for processing (15)
  • packages/enclave-react/README.md
  • templates/default/client/src/context/WizardContext.tsx
  • templates/default/client/src/pages/WizardRoutes.tsx
  • templates/default/client/src/pages/components/ErrorDisplay.tsx
  • templates/default/client/src/pages/steps/ActivateE3.tsx
  • templates/default/client/src/pages/steps/EncryptSubmit.tsx
  • templates/default/client/src/pages/steps/EnterInputs.tsx
  • templates/default/client/src/pages/steps/RequestComputation.tsx
  • templates/default/client/src/pages/steps/Results.tsx
  • templates/default/client/src/utils/error-formatting.ts
  • templates/default/client/src/utils/input.ts
  • templates/default/deployed_contracts.json
  • templates/default/enclave.config.yaml
  • templates/default/scripts/dev_all_concurrently.sh
  • templates/default/scripts/dev_frontend.sh
💤 Files with no reviewable changes (3)
  • templates/default/client/src/pages/steps/ActivateE3.tsx
  • packages/enclave-react/README.md
  • templates/default/client/src/utils/error-formatting.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • templates/default/enclave.config.yaml
  • templates/default/scripts/dev_all_concurrently.sh
  • templates/default/client/src/pages/components/ErrorDisplay.tsx
  • templates/default/deployed_contracts.json

@cedoor cedoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK

@ctrlc03 ctrlc03 enabled auto-merge (squash) March 17, 2026 15:12
@ctrlc03 ctrlc03 merged commit d053ae8 into main Mar 17, 2026
27 checks passed
@github-actions github-actions Bot deleted the fix/template branch March 25, 2026 03:17
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.

Missing token approval for template client flow

2 participants