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

[TRA-461] define MsgWithdrawFromVault proto #1815

Merged
merged 14 commits into from
Jul 1, 2024
Merged

Conversation

ttl33
Copy link
Contributor

@ttl33 ttl33 commented Jun 28, 2024

Changelist

  1. defined MsgWithdrawFromVault proto
  2. added an empty msg_server impl
  3. registered msg interface + msg categorization
  4. ran make proto-gen and cd indexer/packages/v4-protos && npm run build:proto

Test Plan

n/a

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 functionality for withdrawing assets from a vault to a subaccount.
    • Added a new interface and supporting methods for MsgWithdrawFromVault and MsgWithdrawFromVaultResponse.
  • Documentation

    • Updated descriptions for deposit and withdrawal messages to clarify their actions.
  • Chores

    • Enhanced the interface registry configuration to include new withdrawal messages.

Copy link

linear bot commented Jun 28, 2024

Copy link
Contributor

coderabbitai bot commented Jun 28, 2024

Walkthrough

The overall changes entail refining the functionality for asset management in the dydxprotocol vault module, specifically adding mechanisms for withdrawing assets. This includes the introduction of new messages and encoding/decoding functionalities related to withdrawals, expanding the interface registry, and updating relevant Go files to support the new withdrawal operations.

Changes

File(s) Change Summary
proto/dydxprotocol/vault/tx.proto Added new messages for withdrawing assets, including MsgWithdrawFromVault and MsgWithdrawFromVaultResponse.
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts Added interfaces and functions for encoding/decoding withdrawal messages.
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts Updated Msg interface and implemented withdrawFromVault method in MsgClientImpl.
proto/dydxprotocol/vault/genesis.proto Removed import statement for dydxprotocol/vault/query.proto.
protocol/app/module/interface_registry.go Added MsgWithdrawFromVault to the interface registry.
protocol/app/msgs/all_msgs.go Added MsgWithdrawFromVault and MsgWithdrawFromVaultResponse declarations.
protocol/app/msgs/normal_msgs.go Declared MsgWithdrawFromVault and MsgWithdrawFromVaultResponse.
protocol/testutil/encoding/utils.go Added MsgWithdrawFromVault to the GetTestEncodingCfg() function.
protocol/x/vault/keeper/msg_server_withdraw_from_vault.go Implemented the WithdrawFromVault function to handle withdrawal operations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Client
    participant VaultService

    User->>Client: Initiate Withdraw Request
    Client->>VaultService: Send MsgWithdrawFromVault
    VaultService-->>Client: Return MsgWithdrawFromVaultResponse
    Client-->>User: Display Withdrawal Response
Loading

Poem

In a vault, so mighty and grand,
Deposits rest by firm command.
Withdrawals now, a brand new tale,
Assets flow, the system prevails.
Code refined, in lines so neat,
A rabbit's dream, a programmer's feat.
🐰✨ In vaults, we trust, our funds replete.


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

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 Configration 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.

dydxprotocol.subaccounts.SubaccountId subaccount_id = 2;

// Number of shares to withdraw.
uint64 shares = 3;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the original spec calls for quote_quantums but i think it makes more sense to specify the # of shares. wdyt?

Copy link
Contributor Author

@ttl33 ttl33 Jun 29, 2024

Choose a reason for hiding this comment

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

offline conclusion: decided to go w specifying USDC (slack thread)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

offline conclusion: decided to go w specifying shares

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 8487f36 and cb14157.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (1)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
Additional comments not posted (4)
proto/dydxprotocol/vault/tx.proto (4)

21-21: Updated description enhances clarity.

The updated comment for MsgDepositToVault improves clarity about the operation, which is beneficial for developers interacting with this API.


42-53: Well-defined new message for vault withdrawal.

The MsgWithdrawFromVault is clearly defined with appropriate fields and types, aligning well with the existing message structures in this protocol.


21-21: Verify consistency of field annotations across similar messages.

The use of custom types and nullability settings here should be consistently applied across similar messages to ensure uniformity.

