Skip to content
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

feat(wallet): use set_account_metadata on holds to make operation atomic #1338

Merged
merged 1 commit into from Mar 19, 2024

Conversation

gfyrag
Copy link
Contributor

@gfyrag gfyrag commented Mar 18, 2024

Fixes ENG-726

Summary by CodeRabbit

  • New Features
    • Enhanced script construction for debit transactions, including support for ledger metadata.
    • Introduced a metadata handling mechanism in the wallet management logic.
  • Bug Fixes
    • Corrected the string representation of keys in test data to remove unnecessary escape characters.
  • Refactor
    • Updated references and function signatures in the ledger component to streamline types and functions.
  • Tests
    • Adjusted test cases to align with new parameters and logic in script generation for debit transactions.
  • Documentation
    • No visible changes to end-users.

@gfyrag gfyrag requested a review from a team as a code owner March 18, 2024 14:38
Copy link
Contributor

coderabbitai bot commented Mar 18, 2024

Walkthrough

The changes across various files primarily focus on enhancing the debit transaction process within a ledger system. This includes updating references and types for program resources, correcting data representations, and introducing metadata handling in debit transactions. The modifications aim to make debit holds atomic and address issues related to incorrect balance holds, thereby improving the reliability and functionality of the wallet management system.

Changes

Files Change Summary
ee/wallets/pkg/api/handler_wallets_debit_test.go
ee/wallets/pkg/manager.go
ee/wallets/pkg/scripts.go
Updated BuildDebitWalletScript calls with additional parameters and modified script generation logic to include metadata handling. Introduced ledger metadata mapping.
ee/wallets/pkg/numscript/debit-wallet.num Added code block to set account metadata in debit transactions.
ee/wallets/pkg/scripts.go Added import for strconv, modified renderTemplate function, and updated BuildDebitWalletScript function signature to accept metadata.

Assessment against linked issues

Objective Addressed Explanation
Make debit holds atomic using set_account_meta (ENG-726)

Poem

🐇 In the world of code, where ledgers unfold,
A rabbit hopped in, with changes bold.
Metadata mapped, and scripts anew,
Balances fixed, no errors in view.
🌟 With every commit, the ledger grows strong,
In this digital burrow, where bytes belong.
Cheers to the devs, with minds so bright,
For making the ledger's future light. 🚀

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@gfyrag gfyrag force-pushed the feat/wallets-atomic-debits branch from fc67162 to 3d34b0d Compare March 18, 2024 14:41
@gfyrag gfyrag changed the title use set_account_metadata on holds to make operation atomic feat(wallet): use set_account_metadata on holds to make operation atomic Mar 18, 2024
@gfyrag gfyrag force-pushed the feat/wallets-atomic-debits branch from 3d34b0d to 8aec220 Compare March 18, 2024 14:57
Base automatically changed from feat/ledger-extends-strings-support-in-numscript to main March 18, 2024 15:53
@gfyrag gfyrag force-pushed the feat/wallets-atomic-debits branch from 8aec220 to e171538 Compare March 18, 2024 16:29
@gfyrag gfyrag changed the base branch from main to fix/ledger-string-literal March 18, 2024 16:30
@@ -1,6 +1,7 @@
package wallet

import (
"fmt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of the fmt import is necessary for the debug print statement introduced. However, using fmt.Println for debugging in library code is not advisable.

Consider removing the debug print statement or replacing it with a proper logging mechanism.

- fmt.Println(v)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
"fmt"
"fmt"

Base automatically changed from fix/ledger-string-literal to main March 18, 2024 17:00
@gfyrag gfyrag force-pushed the feat/wallets-atomic-debits branch from e171538 to 82937a8 Compare March 19, 2024 09:29
@gfyrag gfyrag enabled auto-merge March 19, 2024 09:32
@gfyrag gfyrag added this pull request to the merge queue Mar 19, 2024
Copy link
Contributor

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1518e8d and 82937a8.
Files selected for processing (4)
  • ee/wallets/pkg/api/handler_wallets_debit_test.go (11 hunks)
  • ee/wallets/pkg/manager.go (2 hunks)
  • ee/wallets/pkg/numscript/debit-wallet.num (1 hunks)
  • ee/wallets/pkg/scripts.go (3 hunks)
Files skipped from review as they are similar to previous changes (4)
  • ee/wallets/pkg/api/handler_wallets_debit_test.go
  • ee/wallets/pkg/manager.go
  • ee/wallets/pkg/numscript/debit-wallet.num
  • ee/wallets/pkg/scripts.go

Merged via the queue into main with commit ede425c Mar 19, 2024
10 checks passed
@gfyrag gfyrag deleted the feat/wallets-atomic-debits branch March 19, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants