Skip to content

fix(wallet): idempotent ops#263

Open
mitinarseny wants to merge 5 commits into
mainfrom
fix/wallet-idempotent-ops
Open

fix(wallet): idempotent ops#263
mitinarseny wants to merge 5 commits into
mainfrom
fix/wallet-idempotent-ops

Conversation

@mitinarseny
Copy link
Copy Markdown
Collaborator

@mitinarseny mitinarseny commented May 6, 2026

This PR makes all current ops to have idempotent semantics

Summary by CodeRabbit

  • Bug Fixes

    • Wallet operations (SetSignatureMode, AddExtension, RemoveExtension) are now idempotent—repeating the same operation returns success instead of an error.
    • Events are only emitted when actual state changes occur, reducing unnecessary event noise.
  • Removals

    • Custom wallet operations are no longer supported.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@mitinarseny has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 18 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c8ff869-4163-4140-8f11-2f888f2bc9b7

📥 Commits

Reviewing files that changed from the base of the PR and between 6c8a531 and 0c380fd.

📒 Files selected for processing (2)
  • contracts/wallet/src/contract/mod.rs
  • contracts/wallet/src/request/ops.rs
📝 Walkthrough

Walkthrough

The wallet contract refactors three operations (SetSignatureMode, AddExtension, RemoveExtension) to return success immediately when requests are idempotent, emitting events only on actual state changes. Unused error variants are removed, and the Custom operation variant is eliminated from the WalletOp enum.

Changes

Wallet Operation Idempotency & Event Emission

Layer / File(s) Summary
API & Error Cleanup
contracts/wallet/src/request/ops.rs, contracts/wallet/src/error.rs
WalletOp::Custom variant removed; error variants ThisSignatureModeAlreadySet and ExtensionEnabled(AccountId) are no longer defined.
Operation Logic
contracts/wallet/src/contract/mod.rs
set_signature_mode, add_extension, and remove_extension now return Ok(()) immediately when no state change occurs; events (SignatureModeSet, ExtensionAdded, ExtensionRemoved) emit only after successful state updates. check_lockout() is invoked only when appropriate.
Documentation
contracts/wallet/src/lib.rs
Doc comments for w_execute_signed expanded to describe failure conditions; w_execute_extension formatting adjusted to emphasize non-zero deposit acceptance.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 These ops now leap with quiet grace,
Emitting events only when state shifts place,
No needless noise, just changes real,
Idempotency sealed with a proper feel,
Custom ops fade, the wallet stands tall!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(wallet): idempotent ops' directly matches the PR's main objective of making wallet operations idempotent, clearly summarizing the primary change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 fix/wallet-idempotent-ops

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
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contracts/wallet/src/request/ops.rs`:
- Line 7: Fix the public API documentation typo: change "expess" to "express" in
the module-level comment string that starts with "Currently, all operations are
idempotent, i.e. they expess an intent on" so the sentence reads "express an
intent on" (update the doc comment in contracts/wallet/src/request/ops.rs
accordingly).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 427644c0-f0ac-48a4-8036-ed5d869b153d

📥 Commits

Reviewing files that changed from the base of the PR and between 5350a47 and 6c8a531.

📒 Files selected for processing (4)
  • contracts/wallet/src/contract/mod.rs
  • contracts/wallet/src/error.rs
  • contracts/wallet/src/lib.rs
  • contracts/wallet/src/request/ops.rs
💤 Files with no reviewable changes (1)
  • contracts/wallet/src/error.rs

Comment thread contracts/wallet/src/request/ops.rs Outdated
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