From a99616be78551bb41681a7a8ef36b9aa7f43340a Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Thu, 28 Mar 2024 14:51:06 -0400 Subject: [PATCH 1/2] add vault query --- .../codegen/dydxprotocol/vault/query.lcd.ts | 10 +- .../dydxprotocol/vault/query.rpc.Query.ts | 16 +- .../src/codegen/dydxprotocol/vault/query.ts | 253 ++++- proto/dydxprotocol/vault/query.proto | 29 + protocol/x/vault/client/cli/query.go | 47 + protocol/x/vault/keeper/grpc_query_vault.go | 77 ++ .../x/vault/keeper/grpc_query_vault_test.go | 156 ++++ protocol/x/vault/types/query.pb.go | 883 +++++++++++++++++- protocol/x/vault/types/query.pb.gw.go | 129 +++ 9 files changed, 1578 insertions(+), 22 deletions(-) create mode 100644 protocol/x/vault/keeper/grpc_query_vault.go create mode 100644 protocol/x/vault/keeper/grpc_query_vault_test.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.lcd.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.lcd.ts index bf1e99fb60..3d7b91613c 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.lcd.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.lcd.ts @@ -1,5 +1,5 @@ import { LCDClient } from "@osmonauts/lcd"; -import { QueryParamsRequest, QueryParamsResponseSDKType } from "./query"; +import { QueryParamsRequest, QueryParamsResponseSDKType, QueryVaultRequest, QueryVaultResponseSDKType } from "./query"; export class LCDQueryClient { req: LCDClient; @@ -10,6 +10,7 @@ export class LCDQueryClient { }) { this.req = requestClient; this.params = this.params.bind(this); + this.vault = this.vault.bind(this); } /* Queries the Params. */ @@ -18,5 +19,12 @@ export class LCDQueryClient { const endpoint = `dydxprotocol/v4/vault/params`; return await this.req.get(endpoint); } + /* Queries a Vault by type and number. */ + + + async vault(params: QueryVaultRequest): Promise { + const endpoint = `dydxprotocol/v4/vault/vaults/${params.type}/${params.number}`; + return await this.req.get(endpoint); + } } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts index 26983c84e0..2aee4acbe5 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts @@ -1,12 +1,15 @@ import { Rpc } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; -import { QueryParamsRequest, QueryParamsResponse } from "./query"; +import { QueryParamsRequest, QueryParamsResponse, QueryVaultRequest, QueryVaultResponse } from "./query"; /** Query defines the gRPC querier service. */ export interface Query { /** Queries the Params. */ params(request?: QueryParamsRequest): Promise; + /** Queries a Vault by type and number. */ + + vault(request: QueryVaultRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; @@ -14,6 +17,7 @@ export class QueryClientImpl implements Query { constructor(rpc: Rpc) { this.rpc = rpc; this.params = this.params.bind(this); + this.vault = this.vault.bind(this); } params(request: QueryParamsRequest = {}): Promise { @@ -22,6 +26,12 @@ export class QueryClientImpl implements Query { return promise.then(data => QueryParamsResponse.decode(new _m0.Reader(data))); } + vault(request: QueryVaultRequest): Promise { + const data = QueryVaultRequest.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.vault.Query", "Vault", data); + return promise.then(data => QueryVaultResponse.decode(new _m0.Reader(data))); + } + } export const createRpcQueryExtension = (base: QueryClient) => { const rpc = createProtobufRpcClient(base); @@ -29,6 +39,10 @@ export const createRpcQueryExtension = (base: QueryClient) => { return { params(request?: QueryParamsRequest): Promise { return queryService.params(request); + }, + + vault(request: QueryVaultRequest): Promise { + return queryService.vault(request); } }; diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts index 095ba9f2be..443f43d4ce 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts @@ -1,6 +1,8 @@ +import { VaultType, VaultTypeSDKType, VaultId, VaultIdSDKType } from "./vault"; import { Params, ParamsSDKType } from "./params"; +import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial } from "../../helpers"; +import { DeepPartial, Long } from "../../helpers"; /** QueryParamsRequest is a request type for the Params RPC method. */ export interface QueryParamsRequest {} @@ -17,6 +19,50 @@ export interface QueryParamsResponse { export interface QueryParamsResponseSDKType { params?: ParamsSDKType; } +/** QueryVaultRequest is a request type for the Vault RPC method. */ + +export interface QueryVaultRequest { + type: VaultType; + number: number; +} +/** QueryVaultRequest is a request type for the Vault RPC method. */ + +export interface QueryVaultRequestSDKType { + type: VaultTypeSDKType; + number: number; +} +/** QueryVaultResponse is a response type for the Vault RPC method. */ + +export interface QueryVaultResponse { + vaultId?: VaultId; + subaccountId?: SubaccountId; + equity: Long; + inventory: Long; + totalShares: Long; + allOwnerShares: OwnerShares[]; +} +/** QueryVaultResponse is a response type for the Vault RPC method. */ + +export interface QueryVaultResponseSDKType { + vault_id?: VaultIdSDKType; + subaccount_id?: SubaccountIdSDKType; + equity: Long; + inventory: Long; + total_shares: Long; + all_owner_shares: OwnerSharesSDKType[]; +} +/** OwnerShares is a message type for an owner and their shares. */ + +export interface OwnerShares { + owner: string; + shares: Long; +} +/** OwnerShares is a message type for an owner and their shares. */ + +export interface OwnerSharesSDKType { + owner: string; + shares: Long; +} function createBaseQueryParamsRequest(): QueryParamsRequest { return {}; @@ -95,4 +141,209 @@ export const QueryParamsResponse = { return message; } +}; + +function createBaseQueryVaultRequest(): QueryVaultRequest { + return { + type: 0, + number: 0 + }; +} + +export const QueryVaultRequest = { + encode(message: QueryVaultRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + + if (message.number !== 0) { + writer.uint32(16).uint32(message.number); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryVaultRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVaultRequest(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.type = (reader.int32() as any); + break; + + case 2: + message.number = reader.uint32(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): QueryVaultRequest { + const message = createBaseQueryVaultRequest(); + message.type = object.type ?? 0; + message.number = object.number ?? 0; + return message; + } + +}; + +function createBaseQueryVaultResponse(): QueryVaultResponse { + return { + vaultId: undefined, + subaccountId: undefined, + equity: Long.UZERO, + inventory: Long.UZERO, + totalShares: Long.UZERO, + allOwnerShares: [] + }; +} + +export const QueryVaultResponse = { + encode(message: QueryVaultResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.vaultId !== undefined) { + VaultId.encode(message.vaultId, writer.uint32(10).fork()).ldelim(); + } + + if (message.subaccountId !== undefined) { + SubaccountId.encode(message.subaccountId, writer.uint32(18).fork()).ldelim(); + } + + if (!message.equity.isZero()) { + writer.uint32(24).uint64(message.equity); + } + + if (!message.inventory.isZero()) { + writer.uint32(32).uint64(message.inventory); + } + + if (!message.totalShares.isZero()) { + writer.uint32(40).uint64(message.totalShares); + } + + for (const v of message.allOwnerShares) { + OwnerShares.encode(v!, writer.uint32(50).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryVaultResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVaultResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.vaultId = VaultId.decode(reader, reader.uint32()); + break; + + case 2: + message.subaccountId = SubaccountId.decode(reader, reader.uint32()); + break; + + case 3: + message.equity = (reader.uint64() as Long); + break; + + case 4: + message.inventory = (reader.uint64() as Long); + break; + + case 5: + message.totalShares = (reader.uint64() as Long); + break; + + case 6: + message.allOwnerShares.push(OwnerShares.decode(reader, reader.uint32())); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): QueryVaultResponse { + const message = createBaseQueryVaultResponse(); + message.vaultId = object.vaultId !== undefined && object.vaultId !== null ? VaultId.fromPartial(object.vaultId) : undefined; + message.subaccountId = object.subaccountId !== undefined && object.subaccountId !== null ? SubaccountId.fromPartial(object.subaccountId) : undefined; + message.equity = object.equity !== undefined && object.equity !== null ? Long.fromValue(object.equity) : Long.UZERO; + message.inventory = object.inventory !== undefined && object.inventory !== null ? Long.fromValue(object.inventory) : Long.UZERO; + message.totalShares = object.totalShares !== undefined && object.totalShares !== null ? Long.fromValue(object.totalShares) : Long.UZERO; + message.allOwnerShares = object.allOwnerShares?.map(e => OwnerShares.fromPartial(e)) || []; + return message; + } + +}; + +function createBaseOwnerShares(): OwnerShares { + return { + owner: "", + shares: Long.UZERO + }; +} + +export const OwnerShares = { + encode(message: OwnerShares, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.owner !== "") { + writer.uint32(10).string(message.owner); + } + + if (!message.shares.isZero()) { + writer.uint32(16).uint64(message.shares); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OwnerShares { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOwnerShares(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + + case 2: + message.shares = (reader.uint64() as Long); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): OwnerShares { + const message = createBaseOwnerShares(); + message.owner = object.owner ?? ""; + message.shares = object.shares !== undefined && object.shares !== null ? Long.fromValue(object.shares) : Long.UZERO; + return message; + } + }; \ No newline at end of file diff --git a/proto/dydxprotocol/vault/query.proto b/proto/dydxprotocol/vault/query.proto index e4ce844f3d..8ad0b6f05e 100644 --- a/proto/dydxprotocol/vault/query.proto +++ b/proto/dydxprotocol/vault/query.proto @@ -3,7 +3,9 @@ package dydxprotocol.vault; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "dydxprotocol/subaccounts/subaccount.proto"; import "dydxprotocol/vault/params.proto"; +import "dydxprotocol/vault/vault.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"; @@ -13,6 +15,10 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/dydxprotocol/v4/vault/params"; } + // Queries a Vault by type and number. + rpc Vault(QueryVaultRequest) returns (QueryVaultResponse) { + option (google.api.http).get = "/dydxprotocol/v4/vault/vaults/{type}/{number}"; + } } // QueryParamsRequest is a request type for the Params RPC method. @@ -22,3 +28,26 @@ message QueryParamsRequest {} message QueryParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; } + +// QueryVaultRequest is a request type for the Vault RPC method. +message QueryVaultRequest { + VaultType type = 1; + uint32 number = 2; +} + +// QueryVaultResponse is a response type for the Vault RPC method. +message QueryVaultResponse { + VaultId vault_id = 1 [ (gogoproto.nullable) = false ]; + dydxprotocol.subaccounts.SubaccountId subaccount_id = 2 + [ (gogoproto.nullable) = false ]; + uint64 equity = 3; + uint64 inventory = 4; + uint64 total_shares = 5; + repeated OwnerShares all_owner_shares = 6 [ (gogoproto.nullable) = false ]; +} + +// OwnerShares is a message type for an owner and their shares. +message OwnerShares { + string owner = 1; + uint64 shares = 2; +} diff --git a/protocol/x/vault/client/cli/query.go b/protocol/x/vault/client/cli/query.go index b7220913ba..3c16747a7f 100644 --- a/protocol/x/vault/client/cli/query.go +++ b/protocol/x/vault/client/cli/query.go @@ -3,6 +3,7 @@ package cli import ( "context" "fmt" + "strconv" "github.com/spf13/cobra" @@ -23,6 +24,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdQueryVault()) return cmd } @@ -49,3 +51,48 @@ func CmdQueryParams() *cobra.Command { return cmd } + +func CmdQueryVault() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-vault [type] [number]", + Short: "get a vault by its type and number", + Long: "get a vault by its type and number. Current support types are: clob.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + // Parse vault type. + rawType := args[0] + var vaultType types.VaultType + switch rawType { + case "clob": + vaultType = types.VaultType_VAULT_TYPE_CLOB + default: + return fmt.Errorf("invalid vault type %s", rawType) + } + + // Parse vault number. + vaultNumber, err := strconv.ParseUint(args[1], 10, 32) + if err != nil { + return err + } + + res, err := queryClient.Vault( + context.Background(), + &types.QueryVaultRequest{ + Type: vaultType, + Number: uint32(vaultNumber), + }, + ) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/protocol/x/vault/keeper/grpc_query_vault.go b/protocol/x/vault/keeper/grpc_query_vault.go new file mode 100644 index 0000000000..aa8b22b3a2 --- /dev/null +++ b/protocol/x/vault/keeper/grpc_query_vault.go @@ -0,0 +1,77 @@ +package keeper + +import ( + "context" + "fmt" + "sort" + + storetypes "cosmossdk.io/store/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/dydxprotocol/v4-chain/protocol/lib" + clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +func (k Keeper) Vault( + goCtx context.Context, + req *types.QueryVaultRequest, +) (*types.QueryVaultResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := lib.UnwrapSDKContext(goCtx, types.ModuleName) + + vaultId := types.VaultId{ + Type: req.Type, + Number: req.Number, + } + + // Get total shares. + totalShares, exists := k.GetTotalShares(ctx, vaultId) + if !exists { + return nil, status.Error(codes.NotFound, "vault not found") + } + + // Get all owner shares. + allOwnerShares := []types.OwnerShares{} + ownerSharesStore := k.getVaultOwnerSharesStore(ctx, vaultId) + ownerSharesIterator := storetypes.KVStorePrefixIterator(ownerSharesStore, []byte{}) + defer ownerSharesIterator.Close() + for ; ownerSharesIterator.Valid(); ownerSharesIterator.Next() { + var shares types.NumShares + k.cdc.MustUnmarshal(ownerSharesIterator.Value(), &shares) + + allOwnerShares = append(allOwnerShares, types.OwnerShares{ + Owner: string(ownerSharesIterator.Key()), + Shares: shares.NumShares.BigInt().Uint64(), + }) + } + sort.Slice(allOwnerShares, func(i, j int) bool { + return allOwnerShares[i].Shares > allOwnerShares[j].Shares + }) + + // Get vault equity. + equity, err := k.GetVaultEquity(ctx, vaultId) + if err != nil { + return nil, status.Error(codes.Internal, "failed to get vault equity") + } + + // Get vault inventory. + clobPair, exists := k.clobKeeper.GetClobPair(ctx, clobtypes.ClobPairId(vaultId.Number)) + if !exists { + return nil, status.Error(codes.Internal, fmt.Sprintf("clob pair %d doesn't exist", vaultId.Number)) + } + perpId := clobPair.Metadata.(*clobtypes.ClobPair_PerpetualClobMetadata).PerpetualClobMetadata.PerpetualId + inventory := k.GetVaultInventoryInPerpetual(ctx, vaultId, perpId) + + return &types.QueryVaultResponse{ + VaultId: vaultId, + SubaccountId: *vaultId.ToSubaccountId(), + Equity: equity.Uint64(), + Inventory: inventory.Uint64(), + TotalShares: totalShares.NumShares.BigInt().Uint64(), + AllOwnerShares: allOwnerShares, + }, nil +} diff --git a/protocol/x/vault/keeper/grpc_query_vault_test.go b/protocol/x/vault/keeper/grpc_query_vault_test.go new file mode 100644 index 0000000000..66695aef72 --- /dev/null +++ b/protocol/x/vault/keeper/grpc_query_vault_test.go @@ -0,0 +1,156 @@ +package keeper_test + +import ( + "math/big" + "testing" + + "github.com/cometbft/cometbft/types" + "github.com/dydxprotocol/v4-chain/protocol/dtypes" + testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + assettypes "github.com/dydxprotocol/v4-chain/protocol/x/assets/types" + satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" + "github.com/stretchr/testify/require" +) + +func TestVault(t *testing.T) { + tests := map[string]struct { + /* --- Setup --- */ + // Vault ID. + vaultId vaulttypes.VaultId + // Vault asset. + asset *big.Int + // Perp ID that corresponds to the vault. + perpId uint32 + // Vault inventory. + inventory *big.Int + // Total shares. + totalShares *big.Int + // All owner shares (in descending number of shares). + allOwnerShares []vaulttypes.OwnerShares + // Query request. + req *vaulttypes.QueryVaultRequest + + /* --- Expectations --- */ + expectedEquity uint64 + expectedErr string + }{ + "Success": { + req: &vaulttypes.QueryVaultRequest{ + Type: vaulttypes.VaultType_VAULT_TYPE_CLOB, + Number: 0, + }, + vaultId: constants.Vault_Clob_0, + asset: big.NewInt(100), + perpId: 0, + inventory: big.NewInt(200), + totalShares: big.NewInt(300), + allOwnerShares: []vaulttypes.OwnerShares{ + { + Owner: constants.Alice_Num0.Owner, + Shares: 244, + }, + { + Owner: constants.Bob_Num0.Owner, + Shares: 56, + }, + }, + expectedEquity: 500, + }, + "Error: query non-existent vault": { + req: &vaulttypes.QueryVaultRequest{ + Type: vaulttypes.VaultType_VAULT_TYPE_CLOB, + Number: 1, // Non-existent vault. + }, + vaultId: constants.Vault_Clob_0, + asset: big.NewInt(100), + perpId: 0, + inventory: big.NewInt(200), + totalShares: big.NewInt(300), + allOwnerShares: []vaulttypes.OwnerShares{ + { + Owner: constants.Alice_Num0.Owner, + Shares: 244, + }, + { + Owner: constants.Bob_Num0.Owner, + Shares: 56, + }, + }, + expectedErr: "vault not found", + }, + "Error: nil request": { + req: nil, + vaultId: constants.Vault_Clob_0, + asset: big.NewInt(100), + perpId: 0, + inventory: big.NewInt(200), + totalShares: big.NewInt(300), + expectedErr: "invalid request", + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).WithGenesisDocFn(func() (genesis types.GenesisDoc) { + genesis = testapp.DefaultGenesis() + testapp.UpdateGenesisDocWithAppStateForModule( + &genesis, + func(genesisState *satypes.GenesisState) { + genesisState.Subaccounts = []satypes.Subaccount{ + { + Id: tc.vaultId.ToSubaccountId(), + AssetPositions: []*satypes.AssetPosition{ + { + AssetId: assettypes.AssetUsdc.Id, + Quantums: dtypes.NewIntFromBigInt(tc.asset), + }, + }, + PerpetualPositions: []*satypes.PerpetualPosition{ + { + PerpetualId: tc.perpId, + Quantums: dtypes.NewIntFromBigInt(tc.inventory), + }, + }, + }, + } + }, + ) + return genesis + }).Build() + ctx := tApp.InitChain() + k := tApp.App.VaultKeeper + + // Set total shares and owner shares. + err := k.SetTotalShares(ctx, tc.vaultId, vaulttypes.BigIntToNumShares(tc.totalShares)) + require.NoError(t, err) + for _, ownerShares := range tc.allOwnerShares { + err := k.SetOwnerShares( + ctx, + tc.vaultId, + ownerShares.Owner, + vaulttypes.BigIntToNumShares(big.NewInt(int64(ownerShares.Shares))), + ) + require.NoError(t, err) + } + + // Check Vault query response is as expected. + response, err := k.Vault(ctx, tc.req) + if tc.expectedErr != "" { + require.ErrorContains(t, err, tc.expectedErr) + } else { + require.NoError(t, err) + expectedResponse := vaulttypes.QueryVaultResponse{ + VaultId: tc.vaultId, + SubaccountId: *tc.vaultId.ToSubaccountId(), + Equity: tc.expectedEquity, + Inventory: tc.inventory.Uint64(), + TotalShares: tc.totalShares.Uint64(), + AllOwnerShares: tc.allOwnerShares, + } + require.Equal(t, expectedResponse, *response) + } + }) + } +} diff --git a/protocol/x/vault/types/query.pb.go b/protocol/x/vault/types/query.pb.go index e186b0d621..6c5f947651 100644 --- a/protocol/x/vault/types/query.pb.go +++ b/protocol/x/vault/types/query.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + types "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -111,33 +112,244 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryVaultRequest is a request type for the Vault RPC method. +type QueryVaultRequest struct { + Type VaultType `protobuf:"varint,1,opt,name=type,proto3,enum=dydxprotocol.vault.VaultType" json:"type,omitempty"` + Number uint32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` +} + +func (m *QueryVaultRequest) Reset() { *m = QueryVaultRequest{} } +func (m *QueryVaultRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVaultRequest) ProtoMessage() {} +func (*QueryVaultRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_478fb8dc0ff21ea6, []int{2} +} +func (m *QueryVaultRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVaultRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVaultRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryVaultRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVaultRequest.Merge(m, src) +} +func (m *QueryVaultRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVaultRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVaultRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVaultRequest proto.InternalMessageInfo + +func (m *QueryVaultRequest) GetType() VaultType { + if m != nil { + return m.Type + } + return VaultType_VAULT_TYPE_UNSPECIFIED +} + +func (m *QueryVaultRequest) GetNumber() uint32 { + if m != nil { + return m.Number + } + return 0 +} + +// QueryVaultResponse is a response type for the Vault RPC method. +type QueryVaultResponse struct { + VaultId VaultId `protobuf:"bytes,1,opt,name=vault_id,json=vaultId,proto3" json:"vault_id"` + SubaccountId types.SubaccountId `protobuf:"bytes,2,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id"` + Equity uint64 `protobuf:"varint,3,opt,name=equity,proto3" json:"equity,omitempty"` + Inventory uint64 `protobuf:"varint,4,opt,name=inventory,proto3" json:"inventory,omitempty"` + TotalShares uint64 `protobuf:"varint,5,opt,name=total_shares,json=totalShares,proto3" json:"total_shares,omitempty"` + AllOwnerShares []OwnerShares `protobuf:"bytes,6,rep,name=all_owner_shares,json=allOwnerShares,proto3" json:"all_owner_shares"` +} + +func (m *QueryVaultResponse) Reset() { *m = QueryVaultResponse{} } +func (m *QueryVaultResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVaultResponse) ProtoMessage() {} +func (*QueryVaultResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_478fb8dc0ff21ea6, []int{3} +} +func (m *QueryVaultResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVaultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVaultResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryVaultResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVaultResponse.Merge(m, src) +} +func (m *QueryVaultResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVaultResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVaultResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVaultResponse proto.InternalMessageInfo + +func (m *QueryVaultResponse) GetVaultId() VaultId { + if m != nil { + return m.VaultId + } + return VaultId{} +} + +func (m *QueryVaultResponse) GetSubaccountId() types.SubaccountId { + if m != nil { + return m.SubaccountId + } + return types.SubaccountId{} +} + +func (m *QueryVaultResponse) GetEquity() uint64 { + if m != nil { + return m.Equity + } + return 0 +} + +func (m *QueryVaultResponse) GetInventory() uint64 { + if m != nil { + return m.Inventory + } + return 0 +} + +func (m *QueryVaultResponse) GetTotalShares() uint64 { + if m != nil { + return m.TotalShares + } + return 0 +} + +func (m *QueryVaultResponse) GetAllOwnerShares() []OwnerShares { + if m != nil { + return m.AllOwnerShares + } + return nil +} + +// OwnerShares is a message type for an owner and their shares. +type OwnerShares struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Shares uint64 `protobuf:"varint,2,opt,name=shares,proto3" json:"shares,omitempty"` +} + +func (m *OwnerShares) Reset() { *m = OwnerShares{} } +func (m *OwnerShares) String() string { return proto.CompactTextString(m) } +func (*OwnerShares) ProtoMessage() {} +func (*OwnerShares) Descriptor() ([]byte, []int) { + return fileDescriptor_478fb8dc0ff21ea6, []int{4} +} +func (m *OwnerShares) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OwnerShares) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OwnerShares.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OwnerShares) XXX_Merge(src proto.Message) { + xxx_messageInfo_OwnerShares.Merge(m, src) +} +func (m *OwnerShares) XXX_Size() int { + return m.Size() +} +func (m *OwnerShares) XXX_DiscardUnknown() { + xxx_messageInfo_OwnerShares.DiscardUnknown(m) +} + +var xxx_messageInfo_OwnerShares proto.InternalMessageInfo + +func (m *OwnerShares) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *OwnerShares) GetShares() uint64 { + if m != nil { + return m.Shares + } + return 0 +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "dydxprotocol.vault.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "dydxprotocol.vault.QueryParamsResponse") + proto.RegisterType((*QueryVaultRequest)(nil), "dydxprotocol.vault.QueryVaultRequest") + proto.RegisterType((*QueryVaultResponse)(nil), "dydxprotocol.vault.QueryVaultResponse") + proto.RegisterType((*OwnerShares)(nil), "dydxprotocol.vault.OwnerShares") } func init() { proto.RegisterFile("dydxprotocol/vault/query.proto", fileDescriptor_478fb8dc0ff21ea6) } var fileDescriptor_478fb8dc0ff21ea6 = []byte{ - // 275 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xa9, 0x4c, 0xa9, - 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4b, 0x2c, 0xcd, 0x29, 0xd1, 0x2f, - 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x03, 0x0b, 0x0a, 0x09, 0x21, 0xcb, 0xeb, 0x81, 0xe5, 0xa5, 0x44, - 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x62, 0xfa, 0x20, 0x16, 0x44, 0xa5, 0x94, 0x4c, 0x7a, 0x7e, 0x7e, - 0x7a, 0x4e, 0xaa, 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, 0x49, 0x62, 0x49, 0x66, - 0x7e, 0x5e, 0x31, 0x54, 0x56, 0x1e, 0x8b, 0x3d, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x05, 0x4a, - 0x22, 0x5c, 0x42, 0x81, 0x20, 0x7b, 0x03, 0xc0, 0x82, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, - 0x4a, 0xfe, 0x5c, 0xc2, 0x28, 0xa2, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x16, 0x5c, 0x6c, - 0x10, 0xcd, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x52, 0x7a, 0x98, 0xce, 0xd4, 0x83, 0xe8, - 0x71, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0xde, 0xa8, 0x8b, 0x91, 0x8b, 0x15, 0x6c, - 0xa2, 0x50, 0x03, 0x23, 0x17, 0x1b, 0x44, 0x89, 0x90, 0x1a, 0x36, 0xed, 0x98, 0xae, 0x91, 0x52, - 0x27, 0xa8, 0x0e, 0xe2, 0x3e, 0x25, 0xd5, 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0xc9, 0x0b, 0xc9, 0xea, - 0xa3, 0x7a, 0xdb, 0x04, 0xc5, 0xe7, 0x4e, 0x81, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, - 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, - 0xc7, 0x10, 0x65, 0x9e, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x8b, 0x6e, 0x84, - 0x6e, 0x72, 0x46, 0x62, 0x66, 0x9e, 0x3e, 0x5c, 0xa4, 0x02, 0x6a, 0x66, 0x49, 0x65, 0x41, 0x6a, - 0x71, 0x12, 0x1b, 0x58, 0xdc, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x2c, 0xa1, 0x80, 0x8e, 0xd8, - 0x01, 0x00, 0x00, + // 559 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0x6e, 0x93, 0x68, 0x27, 0x6d, 0xd1, 0x31, 0x48, 0x88, 0xed, 0x26, 0x2e, 0x34, 0xc6, + 0x43, 0x77, 0x31, 0x2a, 0x0a, 0x7a, 0xea, 0xcd, 0x53, 0xcc, 0x56, 0x3c, 0x78, 0x30, 0x4c, 0x92, + 0x21, 0x59, 0xd8, 0xcc, 0x6c, 0x76, 0x66, 0x63, 0x97, 0x52, 0x10, 0xef, 0x82, 0xe0, 0xcd, 0x5f, + 0xd4, 0x9b, 0x05, 0x2f, 0x9e, 0x44, 0x12, 0x7f, 0x88, 0xec, 0x9b, 0x69, 0xba, 0x69, 0x13, 0x7a, + 0x59, 0xe6, 0x7d, 0xef, 0x9b, 0xef, 0x7b, 0x6f, 0xde, 0x5b, 0x64, 0x0d, 0x92, 0xc1, 0x71, 0x18, + 0x71, 0xc9, 0xfb, 0x3c, 0x70, 0xa7, 0x24, 0x0e, 0xa4, 0x3b, 0x89, 0x69, 0x94, 0x38, 0x00, 0x62, + 0x9c, 0xcd, 0x3b, 0x90, 0xaf, 0x96, 0x87, 0x7c, 0xc8, 0x01, 0x73, 0xd3, 0x93, 0x62, 0x56, 0x77, + 0x87, 0x9c, 0x0f, 0x03, 0xea, 0x92, 0xd0, 0x77, 0x09, 0x63, 0x5c, 0x12, 0xe9, 0x73, 0x26, 0x74, + 0xf6, 0xf1, 0x92, 0x8f, 0x88, 0x7b, 0xa4, 0xdf, 0xe7, 0x31, 0x93, 0x22, 0x73, 0xd6, 0xd4, 0xda, + 0x8a, 0x92, 0x42, 0x12, 0x91, 0xf1, 0x85, 0xd6, 0xaa, 0x9a, 0xe1, 0xab, 0xf2, 0x76, 0x19, 0xe1, + 0x4e, 0xda, 0xc2, 0x5b, 0xb8, 0xe4, 0xd1, 0x49, 0x4c, 0x85, 0xb4, 0xdb, 0xe8, 0xde, 0x12, 0x2a, + 0x42, 0xce, 0x04, 0xc5, 0x2f, 0x51, 0x51, 0x89, 0x57, 0x8c, 0xba, 0xd1, 0x2c, 0xb5, 0xaa, 0xce, + 0xf5, 0x8e, 0x1d, 0x75, 0xe7, 0x30, 0x7f, 0xf6, 0xa7, 0x96, 0xf3, 0x34, 0xdf, 0xfe, 0x88, 0xee, + 0x82, 0xe0, 0xfb, 0x94, 0xa2, 0x5d, 0xf0, 0x13, 0x94, 0x97, 0x49, 0x48, 0x41, 0x6c, 0xa7, 0xb5, + 0xb7, 0x4a, 0x0c, 0xf8, 0xef, 0x92, 0x90, 0x7a, 0x40, 0xc5, 0xf7, 0x51, 0x91, 0xc5, 0xe3, 0x1e, + 0x8d, 0x2a, 0x66, 0xdd, 0x68, 0x6e, 0x7b, 0x3a, 0xb2, 0x7f, 0x9a, 0xba, 0x0f, 0x6d, 0xa0, 0x0b, + 0x7e, 0x8d, 0x6e, 0x83, 0x4e, 0xd7, 0x1f, 0xe8, 0x92, 0x1f, 0xac, 0x75, 0x79, 0x33, 0xd0, 0x35, + 0xdf, 0x9a, 0xaa, 0x10, 0x77, 0xd0, 0xf6, 0xe5, 0x83, 0xa7, 0x12, 0x26, 0x48, 0x34, 0x96, 0x25, + 0x32, 0xf3, 0x71, 0x8e, 0x16, 0xe7, 0x85, 0xda, 0x96, 0xc8, 0x60, 0x69, 0xfd, 0x74, 0x12, 0xfb, + 0x32, 0xa9, 0x6c, 0xd4, 0x8d, 0x66, 0xde, 0xd3, 0x11, 0xde, 0x45, 0x9b, 0x3e, 0x9b, 0x52, 0x26, + 0x79, 0x94, 0x54, 0xf2, 0x90, 0xba, 0x04, 0xf0, 0x43, 0xb4, 0x25, 0xb9, 0x24, 0x41, 0x57, 0x8c, + 0x48, 0x44, 0x45, 0xa5, 0x00, 0x84, 0x12, 0x60, 0x47, 0x00, 0xe1, 0x36, 0xba, 0x43, 0x82, 0xa0, + 0xcb, 0x3f, 0x31, 0x1a, 0x5d, 0xd0, 0x8a, 0xf5, 0x8d, 0x66, 0xa9, 0x55, 0x5b, 0xd5, 0x71, 0x3b, + 0xe5, 0xa9, 0xab, 0xba, 0xce, 0x1d, 0x12, 0x04, 0x19, 0xd4, 0x7e, 0x85, 0x4a, 0x99, 0x10, 0x97, + 0x51, 0x01, 0xb4, 0xe1, 0x19, 0x37, 0x3d, 0x15, 0xa4, 0xed, 0x68, 0x2f, 0x53, 0xb5, 0xa3, 0xa2, + 0xd6, 0x0f, 0x13, 0x15, 0x60, 0x1c, 0xf8, 0xb3, 0x81, 0x8a, 0x6a, 0x23, 0x70, 0x63, 0x55, 0x21, + 0xd7, 0x97, 0xaf, 0xfa, 0xe8, 0x46, 0x9e, 0x9a, 0xae, 0xbd, 0xff, 0xe5, 0xd7, 0xbf, 0xef, 0x66, + 0x0d, 0xef, 0xb9, 0xcb, 0x4b, 0xfe, 0x6c, 0xe9, 0x47, 0xc0, 0x5f, 0x0d, 0x54, 0x80, 0x09, 0xe3, + 0xfd, 0xb5, 0xca, 0xd9, 0xbd, 0xac, 0x36, 0x6e, 0xa2, 0x69, 0xff, 0xe7, 0xe0, 0xef, 0xe2, 0x83, + 0x35, 0xfe, 0xf0, 0x15, 0xee, 0x49, 0xba, 0xb9, 0xa7, 0xee, 0x89, 0x5a, 0xd5, 0xd3, 0xc3, 0xce, + 0xd9, 0xcc, 0x32, 0xce, 0x67, 0x96, 0xf1, 0x77, 0x66, 0x19, 0xdf, 0xe6, 0x56, 0xee, 0x7c, 0x6e, + 0xe5, 0x7e, 0xcf, 0xad, 0xdc, 0x87, 0x17, 0x43, 0x5f, 0x8e, 0xe2, 0x9e, 0xd3, 0xe7, 0xe3, 0xab, + 0x92, 0x07, 0xfd, 0x11, 0xf1, 0x99, 0xbb, 0x40, 0x8e, 0xb5, 0x47, 0xaa, 0x2d, 0x7a, 0x45, 0xc0, + 0x9f, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x6a, 0xd1, 0x53, 0xbe, 0xa2, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -154,6 +366,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Queries the Params. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a Vault by type and number. + Vault(ctx context.Context, in *QueryVaultRequest, opts ...grpc.CallOption) (*QueryVaultResponse, error) } type queryClient struct { @@ -173,10 +387,21 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) Vault(ctx context.Context, in *QueryVaultRequest, opts ...grpc.CallOption) (*QueryVaultResponse, error) { + out := new(QueryVaultResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.vault.Query/Vault", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Queries the Params. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a Vault by type and number. + Vault(context.Context, *QueryVaultRequest) (*QueryVaultResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -186,6 +411,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) Vault(ctx context.Context, req *QueryVaultRequest) (*QueryVaultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Vault not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -209,6 +437,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_Vault_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVaultRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Vault(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.vault.Query/Vault", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Vault(ctx, req.(*QueryVaultRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "dydxprotocol.vault.Query", HandlerType: (*QueryServer)(nil), @@ -217,6 +463,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "Vault", + Handler: _Query_Vault_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "dydxprotocol/vault/query.proto", @@ -278,6 +528,146 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryVaultRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryVaultRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVaultRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Number != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x10 + } + if m.Type != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVaultResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryVaultResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVaultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AllOwnerShares) > 0 { + for iNdEx := len(m.AllOwnerShares) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AllOwnerShares[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.TotalShares != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.TotalShares)) + i-- + dAtA[i] = 0x28 + } + if m.Inventory != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Inventory)) + i-- + dAtA[i] = 0x20 + } + if m.Equity != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Equity)) + i-- + dAtA[i] = 0x18 + } + { + size, err := m.SubaccountId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.VaultId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *OwnerShares) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OwnerShares) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OwnerShares) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Shares != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Shares)) + i-- + dAtA[i] = 0x10 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -309,6 +699,65 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryVaultRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovQuery(uint64(m.Type)) + } + if m.Number != 0 { + n += 1 + sovQuery(uint64(m.Number)) + } + return n +} + +func (m *QueryVaultResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.VaultId.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.SubaccountId.Size() + n += 1 + l + sovQuery(uint64(l)) + if m.Equity != 0 { + n += 1 + sovQuery(uint64(m.Equity)) + } + if m.Inventory != 0 { + n += 1 + sovQuery(uint64(m.Inventory)) + } + if m.TotalShares != 0 { + n += 1 + sovQuery(uint64(m.TotalShares)) + } + if len(m.AllOwnerShares) > 0 { + for _, e := range m.AllOwnerShares { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *OwnerShares) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Shares != 0 { + n += 1 + sovQuery(uint64(m.Shares)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -448,6 +897,402 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryVaultRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryVaultRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVaultRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= VaultType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVaultResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryVaultResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVaultResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VaultId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VaultId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubaccountId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SubaccountId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Equity", wireType) + } + m.Equity = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Equity |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Inventory", wireType) + } + m.Inventory = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Inventory |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalShares", wireType) + } + m.TotalShares = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalShares |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllOwnerShares", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllOwnerShares = append(m.AllOwnerShares, OwnerShares{}) + if err := m.AllOwnerShares[len(m.AllOwnerShares)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OwnerShares) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OwnerShares: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OwnerShares: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) + } + m.Shares = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Shares |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/protocol/x/vault/types/query.pb.gw.go b/protocol/x/vault/types/query.pb.gw.go index 40cafb6ba6..7cf3f8de49 100644 --- a/protocol/x/vault/types/query.pb.gw.go +++ b/protocol/x/vault/types/query.pb.gw.go @@ -51,6 +51,88 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_Vault_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVaultRequest + var metadata runtime.ServerMetadata + + var ( + val string + e int32 + ok bool + err error + _ = err + ) + + val, ok = pathParams["type"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "type") + } + + e, err = runtime.Enum(val, VaultType_value) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "type", err) + } + + protoReq.Type = VaultType(e) + + val, ok = pathParams["number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "number") + } + + protoReq.Number, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "number", err) + } + + msg, err := client.Vault(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Vault_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVaultRequest + var metadata runtime.ServerMetadata + + var ( + val string + e int32 + ok bool + err error + _ = err + ) + + val, ok = pathParams["type"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "type") + } + + e, err = runtime.Enum(val, VaultType_value) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "type", err) + } + + protoReq.Type = VaultType(e) + + val, ok = pathParams["number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "number") + } + + protoReq.Number, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "number", err) + } + + msg, err := server.Vault(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -80,6 +162,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Vault_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Vault_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Vault_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +246,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Vault_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Vault_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Vault_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dydxprotocol", "v4", "vault", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Vault_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"dydxprotocol", "v4", "vault", "vaults", "type", "number"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Vault_0 = runtime.ForwardResponseMessage ) From 3ceb80c22a04a323554bdb1571cff64a8b0d2984 Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Thu, 28 Mar 2024 15:06:42 -0400 Subject: [PATCH 2/2] remove owner shares from query response --- .../src/codegen/dydxprotocol/vault/query.ts | 81 +--- proto/dydxprotocol/vault/query.proto | 10 +- protocol/x/vault/keeper/grpc_query_vault.go | 31 +- .../x/vault/keeper/grpc_query_vault_test.go | 54 +-- protocol/x/vault/types/query.pb.go | 347 ++---------------- 5 files changed, 57 insertions(+), 466 deletions(-) diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts index 443f43d4ce..5c1bae70b8 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts @@ -39,7 +39,6 @@ export interface QueryVaultResponse { equity: Long; inventory: Long; totalShares: Long; - allOwnerShares: OwnerShares[]; } /** QueryVaultResponse is a response type for the Vault RPC method. */ @@ -49,19 +48,6 @@ export interface QueryVaultResponseSDKType { equity: Long; inventory: Long; total_shares: Long; - all_owner_shares: OwnerSharesSDKType[]; -} -/** OwnerShares is a message type for an owner and their shares. */ - -export interface OwnerShares { - owner: string; - shares: Long; -} -/** OwnerShares is a message type for an owner and their shares. */ - -export interface OwnerSharesSDKType { - owner: string; - shares: Long; } function createBaseQueryParamsRequest(): QueryParamsRequest { @@ -204,8 +190,7 @@ function createBaseQueryVaultResponse(): QueryVaultResponse { subaccountId: undefined, equity: Long.UZERO, inventory: Long.UZERO, - totalShares: Long.UZERO, - allOwnerShares: [] + totalShares: Long.UZERO }; } @@ -231,10 +216,6 @@ export const QueryVaultResponse = { writer.uint32(40).uint64(message.totalShares); } - for (const v of message.allOwnerShares) { - OwnerShares.encode(v!, writer.uint32(50).fork()).ldelim(); - } - return writer; }, @@ -267,10 +248,6 @@ export const QueryVaultResponse = { message.totalShares = (reader.uint64() as Long); break; - case 6: - message.allOwnerShares.push(OwnerShares.decode(reader, reader.uint32())); - break; - default: reader.skipType(tag & 7); break; @@ -287,62 +264,6 @@ export const QueryVaultResponse = { message.equity = object.equity !== undefined && object.equity !== null ? Long.fromValue(object.equity) : Long.UZERO; message.inventory = object.inventory !== undefined && object.inventory !== null ? Long.fromValue(object.inventory) : Long.UZERO; message.totalShares = object.totalShares !== undefined && object.totalShares !== null ? Long.fromValue(object.totalShares) : Long.UZERO; - message.allOwnerShares = object.allOwnerShares?.map(e => OwnerShares.fromPartial(e)) || []; - return message; - } - -}; - -function createBaseOwnerShares(): OwnerShares { - return { - owner: "", - shares: Long.UZERO - }; -} - -export const OwnerShares = { - encode(message: OwnerShares, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.owner !== "") { - writer.uint32(10).string(message.owner); - } - - if (!message.shares.isZero()) { - writer.uint32(16).uint64(message.shares); - } - - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): OwnerShares { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseOwnerShares(); - - while (reader.pos < end) { - const tag = reader.uint32(); - - switch (tag >>> 3) { - case 1: - message.owner = reader.string(); - break; - - case 2: - message.shares = (reader.uint64() as Long); - break; - - default: - reader.skipType(tag & 7); - break; - } - } - - return message; - }, - - fromPartial(object: DeepPartial): OwnerShares { - const message = createBaseOwnerShares(); - message.owner = object.owner ?? ""; - message.shares = object.shares !== undefined && object.shares !== null ? Long.fromValue(object.shares) : Long.UZERO; return message; } diff --git a/proto/dydxprotocol/vault/query.proto b/proto/dydxprotocol/vault/query.proto index 8ad0b6f05e..019a07acb5 100644 --- a/proto/dydxprotocol/vault/query.proto +++ b/proto/dydxprotocol/vault/query.proto @@ -17,7 +17,8 @@ service Query { } // Queries a Vault by type and number. rpc Vault(QueryVaultRequest) returns (QueryVaultResponse) { - option (google.api.http).get = "/dydxprotocol/v4/vault/vaults/{type}/{number}"; + option (google.api.http).get = + "/dydxprotocol/v4/vault/vaults/{type}/{number}"; } } @@ -43,11 +44,4 @@ message QueryVaultResponse { uint64 equity = 3; uint64 inventory = 4; uint64 total_shares = 5; - repeated OwnerShares all_owner_shares = 6 [ (gogoproto.nullable) = false ]; -} - -// OwnerShares is a message type for an owner and their shares. -message OwnerShares { - string owner = 1; - uint64 shares = 2; } diff --git a/protocol/x/vault/keeper/grpc_query_vault.go b/protocol/x/vault/keeper/grpc_query_vault.go index aa8b22b3a2..48f7873b68 100644 --- a/protocol/x/vault/keeper/grpc_query_vault.go +++ b/protocol/x/vault/keeper/grpc_query_vault.go @@ -3,9 +3,7 @@ package keeper import ( "context" "fmt" - "sort" - storetypes "cosmossdk.io/store/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -34,24 +32,6 @@ func (k Keeper) Vault( return nil, status.Error(codes.NotFound, "vault not found") } - // Get all owner shares. - allOwnerShares := []types.OwnerShares{} - ownerSharesStore := k.getVaultOwnerSharesStore(ctx, vaultId) - ownerSharesIterator := storetypes.KVStorePrefixIterator(ownerSharesStore, []byte{}) - defer ownerSharesIterator.Close() - for ; ownerSharesIterator.Valid(); ownerSharesIterator.Next() { - var shares types.NumShares - k.cdc.MustUnmarshal(ownerSharesIterator.Value(), &shares) - - allOwnerShares = append(allOwnerShares, types.OwnerShares{ - Owner: string(ownerSharesIterator.Key()), - Shares: shares.NumShares.BigInt().Uint64(), - }) - } - sort.Slice(allOwnerShares, func(i, j int) bool { - return allOwnerShares[i].Shares > allOwnerShares[j].Shares - }) - // Get vault equity. equity, err := k.GetVaultEquity(ctx, vaultId) if err != nil { @@ -67,11 +47,10 @@ func (k Keeper) Vault( inventory := k.GetVaultInventoryInPerpetual(ctx, vaultId, perpId) return &types.QueryVaultResponse{ - VaultId: vaultId, - SubaccountId: *vaultId.ToSubaccountId(), - Equity: equity.Uint64(), - Inventory: inventory.Uint64(), - TotalShares: totalShares.NumShares.BigInt().Uint64(), - AllOwnerShares: allOwnerShares, + VaultId: vaultId, + SubaccountId: *vaultId.ToSubaccountId(), + Equity: equity.Uint64(), + Inventory: inventory.Uint64(), + TotalShares: totalShares.NumShares.BigInt().Uint64(), }, nil } diff --git a/protocol/x/vault/keeper/grpc_query_vault_test.go b/protocol/x/vault/keeper/grpc_query_vault_test.go index 66695aef72..07d02a166a 100644 --- a/protocol/x/vault/keeper/grpc_query_vault_test.go +++ b/protocol/x/vault/keeper/grpc_query_vault_test.go @@ -27,8 +27,6 @@ func TestVault(t *testing.T) { inventory *big.Int // Total shares. totalShares *big.Int - // All owner shares (in descending number of shares). - allOwnerShares []vaulttypes.OwnerShares // Query request. req *vaulttypes.QueryVaultRequest @@ -41,21 +39,11 @@ func TestVault(t *testing.T) { Type: vaulttypes.VaultType_VAULT_TYPE_CLOB, Number: 0, }, - vaultId: constants.Vault_Clob_0, - asset: big.NewInt(100), - perpId: 0, - inventory: big.NewInt(200), - totalShares: big.NewInt(300), - allOwnerShares: []vaulttypes.OwnerShares{ - { - Owner: constants.Alice_Num0.Owner, - Shares: 244, - }, - { - Owner: constants.Bob_Num0.Owner, - Shares: 56, - }, - }, + vaultId: constants.Vault_Clob_0, + asset: big.NewInt(100), + perpId: 0, + inventory: big.NewInt(200), + totalShares: big.NewInt(300), expectedEquity: 500, }, "Error: query non-existent vault": { @@ -68,16 +56,6 @@ func TestVault(t *testing.T) { perpId: 0, inventory: big.NewInt(200), totalShares: big.NewInt(300), - allOwnerShares: []vaulttypes.OwnerShares{ - { - Owner: constants.Alice_Num0.Owner, - Shares: 244, - }, - { - Owner: constants.Bob_Num0.Owner, - Shares: 56, - }, - }, expectedErr: "vault not found", }, "Error: nil request": { @@ -122,18 +100,9 @@ func TestVault(t *testing.T) { ctx := tApp.InitChain() k := tApp.App.VaultKeeper - // Set total shares and owner shares. + // Set total shares. err := k.SetTotalShares(ctx, tc.vaultId, vaulttypes.BigIntToNumShares(tc.totalShares)) require.NoError(t, err) - for _, ownerShares := range tc.allOwnerShares { - err := k.SetOwnerShares( - ctx, - tc.vaultId, - ownerShares.Owner, - vaulttypes.BigIntToNumShares(big.NewInt(int64(ownerShares.Shares))), - ) - require.NoError(t, err) - } // Check Vault query response is as expected. response, err := k.Vault(ctx, tc.req) @@ -142,12 +111,11 @@ func TestVault(t *testing.T) { } else { require.NoError(t, err) expectedResponse := vaulttypes.QueryVaultResponse{ - VaultId: tc.vaultId, - SubaccountId: *tc.vaultId.ToSubaccountId(), - Equity: tc.expectedEquity, - Inventory: tc.inventory.Uint64(), - TotalShares: tc.totalShares.Uint64(), - AllOwnerShares: tc.allOwnerShares, + VaultId: tc.vaultId, + SubaccountId: *tc.vaultId.ToSubaccountId(), + Equity: tc.expectedEquity, + Inventory: tc.inventory.Uint64(), + TotalShares: tc.totalShares.Uint64(), } require.Equal(t, expectedResponse, *response) } diff --git a/protocol/x/vault/types/query.pb.go b/protocol/x/vault/types/query.pb.go index 6c5f947651..ecc6d74eb1 100644 --- a/protocol/x/vault/types/query.pb.go +++ b/protocol/x/vault/types/query.pb.go @@ -167,12 +167,11 @@ func (m *QueryVaultRequest) GetNumber() uint32 { // QueryVaultResponse is a response type for the Vault RPC method. type QueryVaultResponse struct { - VaultId VaultId `protobuf:"bytes,1,opt,name=vault_id,json=vaultId,proto3" json:"vault_id"` - SubaccountId types.SubaccountId `protobuf:"bytes,2,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id"` - Equity uint64 `protobuf:"varint,3,opt,name=equity,proto3" json:"equity,omitempty"` - Inventory uint64 `protobuf:"varint,4,opt,name=inventory,proto3" json:"inventory,omitempty"` - TotalShares uint64 `protobuf:"varint,5,opt,name=total_shares,json=totalShares,proto3" json:"total_shares,omitempty"` - AllOwnerShares []OwnerShares `protobuf:"bytes,6,rep,name=all_owner_shares,json=allOwnerShares,proto3" json:"all_owner_shares"` + VaultId VaultId `protobuf:"bytes,1,opt,name=vault_id,json=vaultId,proto3" json:"vault_id"` + SubaccountId types.SubaccountId `protobuf:"bytes,2,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id"` + Equity uint64 `protobuf:"varint,3,opt,name=equity,proto3" json:"equity,omitempty"` + Inventory uint64 `protobuf:"varint,4,opt,name=inventory,proto3" json:"inventory,omitempty"` + TotalShares uint64 `protobuf:"varint,5,opt,name=total_shares,json=totalShares,proto3" json:"total_shares,omitempty"` } func (m *QueryVaultResponse) Reset() { *m = QueryVaultResponse{} } @@ -243,113 +242,49 @@ func (m *QueryVaultResponse) GetTotalShares() uint64 { return 0 } -func (m *QueryVaultResponse) GetAllOwnerShares() []OwnerShares { - if m != nil { - return m.AllOwnerShares - } - return nil -} - -// OwnerShares is a message type for an owner and their shares. -type OwnerShares struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` - Shares uint64 `protobuf:"varint,2,opt,name=shares,proto3" json:"shares,omitempty"` -} - -func (m *OwnerShares) Reset() { *m = OwnerShares{} } -func (m *OwnerShares) String() string { return proto.CompactTextString(m) } -func (*OwnerShares) ProtoMessage() {} -func (*OwnerShares) Descriptor() ([]byte, []int) { - return fileDescriptor_478fb8dc0ff21ea6, []int{4} -} -func (m *OwnerShares) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *OwnerShares) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_OwnerShares.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *OwnerShares) XXX_Merge(src proto.Message) { - xxx_messageInfo_OwnerShares.Merge(m, src) -} -func (m *OwnerShares) XXX_Size() int { - return m.Size() -} -func (m *OwnerShares) XXX_DiscardUnknown() { - xxx_messageInfo_OwnerShares.DiscardUnknown(m) -} - -var xxx_messageInfo_OwnerShares proto.InternalMessageInfo - -func (m *OwnerShares) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *OwnerShares) GetShares() uint64 { - if m != nil { - return m.Shares - } - return 0 -} - func init() { proto.RegisterType((*QueryParamsRequest)(nil), "dydxprotocol.vault.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "dydxprotocol.vault.QueryParamsResponse") proto.RegisterType((*QueryVaultRequest)(nil), "dydxprotocol.vault.QueryVaultRequest") proto.RegisterType((*QueryVaultResponse)(nil), "dydxprotocol.vault.QueryVaultResponse") - proto.RegisterType((*OwnerShares)(nil), "dydxprotocol.vault.OwnerShares") } func init() { proto.RegisterFile("dydxprotocol/vault/query.proto", fileDescriptor_478fb8dc0ff21ea6) } var fileDescriptor_478fb8dc0ff21ea6 = []byte{ - // 559 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xce, 0x6e, 0x93, 0x68, 0x27, 0x6d, 0xd1, 0x31, 0x48, 0x88, 0xed, 0x26, 0x2e, 0x34, 0xc6, - 0x43, 0x77, 0x31, 0x2a, 0x0a, 0x7a, 0xea, 0xcd, 0x53, 0xcc, 0x56, 0x3c, 0x78, 0x30, 0x4c, 0x92, - 0x21, 0x59, 0xd8, 0xcc, 0x6c, 0x76, 0x66, 0x63, 0x97, 0x52, 0x10, 0xef, 0x82, 0xe0, 0xcd, 0x5f, - 0xd4, 0x9b, 0x05, 0x2f, 0x9e, 0x44, 0x12, 0x7f, 0x88, 0xec, 0x9b, 0x69, 0xba, 0x69, 0x13, 0x7a, - 0x59, 0xe6, 0x7d, 0xef, 0x9b, 0xef, 0x7b, 0x6f, 0xde, 0x5b, 0x64, 0x0d, 0x92, 0xc1, 0x71, 0x18, - 0x71, 0xc9, 0xfb, 0x3c, 0x70, 0xa7, 0x24, 0x0e, 0xa4, 0x3b, 0x89, 0x69, 0x94, 0x38, 0x00, 0x62, - 0x9c, 0xcd, 0x3b, 0x90, 0xaf, 0x96, 0x87, 0x7c, 0xc8, 0x01, 0x73, 0xd3, 0x93, 0x62, 0x56, 0x77, - 0x87, 0x9c, 0x0f, 0x03, 0xea, 0x92, 0xd0, 0x77, 0x09, 0x63, 0x5c, 0x12, 0xe9, 0x73, 0x26, 0x74, - 0xf6, 0xf1, 0x92, 0x8f, 0x88, 0x7b, 0xa4, 0xdf, 0xe7, 0x31, 0x93, 0x22, 0x73, 0xd6, 0xd4, 0xda, - 0x8a, 0x92, 0x42, 0x12, 0x91, 0xf1, 0x85, 0xd6, 0xaa, 0x9a, 0xe1, 0xab, 0xf2, 0x76, 0x19, 0xe1, - 0x4e, 0xda, 0xc2, 0x5b, 0xb8, 0xe4, 0xd1, 0x49, 0x4c, 0x85, 0xb4, 0xdb, 0xe8, 0xde, 0x12, 0x2a, - 0x42, 0xce, 0x04, 0xc5, 0x2f, 0x51, 0x51, 0x89, 0x57, 0x8c, 0xba, 0xd1, 0x2c, 0xb5, 0xaa, 0xce, - 0xf5, 0x8e, 0x1d, 0x75, 0xe7, 0x30, 0x7f, 0xf6, 0xa7, 0x96, 0xf3, 0x34, 0xdf, 0xfe, 0x88, 0xee, - 0x82, 0xe0, 0xfb, 0x94, 0xa2, 0x5d, 0xf0, 0x13, 0x94, 0x97, 0x49, 0x48, 0x41, 0x6c, 0xa7, 0xb5, - 0xb7, 0x4a, 0x0c, 0xf8, 0xef, 0x92, 0x90, 0x7a, 0x40, 0xc5, 0xf7, 0x51, 0x91, 0xc5, 0xe3, 0x1e, - 0x8d, 0x2a, 0x66, 0xdd, 0x68, 0x6e, 0x7b, 0x3a, 0xb2, 0x7f, 0x9a, 0xba, 0x0f, 0x6d, 0xa0, 0x0b, - 0x7e, 0x8d, 0x6e, 0x83, 0x4e, 0xd7, 0x1f, 0xe8, 0x92, 0x1f, 0xac, 0x75, 0x79, 0x33, 0xd0, 0x35, - 0xdf, 0x9a, 0xaa, 0x10, 0x77, 0xd0, 0xf6, 0xe5, 0x83, 0xa7, 0x12, 0x26, 0x48, 0x34, 0x96, 0x25, - 0x32, 0xf3, 0x71, 0x8e, 0x16, 0xe7, 0x85, 0xda, 0x96, 0xc8, 0x60, 0x69, 0xfd, 0x74, 0x12, 0xfb, - 0x32, 0xa9, 0x6c, 0xd4, 0x8d, 0x66, 0xde, 0xd3, 0x11, 0xde, 0x45, 0x9b, 0x3e, 0x9b, 0x52, 0x26, - 0x79, 0x94, 0x54, 0xf2, 0x90, 0xba, 0x04, 0xf0, 0x43, 0xb4, 0x25, 0xb9, 0x24, 0x41, 0x57, 0x8c, - 0x48, 0x44, 0x45, 0xa5, 0x00, 0x84, 0x12, 0x60, 0x47, 0x00, 0xe1, 0x36, 0xba, 0x43, 0x82, 0xa0, - 0xcb, 0x3f, 0x31, 0x1a, 0x5d, 0xd0, 0x8a, 0xf5, 0x8d, 0x66, 0xa9, 0x55, 0x5b, 0xd5, 0x71, 0x3b, - 0xe5, 0xa9, 0xab, 0xba, 0xce, 0x1d, 0x12, 0x04, 0x19, 0xd4, 0x7e, 0x85, 0x4a, 0x99, 0x10, 0x97, - 0x51, 0x01, 0xb4, 0xe1, 0x19, 0x37, 0x3d, 0x15, 0xa4, 0xed, 0x68, 0x2f, 0x53, 0xb5, 0xa3, 0xa2, - 0xd6, 0x0f, 0x13, 0x15, 0x60, 0x1c, 0xf8, 0xb3, 0x81, 0x8a, 0x6a, 0x23, 0x70, 0x63, 0x55, 0x21, - 0xd7, 0x97, 0xaf, 0xfa, 0xe8, 0x46, 0x9e, 0x9a, 0xae, 0xbd, 0xff, 0xe5, 0xd7, 0xbf, 0xef, 0x66, - 0x0d, 0xef, 0xb9, 0xcb, 0x4b, 0xfe, 0x6c, 0xe9, 0x47, 0xc0, 0x5f, 0x0d, 0x54, 0x80, 0x09, 0xe3, - 0xfd, 0xb5, 0xca, 0xd9, 0xbd, 0xac, 0x36, 0x6e, 0xa2, 0x69, 0xff, 0xe7, 0xe0, 0xef, 0xe2, 0x83, - 0x35, 0xfe, 0xf0, 0x15, 0xee, 0x49, 0xba, 0xb9, 0xa7, 0xee, 0x89, 0x5a, 0xd5, 0xd3, 0xc3, 0xce, - 0xd9, 0xcc, 0x32, 0xce, 0x67, 0x96, 0xf1, 0x77, 0x66, 0x19, 0xdf, 0xe6, 0x56, 0xee, 0x7c, 0x6e, - 0xe5, 0x7e, 0xcf, 0xad, 0xdc, 0x87, 0x17, 0x43, 0x5f, 0x8e, 0xe2, 0x9e, 0xd3, 0xe7, 0xe3, 0xab, - 0x92, 0x07, 0xfd, 0x11, 0xf1, 0x99, 0xbb, 0x40, 0x8e, 0xb5, 0x47, 0xaa, 0x2d, 0x7a, 0x45, 0xc0, - 0x9f, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x6a, 0xd1, 0x53, 0xbe, 0xa2, 0x04, 0x00, 0x00, + // 502 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xcf, 0x6b, 0x13, 0x41, + 0x18, 0xcd, 0xc4, 0x24, 0xea, 0xb4, 0x15, 0x1c, 0x8b, 0x84, 0xb5, 0xdd, 0xc4, 0x85, 0xc6, 0x78, + 0xe8, 0x0e, 0x46, 0x45, 0x0f, 0x9e, 0x7a, 0xf3, 0xa4, 0xd9, 0x8a, 0x07, 0x0f, 0x96, 0xc9, 0x66, + 0xd8, 0x2c, 0x24, 0x33, 0x9b, 0x9d, 0xd9, 0xd0, 0xa5, 0x14, 0xc4, 0xbb, 0x20, 0x78, 0xf3, 0x2f, + 0xea, 0xb1, 0xe0, 0xc5, 0x93, 0x48, 0xe2, 0xdf, 0x21, 0xb2, 0xdf, 0x8e, 0xe9, 0x6e, 0x9b, 0xd0, + 0xcb, 0x30, 0xf3, 0xbe, 0x37, 0xef, 0x7d, 0xbf, 0xb0, 0x3d, 0x4c, 0x87, 0xc7, 0x51, 0x2c, 0xb5, + 0xf4, 0xe5, 0x98, 0xce, 0x58, 0x32, 0xd6, 0x74, 0x9a, 0xf0, 0x38, 0x75, 0x01, 0x24, 0xa4, 0x18, + 0x77, 0x21, 0x6e, 0x6d, 0x07, 0x32, 0x90, 0x80, 0xd1, 0xec, 0x96, 0x33, 0xad, 0x9d, 0x40, 0xca, + 0x60, 0xcc, 0x29, 0x8b, 0x42, 0xca, 0x84, 0x90, 0x9a, 0xe9, 0x50, 0x0a, 0x65, 0xa2, 0x8f, 0x4b, + 0x3e, 0x2a, 0x19, 0x30, 0xdf, 0x97, 0x89, 0xd0, 0xaa, 0x70, 0x37, 0xd4, 0xd6, 0x8a, 0x94, 0x22, + 0x16, 0xb3, 0xc9, 0x7f, 0xad, 0x55, 0x39, 0xc3, 0x99, 0xc7, 0x9d, 0x6d, 0x4c, 0xfa, 0x59, 0x09, + 0x6f, 0xe1, 0x93, 0xc7, 0xa7, 0x09, 0x57, 0xda, 0x79, 0x83, 0xef, 0x95, 0x50, 0x15, 0x49, 0xa1, + 0x38, 0x79, 0x89, 0x1b, 0xb9, 0x78, 0x13, 0xb5, 0x51, 0x77, 0xa3, 0x67, 0xb9, 0x57, 0x2b, 0x76, + 0xf3, 0x3f, 0x07, 0xb5, 0xb3, 0x5f, 0xad, 0x8a, 0x67, 0xf8, 0xce, 0x47, 0x7c, 0x17, 0x04, 0xdf, + 0x67, 0x14, 0xe3, 0x42, 0x9e, 0xe0, 0x9a, 0x4e, 0x23, 0x0e, 0x62, 0x77, 0x7a, 0xbb, 0xab, 0xc4, + 0x80, 0xff, 0x2e, 0x8d, 0xb8, 0x07, 0x54, 0x72, 0x1f, 0x37, 0x44, 0x32, 0x19, 0xf0, 0xb8, 0x59, + 0x6d, 0xa3, 0xee, 0x96, 0x67, 0x5e, 0xce, 0x5f, 0x64, 0xea, 0x30, 0x06, 0x26, 0xe1, 0x57, 0xf8, + 0x16, 0xe8, 0x1c, 0x85, 0x43, 0x93, 0xf2, 0x83, 0xb5, 0x2e, 0xaf, 0x87, 0x26, 0xe7, 0x9b, 0xb3, + 0xfc, 0x49, 0xfa, 0x78, 0xeb, 0xa2, 0xe1, 0x99, 0x44, 0x15, 0x24, 0x3a, 0x65, 0x89, 0xc2, 0x7c, + 0xdc, 0xc3, 0xe5, 0x7d, 0xa9, 0xb6, 0xa9, 0x0a, 0x58, 0x96, 0x3f, 0x9f, 0x26, 0xa1, 0x4e, 0x9b, + 0x37, 0xda, 0xa8, 0x5b, 0xf3, 0xcc, 0x8b, 0xec, 0xe0, 0xdb, 0xa1, 0x98, 0x71, 0xa1, 0x65, 0x9c, + 0x36, 0x6b, 0x10, 0xba, 0x00, 0xc8, 0x43, 0xbc, 0xa9, 0xa5, 0x66, 0xe3, 0x23, 0x35, 0x62, 0x31, + 0x57, 0xcd, 0x3a, 0x10, 0x36, 0x00, 0x3b, 0x04, 0xa8, 0xf7, 0xbd, 0x8a, 0xeb, 0xd0, 0x00, 0xf2, + 0x09, 0xe1, 0x46, 0x3e, 0x03, 0xd2, 0x59, 0x55, 0xec, 0xd5, 0x71, 0x5b, 0x8f, 0xae, 0xe5, 0xe5, + 0xfd, 0x74, 0xf6, 0x3e, 0xff, 0xf8, 0xf3, 0xad, 0xda, 0x22, 0xbb, 0xb4, 0xbc, 0x56, 0xcf, 0x4a, + 0xab, 0x47, 0xbe, 0x20, 0x5c, 0x87, 0x9e, 0x92, 0xbd, 0xb5, 0xca, 0xc5, 0x4d, 0xb0, 0x3a, 0xd7, + 0xd1, 0x8c, 0xff, 0x73, 0xf0, 0xa7, 0x64, 0x7f, 0x8d, 0x3f, 0x9c, 0x8a, 0x9e, 0x64, 0xbb, 0x72, + 0x4a, 0x4f, 0xf2, 0xe5, 0x38, 0x3d, 0xe8, 0x9f, 0xcd, 0x6d, 0x74, 0x3e, 0xb7, 0xd1, 0xef, 0xb9, + 0x8d, 0xbe, 0x2e, 0xec, 0xca, 0xf9, 0xc2, 0xae, 0xfc, 0x5c, 0xd8, 0x95, 0x0f, 0x2f, 0x82, 0x50, + 0x8f, 0x92, 0x81, 0xeb, 0xcb, 0xc9, 0x65, 0xc9, 0x7d, 0x7f, 0xc4, 0x42, 0x41, 0x97, 0xc8, 0xb1, + 0xf1, 0xc8, 0xb4, 0xd5, 0xa0, 0x01, 0xf8, 0xd3, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xca, + 0xa6, 0x6c, 0x14, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -581,20 +516,6 @@ func (m *QueryVaultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.AllOwnerShares) > 0 { - for iNdEx := len(m.AllOwnerShares) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AllOwnerShares[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } if m.TotalShares != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.TotalShares)) i-- @@ -633,41 +554,6 @@ func (m *QueryVaultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *OwnerShares) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *OwnerShares) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *OwnerShares) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Shares != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Shares)) - i-- - dAtA[i] = 0x10 - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -733,28 +619,6 @@ func (m *QueryVaultResponse) Size() (n int) { if m.TotalShares != 0 { n += 1 + sovQuery(uint64(m.TotalShares)) } - if len(m.AllOwnerShares) > 0 { - for _, e := range m.AllOwnerShares { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *OwnerShares) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Shares != 0 { - n += 1 + sovQuery(uint64(m.Shares)) - } return n } @@ -1137,141 +1001,6 @@ func (m *QueryVaultResponse) Unmarshal(dAtA []byte) error { break } } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AllOwnerShares", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AllOwnerShares = append(m.AllOwnerShares, OwnerShares{}) - if err := m.AllOwnerShares[len(m.AllOwnerShares)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *OwnerShares) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: OwnerShares: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: OwnerShares: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) - } - m.Shares = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Shares |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:])