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

[OTE-752] Add totalVolume and isWhitelistAffiliate to wallets table #2166

Merged
merged 6 commits into from
Aug 29, 2024

Conversation

jerryfan01234
Copy link
Contributor

@jerryfan01234 jerryfan01234 commented Aug 28, 2024

Changelist

[Describe or list the changes made in this PR]

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Introduced new properties totalVolume and isWhitelistAffiliate across various wallet-related functionalities to enhance wallet management and reporting capabilities.
    • Updated query configurations to allow filtering based on wallet affiliate status.
  • Bug Fixes

    • Enhanced test cases to reflect the new wallet attributes, ensuring correct functionality and validation.
  • Documentation

    • Updated documentation to include new properties in wallet-related interfaces and models, facilitating better understanding of wallet data structures.
  • Chores

    • Systematic updates made across tests to align with new wallet object structures, improving overall test coverage and accuracy.

@jerryfan01234 jerryfan01234 requested a review from a team as a code owner August 28, 2024 15:36
Copy link

linear bot commented Aug 28, 2024

Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Walkthrough

The changes introduce two new properties, totalVolume and isWhitelistAffiliate, to various wallet-related objects, tests, and database migrations. These modifications enhance the wallet data structure, enabling improved tracking of transaction volumes and affiliate status. The updates span multiple files, including constants, models, query types, and SQL scripts, ensuring consistent integration of the new attributes across the application.

Changes

File(s) Change Summary
indexer/packages/postgres/__tests__/helpers/constants.ts, indexer/packages/postgres/__tests__/stores/transfer-table.test.ts, indexer/packages/postgres/__tests__/stores/wallet-table.test.ts Added totalVolume and isWhitelistAffiliate properties to wallet objects and updated tests to reflect these changes.
indexer/packages/postgres/src/db/migrations/migration_files/20240827162119_add_wallets_total_volume_and_affiliates_whitelist.ts Introduced a migration script to add totalVolume and isWhitelistAffiliate columns to the wallets table.
indexer/packages/postgres/src/models/wallet-model.ts Updated WalletModel class to include totalVolume and isWhitelistAffiliate properties in schema validation and SQL-to-JSON conversion.
indexer/packages/postgres/src/stores/wallet-table.ts Modified the findAll function to accept isWhitelistAffiliate as a parameter for filtering results.
indexer/packages/postgres/src/types/db-model-types.ts Added totalVolume and isWhitelistAffiliate to the WalletFromDatabase interface.
indexer/packages/postgres/src/types/query-types.ts Added IS_WHITELIST_AFFILIATE to QueryableField enum and updated WalletQueryConfig interface to include it.
indexer/packages/postgres/src/types/wallet-types.ts Enhanced WalletCreateObject, WalletUpdateObject, and WalletColumns enum to include totalVolume and isWhitelistAffiliate.
indexer/services/comlink/__tests__/controllers/api/v4/transfers-controller.test.ts, indexer/services/ender/__tests__/handlers/trading-rewards-handler.test.ts, indexer/services/ender/__tests__/handlers/transfer-handler.test.ts Added totalVolume and isWhitelistAffiliate properties to wallet objects in various test cases.
indexer/services/ender/src/scripts/handlers/dydx_transfer_handler.sql Updated SQL script to add totalVolume and isWhitelistAffiliate fields in wallet records.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WalletTable
    participant Database

    User->>WalletTable: Create Wallet
    WalletTable->>Database: Insert wallet with totalVolume and isWhitelistAffiliate
    Database-->>WalletTable: Confirm insert
    WalletTable-->>User: Return wallet details
Loading

🐇 In the land where wallets grow,
New fields bloom, all in a row.
Volume tracked and status bright,
Whitelist dreams take flight tonight!
With every change, we hop and cheer,
A brighter future, oh so near! 🌼


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 testing code 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 testing code 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 testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6cd770f and c9e4411.

