-
Notifications
You must be signed in to change notification settings - Fork 10
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
Improve COA creation transaction to gracefully handle existing COA in storage #500
Conversation
WalkthroughThe changes introduce enhancements to the transaction logic for creating a Cadence-owned account, ensuring that if an account already exists for the signer, the process exits early to avoid unnecessary operations. Additionally, error handling in the requester service is improved by providing detailed error messages during the COA resource creation, enhancing robustness and clarity in error management. Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- services/requester/cadence/create_coa.cdc (1 hunks)
- services/requester/requester.go (1 hunks)
Additional comments not posted (3)
services/requester/cadence/create_coa.cdc (2)
13-16
: Early exit logic is well-implemented.The check for an existing Cadence-owned account and early exit if found is a good practice to avoid unnecessary operations.
26-29
: Proper use of storage saving.Saving the newly created account to storage is done correctly. The path and method used are appropriate for the operation.
services/requester/requester.go (1)
191-195
: Enhanced error handling in COA creation.The modifications to return detailed error messages instead of just logging them improve the robustness and clarity of the function. This change ensures that errors are properly communicated back to the caller, which is crucial for better error management.
let vaultRef = self.auth.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>( | ||
from: /storage/flowTokenVault | ||
) ?? panic("Could not borrow reference to the owner's Vault!") | ||
let vault <- vaultRef.withdraw(amount: amount) as! @FlowToken.Vault |
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.
Potential risk with force unwrapping.
Using as!
for unwrapping the vault withdrawal could lead to a runtime panic if the cast fails. Consider handling this scenario more gracefully to improve error resilience.
Suggest using a safer casting method or adding error handling around this operation.
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.
Very nice idea to handle that in tx
Closes: #499
Description
This will allow us to distinguish the actual errors that might arise from the COA creation transaction, as until now we ignored the returned error.
For contributor use:
master
branchFiles changed
in the Github PR explorerSummary by CodeRabbit
New Features
Bug Fixes
Documentation