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

Use dedicated struct for wallet balance. #366

Open
KnowWhoami opened this issue Jan 6, 2025 · 7 comments
Open

Use dedicated struct for wallet balance. #366

KnowWhoami opened this issue Jan 6, 2025 · 7 comments
Labels
apps App related improvements enhancement This enhances the code and improves stuffs
Milestone

Comments

@KnowWhoami
Copy link
Collaborator

Description:

Right now, our cli-apps have many rpc commands for showing balances of each utxo type and their total as shown below :

  1. maker-cli:

    SeedBalance,
    /// Returns the total swap coin balance
    SwapBalance,
    /// Returns the total live contract balance
    ContractBalance,
    /// Returns the total fidelity balance
    FidelityBalance,

  2. taker-cli:

    SeedBalance,
    /// Returns the total swap coin balance
    SwapBalance,
    /// Returns the total live contract balance
    ContractBalance,
    /// Returns the total balance of taker wallet
    TotalBalance,

Due to which , these cli-apps now have many rpc commands and could become a bad UX from user perspective as they would have to call different command to see a particular utxo balance.
Also TotalBalance rpc command in taker cli app -> just show the total balance of the wallet -> It doesn't denote that which utxos type contribute to how much balance , which the user manually have to calculate by juggling among these rpc commands.

Proposed Solution:

Instead, we can have a dedicated struct for denoting balances of each type as:

struct Balance {
    seed: Amount,
    swap: Amount,
    contract: Amount,
    fidelity: Amount,
    spendable:Amount
}

This struct would remove redundancy as we just to need to have single rpc command get-balance which would give balance of the wallet in this format , describing all the balance info , which a user must need to know.

@KnowWhoami KnowWhoami added enhancement This enhances the code and improves stuffs apps App related improvements labels Jan 6, 2025
@KnowWhoami KnowWhoami added this to the v0.1.1 milestone Jan 6, 2025
@Levi0804
Copy link

Hello, can I take this one and work on it?

@mojoX911
Copy link

Sure give it a shot.

@Levi0804
Copy link

Hey, I noticed the files mentioned in this issue have changed, especially the variants of the Command enum. Could you update the details to reflect the current state? thanks!

@mojoX911
Copy link

Current structure is mostly the same with some name changes. Irrespective of that the new balance structure will look as below.

struct Balance {
    regular: Amount, #aka seed balance
    swap: Amount, #only the incoming swap coin balance
    contract: Amount, #all unfinished timelock contract balance. 
    fidelity: Amount, #this only applies to the maker.
    spendable:Amount #seed + swap balance
}

You wanna build on top of #380 as some new APIs for calculating the above ones are added there.

@Levi0804
Copy link

I have started working on the maker cli part and I was wondering if it’s okay to push the incomplete changes for you to take a look. It would be great to know if I’m heading in the right direction before I proceed further.

@mojoX911
Copy link

Sure, open up a PR.

@Levi0804
Copy link

@mojoX911 I created a PR #385

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apps App related improvements enhancement This enhances the code and improves stuffs
Projects
None yet
Development

No branches or pull requests

3 participants