Files selected for processing (13)
  • indexer/packages/postgres/tests/helpers/constants.ts (1 hunks)
  • indexer/packages/postgres/tests/stores/transfer-table.test.ts (2 hunks)
  • indexer/packages/postgres/tests/stores/wallet-table.test.ts (4 hunks)
  • indexer/packages/postgres/src/db/migrations/migration_files/20240827162119_add_wallets_total_volume_and_affiliates_whitelist.ts (1 hunks)
  • indexer/packages/postgres/src/models/wallet-model.ts (3 hunks)
  • indexer/packages/postgres/src/stores/wallet-table.ts (3 hunks)
  • indexer/packages/postgres/src/types/db-model-types.ts (1 hunks)
  • indexer/packages/postgres/src/types/query-types.ts (2 hunks)
  • indexer/packages/postgres/src/types/wallet-types.ts (1 hunks)
  • indexer/services/comlink/tests/controllers/api/v4/transfers-controller.test.ts (6 hunks)
  • indexer/services/ender/tests/handlers/trading-rewards-handler.test.ts (3 hunks)
  • indexer/services/ender/tests/handlers/transfer-handler.test.ts (3 hunks)
  • indexer/services/ender/src/scripts/handlers/dydx_transfer_handler.sql (2 hunks)
Additional comments not posted (46)
indexer/packages/postgres/src/types/wallet-types.ts (3)

6-7: LGTM!

The new properties totalVolume and isWhitelistAffiliate are correctly added and typed.

The code changes are approved.


13-14: LGTM!

The new properties totalVolume and isWhitelistAffiliate are correctly added and typed.

The code changes are approved.


20-21: LGTM!

The new members totalVolume and isWhitelistAffiliate are correctly added and typed.

The code changes are approved.

indexer/packages/postgres/src/db/migrations/migration_files/20240827162119_add_wallets_total_volume_and_affiliates_whitelist.ts (2)

3-9: LGTM!

The new columns totalVolume and isWhitelistAffiliate are correctly added with appropriate types and default values.

The code changes are approved.


12-18: LGTM!

The columns totalVolume and isWhitelistAffiliate are correctly dropped.

The code changes are approved.

indexer/packages/postgres/src/models/wallet-model.ts (4)

43-44: LGTM!

The new properties totalVolume and isWhitelistAffiliate are correctly added and typed.

The code changes are approved.

Also applies to: 49-50


65-66: LGTM!

The new mappings totalVolume and isWhitelistAffiliate are correctly added and typed.

The code changes are approved.


76-76: LGTM!

The new class field totalVolume is correctly added and typed.

The code changes are approved.


78-78: LGTM!

The new class field isWhitelistAffiliate is correctly added and typed.

The code changes are approved.

indexer/packages/postgres/__tests__/stores/wallet-table.test.ts (3)

30-41: LGTM!

The function correctly tests the upsert method with the new properties isWhitelistAffiliate and totalVolume.

The code changes are approved.


50-51: LGTM!

The function correctly tests the findAll method with the new properties isWhitelistAffiliate and totalVolume.

The code changes are approved.


78-94: LGTM!

The function correctly tests the findAll method with the isWhitelistAffiliate property.

The code changes are approved.

indexer/packages/postgres/src/stores/wallet-table.ts (1)

22-23: LGTM!

The function correctly includes isWhitelistAffiliate in the query, allowing for more granular filtering.

The code changes are approved.

Also applies to: 31-32, 46-48

indexer/services/ender/src/scripts/handlers/dydx_transfer_handler.sql (1)

60-61: LGTM!

The function correctly includes totalVolume and isWhitelistAffiliate in the wallet records, enhancing the data model.

The code changes are approved.

Also applies to: 70-71

indexer/packages/postgres/src/types/db-model-types.ts (2)

31-31: LGTM! But verify the usage of the new property.

The addition of totalVolume to the WalletFromDatabase interface looks good. Ensure that this new property is consistently integrated and utilized in the codebase.

The code changes are approved.

Run the following script to verify the usage of the new property:

Verification successful

The totalVolume property is consistently integrated and utilized across the codebase.

The property appears in various files, including models, migration scripts, and test files, indicating thorough integration.

  • Files:
    • indexer/packages/postgres/src/models/wallet-model.ts
    • indexer/packages/postgres/src/db/migrations/migration_files/20240827162119_add_wallets_total_volume_and_affiliates_whitelist.ts
    • indexer/packages/postgres/__tests__/helpers/constants.ts
    • indexer/packages/postgres/__tests__/stores/wallet-table.test.ts
    • And others.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of the `totalVolume` property.

# Test: Search for the property usage. Expect: Consistent integration and utilization.
rg --type python -A 5 $'totalVolume'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify all usages of the `totalVolume` property in TypeScript files.

# Test: Search for the property usage. Expect: Consistent integration and utilization.
rg --type ts -A 5 $'totalVolume'

Length of output: 21559


32-32: LGTM! But verify the usage of the new property.

