Skip to content

feat: add appeal bond support and appeal-bond command#285

Merged
MuncleUscles merged 3 commits intomainfrom
feat/appeal-bond-support
Mar 19, 2026
Merged

feat: add appeal bond support and appeal-bond command#285
MuncleUscles merged 3 commits intomainfrom
feat/appeal-bond-support

Conversation

@MuncleUscles
Copy link
Member

@MuncleUscles MuncleUscles commented Mar 19, 2026

Summary

  • Enhanced genlayer appeal <txId> to auto-calculate minimum bond, display it, and confirm before submitting. Supports --bond <amount> for explicit bond (e.g. 500gen)
  • New genlayer appeal-bond <txId> read-only command to check minimum appeal bond
  • Bumps genlayer-js to 0.21.4 (getMinAppealBond + auto-bond appeal support)

Test plan

  • 7 action tests (auto-bond, explicit bond, bond calc failure fallback, errors, custom RPC, appeal-bond success/error)
  • 7 command tests (default options, RPC, bond flag, unrecognized options, appeal-bond command)
  • All 445 tests pass
  • CLI build succeeds, --help shows correct options

Summary by CodeRabbit

  • New Features

    • Added an appeal-bond command to fetch the minimum appeal bond for a transaction.
    • Added a --bond option to the appeal command to specify a custom bond amount.
  • Improvements

    • Appeal actions now require explicit user confirmation before submission.
    • Improved spinner/messaging while waiting and on successful appeal execution.
  • Tests

    • Expanded tests to cover bond lookup, explicit bond usage, fallbacks, and the new appeal-bond command.
  • Chores

    • Updated genlayer-js dependency to v0.22.1.

- `genlayer appeal <txId>` now auto-calculates minimum bond via
  getMinAppealBond, shows it, and asks for confirmation before submitting
- `--bond <amount>` option to specify explicit bond (e.g. 500gen)
- New `genlayer appeal-bond <txId>` read-only command to check
  minimum appeal bond without submitting
- Bumps genlayer-js to 0.21.4 for getMinAppealBond + auto-bond support
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 516d6178-fb7d-4e8d-99cb-b0c60803fa28

📥 Commits

Reviewing files that changed from the base of the PR and between 1bedff2 and e063b78.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • package.json

📝 Walkthrough

Walkthrough

Adds optional bond support to appeals (CLI flag --bond), auto-fetches minimum bond when omitted, prompts for confirmation, submits appeals with an explicit value, adds an appeal-bond subcommand to show the minimum bond, updates tests and mocks, and bumps genlayer-js dependency to ^0.22.1.

Changes

Cohort / File(s) Summary
Dependency
package.json
Bumped genlayer-js dependency from ^0.21.3 to ^0.22.1.
Core Appeal Logic
src/commands/transactions/appeal.ts
Added bond?: string to AppealOptions; compute value from provided bond (via parseStakingAmount) or by calling client.getMinAppealBond({ txId }) with fallback on error; removed initializeConsensusSmartContract() call; added confirmation prompt before submission; pass value into client.appealTransaction; updated spinner texts; added new appealBond(...) method and AppealBondOptions type.
CLI Wiring
src/commands/transactions/index.ts
Added --bond <amount> option to appeal command and new appeal-bond <txId> subcommand with --rpc option wired to AppealAction.appealBond.
Action Tests
tests/actions/appeal.test.ts
Reworked genlayer-js mock factory to wrap original module and mock createClient/createAccount; extended mockClient with getMinAppealBond; updated tests to cover auto-calculated bond flow, explicit --bond usage, fallback on bond lookup failure, appealBond success and error paths; adjusted spinner/confirm stubs and expectations.
Command Tests
tests/commands/appeal.test.ts
Added tests asserting --bond is forwarded to AppealAction.appeal and new appeal-bond command invokes AppealAction.appealBond (with and without --rpc).

Sequence Diagram(s)

