From 20ffef4b58aa7ca319865de65541c7f860729d74 Mon Sep 17 00:00:00 2001 From: Tian Date: Thu, 14 Mar 2024 11:36:00 -0400 Subject: [PATCH] [tra-87] add x/vault protos (#1169) * add x/vault protos --- .../src/codegen/dydxprotocol/bundle.ts | 204 +++--- .../src/codegen/dydxprotocol/rpc.tx.ts | 1 + .../codegen/dydxprotocol/vault/tx.rpc.msg.ts | 24 + .../src/codegen/dydxprotocol/vault/tx.ts | 134 +++- .../src/codegen/dydxprotocol/vault/vault.ts | 181 ++++++ .../v4-protos/src/codegen/gogoproto/bundle.ts | 4 +- .../v4-protos/src/codegen/google/bundle.ts | 22 +- proto/dydxprotocol/vault/tx.proto | 28 +- proto/dydxprotocol/vault/vault.proto | 34 + protocol/app/basic_manager/basic_manager.go | 2 + protocol/app/msgs/all_msgs.go | 4 + protocol/app/msgs/normal_msgs.go | 5 + protocol/app/msgs/normal_msgs_test.go | 4 + protocol/testutil/app/app.go | 6 +- .../keeper/msg_server_deposit_to_vault.go | 15 + .../x/vault/types/msg_deposit_to_vault.go | 5 + protocol/x/vault/types/tx.pb.go | 595 +++++++++++++++++- protocol/x/vault/types/vault.pb.go | 543 ++++++++++++++++ 18 files changed, 1685 insertions(+), 126 deletions(-) create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts create mode 100644 proto/dydxprotocol/vault/vault.proto create mode 100644 protocol/x/vault/keeper/msg_server_deposit_to_vault.go create mode 100644 protocol/x/vault/types/msg_deposit_to_vault.go create mode 100644 protocol/x/vault/types/vault.pb.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts index 5d00767e2b..3ac4f1e980 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts @@ -90,73 +90,75 @@ import * as _93 from "./subaccounts/subaccount"; import * as _94 from "./vault/genesis"; import * as _95 from "./vault/query"; import * as _96 from "./vault/tx"; -import * as _97 from "./vest/genesis"; -import * as _98 from "./vest/query"; -import * as _99 from "./vest/tx"; -import * as _100 from "./vest/vest_entry"; -import * as _108 from "./assets/query.lcd"; -import * as _109 from "./blocktime/query.lcd"; -import * as _110 from "./bridge/query.lcd"; -import * as _111 from "./clob/query.lcd"; -import * as _112 from "./delaymsg/query.lcd"; -import * as _113 from "./epochs/query.lcd"; -import * as _114 from "./feetiers/query.lcd"; -import * as _115 from "./perpetuals/query.lcd"; -import * as _116 from "./prices/query.lcd"; -import * as _117 from "./ratelimit/query.lcd"; -import * as _118 from "./rewards/query.lcd"; -import * as _119 from "./stats/query.lcd"; -import * as _120 from "./subaccounts/query.lcd"; -import * as _121 from "./vest/query.lcd"; -import * as _122 from "./assets/query.rpc.Query"; -import * as _123 from "./blocktime/query.rpc.Query"; -import * as _124 from "./bridge/query.rpc.Query"; -import * as _125 from "./clob/query.rpc.Query"; -import * as _126 from "./delaymsg/query.rpc.Query"; -import * as _127 from "./epochs/query.rpc.Query"; -import * as _128 from "./feetiers/query.rpc.Query"; -import * as _129 from "./govplus/query.rpc.Query"; -import * as _130 from "./perpetuals/query.rpc.Query"; -import * as _131 from "./prices/query.rpc.Query"; -import * as _132 from "./ratelimit/query.rpc.Query"; -import * as _133 from "./rewards/query.rpc.Query"; -import * as _134 from "./sending/query.rpc.Query"; -import * as _135 from "./stats/query.rpc.Query"; -import * as _136 from "./subaccounts/query.rpc.Query"; -import * as _137 from "./vault/query.rpc.Query"; -import * as _138 from "./vest/query.rpc.Query"; -import * as _139 from "./blocktime/tx.rpc.msg"; -import * as _140 from "./bridge/tx.rpc.msg"; -import * as _141 from "./clob/tx.rpc.msg"; -import * as _142 from "./delaymsg/tx.rpc.msg"; -import * as _143 from "./feetiers/tx.rpc.msg"; -import * as _144 from "./govplus/tx.rpc.msg"; -import * as _145 from "./perpetuals/tx.rpc.msg"; -import * as _146 from "./prices/tx.rpc.msg"; -import * as _147 from "./ratelimit/tx.rpc.msg"; -import * as _148 from "./rewards/tx.rpc.msg"; -import * as _149 from "./sending/tx.rpc.msg"; -import * as _150 from "./stats/tx.rpc.msg"; -import * as _151 from "./vest/tx.rpc.msg"; -import * as _152 from "./lcd"; -import * as _153 from "./rpc.query"; -import * as _154 from "./rpc.tx"; +import * as _97 from "./vault/vault"; +import * as _98 from "./vest/genesis"; +import * as _99 from "./vest/query"; +import * as _100 from "./vest/tx"; +import * as _101 from "./vest/vest_entry"; +import * as _109 from "./assets/query.lcd"; +import * as _110 from "./blocktime/query.lcd"; +import * as _111 from "./bridge/query.lcd"; +import * as _112 from "./clob/query.lcd"; +import * as _113 from "./delaymsg/query.lcd"; +import * as _114 from "./epochs/query.lcd"; +import * as _115 from "./feetiers/query.lcd"; +import * as _116 from "./perpetuals/query.lcd"; +import * as _117 from "./prices/query.lcd"; +import * as _118 from "./ratelimit/query.lcd"; +import * as _119 from "./rewards/query.lcd"; +import * as _120 from "./stats/query.lcd"; +import * as _121 from "./subaccounts/query.lcd"; +import * as _122 from "./vest/query.lcd"; +import * as _123 from "./assets/query.rpc.Query"; +import * as _124 from "./blocktime/query.rpc.Query"; +import * as _125 from "./bridge/query.rpc.Query"; +import * as _126 from "./clob/query.rpc.Query"; +import * as _127 from "./delaymsg/query.rpc.Query"; +import * as _128 from "./epochs/query.rpc.Query"; +import * as _129 from "./feetiers/query.rpc.Query"; +import * as _130 from "./govplus/query.rpc.Query"; +import * as _131 from "./perpetuals/query.rpc.Query"; +import * as _132 from "./prices/query.rpc.Query"; +import * as _133 from "./ratelimit/query.rpc.Query"; +import * as _134 from "./rewards/query.rpc.Query"; +import * as _135 from "./sending/query.rpc.Query"; +import * as _136 from "./stats/query.rpc.Query"; +import * as _137 from "./subaccounts/query.rpc.Query"; +import * as _138 from "./vault/query.rpc.Query"; +import * as _139 from "./vest/query.rpc.Query"; +import * as _140 from "./blocktime/tx.rpc.msg"; +import * as _141 from "./bridge/tx.rpc.msg"; +import * as _142 from "./clob/tx.rpc.msg"; +import * as _143 from "./delaymsg/tx.rpc.msg"; +import * as _144 from "./feetiers/tx.rpc.msg"; +import * as _145 from "./govplus/tx.rpc.msg"; +import * as _146 from "./perpetuals/tx.rpc.msg"; +import * as _147 from "./prices/tx.rpc.msg"; +import * as _148 from "./ratelimit/tx.rpc.msg"; +import * as _149 from "./rewards/tx.rpc.msg"; +import * as _150 from "./sending/tx.rpc.msg"; +import * as _151 from "./stats/tx.rpc.msg"; +import * as _152 from "./vault/tx.rpc.msg"; +import * as _153 from "./vest/tx.rpc.msg"; +import * as _154 from "./lcd"; +import * as _155 from "./rpc.query"; +import * as _156 from "./rpc.tx"; export namespace dydxprotocol { export const assets = { ..._5, ..._6, ..._7, ..._8, - ..._108, - ..._122 + ..._109, + ..._123 }; export const blocktime = { ..._9, ..._10, ..._11, ..._12, ..._13, - ..._109, - ..._123, - ..._139 + ..._110, + ..._124, + ..._140 }; export const bridge = { ..._14, ..._15, @@ -164,9 +166,9 @@ export namespace dydxprotocol { ..._17, ..._18, ..._19, - ..._110, - ..._124, - ..._140 + ..._111, + ..._125, + ..._141 }; export const clob = { ..._20, ..._21, @@ -182,9 +184,9 @@ export namespace dydxprotocol { ..._31, ..._32, ..._33, - ..._111, - ..._125, - ..._141 + ..._112, + ..._126, + ..._142 }; export namespace daemons { export const bridge = { ..._34 @@ -199,29 +201,29 @@ export namespace dydxprotocol { ..._39, ..._40, ..._41, - ..._112, - ..._126, - ..._142 + ..._113, + ..._127, + ..._143 }; export const epochs = { ..._42, ..._43, ..._44, - ..._113, - ..._127 + ..._114, + ..._128 }; export const feetiers = { ..._45, ..._46, ..._47, ..._48, - ..._114, - ..._128, - ..._143 + ..._115, + ..._129, + ..._144 }; export const govplus = { ..._49, ..._50, ..._51, - ..._129, - ..._144 + ..._130, + ..._145 }; export namespace indexer { export const events = { ..._52 @@ -247,76 +249,78 @@ export namespace dydxprotocol { ..._62, ..._63, ..._64, - ..._115, - ..._130, - ..._145 + ..._116, + ..._131, + ..._146 }; export const prices = { ..._65, ..._66, ..._67, ..._68, ..._69, - ..._116, - ..._131, - ..._146 + ..._117, + ..._132, + ..._147 }; export const ratelimit = { ..._70, ..._71, ..._72, ..._73, ..._74, - ..._117, - ..._132, - ..._147 + ..._118, + ..._133, + ..._148 }; export const rewards = { ..._75, ..._76, ..._77, ..._78, ..._79, - ..._118, - ..._133, - ..._148 + ..._119, + ..._134, + ..._149 }; export const sending = { ..._80, ..._81, ..._82, ..._83, - ..._134, - ..._149 + ..._135, + ..._150 }; export const stats = { ..._84, ..._85, ..._86, ..._87, ..._88, - ..._119, - ..._135, - ..._150 + ..._120, + ..._136, + ..._151 }; export const subaccounts = { ..._89, ..._90, ..._91, ..._92, ..._93, - ..._120, - ..._136 + ..._121, + ..._137 }; export const vault = { ..._94, ..._95, ..._96, - ..._137 + ..._97, + ..._138, + ..._152 }; - export const vest = { ..._97, - ..._98, + export const vest = { ..._98, ..._99, ..._100, - ..._121, - ..._138, - ..._151 + ..._101, + ..._122, + ..._139, + ..._153 }; - export const ClientFactory = { ..._152, - ..._153, - ..._154 + export const ClientFactory = { ..._154, + ..._155, + ..._156 }; } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts index 1fd6591912..2c23915bc5 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts @@ -17,6 +17,7 @@ export const createRPCMsgClient = async ({ rewards: new (await import("./rewards/tx.rpc.msg")).MsgClientImpl(rpc), sending: new (await import("./sending/tx.rpc.msg")).MsgClientImpl(rpc), stats: new (await import("./stats/tx.rpc.msg")).MsgClientImpl(rpc), + vault: new (await import("./vault/tx.rpc.msg")).MsgClientImpl(rpc), vest: new (await import("./vest/tx.rpc.msg")).MsgClientImpl(rpc) } }); \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts new file mode 100644 index 0000000000..e4028957d6 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts @@ -0,0 +1,24 @@ +import { Rpc } from "../../helpers"; +import * as _m0 from "protobufjs/minimal"; +import { MsgDepositToVault, MsgDepositToVaultResponse } from "./tx"; +/** Msg defines the Msg service. */ + +export interface Msg { + /** DepositToVault deposits funds into a vault. */ + depositToVault(request: MsgDepositToVault): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + + constructor(rpc: Rpc) { + this.rpc = rpc; + this.depositToVault = this.depositToVault.bind(this); + } + + depositToVault(request: MsgDepositToVault): Promise { + const data = MsgDepositToVault.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.vault.Msg", "DepositToVault", data); + return promise.then(data => MsgDepositToVaultResponse.decode(new _m0.Reader(data))); + } + +} \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts index 693da49fc4..b3587f335b 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts @@ -1 +1,133 @@ -export {} \ No newline at end of file +import { VaultId, VaultIdSDKType } from "./vault"; +import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount"; +import * as _m0 from "protobufjs/minimal"; +import { DeepPartial } from "../../helpers"; +/** MsgDepositToVault is the Msg/DepositToVault request type. */ + +export interface MsgDepositToVault { + /** The vault to deposit into. */ + vaultId?: VaultId; + /** The subaccount to deposit from. */ + + subaccountId?: SubaccountId; + /** Number of quote quantums to deposit. */ + + quoteQuantums: Uint8Array; +} +/** MsgDepositToVault is the Msg/DepositToVault request type. */ + +export interface MsgDepositToVaultSDKType { + /** The vault to deposit into. */ + vault_id?: VaultIdSDKType; + /** The subaccount to deposit from. */ + + subaccount_id?: SubaccountIdSDKType; + /** Number of quote quantums to deposit. */ + + quote_quantums: Uint8Array; +} +/** MsgDepositToVaultResponse is the Msg/DepositToVault response type. */ + +export interface MsgDepositToVaultResponse {} +/** MsgDepositToVaultResponse is the Msg/DepositToVault response type. */ + +export interface MsgDepositToVaultResponseSDKType {} + +function createBaseMsgDepositToVault(): MsgDepositToVault { + return { + vaultId: undefined, + subaccountId: undefined, + quoteQuantums: new Uint8Array() + }; +} + +export const MsgDepositToVault = { + encode(message: MsgDepositToVault, 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.quoteQuantums.length !== 0) { + writer.uint32(26).bytes(message.quoteQuantums); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgDepositToVault { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositToVault(); + + 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.quoteQuantums = reader.bytes(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): MsgDepositToVault { + const message = createBaseMsgDepositToVault(); + 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.quoteQuantums = object.quoteQuantums ?? new Uint8Array(); + return message; + } + +}; + +function createBaseMsgDepositToVaultResponse(): MsgDepositToVaultResponse { + return {}; +} + +export const MsgDepositToVaultResponse = { + encode(_: MsgDepositToVaultResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgDepositToVaultResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositToVaultResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(_: DeepPartial): MsgDepositToVaultResponse { + const message = createBaseMsgDepositToVaultResponse(); + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts new file mode 100644 index 0000000000..cc93d62a58 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts @@ -0,0 +1,181 @@ +import * as _m0 from "protobufjs/minimal"; +import { DeepPartial } from "../../helpers"; +/** VaultType represents different types of vaults. */ + +export enum VaultType { + /** VAULT_TYPE_UNSPECIFIED - Default value, invalid and unused. */ + VAULT_TYPE_UNSPECIFIED = 0, + + /** VAULT_TYPE_CLOB - Vault is associated with a CLOB pair. */ + VAULT_TYPE_CLOB = 1, + UNRECOGNIZED = -1, +} +/** VaultType represents different types of vaults. */ + +export enum VaultTypeSDKType { + /** VAULT_TYPE_UNSPECIFIED - Default value, invalid and unused. */ + VAULT_TYPE_UNSPECIFIED = 0, + + /** VAULT_TYPE_CLOB - Vault is associated with a CLOB pair. */ + VAULT_TYPE_CLOB = 1, + UNRECOGNIZED = -1, +} +export function vaultTypeFromJSON(object: any): VaultType { + switch (object) { + case 0: + case "VAULT_TYPE_UNSPECIFIED": + return VaultType.VAULT_TYPE_UNSPECIFIED; + + case 1: + case "VAULT_TYPE_CLOB": + return VaultType.VAULT_TYPE_CLOB; + + case -1: + case "UNRECOGNIZED": + default: + return VaultType.UNRECOGNIZED; + } +} +export function vaultTypeToJSON(object: VaultType): string { + switch (object) { + case VaultType.VAULT_TYPE_UNSPECIFIED: + return "VAULT_TYPE_UNSPECIFIED"; + + case VaultType.VAULT_TYPE_CLOB: + return "VAULT_TYPE_CLOB"; + + case VaultType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** VaultId uniquely identifies a vault by its type and number. */ + +export interface VaultId { + /** Type of the vault. */ + type: VaultType; + /** Unique ID of the vault within above type. */ + + number: number; +} +/** VaultId uniquely identifies a vault by its type and number. */ + +export interface VaultIdSDKType { + /** Type of the vault. */ + type: VaultTypeSDKType; + /** Unique ID of the vault within above type. */ + + number: number; +} +/** NumShares represents the number of shares in a vault. */ + +export interface NumShares { + /** Number of shares. */ + numShares: Uint8Array; +} +/** NumShares represents the number of shares in a vault. */ + +export interface NumSharesSDKType { + /** Number of shares. */ + num_shares: Uint8Array; +} + +function createBaseVaultId(): VaultId { + return { + type: 0, + number: 0 + }; +} + +export const VaultId = { + encode(message: VaultId, 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): VaultId { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVaultId(); + + 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): VaultId { + const message = createBaseVaultId(); + message.type = object.type ?? 0; + message.number = object.number ?? 0; + return message; + } + +}; + +function createBaseNumShares(): NumShares { + return { + numShares: new Uint8Array() + }; +} + +export const NumShares = { + encode(message: NumShares, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.numShares.length !== 0) { + writer.uint32(10).bytes(message.numShares); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): NumShares { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseNumShares(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.numShares = reader.bytes(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): NumShares { + const message = createBaseNumShares(); + message.numShares = object.numShares ?? new Uint8Array(); + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts index ac7a691883..376d487cb4 100644 --- a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts @@ -1,3 +1,3 @@ -import * as _101 from "./gogo"; -export const gogoproto = { ..._101 +import * as _102 from "./gogo"; +export const gogoproto = { ..._102 }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/google/bundle.ts b/indexer/packages/v4-protos/src/codegen/google/bundle.ts index 3312f4c5c1..bb317adb1e 100644 --- a/indexer/packages/v4-protos/src/codegen/google/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/google/bundle.ts @@ -1,16 +1,16 @@ -import * as _102 from "./api/annotations"; -import * as _103 from "./api/http"; -import * as _104 from "./protobuf/descriptor"; -import * as _105 from "./protobuf/duration"; -import * as _106 from "./protobuf/timestamp"; -import * as _107 from "./protobuf/any"; +import * as _103 from "./api/annotations"; +import * as _104 from "./api/http"; +import * as _105 from "./protobuf/descriptor"; +import * as _106 from "./protobuf/duration"; +import * as _107 from "./protobuf/timestamp"; +import * as _108 from "./protobuf/any"; export namespace google { - export const api = { ..._102, - ..._103 + export const api = { ..._103, + ..._104 }; - export const protobuf = { ..._104, - ..._105, + export const protobuf = { ..._105, ..._106, - ..._107 + ..._107, + ..._108 }; } \ No newline at end of file diff --git a/proto/dydxprotocol/vault/tx.proto b/proto/dydxprotocol/vault/tx.proto index d6afd1bdbd..90da68e40f 100644 --- a/proto/dydxprotocol/vault/tx.proto +++ b/proto/dydxprotocol/vault/tx.proto @@ -1,7 +1,33 @@ syntax = "proto3"; package dydxprotocol.vault; +import "dydxprotocol/subaccounts/subaccount.proto"; +import "dydxprotocol/vault/vault.proto"; +import "gogoproto/gogo.proto"; + option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"; // Msg defines the Msg service. -service Msg {} +service Msg { + // DepositToVault deposits funds into a vault. + rpc DepositToVault(MsgDepositToVault) returns (MsgDepositToVaultResponse); +} + +// MsgDepositToVault is the Msg/DepositToVault request type. +message MsgDepositToVault { + // The vault to deposit into. + VaultId vault_id = 1; + + // The subaccount to deposit from. + dydxprotocol.subaccounts.SubaccountId subaccount_id = 2; + + // Number of quote quantums to deposit. + bytes quote_quantums = 3 [ + (gogoproto.customtype) = + "github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt", + (gogoproto.nullable) = false + ]; +} + +// MsgDepositToVaultResponse is the Msg/DepositToVault response type. +message MsgDepositToVaultResponse {} diff --git a/proto/dydxprotocol/vault/vault.proto b/proto/dydxprotocol/vault/vault.proto new file mode 100644 index 0000000000..87b8c9dd5a --- /dev/null +++ b/proto/dydxprotocol/vault/vault.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; +package dydxprotocol.vault; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"; + +// VaultType represents different types of vaults. +enum VaultType { + // Default value, invalid and unused. + VAULT_TYPE_UNSPECIFIED = 0; + + // Vault is associated with a CLOB pair. + VAULT_TYPE_CLOB = 1; +} + +// VaultId uniquely identifies a vault by its type and number. +message VaultId { + // Type of the vault. + VaultType type = 1; + + // Unique ID of the vault within above type. + uint32 number = 2; +} + +// NumShares represents the number of shares in a vault. +message NumShares { + // Number of shares. + bytes num_shares = 1 [ + (gogoproto.customtype) = + "github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt", + (gogoproto.nullable) = false + ]; +} diff --git a/protocol/app/basic_manager/basic_manager.go b/protocol/app/basic_manager/basic_manager.go index 8368247bdf..f1cec344bc 100644 --- a/protocol/app/basic_manager/basic_manager.go +++ b/protocol/app/basic_manager/basic_manager.go @@ -36,6 +36,7 @@ import ( sendingmodule "github.com/dydxprotocol/v4-chain/protocol/x/sending" statsmodule "github.com/dydxprotocol/v4-chain/protocol/x/stats" subaccountsmodule "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts" + vaultmodule "github.com/dydxprotocol/v4-chain/protocol/x/vault" vestmodule "github.com/dydxprotocol/v4-chain/protocol/x/vest" ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" @@ -91,5 +92,6 @@ var ( epochsmodule.AppModuleBasic{}, ratelimitmodule.AppModuleBasic{}, govplusmodule.AppModuleBasic{}, + vaultmodule.AppModuleBasic{}, ) ) diff --git a/protocol/app/msgs/all_msgs.go b/protocol/app/msgs/all_msgs.go index 15abfff329..dc4715319f 100644 --- a/protocol/app/msgs/all_msgs.go +++ b/protocol/app/msgs/all_msgs.go @@ -234,6 +234,10 @@ var ( "/dydxprotocol.stats.MsgUpdateParams": {}, "/dydxprotocol.stats.MsgUpdateParamsResponse": {}, + // vault + "/dydxprotocol.vault.MsgDepositToVault": {}, + "/dydxprotocol.vault.MsgDepositToVaultResponse": {}, + // vest "/dydxprotocol.vest.MsgSetVestEntry": {}, "/dydxprotocol.vest.MsgSetVestEntryResponse": {}, diff --git a/protocol/app/msgs/normal_msgs.go b/protocol/app/msgs/normal_msgs.go index 8bc4818191..7808cf1c8e 100644 --- a/protocol/app/msgs/normal_msgs.go +++ b/protocol/app/msgs/normal_msgs.go @@ -19,6 +19,7 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/lib" clob "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" sending "github.com/dydxprotocol/v4-chain/protocol/x/sending/types" + vault "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" ) var ( @@ -233,5 +234,9 @@ var ( "/dydxprotocol.sending.MsgDepositToSubaccountResponse": nil, "/dydxprotocol.sending.MsgWithdrawFromSubaccount": &sending.MsgWithdrawFromSubaccount{}, "/dydxprotocol.sending.MsgWithdrawFromSubaccountResponse": nil, + + // vault + "/dydxprotocol.vault.MsgDepositToVault": &vault.MsgDepositToVault{}, + "/dydxprotocol.vault.MsgDepositToVaultResponse": nil, } ) diff --git a/protocol/app/msgs/normal_msgs_test.go b/protocol/app/msgs/normal_msgs_test.go index 6eb1c3aec2..c5bba587c3 100644 --- a/protocol/app/msgs/normal_msgs_test.go +++ b/protocol/app/msgs/normal_msgs_test.go @@ -138,6 +138,10 @@ func TestNormalMsgs_Key(t *testing.T) { "/dydxprotocol.sending.MsgWithdrawFromSubaccount", "/dydxprotocol.sending.MsgWithdrawFromSubaccountResponse", + // vault + "/dydxprotocol.vault.MsgDepositToVault", + "/dydxprotocol.vault.MsgDepositToVaultResponse", + // ibc application module: ICA "/ibc.applications.interchain_accounts.v1.InterchainAccount", diff --git a/protocol/testutil/app/app.go b/protocol/testutil/app/app.go index da22536657..769df56f6d 100644 --- a/protocol/testutil/app/app.go +++ b/protocol/testutil/app/app.go @@ -63,6 +63,7 @@ import ( sendingtypes "github.com/dydxprotocol/v4-chain/protocol/x/sending/types" stattypes "github.com/dydxprotocol/v4-chain/protocol/x/stats/types" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" vesttypes "github.com/dydxprotocol/v4-chain/protocol/x/vest/types" "github.com/stretchr/testify/require" "golang.org/x/exp/slices" @@ -200,7 +201,8 @@ type GenesisStates interface { bridgetypes.GenesisState | govtypesv1.GenesisState | ratelimittypes.GenesisState | - govplus.GenesisState + govplus.GenesisState | + vaulttypes.GenesisState } // UpdateGenesisDocWithAppStateForModule updates the supplied genesis doc using the provided function. The function @@ -254,6 +256,8 @@ func UpdateGenesisDocWithAppStateForModule[T GenesisStates](genesisDoc *types.Ge moduleName = ratelimittypes.ModuleName case govplus.GenesisState: moduleName = govplus.ModuleName + case vaulttypes.GenesisState: + moduleName = vaulttypes.ModuleName default: panic(fmt.Errorf("Unsupported type %T", t)) } diff --git a/protocol/x/vault/keeper/msg_server_deposit_to_vault.go b/protocol/x/vault/keeper/msg_server_deposit_to_vault.go new file mode 100644 index 0000000000..f462f19f39 --- /dev/null +++ b/protocol/x/vault/keeper/msg_server_deposit_to_vault.go @@ -0,0 +1,15 @@ +package keeper + +import ( + "context" + + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +// DepositToVault deposits from a subaccount to a vault. +func (k msgServer) DepositToVault( + goCtx context.Context, + msg *types.MsgDepositToVault, +) (*types.MsgDepositToVaultResponse, error) { + return &types.MsgDepositToVaultResponse{}, nil +} diff --git a/protocol/x/vault/types/msg_deposit_to_vault.go b/protocol/x/vault/types/msg_deposit_to_vault.go new file mode 100644 index 0000000000..eefaed1c28 --- /dev/null +++ b/protocol/x/vault/types/msg_deposit_to_vault.go @@ -0,0 +1,5 @@ +package types + +func (msg *MsgDepositToVault) ValidateBasic() error { + return nil +} diff --git a/protocol/x/vault/types/tx.pb.go b/protocol/x/vault/types/tx.pb.go index ce1c55128a..4289883ce0 100644 --- a/protocol/x/vault/types/tx.pb.go +++ b/protocol/x/vault/types/tx.pb.go @@ -6,10 +6,17 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + github_com_dydxprotocol_v4_chain_protocol_dtypes "github.com/dydxprotocol/v4-chain/protocol/dtypes" + types "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,18 +30,131 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgDepositToVault is the Msg/DepositToVault request type. +type MsgDepositToVault struct { + // The vault to deposit into. + VaultId *VaultId `protobuf:"bytes,1,opt,name=vault_id,json=vaultId,proto3" json:"vault_id,omitempty"` + // The subaccount to deposit from. + SubaccountId *types.SubaccountId `protobuf:"bytes,2,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id,omitempty"` + // Number of quote quantums to deposit. + QuoteQuantums github_com_dydxprotocol_v4_chain_protocol_dtypes.SerializableInt `protobuf:"bytes,3,opt,name=quote_quantums,json=quoteQuantums,proto3,customtype=github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" json:"quote_quantums"` +} + +func (m *MsgDepositToVault) Reset() { *m = MsgDepositToVault{} } +func (m *MsgDepositToVault) String() string { return proto.CompactTextString(m) } +func (*MsgDepositToVault) ProtoMessage() {} +func (*MsgDepositToVault) Descriptor() ([]byte, []int) { + return fileDescriptor_ced574c6017ce006, []int{0} +} +func (m *MsgDepositToVault) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDepositToVault) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDepositToVault.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 *MsgDepositToVault) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDepositToVault.Merge(m, src) +} +func (m *MsgDepositToVault) XXX_Size() int { + return m.Size() +} +func (m *MsgDepositToVault) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDepositToVault.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDepositToVault proto.InternalMessageInfo + +func (m *MsgDepositToVault) GetVaultId() *VaultId { + if m != nil { + return m.VaultId + } + return nil +} + +func (m *MsgDepositToVault) GetSubaccountId() *types.SubaccountId { + if m != nil { + return m.SubaccountId + } + return nil +} + +// MsgDepositToVaultResponse is the Msg/DepositToVault response type. +type MsgDepositToVaultResponse struct { +} + +func (m *MsgDepositToVaultResponse) Reset() { *m = MsgDepositToVaultResponse{} } +func (m *MsgDepositToVaultResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDepositToVaultResponse) ProtoMessage() {} +func (*MsgDepositToVaultResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ced574c6017ce006, []int{1} +} +func (m *MsgDepositToVaultResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDepositToVaultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDepositToVaultResponse.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 *MsgDepositToVaultResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDepositToVaultResponse.Merge(m, src) +} +func (m *MsgDepositToVaultResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDepositToVaultResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDepositToVaultResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDepositToVaultResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgDepositToVault)(nil), "dydxprotocol.vault.MsgDepositToVault") + proto.RegisterType((*MsgDepositToVaultResponse)(nil), "dydxprotocol.vault.MsgDepositToVaultResponse") +} + func init() { proto.RegisterFile("dydxprotocol/vault/tx.proto", fileDescriptor_ced574c6017ce006) } var fileDescriptor_ced574c6017ce006 = []byte{ - // 128 bytes of a gzipped FileDescriptorProto + // 343 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xa9, 0x4c, 0xa9, 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4b, 0x2c, 0xcd, 0x29, 0xd1, 0x2f, - 0xa9, 0xd0, 0x03, 0x8b, 0x08, 0x09, 0x21, 0x4b, 0xea, 0x81, 0x25, 0x8d, 0x58, 0xb9, 0x98, 0x7d, - 0x8b, 0xd3, 0x9d, 0x02, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, - 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3c, - 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xd5, 0x70, 0x13, 0xdd, 0xe4, - 0x8c, 0xc4, 0xcc, 0x3c, 0x7d, 0xb8, 0x48, 0x05, 0xcc, 0xc2, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, - 0xb0, 0xb8, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x2f, 0x7f, 0xc8, 0xf1, 0x93, 0x00, 0x00, 0x00, + 0xa9, 0xd0, 0x03, 0x8b, 0x08, 0x09, 0x21, 0x4b, 0xea, 0x81, 0x25, 0xa5, 0x34, 0x51, 0x34, 0x14, + 0x97, 0x26, 0x25, 0x26, 0x27, 0xe7, 0x97, 0xe6, 0x95, 0x14, 0x23, 0xb1, 0x21, 0xda, 0xa5, 0xe4, + 0xb0, 0x98, 0x0d, 0x26, 0xa1, 0xf2, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, 0x88, 0x05, + 0x11, 0x55, 0xea, 0x64, 0xe2, 0x12, 0xf4, 0x2d, 0x4e, 0x77, 0x49, 0x2d, 0xc8, 0x2f, 0xce, 0x2c, + 0x09, 0xc9, 0x0f, 0x03, 0xe9, 0x10, 0x32, 0xe3, 0xe2, 0x00, 0x6b, 0x8d, 0xcf, 0x4c, 0x91, 0x60, + 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd6, 0xc3, 0x74, 0x9d, 0x1e, 0x58, 0xb1, 0x67, 0x4a, 0x10, + 0x7b, 0x19, 0x84, 0x21, 0xe4, 0xcd, 0xc5, 0x8b, 0x70, 0x17, 0x48, 0x33, 0x13, 0x58, 0xb3, 0x1a, + 0xaa, 0x66, 0x24, 0x6f, 0xe8, 0x05, 0xc3, 0xd9, 0x9e, 0x29, 0x41, 0x3c, 0xc5, 0x48, 0x3c, 0xa1, + 0x7c, 0x2e, 0xbe, 0xc2, 0xd2, 0xfc, 0x92, 0xd4, 0xf8, 0xc2, 0xd2, 0xc4, 0xbc, 0x92, 0xd2, 0xdc, + 0x62, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x1e, 0x27, 0x8f, 0x13, 0xf7, 0xe4, 0x19, 0x6e, 0xdd, 0x93, + 0x77, 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0xf5, 0xbb, 0x89, + 0x6e, 0x72, 0x46, 0x62, 0x66, 0x9e, 0x3e, 0x5c, 0x24, 0xa5, 0xa4, 0xb2, 0x20, 0xb5, 0x58, 0x2f, + 0x38, 0xb5, 0x28, 0x33, 0x31, 0x27, 0xb3, 0x2a, 0x31, 0x29, 0x27, 0xd5, 0x33, 0xaf, 0x24, 0x88, + 0x17, 0x6c, 0x7e, 0x20, 0xd4, 0x78, 0x25, 0x69, 0x2e, 0x49, 0x8c, 0xa0, 0x08, 0x4a, 0x2d, 0x2e, + 0xc8, 0xcf, 0x2b, 0x4e, 0x35, 0xca, 0xe5, 0x62, 0xf6, 0x2d, 0x4e, 0x17, 0x4a, 0xe3, 0xe2, 0x43, + 0x0b, 0x2b, 0x55, 0x6c, 0x21, 0x83, 0x61, 0x8e, 0x94, 0x2e, 0x51, 0xca, 0x60, 0xd6, 0x39, 0x05, + 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, + 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x39, 0xf1, 0xde, 0xae, 0x80, + 0x25, 0x31, 0x90, 0xef, 0x93, 0xd8, 0xc0, 0xe2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa5, + 0x6a, 0xc3, 0x6b, 0x85, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -49,6 +169,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // DepositToVault deposits funds into a vault. + DepositToVault(ctx context.Context, in *MsgDepositToVault, opts ...grpc.CallOption) (*MsgDepositToVaultResponse, error) } type msgClient struct { @@ -59,22 +181,475 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) DepositToVault(ctx context.Context, in *MsgDepositToVault, opts ...grpc.CallOption) (*MsgDepositToVaultResponse, error) { + out := new(MsgDepositToVaultResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.vault.Msg/DepositToVault", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + // DepositToVault deposits funds into a vault. + DepositToVault(context.Context, *MsgDepositToVault) (*MsgDepositToVaultResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) DepositToVault(ctx context.Context, req *MsgDepositToVault) (*MsgDepositToVaultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DepositToVault not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_DepositToVault_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDepositToVault) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DepositToVault(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.vault.Msg/DepositToVault", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DepositToVault(ctx, req.(*MsgDepositToVault)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "dydxprotocol.vault.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "dydxprotocol/vault/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "DepositToVault", + Handler: _Msg_DepositToVault_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dydxprotocol/vault/tx.proto", +} + +func (m *MsgDepositToVault) 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 *MsgDepositToVault) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDepositToVault) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.QuoteQuantums.Size() + i -= size + if _, err := m.QuoteQuantums.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.SubaccountId != nil { + { + size, err := m.SubaccountId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.VaultId != nil { + { + size, err := m.VaultId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } + +func (m *MsgDepositToVaultResponse) 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 *MsgDepositToVaultResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDepositToVaultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgDepositToVault) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.VaultId != nil { + l = m.VaultId.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.SubaccountId != nil { + l = m.SubaccountId.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = m.QuoteQuantums.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgDepositToVaultResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgDepositToVault) 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 ErrIntOverflowTx + } + 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: MsgDepositToVault: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDepositToVault: 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.VaultId == nil { + m.VaultId = &VaultId{} + } + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SubaccountId == nil { + m.SubaccountId = &types.SubaccountId{} + } + if err := m.SubaccountId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteQuantums", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.QuoteQuantums.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDepositToVaultResponse) 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 ErrIntOverflowTx + } + 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: MsgDepositToVaultResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDepositToVaultResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/protocol/x/vault/types/vault.pb.go b/protocol/x/vault/types/vault.pb.go new file mode 100644 index 0000000000..f0797dd494 --- /dev/null +++ b/protocol/x/vault/types/vault.pb.go @@ -0,0 +1,543 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/vault/vault.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_dydxprotocol_v4_chain_protocol_dtypes "github.com/dydxprotocol/v4-chain/protocol/dtypes" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// VaultType represents different types of vaults. +type VaultType int32 + +const ( + // Default value, invalid and unused. + VaultType_VAULT_TYPE_UNSPECIFIED VaultType = 0 + // Vault is associated with a CLOB pair. + VaultType_VAULT_TYPE_CLOB VaultType = 1 +) + +var VaultType_name = map[int32]string{ + 0: "VAULT_TYPE_UNSPECIFIED", + 1: "VAULT_TYPE_CLOB", +} + +var VaultType_value = map[string]int32{ + "VAULT_TYPE_UNSPECIFIED": 0, + "VAULT_TYPE_CLOB": 1, +} + +func (x VaultType) String() string { + return proto.EnumName(VaultType_name, int32(x)) +} + +func (VaultType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_32accb5830bb2860, []int{0} +} + +// VaultId uniquely identifies a vault by its type and number. +type VaultId struct { + // Type of the vault. + Type VaultType `protobuf:"varint,1,opt,name=type,proto3,enum=dydxprotocol.vault.VaultType" json:"type,omitempty"` + // Unique ID of the vault within above type. + Number uint32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` +} + +func (m *VaultId) Reset() { *m = VaultId{} } +func (m *VaultId) String() string { return proto.CompactTextString(m) } +func (*VaultId) ProtoMessage() {} +func (*VaultId) Descriptor() ([]byte, []int) { + return fileDescriptor_32accb5830bb2860, []int{0} +} +func (m *VaultId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VaultId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VaultId.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 *VaultId) XXX_Merge(src proto.Message) { + xxx_messageInfo_VaultId.Merge(m, src) +} +func (m *VaultId) XXX_Size() int { + return m.Size() +} +func (m *VaultId) XXX_DiscardUnknown() { + xxx_messageInfo_VaultId.DiscardUnknown(m) +} + +var xxx_messageInfo_VaultId proto.InternalMessageInfo + +func (m *VaultId) GetType() VaultType { + if m != nil { + return m.Type + } + return VaultType_VAULT_TYPE_UNSPECIFIED +} + +func (m *VaultId) GetNumber() uint32 { + if m != nil { + return m.Number + } + return 0 +} + +// NumShares represents the number of shares in a vault. +type NumShares struct { + // Number of shares. + NumShares github_com_dydxprotocol_v4_chain_protocol_dtypes.SerializableInt `protobuf:"bytes,1,opt,name=num_shares,json=numShares,proto3,customtype=github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" json:"num_shares"` +} + +func (m *NumShares) Reset() { *m = NumShares{} } +func (m *NumShares) String() string { return proto.CompactTextString(m) } +func (*NumShares) ProtoMessage() {} +func (*NumShares) Descriptor() ([]byte, []int) { + return fileDescriptor_32accb5830bb2860, []int{1} +} +func (m *NumShares) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NumShares) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NumShares.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 *NumShares) XXX_Merge(src proto.Message) { + xxx_messageInfo_NumShares.Merge(m, src) +} +func (m *NumShares) XXX_Size() int { + return m.Size() +} +func (m *NumShares) XXX_DiscardUnknown() { + xxx_messageInfo_NumShares.DiscardUnknown(m) +} + +var xxx_messageInfo_NumShares proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("dydxprotocol.vault.VaultType", VaultType_name, VaultType_value) + proto.RegisterType((*VaultId)(nil), "dydxprotocol.vault.VaultId") + proto.RegisterType((*NumShares)(nil), "dydxprotocol.vault.NumShares") +} + +func init() { proto.RegisterFile("dydxprotocol/vault/vault.proto", fileDescriptor_32accb5830bb2860) } + +var fileDescriptor_32accb5830bb2860 = []byte{ + // 300 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, 0x81, 0x90, + 0x7a, 0x60, 0x41, 0x21, 0x21, 0x64, 0x79, 0x3d, 0xb0, 0x8c, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, + 0x58, 0x4c, 0x1f, 0xc4, 0x82, 0xa8, 0x54, 0x0a, 0xe1, 0x62, 0x0f, 0x03, 0x49, 0x7b, 0xa6, 0x08, + 0x19, 0x72, 0xb1, 0x94, 0x54, 0x16, 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x19, 0xc9, 0xea, + 0x61, 0x9a, 0xa1, 0x07, 0x56, 0x1a, 0x52, 0x59, 0x90, 0x1a, 0x04, 0x56, 0x2a, 0x24, 0xc6, 0xc5, + 0x96, 0x57, 0x9a, 0x9b, 0x94, 0x5a, 0x24, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x1b, 0x04, 0xe5, 0x29, + 0x95, 0x70, 0x71, 0xfa, 0x95, 0xe6, 0x06, 0x67, 0x24, 0x16, 0xa5, 0x16, 0x0b, 0xa5, 0x73, 0x71, + 0xe5, 0x95, 0xe6, 0xc6, 0x17, 0x83, 0x79, 0x60, 0xd3, 0x79, 0x9c, 0x3c, 0x4e, 0xdc, 0x93, 0x67, + 0xb8, 0x75, 0x4f, 0xde, 0x21, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, + 0xd5, 0x4f, 0x26, 0xba, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xfa, 0x70, 0x91, 0x14, 0x90, 0x8d, 0xc5, + 0x7a, 0xc1, 0xa9, 0x45, 0x99, 0x89, 0x39, 0x99, 0x55, 0x89, 0x49, 0x39, 0xa9, 0x9e, 0x79, 0x25, + 0x41, 0x9c, 0x79, 0x30, 0x8b, 0xb4, 0x6c, 0xb8, 0x38, 0xe1, 0x0e, 0x14, 0x92, 0xe2, 0x12, 0x0b, + 0x73, 0x0c, 0xf5, 0x09, 0x89, 0x0f, 0x89, 0x0c, 0x70, 0x8d, 0x0f, 0xf5, 0x0b, 0x0e, 0x70, 0x75, + 0xf6, 0x74, 0xf3, 0x74, 0x75, 0x11, 0x60, 0x10, 0x12, 0xe6, 0xe2, 0x47, 0x92, 0x73, 0xf6, 0xf1, + 0x77, 0x12, 0x60, 0x74, 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, + 0x73, 0xe2, 0x1d, 0x59, 0x01, 0x8d, 0x0c, 0xb0, 0x5b, 0x93, 0xd8, 0xc0, 0xe2, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x22, 0x8c, 0x36, 0xdc, 0xaf, 0x01, 0x00, 0x00, +} + +func (m *VaultId) 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 *VaultId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VaultId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Number != 0 { + i = encodeVarintVault(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x10 + } + if m.Type != 0 { + i = encodeVarintVault(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *NumShares) 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 *NumShares) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NumShares) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.NumShares.Size() + i -= size + if _, err := m.NumShares.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintVault(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintVault(dAtA []byte, offset int, v uint64) int { + offset -= sovVault(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *VaultId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovVault(uint64(m.Type)) + } + if m.Number != 0 { + n += 1 + sovVault(uint64(m.Number)) + } + return n +} + +func (m *NumShares) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.NumShares.Size() + n += 1 + l + sovVault(uint64(l)) + return n +} + +func sovVault(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozVault(x uint64) (n int) { + return sovVault(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *VaultId) 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 ErrIntOverflowVault + } + 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: VaultId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VaultId: 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 ErrIntOverflowVault + } + 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 ErrIntOverflowVault + } + 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 := skipVault(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVault + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NumShares) 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 ErrIntOverflowVault + } + 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: NumShares: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NumShares: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumShares", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVault + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVault + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVault + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVault(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVault + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipVault(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVault + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVault + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVault + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthVault + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupVault + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthVault + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthVault = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowVault = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupVault = fmt.Errorf("proto: unexpected end of group") +)