The addition of isWhitelistAffiliate to the WalletFromDatabase interface looks good. Ensure that this new property is consistently integrated and utilized in the codebase.

The code changes are approved.

Run the following script to verify the usage of the new property:

Verification successful

The isWhitelistAffiliate property is consistently integrated and utilized across the codebase.

The property is used in various test files, store files, and migration files, indicating thorough integration and testing.

  • Test Files: The property is tested in multiple test cases, ensuring its behavior is verified.
  • Store Files: It is part of the data handling logic, showing its role in application functionality.
  • Migration Files: The property is included in the database schema, confirming its support at the database level.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of the `isWhitelistAffiliate` property.

# Test: Search for the property usage. Expect: Consistent integration and utilization.
rg --type python -A 5 $'isWhitelistAffiliate'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify all usages of the `isWhitelistAffiliate` property in TypeScript files.

# Test: Search for the property usage. Expect: Consistent integration and utilization.
rg --type ts -A 5 $'isWhitelistAffiliate'

Length of output: 19751

indexer/services/ender/__tests__/handlers/trading-rewards-handler.test.ts (6)

177-177: LGTM!

The addition of totalVolume with a default value of '0' to the wallet object in the test case looks good.

The code changes are approved.


178-178: LGTM!

The addition of isWhitelistAffiliate with a default value of false to the wallet object in the test case looks good.

The code changes are approved.


202-202: LGTM!

The addition of totalVolume with a default value of '0' to the wallet object in the test case looks good.

The code changes are approved.


203-203: LGTM!

The addition of isWhitelistAffiliate with a default value of false to the wallet object in the test case looks good.

The code changes are approved.


213-213: LGTM!

The addition of totalVolume with a default value of '0' to the wallet object in the test case looks good.

The code changes are approved.


214-214: LGTM!

The addition of isWhitelistAffiliate with a default value of false to the wallet object in the test case looks good.

The code changes are approved.

indexer/packages/postgres/src/types/query-types.ts (2)

114-114: LGTM! But verify the usage of the new property.

The addition of [QueryableField.IS_WHITELIST_AFFILIATE]?: boolean; to the WalletQueryConfig interface looks good. Ensure that this new property is consistently integrated and utilized in the codebase.

The code changes are approved.

Run the following script to verify the usage of the new property:


91-91: LGTM! But verify the usage of the new value.

The addition of IS_WHITELIST_AFFILIATE to the QueryableField enum looks good. Ensure that this new value is consistently integrated and utilized in the codebase.

The code changes are approved.

Run the following script to verify the usage of the new value:

indexer/packages/postgres/__tests__/stores/transfer-table.test.ts (2)

325-325: Verify handling of totalVolume in WalletTable.

Ensure that the totalVolume field is properly handled in the WalletTable implementation.


326-326: Verify handling of isWhitelistAffiliate in WalletTable.

Ensure that the isWhitelistAffiliate field is properly handled in the WalletTable implementation.

indexer/services/ender/__tests__/handlers/transfer-handler.test.ts (4)

309-309: Verify handling of totalVolume in WalletTable.

Ensure that the totalVolume field is properly handled in the WalletTable implementation.


310-310: Verify handling of isWhitelistAffiliate in WalletTable.

Ensure that the isWhitelistAffiliate field is properly handled in the WalletTable implementation.


363-363: Verify handling of totalVolume in WalletTable.

Ensure that the totalVolume field is properly handled in the WalletTable implementation.


364-364: Verify handling of isWhitelistAffiliate in WalletTable.

Ensure that the isWhitelistAffiliate field is properly handled in the WalletTable implementation.

indexer/packages/postgres/__tests__/helpers/constants.ts (4)

161-161: Verify handling of totalVolume in WalletTable.

Ensure that the totalVolume field is properly handled in the WalletTable implementation.


162-162: Verify handling of isWhitelistAffiliate in WalletTable.

Ensure that the isWhitelistAffiliate field is properly handled in the WalletTable implementation.


168-168: Verify handling of totalVolume in WalletTable.

Ensure that the totalVolume field is properly handled in the WalletTable implementation.


169-169: Verify handling of isWhitelistAffiliate in WalletTable.

Ensure that the isWhitelistAffiliate field is properly handled in the WalletTable implementation.

indexer/services/comlink/__tests__/controllers/api/v4/transfers-controller.test.ts (12)

59-60: LGTM!

The addition of totalVolume to the WalletTable.create function call is correct and consistent with the PR objectives.


60-60: LGTM!

