feat: add appeal bond support and appeal-bond command#285
Conversation
- `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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds optional bond support to appeals (CLI flag Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
🧹 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
undefinedmay 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
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
package.jsonsrc/commands/transactions/appeal.tssrc/commands/transactions/index.tstests/actions/appeal.test.tstests/commands/appeal.test.ts
Testnets now use proper HTTPS domain URLs: - https://rpc-bradbury.genlayer.com - https://rpc-asimov.genlayer.com
Summary
genlayer appeal <txId>to auto-calculate minimum bond, display it, and confirm before submitting. Supports--bond <amount>for explicit bond (e.g.500gen)genlayer appeal-bond <txId>read-only command to check minimum appeal bondTest plan
--helpshows correct optionsSummary by CodeRabbit
New Features
Improvements
Tests
Chores