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

Update multi wallet balance #1315

Merged
merged 5 commits into from
Mar 18, 2021
Merged

Update multi wallet balance #1315

merged 5 commits into from
Mar 18, 2021

Conversation

jowlee
Copy link
Contributor

@jowlee jowlee commented Mar 16, 2021

Description

Adds support for updating the user's audio balance in discovery with multiple wallets

Changes
  • Adds a migration to add a column associated_wallets_balance to the user_balances table.
    • This column represents the sum of the total balance, staked, and delegated amounts across all the associated wallets
  • Adds the DelegateManager and Staking contracts to discovery
    • Needed to fetch the staking and delegation amounts for the associated wallets.
  • Updates the populate_user_metadata function to add a field associated_wallets_balance, so that the client can sum the totals to calculate the user's badge.

Tests

I ran the system locally, added associated wallets, and staked and delegated with those wallets. I checked that the balances were updated in the Discovery DB and that the correct amounts were passed back when querying for the user.

Copy link
Contributor

@sddioulde sddioulde left a comment

Choose a reason for hiding this comment

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

looks good

Copy link
Contributor

@piazzatron piazzatron left a comment

Choose a reason for hiding this comment

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

Looks great!

balance = token_contract.functions.balanceOf(wallet).call()
delegation_balance = delegate_manager_contract.functions.getTotalDelegatorStake(wallet).call()
stake_balance = staking_contract.functions.totalStakedFor(wallet).call()
associated_balance += balance + delegation_balance + stake_balance
Copy link
Contributor

Choose a reason for hiding this comment

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

So these are definitely safe to just add together, yeah?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah!

@jowlee jowlee merged commit 59d220c into master Mar 18, 2021
@jowlee jowlee deleted the jowlee-update-wallet-staked branch March 18, 2021 13:37
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.

None yet

5 participants