sequenceDiagram
    participant User as CLI/User
    participant CLI as Command Parser
    participant Action as AppealAction
    participant Client as GenLayer Client
    participant Spinner as Spinner/Prompts

    rect rgba(200,150,255,0.5)
    Note over User,Client: appeal command (explicit bond)
    User->>CLI: appeal <txId> --bond "100gen"
    CLI->>Action: appeal({txId, bond: "100gen"})
    Action->>Action: parseStakingAmount("100gen")
    Action->>Spinner: confirmPrompt("Proceed with appeal?")
    Spinner-->>Action: confirmed
    Action->>Client: appealTransaction({txId, value: 100000...n})
    Client-->>Action: receipt
    Action->>Spinner: succeed("Appeal successfully executed")
    end

    rect rgba(150,200,255,0.5)
    Note over User,Client: appeal command (auto-calc bond)
    User->>CLI: appeal <txId>
    CLI->>Action: appeal({txId})
    Action->>Client: getMinAppealBond({txId})
    Client-->>Action: minBond
    Action->>Action: formatStakingAmount(minBond)
    Action->>Spinner: confirmPrompt("Proceed with appeal?")
    Spinner-->>Action: confirmed
    Action->>Client: appealTransaction({txId, value: minBond})
    Client-->>Action: receipt
    Action->>Spinner: succeed("Appeal successfully executed")
    end

    rect rgba(255,200,150,0.5)
    Note over User,Client: appeal-bond command
    User->>CLI: appeal-bond <txId> [--rpc <url>]
    CLI->>Action: appealBond({txId, rpc?})
    Action->>Client: getMinAppealBond({txId})
    Client-->>Action: minBond
    Action->>Spinner: succeed("Minimum appeal bond: X GEN")
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • feat: appeal command #233: Prior changes to AppealAction/appeal command that overlap with bond handling, appeal flow, and tests.

Suggested reviewers

  • cristiam86
  • danielrc888

Poem

🐇 I nibbled code and found a bond,

A prompt, a parse, then confirmation fond.
Min bond fetched or user-sent,
The appeal flew with value meant.
Hooray — tests pass, carrots spent! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main changes: adding appeal bond support and the appeal-bond command, which are the primary features introduced across multiple files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/appeal-bond-support
📝 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.

Copy link

@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.

🧹 Nitpick comments (4)
tests/actions/appeal.test.ts (1)