Verification successful

Field annotations are consistent across similar messages.

The use of the custom type github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt and the nullability setting (gogoproto.nullable) = false is consistent across various proto messages.

  • Verified consistency in multiple proto messages:
    • MsgDepositToVault
    • MsgDepositToVaultResponse
    • Other related messages
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify consistency of field annotations in similar messages.

# Test: Search for similar field annotations. Expect: Consistent use of custom types and nullability.
rg --type proto "github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt"

Length of output: 112



Script:

#!/bin/bash
# Description: Verify consistency of field annotations in similar messages.

# Find all .proto files and search for field annotations related to SerializableInt.
fd --extension proto --exec rg "github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" {}

Length of output: 1850



Script:

#!/bin/bash
# Description: Verify the context of field annotations in proto files for consistency.

# Find all .proto files and search for the context around field annotations related to SerializableInt.
fd --extension proto --exec rg -C 5 "github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" {}

Length of output: 7987


54-55: Clarification needed for empty response message.

The MsgWithdrawFromVaultResponse lacks fields, which may be intentional. Verify if this pattern is consistent with other response messages in the protocol.

Verification successful

Empty response message design is consistent.

The MsgWithdrawFromVaultResponse message without fields aligns with the design pattern observed in other response messages in the protocol.

  • Examples: MsgDepositToVaultResponse, MsgCreateTransferResponse, MsgSlashValidatorResponse, etc.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check for other response messages without fields.

# Test: Search for other empty response messages. Expect: Consistency in design.
rg --type proto "message .*Response {}"

Length of output: 165



Script:

#!/bin/bash
# Description: Check for other response messages without fields.

# Test: Search for other empty response messages. Expect: Consistency in design.
rg --type proto "message .*Response \{\}"

Length of output: 73



Script:

#!/bin/bash
# Description: Check for other response messages without fields.

# Find all .proto files and search for empty response messages within them.
fd -e proto -x rg "message .*Response \{\}" {}

Length of output: 1701

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 cb14157 and 2c6074e.

Files selected for processing (1)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto

proto/dydxprotocol/vault/tx.proto Outdated Show resolved Hide resolved
proto/dydxprotocol/vault/tx.proto Outdated 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.

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 2c6074e and 4fc03b1.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (3)
  • proto/dydxprotocol/vault/query.proto (1 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
  • proto/dydxprotocol/vault/vault.proto (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto
Additional comments not posted (2)
proto/dydxprotocol/vault/vault.proto (1)

36-40: LGTM!

The OwnerShare message is well-defined and includes the necessary fields for representing owner shares in a vault.

proto/dydxprotocol/vault/query.proto (1)

Line range hint 35-35: LGTM!

The modification to use repeated OwnerShare owner_shares in QueryOwnerSharesResponse simplifies the structure and improves readability.

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)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts (1)

Line range hint 33-34: Remove Redundant Switch Cases

The switch cases are redundant because the default case is already present. Remove the useless cases.

-    case 0:
-    case "VAULT_TYPE_UNSPECIFIED":
+    case "VAULT_TYPE_UNSPECIFIED":
-    case 1:
-    case "VAULT_TYPE_CLOB":
+    case "VAULT_TYPE_CLOB":
-    case -1:
-    case "UNRECOGNIZED":
+    case "UNRECOGNIZED":

Also applies to: 47-47

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

Line range hint 38-38: Replace Empty Interfaces with Type Aliases

Empty interfaces are equivalent to {}. Replace them with type aliases.

- export interface MsgDepositToVaultResponse {}
+ export type MsgDepositToVaultResponse = {};
- export interface MsgDepositToVaultResponseSDKType {}
+ export type MsgDepositToVaultResponseSDKType = {};
- export interface MsgUpdateParamsResponse {}
+ export type MsgUpdateParamsResponse = {};
- export interface MsgUpdateParamsResponseSDKType {}
+ export type MsgUpdateParamsResponseSDKType = {};

Also applies to: 41-41, 128-128, 131-131

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

Line range hint 9-9: Replace empty interface with type alias.

An empty interface is equivalent to {}. Replace QueryParamsRequest with a type alias.

- export interface QueryParamsRequest {}
+ export type QueryParamsRequest = {};

Line range hint 12-12: Replace empty interface with type alias.

An empty interface is equivalent to {}. Replace QueryParamsRequestSDKType with a type alias.

- export interface QueryParamsRequestSDKType {}
+ export type QueryParamsRequestSDKType = {};
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4fc03b1 and d6d931f.

Files ignored due to path filters (3)
  • protocol/x/vault/types/query.pb.go is excluded by !**/*.pb.go
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
  • protocol/x/vault/types/vault.pb.go is excluded by !**/*.pb.go
Files selected for processing (6)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts (1 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts (3 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (4 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts (2 hunks)
  • proto/dydxprotocol/vault/query.proto (2 hunks)
  • proto/dydxprotocol/vault/vault.proto (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • proto/dydxprotocol/vault/query.proto
  • proto/dydxprotocol/vault/vault.proto
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts

[error] 33-33: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)


[error] 34-34: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)


[error] 47-47: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)

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

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (6)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts (1)

2-2: LGTM!

The import statement has been correctly updated to reflect the new location of OwnerShare and OwnerShareSDKType.

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

82-87: New OwnerShare Interface

The new OwnerShare interface and OwnerShareSDKType have been correctly defined to represent owner shares in a vault.

Also applies to: 90-93


195-199: New Functions for OwnerShare

The functions createBaseOwnerShare, encode, decode, and fromPartial for OwnerShare have been correctly implemented. These functions ensure proper encoding, decoding, and partial creation of OwnerShare objects.

Also applies to: 202-246

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

42-42: New MsgWithdrawFromVault Interface

The new MsgWithdrawFromVault interface has been correctly defined to handle withdrawals from the vault to subaccounts. The related functions for encoding, decoding, and partial creation are implemented correctly.

Also applies to: 46-84


86-108: New MsgWithdrawFromVaultResponse Interface

The new MsgWithdrawFromVaultResponse interface has been correctly defined to handle the response of withdrawals from the vault. The related functions for encoding, decoding, and partial creation are implemented correctly.

indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts (1)

1-1: Update import path for OwnerShare and OwnerShareSDKType.

The import path for OwnerShare and OwnerShareSDKType has been updated to ./vault. Ensure that the new path is correct and aligns with the changes made in the vault.ts file.

proto/dydxprotocol/vault/tx.proto Outdated Show resolved Hide resolved
dydxprotocol.subaccounts.SubaccountId subaccount_id = 2;

// Number of shares to withdraw.
uint64 shares = 3;
Copy link
Contributor Author

@ttl33 ttl33 Jun 29, 2024

Choose a reason for hiding this comment

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

offline conclusion: decided to go w specifying USDC (slack thread)

@@ -82,12 +81,6 @@ message QueryOwnerSharesRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}

// OwnerShare is a type for owner shares in a vault.
message OwnerShare {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved it to vault.proto

}

// MsgWithdrawFromVaultResponse is the Msg/WithdrawFromVault response type.
message MsgWithdrawFromVaultResponse {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note that this has been updated

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

Outside diff range and nitpick comments (3)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (3)

Line range hint 38-38: Replace empty interface with type alias.

The MsgDepositToVaultResponse interface is empty and should be replaced with a type alias to avoid linting errors.

- export interface MsgDepositToVaultResponse {}
+ export type MsgDepositToVaultResponse = {};

Line range hint 128-128: Replace empty interface with type alias.

The MsgUpdateParamsResponse interface is empty and should be replaced with a type alias to avoid linting errors.

- export interface MsgUpdateParamsResponse {}
+ export type MsgUpdateParamsResponse = {};

Line range hint 131-131: Replace empty interface with type alias.

The MsgUpdateParamsResponseSDKType interface is empty and should be replaced with a type alias to avoid linting errors.

- export interface MsgUpdateParamsResponseSDKType {}
+ export type MsgUpdateParamsResponseSDKType = {};
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d6d931f and 5517530.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (2)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (4 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (16)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (16)

47-63: LGTM!

The MsgWithdrawFromVault interface is correctly defined.


240-255: LGTM!

The encode function for MsgWithdrawFromVault is correctly defined.


257-285: LGTM!

The decode function for MsgWithdrawFromVault is correctly defined.


287-293: LGTM!

The fromPartial function for MsgWithdrawFromVault is correctly defined.


69-84: LGTM!

The MsgWithdrawFromVaultSDKType interface is correctly defined.


240-255: LGTM!

The encode function for MsgWithdrawFromVaultSDKType is correctly defined.


257-285: LGTM!

The decode function for MsgWithdrawFromVaultSDKType is correctly defined.


287-293: LGTM!

The fromPartial function for MsgWithdrawFromVaultSDKType is correctly defined.


88-97: LGTM!

The MsgWithdrawFromVaultResponse interface is correctly defined.


306-320: LGTM!

The encode function for MsgWithdrawFromVaultResponse is correctly defined.


322-350: LGTM!

The decode function for MsgWithdrawFromVaultResponse is correctly defined.


352-358: LGTM!

The fromPartial function for MsgWithdrawFromVaultResponse is correctly defined.


100-108: LGTM!

The MsgWithdrawFromVaultResponseSDKType interface is correctly defined.


306-320: LGTM!

The encode function for MsgWithdrawFromVaultResponseSDKType is correctly defined.


322-350: LGTM!

The decode function for MsgWithdrawFromVaultResponseSDKType is correctly defined.


352-358: LGTM!

The fromPartial function for MsgWithdrawFromVaultResponseSDKType is correctly defined.

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

Outside diff range and nitpick comments (3)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (3)

Line range hint 38-38: Replace empty interface with type alias.

The MsgDepositToVaultResponse interface is empty and should be replaced with a type alias to avoid linting errors.

- export interface MsgDepositToVaultResponse {}
+ export type MsgDepositToVaultResponse = {};

Line range hint 140-140: Replace empty interface with type alias.

The MsgUpdateParamsResponse interface is empty and should be replaced with a type alias to avoid linting errors.

- export interface MsgUpdateParamsResponse {}
+ export type MsgUpdateParamsResponse = {};

Line range hint 143-143: Replace empty interface with type alias.

The MsgUpdateParamsResponseSDKType interface is empty and should be replaced with a type alias to avoid linting errors.

- export interface MsgUpdateParamsResponseSDKType {}
+ export type MsgUpdateParamsResponseSDKType = {};
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5517530 and 85c6285.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (2)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (4 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (11)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (11)

1-1: Import statement looks good.

The necessary imports have been updated to include NumShares and NumSharesSDKType.


42-69: LGTM!

The MsgWithdrawFromVault interface and its SDK type have been correctly defined with the necessary fields and comments.


98-120: LGTM!

The MsgWithdrawFromVaultResponse interface and its SDK type have been correctly defined with the necessary fields and comments.


244-250: Base message creation function looks good.

The createBaseMsgWithdrawFromVault function correctly initializes the base message.


252-267: Encoding function looks good.

The encode function correctly handles the encoding of the MsgWithdrawFromVault message.


269-297: Decoding function looks good.

The decode function correctly handles the decoding of the MsgWithdrawFromVault message.


299-305: Partial creation function looks good.

The fromPartial function correctly handles the creation of a partial MsgWithdrawFromVault message.


309-315: Base message creation function looks good.

The createBaseMsgWithdrawFromVaultResponse function correctly initializes the base message.


317-332: Encoding function looks good.

The encode function correctly handles the encoding of the MsgWithdrawFromVaultResponse message.


334-361: Decoding function looks good.

The decode function correctly handles the decoding of the MsgWithdrawFromVaultResponse message.


364-370: Partial creation function looks good.

The fromPartial function correctly handles the creation of a partial MsgWithdrawFromVaultResponse message.

@@ -33,6 +39,86 @@ export interface MsgDepositToVaultResponse {}
/** MsgDepositToVaultResponse is the Msg/DepositToVault response type. */

export interface MsgDepositToVaultResponseSDKType {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace empty interface with type alias.

The MsgDepositToVaultResponseSDKType interface is empty and should be replaced with a type alias to avoid linting errors.

- export interface MsgDepositToVaultResponseSDKType {}
+ export type MsgDepositToVaultResponseSDKType = {};
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
export interface MsgDepositToVaultResponseSDKType {}
export type MsgDepositToVaultResponseSDKType = {};
Tools
Biome

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

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 85c6285 and b0edf57.

Files ignored due to path filters (2)
  • protocol/x/vault/types/genesis.pb.go is excluded by !**/*.pb.go
  • 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 (3 hunks)
  • proto/dydxprotocol/vault/genesis.proto (1 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
  • protocol/app/module/interface_registry.go (1 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/testutil/encoding/utils.go (1 hunks)
  • protocol/x/vault/keeper/msg_server_withdraw_from_vault.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • proto/dydxprotocol/vault/genesis.proto
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto
Additional comments not posted (5)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts (1)

11-11: LGTM!

The method withdrawFromVault correctly handles the request and response for withdrawing from the vault.

Also applies to: 32-36

protocol/testutil/encoding/utils.go (1)

96-96: LGTM!

The MsgWithdrawFromVault message is correctly added to the list of messages to register.

protocol/app/module/interface_registry.go (1)

98-100: LGTM!

The MsgWithdrawFromVault message is correctly added to the list of custom get signers.

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

239-242: LGTM!

The newly added messages for MsgWithdrawFromVault and MsgWithdrawFromVaultResponse are correctly included in the NormalMsgsDydxCustom map.

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

242-245: LGTM!

The newly added messages for MsgWithdrawFromVault and MsgWithdrawFromVaultResponse are correctly included in the AllTypeMessages map.

Comment on lines +144 to +145
"/dydxprotocol.vault.MsgWithdrawFromVault",
"/dydxprotocol.vault.MsgWithdrawFromVaultResponse",
Copy link
Contributor

Choose a reason for hiding this comment

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

Add assertions for new message types.

The test function TestNormalMsgs_Key should include assertions for the newly added message types to ensure they are correctly handled.

+		"/dydxprotocol.vault.MsgWithdrawFromVault",
+		"/dydxprotocol.vault.MsgWithdrawFromVaultResponse",

Committable suggestion was skipped due to low confidence.

Comment on lines +9 to +14
// TODO: implement
func (k msgServer) WithdrawFromVault(
goCtx context.Context,
msg *types.MsgWithdrawFromVault,
) (*types.MsgWithdrawFromVaultResponse, error) {
return &types.MsgWithdrawFromVaultResponse{}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement the WithdrawFromVault function.

The function currently returns an empty response. You should implement the logic to handle the withdrawal from the vault.

Do you want me to help implement the withdrawal logic or open a GitHub issue to track this task?

proto/dydxprotocol/vault/tx.proto Outdated Show resolved Hide resolved
proto/dydxprotocol/vault/tx.proto Outdated 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.

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 b0edf57 and 53d21e3.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (2)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (4 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (8)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (8)

47-64: Verify the necessity of optional fields.

The fields vaultId, subaccountId, and shares are marked as optional. Ensure that these fields can indeed be optional in all cases.


70-86: Verify the necessity of optional fields.

The fields vault_id, subaccount_id, and shares are marked as optional. Ensure that these fields can indeed be optional in all cases.


90-104: Verify the necessity of optional fields.

The fields redeemedShares, remainingShares, and totalVaultShares are marked as optional. Ensure that these fields can indeed be optional in all cases.


108-122: Verify the necessity of optional fields.

The fields redeemed_shares, remaining_shares, and total_vault_shares are marked as optional. Ensure that these fields can indeed be optional in all cases.


246-252: LGTM!

The function correctly initializes the MsgWithdrawFromVault interface with default values.


254-309: LGTM!

The function correctly handles encoding, decoding, and partial message creation for MsgWithdrawFromVault.


311-319: LGTM!

The function correctly initializes the MsgWithdrawFromVaultResponse interface with default values.


321-394: LGTM!

The function correctly handles encoding, decoding, and partial message creation for MsgWithdrawFromVaultResponse.

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 53d21e3 and 66e1eb7.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (2)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (4 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (6)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (6)

47-64: LGTM! New message type MsgWithdrawFromVault.

The new message type MsgWithdrawFromVault is correctly defined with properties vaultId, subaccountId, and shares.


70-87: LGTM! New SDK type MsgWithdrawFromVaultSDKType.

The new SDK type MsgWithdrawFromVaultSDKType is correctly defined with properties vault_id, subaccount_id, and shares.


90-105: LGTM! New message type MsgWithdrawFromVaultResponse.

The new message type MsgWithdrawFromVaultResponse is correctly defined with properties redeemedShares, withdrawnQuoteQuantums, remainingShares, totalVaultShares, and totalVaultEquity.


108-123: LGTM! New SDK type MsgWithdrawFromVaultResponseSDKType.

The new SDK type MsgWithdrawFromVaultResponseSDKType is correctly defined with properties redeemed_shares, withdrawn_quote_quantums, remaining_shares, total_vault_shares, and total_vault_equity.


254-309: LGTM! Encoding/decoding functions for MsgWithdrawFromVault.

The encoding/decoding functions for MsgWithdrawFromVault are correctly defined and follow the structure of other similar functions in the file.


321-394: LGTM! Encoding/decoding functions for MsgWithdrawFromVaultResponse.

The encoding/decoding functions for MsgWithdrawFromVaultResponse are correctly defined and follow the structure of other similar functions in the file.

proto/dydxprotocol/vault/tx.proto Outdated Show resolved Hide resolved
proto/dydxprotocol/vault/tx.proto Outdated Show resolved Hide resolved
proto/dydxprotocol/vault/tx.proto Outdated 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.

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 66e1eb7 and ac152cf.

Files ignored due to path filters (1)
  • protocol/x/vault/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (2)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (4 hunks)
  • proto/dydxprotocol/vault/tx.proto (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/vault/tx.proto
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts

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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)


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

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

Additional comments not posted (8)
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (8)

1-1: Import statement is correct.

The import statement includes the necessary types from the vault module.


47-64: LGTM! The MsgWithdrawFromVault interface is well-defined.

The interface aligns with the purpose of withdrawing from a vault.


70-87: LGTM! The MsgWithdrawFromVaultSDKType interface is well-defined.

The interface aligns with the purpose of withdrawing from a vault.


90-104: LGTM! The MsgWithdrawFromVaultResponse interface is well-defined.

The interface aligns with the purpose of providing a response for withdrawing from a vault.


108-122: LGTM! The MsgWithdrawFromVaultResponseSDKType interface is well-defined.

The interface aligns with the purpose of providing a response for withdrawing from a vault.


246-252: LGTM! The createBaseMsgWithdrawFromVault function is well-defined.

The function initializes the base message correctly.


254-309: LGTM! The encoding and decoding functions for MsgWithdrawFromVault are well-defined.

The functions handle the serialization and deserialization correctly.


321-394: LGTM! The encoding and decoding functions for MsgWithdrawFromVaultResponse are well-defined.

The functions handle the serialization and deserialization correctly.

@ttl33 ttl33 merged commit 4074ccf into main Jul 1, 2024
31 of 33 checks passed
@ttl33 ttl33 deleted the tl/vault-withdraw-proto branch July 1, 2024 22:06
tqin7 pushed a commit that referenced this pull request Jul 11, 2024
tqin7 pushed a commit that referenced this pull request Jul 11, 2024
tqin7 pushed a commit that referenced this pull request Jul 11, 2024
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.

3 participants