The addition of isWhitelistAffiliate to the WalletTable.create function call is correct and consistent with the PR objectives.


185-186: LGTM!

The addition of totalVolume to the WalletTable.create function call is correct and consistent with the PR objectives.


186-186: LGTM!

The addition of isWhitelistAffiliate to the WalletTable.create function call is correct and consistent with the PR objectives.


468-469: LGTM!

The addition of totalVolume to the WalletTable.create function call is correct and consistent with the PR objectives.


469-469: LGTM!

The addition of isWhitelistAffiliate to the WalletTable.create function call is correct and consistent with the PR objectives.


594-595: LGTM!

The addition of totalVolume to the WalletTable.create function call is correct and consistent with the PR objectives.


595-595: LGTM!

The addition of isWhitelistAffiliate to the WalletTable.create function call is correct and consistent with the PR objectives.


749-750: LGTM!

The addition of totalVolume to the WalletTable.create function call is correct and consistent with the PR objectives.


750-750: LGTM!

The addition of isWhitelistAffiliate to the WalletTable.create function call is correct and consistent with the PR objectives.


837-838: LGTM!

The addition of totalVolume to the WalletTable.create function call is correct and consistent with the PR objectives.


838-838: LGTM!

The addition of isWhitelistAffiliate to the WalletTable.create function call is correct and consistent with the PR objectives.

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c9e4411 and ea22dbd.

Files selected for processing (3)
  • indexer/services/comlink/tests/controllers/api/v4/transfers-controller.test.ts (8 hunks)
  • indexer/services/ender/tests/handlers/trading-rewards-handler.test.ts (5 hunks)
  • indexer/services/ender/tests/handlers/transfer-handler.test.ts (4 hunks)
Files skipped from review as they are similar to previous changes (3)
  • indexer/services/comlink/tests/controllers/api/v4/transfers-controller.test.ts
  • indexer/services/ender/tests/handlers/trading-rewards-handler.test.ts
  • indexer/services/ender/tests/handlers/transfer-handler.test.ts

@jerryfan01234 jerryfan01234 force-pushed the affiliates-update-wallets-table branch 2 times, most recently from 7bf6b74 to 8f8400c Compare August 28, 2024 21:47
@@ -27,6 +27,13 @@ import {
} from '@dydxprotocol-indexer/postgres/build/__tests__/helpers/constants';
import Big from 'big.js';

const defaultWallet = {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why not use testConstants.defaultWallet imported from postgres?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

@jerryfan01234 jerryfan01234 force-pushed the affiliates-update-wallets-table branch from 8f8400c to 8a8a2c1 Compare August 29, 2024 03:33
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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ea22dbd and 8a8a2c1.

Files selected for processing (3)
  • indexer/services/comlink/tests/controllers/api/v4/transfers-controller.test.ts (7 hunks)
  • indexer/services/ender/tests/handlers/trading-rewards-handler.test.ts (3 hunks)
  • indexer/services/ender/tests/handlers/transfer-handler.test.ts (5 hunks)
Files skipped from review as they are similar to previous changes (3)
  • indexer/services/comlink/tests/controllers/api/v4/transfers-controller.test.ts
  • indexer/services/ender/tests/handlers/trading-rewards-handler.test.ts
  • indexer/services/ender/tests/handlers/transfer-handler.test.ts

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8a8a2c1 and b189bb7.

Files selected for processing (2)
  • indexer/packages/postgres/src/types/db-model-types.ts (1 hunks)
  • indexer/packages/postgres/src/types/query-types.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • indexer/packages/postgres/src/types/db-model-types.ts
  • indexer/packages/postgres/src/types/query-types.ts

Copy link
Contributor

mergify bot commented Aug 29, 2024

backport release/indexer/v6.x

✅ Backports have been created

@jerryfan01234
Copy link
Contributor Author

jerryfan01234 commented Aug 29, 2024

backport release/indexer/v6.x

🟠 Waiting for conditions to match

Commented on wrong PR, will close packport PR once created

@jerryfan01234 jerryfan01234 merged commit ecc5df6 into main Aug 29, 2024
16 checks passed
@jerryfan01234 jerryfan01234 deleted the affiliates-update-wallets-table branch August 29, 2024 15:22
mergify bot pushed a commit that referenced this pull request Aug 29, 2024
…2166)

(cherry picked from commit ecc5df6)

# Conflicts:
#	indexer/packages/postgres/__tests__/helpers/constants.ts
#	indexer/packages/postgres/src/types/query-types.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants