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

add ability to allocate to vaults #2277

Merged
merged 3 commits into from
Sep 18, 2024
Merged

add ability to allocate to vaults #2277

merged 3 commits into from
Sep 18, 2024

Conversation

tqin7
Copy link
Contributor

@tqin7 tqin7 commented Sep 17, 2024

Changelist

operator and governance have the ability to allocate funds from main vault to sub vaults

Test Plan

  • unit tests
  • localnet testing

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 the allocateToVault method for fund allocation between vaults.
    • Added new request and response types for vault allocation, enhancing control over fund management.
    • Implemented a new RPC method AllocateToVault to facilitate fund transfers.
    • Added a new command in the CLI for managing vault allocations.
  • Bug Fixes

    • Improved error handling for invalid authority in vault management functions.
  • Tests

    • Added comprehensive unit tests for the AllocateToVault functionality, covering various allocation scenarios.
  • Documentation

    • Updated error messages for consistency in authority validation tests.
    • Enhanced the sample_pregenesis.json with a defined subaccount structure.

@tqin7 tqin7 requested a review from a team as a code owner September 17, 2024 18:41
Copy link

linear bot commented Sep 17, 2024

Copy link
Contributor

coderabbitai bot commented Sep 17, 2024

Walkthrough

The changes introduce a new functionality for vault management, specifically the ability to allocate funds from a main vault to a specific vault through the AllocateToVault method. This includes new request and response types, error handling improvements, and the implementation of related server functions and tests. The updates enhance the protocol's capabilities in managing vault operations, ensuring proper authority checks and fund transfers.

Changes

Files Change Summary
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts, indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts, proto/dydxprotocol/vault/tx.proto Added allocateToVault method in Msg interface and MsgClientImpl, along with new request and response types MsgAllocateToVault and MsgAllocateToVaultResponse.
protocol/x/vault/keeper/msg_server_allocate_to_vault.go Implemented AllocateToVault function to handle fund allocation between vaults with authority validation and fund transfer logic.
protocol/x/vault/keeper/msg_server_allocate_to_vault_test.go Introduced unit tests for AllocateToVault, covering various scenarios including successful allocations and error cases.
protocol/x/vault/keeper/msg_server_set_vault_params.go Updated error handling in SetVaultParams to return types.ErrInvalidAuthority for invalid authority checks.
protocol/x/vault/keeper/msg_server_set_vault_params_test.go Modified expected error messages in tests to use vaulttypes.ErrInvalidAuthority.Error() for consistency.
protocol/x/vault/types/errors.go Added new error variable ErrInvalidAuthority for authority validation issues.
protocol/x/vault/types/expected_keepers.go Introduced TransferFundsFromSubaccountToSubaccount method in SubaccountsKeeper interface for fund transfers between subaccounts.

Possibly related PRs

Suggested reviewers

  • vincentwschau
  • teddyding

Poem

🐇 In the vaults where funds do play,
A new path opens, bright as day.
With authority checks in sight,
Allocations flow, oh what delight!
From main to sub, the assets dance,
In our protocol, they take a chance!
Hooray for changes, let’s prance and play! 🎉


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>, please review it.
    -- 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 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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

Outside diff range and nitpick comments (4)
protocol/x/vault/keeper/msg_server_allocate_to_vault.go (1)

14-42: LGTM!

The AllocateToVault function looks good and aligns with the PR objectives of enhancing the functionality of the system by allowing operators and governance to allocate funds from a main vault to sub vaults. The function performs the necessary authority validation and transfers funds from the main vault to the specified vault using the TransferFundsFromSubaccountToSubaccount method. The error handling is clear and appropriate.

Consider adding a log statement to record the successful allocation of funds. This can be helpful for auditing and debugging purposes. For example:

ctx.Logger().Info("Allocated funds to vault", "vault_id", msg.VaultId, "amount", msg.QuoteQuantums)
proto/dydxprotocol/vault/tx.proto (1)

153-154: Empty response message, consider adding fields if needed.

The MsgAllocateToVaultResponse message is currently empty, which suggests that no specific response data is required for the AllocateToVault method. This is acceptable if no additional information needs to be returned.

However, consider if it would be beneficial to include any fields in the response, such as the updated vault balances or a success status, to provide more information to the client.

indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (2)

203-205: Consider using a type alias for an empty interface.

The static analysis tool suggests using a type alias instead of an empty interface for MsgAllocateToVaultResponse. While an empty interface is valid, using a type alias can improve code clarity and maintainability.

-export interface MsgAllocateToVaultResponse {}
+export type MsgAllocateToVaultResponse = Record<string, never>;
Tools
Biome

[error] 205-205: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


206-208: Consider using a type alias for an empty interface.

Similar to the MsgAllocateToVaultResponse interface, the static analysis tool suggests using a type alias instead of an empty interface for MsgAllocateToVaultResponseSDKType. Consider making the same change for consistency and clarity.

-export interface MsgAllocateToVaultResponseSDKType {}
+export type MsgAllocateToVaultResponseSDKType = Record<string, never>;
Tools
Biome

[error] 208-208: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f2fb2b9 and d6d7ba3.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (9)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts (4 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (2 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
  • protocol/x/vault/keeper/msg_server_allocate_to_vault.go (1 hunks)
  • protocol/x/vault/keeper/msg_server_allocate_to_vault_test.go (1 hunks)
  • protocol/x/vault/keeper/msg_server_set_vault_params.go (1 hunks)
  • protocol/x/vault/keeper/msg_server_set_vault_params_test.go (2 hunks)
  • protocol/x/vault/types/errors.go (1 hunks)
  • protocol/x/vault/types/expected_keepers.go (2 hunks)
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts

[error] 205-205: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


[error] 208-208: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (14)
protocol/x/vault/keeper/msg_server_set_vault_params.go (1)

23-23: LGTM!

The change from govtypes.ErrInvalidSigner to types.ErrInvalidAuthority enhances the clarity and specificity of error reporting in the SetVaultParams function. The new error type aligns better with the context of vault authority validation.

protocol/x/vault/types/expected_keepers.go (1)

83-89: LGTM!

The new method TransferFundsFromSubaccountToSubaccount is a great addition to the SubaccountsKeeper interface. It enhances the functionality by allowing the transfer of funds between subaccounts, which aligns with the PR objective of improving the allocation capabilities within the vault system.

The method signature is clear and well-defined:

  • The naming is descriptive and conveys the purpose of the method.
  • The parameters are well-typed and cover all the necessary information for the fund transfer.
  • The error return type allows for proper error handling.

Overall, the method declaration looks good and is unlikely to cause any issues. Great job!

protocol/x/vault/types/errors.go (1)

129-133: LGTM!

The new error variable ErrInvalidAuthority is declared correctly with a unique error code and a clear error message. This addition enhances the error handling capabilities of the module by providing a specific error case related to authority validation, which could be crucial for maintaining security and proper access control within the system.

indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts (4)

3-3: LGTM!

The import statement is correct and necessary for the subsequent code changes.


24-26: LGTM!

The allocateToVault method is correctly defined in the Msg interface, following the established naming convention and type patterns.


38-38: LGTM!

Binding the allocateToVault method to the class context in the constructor is necessary and consistent with the existing code.


71-75: LGTM!

The implementation of the allocateToVault method in MsgClientImpl is correct and follows the established pattern for encoding requests, making RPC calls, and decoding responses.

protocol/x/vault/keeper/msg_server_set_vault_params_test.go (2)

58-58: LGTM!

The change to use vaulttypes.ErrInvalidAuthority.Error() for the expected error message is a good improvement. It ensures consistency between the expected and actual error messages, making the test more reliable and maintainable.


67-67: Looks good!

Using vaulttypes.ErrInvalidAuthority.Error() for the expected error message is a positive change. It keeps the test in sync with the actual error type, improving the test's reliability and making it easier to maintain.

proto/dydxprotocol/vault/tx.proto (2)

34-36: LGTM!

The new RPC method AllocateToVault is well-defined and aligns with the PR objective of enabling fund allocation from the main vault to a specified vault. The method signature follows the existing naming convention.


135-151: Looks good!

The MsgAllocateToVault message is well-structured and includes the necessary fields for performing fund allocation to a specified vault. The field types and annotations are appropriate, and the use of the authority field ensures that only authorized addresses can perform the allocation. The custom serializable type for quote_quantums is a good choice for representing the allocation amount.

protocol/x/vault/keeper/msg_server_allocate_to_vault_test.go (1)

19-184: Comprehensive test suite for AllocateToVault message handling.

The TestMsgAllocateToVault function provides a thorough and well-structured test suite for the AllocateToVault message handling logic. It covers various scenarios, including:

  • Success cases with different authorities (governance and operator) and varying allocation amounts.
  • Failure cases such as insufficient quantums, invalid authority, and empty authority.

The test cases ensure that the message handling behaves correctly in terms of updating vault balances and returning appropriate errors. The use of descriptive names for each test case enhances readability and maintainability.

The test function follows a clear pattern of initializing a test application with custom genesis state, sending the AllocateToVault message, and verifying the expected outcomes based on the success or failure of the operation.

Overall, this test function provides excellent coverage and helps ensure the correctness of the AllocateToVault message handling implementation.

indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (2)

181-191: LGTM!

The MsgAllocateToVault interface is well-defined and captures the necessary properties for the allocation request. The optional vaultId property provides flexibility in specifying the target vault.


192-202: Looks good!

The MsgAllocateToVaultSDKType interface correctly mirrors the MsgAllocateToVault interface using SDK-compatible types. This ensures compatibility with SDK implementations.

@tqin7 tqin7 force-pushed the tq/tra-610 branch 2 times, most recently from d106409 to 18056a0 Compare September 17, 2024 19:16
)

// AllocateToVault allocates funds from main vault to a vault.
func (k msgServer) AllocateToVault(
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if the vault doesn't exist in state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was thinking that the operator needs to separately set vault params to have a vault exist in state

a smoother experience is probably to set vault params with stand_by status here during allocation if the allocated-to vault doesn't exist

Copy link
Contributor

Choose a reason for hiding this comment

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

i was thinking that the operator needs to separately set vault params to have a vault exist in state

Is this validated anywhere? What happens if the operator doesn't make the vault exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not validated so I'd vote to set vault params with stand_by status during allocation. wdyt?

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d6d7ba3 and 5df6e6f.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (15)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts (4 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (2 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
  • protocol/app/msgs/all_msgs.go (1 hunks)
  • protocol/app/msgs/normal_msgs.go (1 hunks)
  • protocol/app/msgs/normal_msgs_test.go (1 hunks)
  • protocol/scripts/genesis/sample_pregenesis.json (1 hunks)
  • protocol/testing/genesis.sh (2 hunks)
  • protocol/x/vault/client/cli/tx.go (2 hunks)
  • protocol/x/vault/keeper/msg_server_allocate_to_vault.go (1 hunks)
  • protocol/x/vault/keeper/msg_server_allocate_to_vault_test.go (1 hunks)
  • protocol/x/vault/keeper/msg_server_set_vault_params.go (1 hunks)
  • protocol/x/vault/keeper/msg_server_set_vault_params_test.go (2 hunks)
  • protocol/x/vault/types/errors.go (1 hunks)
  • protocol/x/vault/types/expected_keepers.go (2 hunks)
Files skipped from review as they are similar to previous changes (8)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts
  • proto/dydxprotocol/vault/tx.proto
  • protocol/x/vault/keeper/msg_server_allocate_to_vault.go
  • protocol/x/vault/keeper/msg_server_allocate_to_vault_test.go
  • protocol/x/vault/keeper/msg_server_set_vault_params.go
  • protocol/x/vault/keeper/msg_server_set_vault_params_test.go
  • protocol/x/vault/types/errors.go
  • protocol/x/vault/types/expected_keepers.go
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts

[error] 205-205: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


[error] 208-208: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (10)
protocol/x/vault/client/cli/tx.go (2)

31-31: LGTM!

Adding the new CmdAllocateToVault command to the list of subcommands is the correct way to extend the CLI functionality.


146-194: Implementation of CmdAllocateToVault looks good!

The CmdAllocateToVault command is implemented correctly:

  • It parses the vault type, vault number, and quantums from the provided arguments and handles parsing errors appropriately.
  • It creates the MsgAllocateToVault message using the parsed values and the provided authority.
  • It broadcasts or generates the transaction using the standard tx.GenerateOrBroadcastTxCLI function and adds the necessary transaction flags.

The command follows the standard pattern for implementing CLI commands in the codebase and enhances the functionality by allowing users to allocate funds to vaults.

protocol/app/msgs/normal_msgs_test.go (1)

150-151: LGTM!

The addition of the new message types "/dydxprotocol.vault.MsgAllocateToVault" and "/dydxprotocol.vault.MsgAllocateToVaultResponse" to the TestNormalMsgs_Key function is consistent with the purpose of the test case and enhances the test coverage for vault-related operations.

protocol/app/msgs/normal_msgs.go (1)

249-250: LGTM!

The addition of the MsgAllocateToVault and MsgAllocateToVaultResponse entries to the NormalMsgsDydxCustom map is correct and consistent with the provided list of alterations.

The MsgAllocateToVault struct is properly mapped to enable serialization and deserialization of the message, while the nil value for the response indicates that no complex data is returned.

These changes enable the handling of the new message type within the protocol, allowing for the allocation of funds from a main vault to sub vaults as described in the PR objectives.

protocol/app/msgs/all_msgs.go (1)

252-253: LGTM!

The new message types MsgAllocateToVault and MsgAllocateToVaultResponse are added consistently with the existing message declarations in the AllTypeMessages map. The naming convention is followed, and the additions suggest an expansion of the vault management functionality within the protocol.

indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (2)

181-191: LGTM!

The MsgAllocateToVault interface is well-defined with clear and appropriate properties to enable vault allocation functionality.


192-202: LGTM!

The MsgAllocateToVaultSDKType interface correctly mirrors the MsgAllocateToVault interface using SDK types for compatibility.

protocol/scripts/genesis/sample_pregenesis.json (1)

3925-3940: New subaccount structure added to the genesis configuration.

The changes introduce a new subaccount object within the subaccounts array. The subaccount is defined with the following key components:

  • asset_positions: An array specifying the assets held by the subaccount, each identified by an asset_id, index, and quantums value.
  • id: An object uniquely identifying the subaccount, including a number and an owner field.
  • margin_enabled: A boolean indicating whether margin trading is permitted for the subaccount.

Consider adding any necessary validation or constraints for the subaccount properties to ensure data integrity and consistency within the genesis state.

To verify the subaccount structure and its usage within the codebase, you can run the following script:

This script searches for:

  1. Usage of the subaccount structure within the codebase, excluding test, mock, and simulation files.
  2. Existence of any validation functions specifically for subaccount properties.

If the script yields relevant results, it indicates that the subaccount structure is being used consistently and that there might be validation functions in place. If no results are found, it suggests that additional validation or usage of the subaccount structure may be needed.

Verification successful

Subaccount properties are verified to be in use

The properties mentioned in your review comment (AssetPositions, SubaccountId, and MarginEnabled) are indeed used extensively throughout the codebase. These properties are part of the Subaccount struct and are utilized in various critical parts of the system, including:

  • Order processing and management
  • Liquidations and deleveraging
  • Transfers between subaccounts
  • Streaming updates and event generation

The widespread use of these properties across different modules confirms their importance in the system's functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash

# Check if the subaccount structure is used consistently in the codebase
echo "Searching for subaccount structure usage..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -A 5 $'subaccounts:\n.*asset_positions:.*\n.*id:.*\n.*margin_enabled:'

# Check if there are any validation functions for the subaccount properties
echo "Searching for subaccount validation functions..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -A 5 $'func.*Validate.*Subaccount'

Length of output: 2348


Script:

#!/bin/bash

# Check if the subaccount structure is used consistently in the codebase
echo "Searching for subaccount structure usage..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -U -A 5 'subaccounts:.*\n.*asset_positions:.*\n.*id:.*\n.*margin_enabled:'

# Check if there are any validation functions for the subaccount properties
echo "Searching for subaccount validation functions..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -A 5 'func.*Validate.*Subaccount'

# Search for more specific subaccount validation functions
echo "Searching for specific subaccount property validation..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -A 5 'func.*Validate.*\b(AssetPositions|SubaccountId|MarginEnabled)\b'

Length of output: 2439


Script:

#!/bin/bash

# Search for a more general subaccount structure pattern
echo "Searching for general subaccount structure usage..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -U -A 10 'type.*Subaccount.*struct'

# Search for functions dealing with subaccount creation or modification
echo "Searching for subaccount creation or modification functions..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -A 5 'func.*(Create|Update|Modify).*Subaccount'

# Search for any mentions of subaccount properties
echo "Searching for subaccount property mentions..."
rg --type go --glob '!*_test.go' --glob '!*mock*.go' --glob '!*simulation*.go' -A 5 '\b(AssetPositions|SubaccountId|MarginEnabled)\b'

Length of output: 503637

protocol/testing/genesis.sh (2)

25-26: LGTM!

The new variables for the megavault main vault account address and initial balance are declared appropriately.


1829-1832: Looks good!

The changes to add the megavault main vault account to the subaccounts module in the edit_genesis function are implemented correctly:

  • The add_subaccount function is called with the appropriate address and initial balance.
  • The acct_idx is incremented to maintain the correct account index.
  • The total_accounts_quote_balance is updated to include the megavault main vault account's balance.

The changes follow the existing pattern and maintain consistency with the rest of the function.

Comment on lines +206 to +208
/** MsgAllocateToVaultResponse is the Msg/AllocateToVault response type. */

export interface MsgAllocateToVaultResponseSDKType {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a type alias instead of an empty interface.

Similar to MsgAllocateToVaultResponse, consider using a type alias instead of an empty interface for clarity:

-export interface MsgAllocateToVaultResponseSDKType {}
+export type MsgAllocateToVaultResponseSDKType = Record<string, never>;

This change will also resolve the lint error.

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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/** MsgAllocateToVaultResponse is the Msg/AllocateToVault response type. */
export interface MsgAllocateToVaultResponseSDKType {}
/** MsgAllocateToVaultResponse is the Msg/AllocateToVault response type. */
export type MsgAllocateToVaultResponseSDKType = Record<string, never>;
Tools
Biome

[error] 208-208: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Comment on lines +203 to +205
/** MsgAllocateToVaultResponse is the Msg/AllocateToVault response type. */

export interface MsgAllocateToVaultResponse {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a type alias instead of an empty interface.

An empty interface is equivalent to {} and can be confusing. Consider using a type alias for clarity:

-export interface MsgAllocateToVaultResponse {}
+export type MsgAllocateToVaultResponse = Record<string, never>;

This change will also resolve the lint error.

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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/** MsgAllocateToVaultResponse is the Msg/AllocateToVault response type. */
export interface MsgAllocateToVaultResponse {}
/** MsgAllocateToVaultResponse is the Msg/AllocateToVault response type. */
export type MsgAllocateToVaultResponse = Record<string, never>;
Tools
Biome

[error] 205-205: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

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