4-4: Use @/* path alias for imports.

As per coding guidelines, use @/* path alias to reference ./src/*.

♻️ Suggested fix
-import {AppealAction} from "../../src/commands/transactions/appeal";
+import {AppealAction} from "@/commands/transactions/appeal";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/actions/appeal.test.ts` at line 4, The import in the test uses a
relative path; update it to use the project path alias so it follows the coding
guideline: replace the "../../src/commands/transactions/appeal" import with the
alias-based path that points to the same module (referencing AppealAction from
the AppealAction export in the appeal module) so the test imports AppealAction
via "@/commands/transactions/appeal" instead of the relative path.
src/commands/transactions/appeal.ts (2)

3-3: Use @/* path alias for imports.

The import should use the configured path alias instead of a relative path. As per coding guidelines, use @/* path alias to reference ./src/*.

♻️ Suggested fix
-import {BaseAction} from "../../lib/actions/BaseAction";
+import {BaseAction} from "@/lib/actions/BaseAction";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/transactions/appeal.ts` at line 3, The import in appeal.ts uses
a relative path for BaseAction; replace the relative import "import {BaseAction}
from '../../lib/actions/BaseAction'" with the project path-alias form using @
(e.g., import {BaseAction} from '@/lib/actions/BaseAction') so it follows the
configured `@/`* alias; update any other similar imports in this file to use `@/`*
as well.

40-43: Consider informing the user when bond calculation fails.

The silent fallback to undefined may leave users unaware that the minimum bond couldn't be determined. A warning message would improve UX before the confirmation prompt.

💡 Suggested improvement
       } catch {
         this.stopSpinner();
+        this.logWarning("Could not calculate minimum bond. The transaction will use the default bond amount.");
         value = undefined;
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/transactions/appeal.ts` around lines 40 - 43, The catch block
that sets `value = undefined` after `this.stopSpinner()` should also inform the
user that the minimum bond calculation failed; update the catch in the appeal
flow (where `this.stopSpinner()` and `value` are handled) to emit a clear
warning (e.g., `this.warn(...)` or `this.log(...)`) stating that the minimum
bond couldn't be determined and that the code will proceed without it before
continuing to the confirmation prompt. Ensure the message mentions the bond
calculation failure so users understand why `value` is undefined.
tests/commands/appeal.test.ts (1)

2-4: Use path aliases for imports.

The imports should use the configured path aliases. As per coding guidelines, use @/* for ./src/* references.

♻️ Suggested fix
-import {AppealAction} from "../../src/commands/transactions/appeal";
+import {AppealAction} from "@/commands/transactions/appeal";
 import {vi, describe, beforeEach, afterEach, test, expect} from "vitest";
-import {initializeTransactionsCommands} from "../../src/commands/transactions";
+import {initializeTransactionsCommands} from "@/commands/transactions";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/commands/appeal.test.ts` around lines 2 - 4, Update the import
statements in tests/commands/appeal.test.ts to use the project path alias
instead of relative paths: replace the relative import of AppealAction
("../../src/commands/transactions/appeal") and the import of
initializeTransactionsCommands ("../../src/commands/transactions") with their `@/`
equivalents so the test imports use "@/commands/transactions/appeal" for
AppealAction and "@/commands/transactions" for initializeTransactionsCommands;
ensure the vitest import remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/commands/transactions/appeal.ts`:
- Line 3: The import in appeal.ts uses a relative path for BaseAction; replace
the relative import "import {BaseAction} from '../../lib/actions/BaseAction'"
with the project path-alias form using @ (e.g., import {BaseAction} from
'@/lib/actions/BaseAction') so it follows the configured `@/`* alias; update any
other similar imports in this file to use `@/`* as well.
- Around line 40-43: The catch block that sets `value = undefined` after
`this.stopSpinner()` should also inform the user that the minimum bond
calculation failed; update the catch in the appeal flow (where
`this.stopSpinner()` and `value` are handled) to emit a clear warning (e.g.,
`this.warn(...)` or `this.log(...)`) stating that the minimum bond couldn't be
determined and that the code will proceed without it before continuing to the
confirmation prompt. Ensure the message mentions the bond calculation failure so
users understand why `value` is undefined.

In `@tests/actions/appeal.test.ts`:
- Line 4: The import in the test uses a relative path; update it to use the
project path alias so it follows the coding guideline: replace the
"../../src/commands/transactions/appeal" import with the alias-based path that
points to the same module (referencing AppealAction from the AppealAction export
in the appeal module) so the test imports AppealAction via
"@/commands/transactions/appeal" instead of the relative path.

In `@tests/commands/appeal.test.ts`:
- Around line 2-4: Update the import statements in tests/commands/appeal.test.ts
to use the project path alias instead of relative paths: replace the relative
import of AppealAction ("../../src/commands/transactions/appeal") and the import
of initializeTransactionsCommands ("../../src/commands/transactions") with their
`@/` equivalents so the test imports use "@/commands/transactions/appeal" for
AppealAction and "@/commands/transactions" for initializeTransactionsCommands;
ensure the vitest import remains unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 840f8ae4-e76d-4a57-bab2-cc007d68eeb5

📥 Commits

Reviewing files that changed from the base of the PR and between 779f114 and 7c1bdb9.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • package.json
  • src/commands/transactions/appeal.ts
  • src/commands/transactions/index.ts
  • tests/actions/appeal.test.ts
  • tests/commands/appeal.test.ts

@MuncleUscles MuncleUscles merged commit 9e51c60 into main Mar 19, 2026
3 checks passed
@MuncleUscles MuncleUscles deleted the feat/appeal-bond-support branch March 19, 2026 10:59
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.

1 participant