-
Notifications
You must be signed in to change notification settings - Fork 48
Rwa fixes #550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rwa fixes #550
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis PR refactors RWA token transfer logic by extracting core transfer checks into a new non-authorized helper function and restructuring Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #550 +/- ##
==========================================
+ Coverage 96.07% 96.11% +0.04%
==========================================
Files 54 54
Lines 5201 5206 +5
==========================================
+ Hits 4997 5004 +7
+ Misses 204 202 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @packages/tokens/src/rwa/storage.rs:
- Line 625: The doc comment for the event data currently uses incorrect quote
formatting around the code snippet; replace /// * data - `["to_muxed_id:
Option<u64>, amount: i128"]` with a properly formatted inline code or list, e.g.
/// * data - [`to_muxed_id: Option<u64>, amount: i128`] or /// * data -
`to_muxed_id: Option<u64>, amount: i128`, so the identifiers to_muxed_id and
amount render correctly in the documentation.
- Around line 596-633: The helper function transfer_no_auth is marked pub but
intentionally bypasses authorization, creating a security risk if called
externally; change its visibility from pub to pub(crate) so only crate-internal
code can call it, update any external callers to use the authorized wrappers
(transfer / transfer_from) or add crate-level accessors if needed, and adjust
the function's docstring/comments to reflect the reduced visibility (retain the
security warning).
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/tokens/src/rwa/storage.rs
⏰ 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). (1)
- GitHub Check: clippy-fmt-test (ubuntu-latest)
🔇 Additional comments (2)
packages/tokens/src/rwa/storage.rs (2)
677-694: LGTM! Clean refactoring with proper authorization.The function now correctly enforces authorization on the
fromaddress and delegates the transfer logic to the centralized helper. The comprehensive documentation clearly outlines all the additional checks performed compared to the base implementation.
702-706: Excellent fix for the authorization bug!This change correctly addresses the authorization issue. By calling
transfer_no_authinstead oftransfer, the function now properly enforces authorization only on thespender(who must be approved) without incorrectly requiring additional authorization from thefromaddress. This is the standard and correct behavior for allowance-based transfers.
brozorec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but I'd organize it differently. What about:
- adding
validate_transfer()with all the pause and freeze checks + identity verifications + the compliance check and hook - calling
validate_transfer()andBase::updateand emitting events intransfer()andtransfer_from()?
|
I like |
|
@brozorec here is some subjective design choice I had to make, and open to discussion about it:
This is a very subjective choice, wondering your opinions on this |
Would be re-naming |
|
I don't like that approach because we emit transfers in the function, and that is for validation. Having validation and hook together does not make sense to me tbh |
Then I'd go with recreating the client in It has no impact on perf/cost and looks cleaner to me as well. |
|
that is what I'm inclining towards also for cleanness. Thanks for the input! |
Co-authored-by: Boyan Barakov <[email protected]>


Fixes #549
PR Checklist
@brozorec take your time on inspecting this one, this is important :)
Reminder to myself: we should merge this after the release
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.