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: add symbol name to the x/uibc QueryAllOutflowsResponse #2374

Merged
merged 16 commits into from
Jan 2, 2024

Conversation

robert-zaremba
Copy link
Member

@robert-zaremba robert-zaremba commented Jan 2, 2024

Description

We extend the QueryAllOutflowsResponse by adding symbol to each outflow entry.

Summary by CodeRabbit

  • New Features

    • Enhanced the display of outflow entries by including token symbols for better identification.
    • Introduced a new data structure to represent coins with their symbol names.
  • Improvements

    • Upgraded query responses to provide more comprehensive data.
  • Documentation

    • Updated CHANGELOG with details of new improvements.
  • Tests

    • Added tests for new utility function converting maps to slices.
  • Refactor

    • Streamlined query handling by shifting method calls within the application's internal structure.
    • Improved code organization by adjusting import paths and method inclusions.

@robert-zaremba robert-zaremba requested a review from a team as a code owner January 2, 2024 13:57
Copy link
Contributor

coderabbitai bot commented Jan 2, 2024

Walkthrough

The updates across various files in the Umee protocol reflect a focus on enhancing data structures and improving query functionalities. A new DecCoinSymbol type is introduced, extending the coin representation. The MapToSlice utility is added, along with its test, indicating a data transformation need. The Querier structure is now favored over direct Keeper calls, suggesting a shift in design pattern. Additionally, token symbol handling is improved, and new methods for token retrieval are implemented across interfaces and mocks.

Changes

File Path Change Summary
proto/umee/uibc/v1/query.proto, proto/umee/uibc/v1/uibc.proto Extended data structures and modified query response formats.
util/genmap/genmap.go, util/genmap/genmap_test.go Introduced MapToSlice function and corresponding tests.
x/leverage/keeper/grpc_query.go, x/uibc/quota/grpc_query.go Shifted from Keeper to Querier methods and enhanced token symbol processing.
x/metoken/mocks/keepers.go, x/uibc/expected_keepers.go, x/uibc/mocks/keepers.go, x/uibc/quota/mocks_test.go Added GetAllRegisteredTokens method and updated import paths and mock structures.

🐇
In the realm of code where the data streams flow,
A rabbit hopped in, with updates in tow.
Symbols and slices, queries refined,
A leap in the logic, with clarity aligned. 🌟
🐇

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 with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git 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.
    • @coderabbitai read the files in the src/scheduler package and generate 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.

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.

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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ed181c6 and 439d983.
Files ignored due to filter (2)
  • x/uibc/query.pb.go
  • x/uibc/uibc.pb.go
Files selected for processing (10)
  • proto/umee/uibc/v1/query.proto (2 hunks)
  • proto/umee/uibc/v1/uibc.proto (1 hunks)
  • util/genmap/genmap.go (1 hunks)
  • util/genmap/genmap_test.go (2 hunks)
  • x/leverage/keeper/grpc_query.go (16 hunks)
  • x/metoken/mocks/keepers.go (1 hunks)
  • x/uibc/expected_keepers.go (1 hunks)
  • x/uibc/mocks/keepers.go (1 hunks)
  • x/uibc/quota/grpc_query.go (1 hunks)
  • x/uibc/quota/mocks_test.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • x/metoken/mocks/keepers.go
Additional comments: 20
proto/umee/uibc/v1/uibc.proto (1)
  • 18-27: The DecCoinSymbol message is well-defined with appropriate field tags and types to include a symbol name with the DecCoin type.
x/uibc/expected_keepers.go (1)
  • 19-19: The addition of the GetAllRegisteredTokens method to the Leverage interface is correctly implemented.
util/genmap/genmap_test.go (1)
  • 34-46: The TestMapToSlice function correctly tests the MapToSlice function with various map inputs, including an empty map.
x/uibc/quota/mocks_test.go (1)
  • 26-28: The addition of the GetAllRegisteredTokens method to the LeverageKeeper mock is correctly implemented and returns a slice of tokens.
x/uibc/quota/grpc_query.go (1)
  • 54-69: The AllOutflows method is correctly updated to include token symbols in the response. Ensure that the GetAllRegisteredTokens method has proper error handling since it's used here without checking for errors.
Verification successful

The GetAllRegisteredTokens method in x/leverage/keeper/iter.go uses store.MustLoadAll, which panics if an error occurs. There is no conventional error handling within this method; it relies on the panic-recover mechanism. This approach is consistent with the use of util.Panic in other iterator methods within the same file, indicating a pattern of error handling in this codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that GetAllRegisteredTokens has proper error handling
rg --type go "GetAllRegisteredTokens"

Length of output: 2495



Script:

#!/bin/bash
# Inspect the implementation of GetAllRegisteredTokens in x/leverage/keeper/iter.go
cat x/leverage/keeper/iter.go

Length of output: 6801

proto/umee/uibc/v1/query.proto (1)
  • 106-106: The QueryAllOutflowsResponse message is correctly updated to use the DecCoinSymbol type for the outflows field, enhancing the response data structure.
x/uibc/mocks/keepers.go (1)
  • 115-127: The GetAllRegisteredTokens method and its mock recorder are correctly added to the MockLeverage struct, following the mock generation conventions.
x/leverage/keeper/grpc_query.go (13)
  • 34-34: The direct call to q.GetParams replaces q.Keeper.GetParams. Ensure that the GetParams method is correctly implemented on the Querier struct and that it maintains the same behavior as the previous Keeper method.

  • 51-57: The logic for retrieving token settings based on req.BaseDenom and getting all registered tokens has been refactored to use methods directly on the Querier struct. Verify that these methods are correctly implemented and handle errors as expected.

Verification successful

The shell script has successfully located the GetTokenSettings and GetAllRegisteredTokens methods in various files within the codebase. Here are the findings:

  • The GetTokenSettings method is implemented in:

    • x/uibc/quota/mocks_test.go
    • x/uibc/mocks/keepers.go
    • x/incentive/keeper/mock_test.go
    • x/leverage/keeper/token.go
    • x/metoken/mocks/keepers.go
    • x/metoken/keeper/mocks_test.go
  • The GetAllRegisteredTokens method is implemented in:

    • x/uibc/quota/mocks_test.go
    • x/uibc/mocks/keepers.go
    • x/leverage/keeper/iter.go

The presence of these methods in the x/leverage/keeper/token.go and x/leverage/keeper/iter.go files suggests that the methods do exist and are likely implemented correctly, as they are part of the actual Keeper struct and not just the mocks or tests.

Given this information, the review comment asking to verify that these methods are correctly implemented and handle errors as expected on the Querier struct is not entirely accurate, as the methods are found on the Keeper struct. However, since the PR's changes involve refactoring to use methods directly on the Querier struct, it's important to ensure that the Querier struct has these methods or appropriately delegates them to the Keeper struct.

Based on the script output, it seems that the methods are indeed part of the Keeper struct, and the PR may have refactored the code to call these methods directly on the Querier struct, which would be a correct approach if the Querier struct is set up to delegate to the Keeper struct.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the GetTokenSettings and GetAllRegisteredTokens methods exist and are implemented correctly in the Querier struct.
ast-grep --lang go --pattern $'func (q Querier) GetTokenSettings($_, $_) $_ { $$$ }'
ast-grep --lang go --pattern $'func (q Querier) GetAllRegisteredTokens($_) $_ { $$$ }'

Length of output: 173



Script:

#!/bin/bash
# Search for the GetTokenSettings and GetAllRegisteredTokens methods in the entire codebase.
ast-grep --lang go --pattern $'func ($_ $_) GetTokenSettings($_, $_) $_ { $$$ }'
ast-grep --lang go --pattern $'func ($_ $_) GetAllRegisteredTokens($_) $_ { $$$ }'

Length of output: 4924

* 77-80: The `GetAllSpecialAssetPairs` and `GetSpecialAssetPairs` methods are now called directly on the `Querier` struct. Confirm that these methods are present and correctly implemented in the `Querier` struct.
  • 100-120: The MarketSummary method has been refactored to use direct calls to Querier methods. Ensure that these methods are correctly implemented and that the logic for calculating market summary values is preserved.

  • 167-173: The TokenPrice method is used to fetch the oracle price and historic price. Ensure that the TokenPrice method is correctly implemented in the Querier struct and that it handles errors appropriately.

  • 201-206: The methods GetAllSupplied, GetBorrowerCollateral, and GetBorrowerBorrows are now called directly on the Querier struct. Confirm that these methods are correctly implemented and that they handle errors as expected.

  • 233-267: The AccountSummary method has been refactored to use direct calls to Querier methods for fetching account information and calculating values. Ensure that these methods are correctly implemented and that the logic for calculating account summary values is preserved.

  • 283-286: The GetAccountPosition method is now called directly on the Querier struct. Verify that this method is correctly implemented in the Querier struct and that it correctly calculates the account position.

  • 296-299: The GetAccountPosition method is used again with a different parameter. Confirm that the method is correctly implemented and that it handles the different parameter correctly.

  • 317-323: The GetEligibleLiquidationTargets method is now called directly on the Querier struct. Verify that this method is correctly implemented in the Querier struct and that it correctly identifies eligible liquidation targets.

  • 375-375: The GetAllRegisteredTokens method is used to fetch all registered tokens. Confirm that this method is correctly implemented in the Querier struct and that it handles the blacklist logic as expected.

  • 388-390: The userMaxWithdraw and ToToken methods are now called directly on the Querier struct. Verify that these methods are correctly implemented in the Querier struct and that they correctly calculate the maximum withdrawable amount.

  • 435-435: The GetAllRegisteredTokens method is used again to fetch all registered tokens. Confirm that this method is correctly implemented in the Querier struct and that it handles the blacklist logic as expected.

util/genmap/genmap.go Outdated Show resolved Hide resolved
x/leverage/keeper/grpc_query.go Show resolved Hide resolved
x/leverage/keeper/grpc_query.go Show resolved Hide resolved
x/leverage/keeper/grpc_query.go Show resolved Hide resolved
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 439d983 and e20415f.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

Copy link

codecov bot commented Jan 2, 2024

Codecov Report

Attention: 93 lines in your changes are missing coverage. Please review.

Comparison is base (7f05ad4) 75.38% compared to head (5b9187f) 70.00%.
Report is 331 commits behind head on main.

❗ Current head 5b9187f differs from pull request most recent head 84fd501. Consider uploading reports for the commit 84fd501 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2374      +/-   ##
==========================================
- Coverage   75.38%   70.00%   -5.39%     
==========================================
  Files         100      174      +74     
  Lines        8025    13006    +4981     
==========================================
+ Hits         6050     9105    +3055     
- Misses       1589     3294    +1705     
- Partials      386      607     +221     
Files Coverage Δ
ante/ante.go 66.66% <100.00%> (+18.45%) ⬆️
ante/fee.go 80.00% <100.00%> (+1.64%) ⬆️
ante/spam_prevention.go 75.92% <ø> (ø)
app/inflation/inflation.go 100.00% <100.00%> (ø)
app/upgradev3/migrations.go 84.21% <ø> (+5.94%) ⬆️
util/coin/utoken.go 100.00% <100.00%> (ø)
util/genmap/genmap.go 100.00% <100.00%> (ø)
util/ibc/ibc.go 58.82% <ø> (ø)
util/sdkutil/events.go 0.00% <ø> (ø)
util/store/iter.go 36.00% <ø> (-0.37%) ⬇️
... and 40 more

... and 114 files with indirect coverage changes

Copy link
Collaborator

@gsk967 gsk967 left a comment

Choose a reason for hiding this comment

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

utACK

util/genmap/genmap.go Dismissed Show dismissed Hide dismissed
@robert-zaremba robert-zaremba added the skip-e2e-test Skip the e2e tests label Jan 2, 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 e20415f and 84fd501.
Files ignored due to filter (2)
  • swagger/swagger.yaml
  • x/uibc/uibc.pb.go
Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • proto/umee/uibc/v1/query.proto (2 hunks)
  • proto/umee/uibc/v1/uibc.proto (2 hunks)
  • util/genmap/genmap.go (1 hunks)
  • util/genmap/genmap_test.go (2 hunks)
  • x/leverage/keeper/grpc_query.go (16 hunks)
  • x/uibc/quota/mocks_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (6)
  • proto/umee/uibc/v1/query.proto
  • proto/umee/uibc/v1/uibc.proto
  • util/genmap/genmap.go
  • util/genmap/genmap_test.go
  • x/leverage/keeper/grpc_query.go
  • x/uibc/quota/mocks_test.go
Additional comments: 1
CHANGELOG.md (1)
  • 49-63: The entries added to the Unreleased section of the CHANGELOG.md are well-formatted and provide the necessary information, including PR links and descriptions for the changes. This follows the standard changelog conventions.

@robert-zaremba robert-zaremba added this pull request to the merge queue Jan 2, 2024
Merged via the queue into main with commit 32f57bd Jan 2, 2024
23 of 37 checks passed
@robert-zaremba robert-zaremba deleted the robert/outflow-symbol branch January 2, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-e2e-test Skip the e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants