Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register deprecated MsgSetVaultQuotingParams #2392

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
259 changes: 178 additions & 81 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,32 +184,6 @@ export interface MsgUnlockSharesResponseSDKType {
/** The number of shares unlocked. */
unlocked_shares?: NumSharesSDKType;
}
/**
* MsgUpdateParams is the Msg/UpdateParams request type.
* Deprecated since v6.x as is replaced by MsgUpdateDefaultQuotingParams.
*/

/** @deprecated */

export interface MsgUpdateParams {
authority: string;
/** The parameters to update. Each field must be set. */

params?: Params;
}
/**
* MsgUpdateParams is the Msg/UpdateParams request type.
* Deprecated since v6.x as is replaced by MsgUpdateDefaultQuotingParams.
*/

/** @deprecated */

export interface MsgUpdateParamsSDKType {
authority: string;
/** The parameters to update. Each field must be set. */

params?: ParamsSDKType;
}
/** MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type. */

export interface MsgUpdateOperatorParams {
Expand Down Expand Up @@ -288,6 +262,64 @@ export interface MsgRetrieveFromVaultResponse {}
/** MsgRetrieveFromVaultResponse is the Msg/RetrieveFromVault response type. */

export interface MsgRetrieveFromVaultResponseSDKType {}
/**
* MsgUpdateParams is the Msg/UpdateParams request type.
* Deprecated since v6.x as is replaced by MsgUpdateDefaultQuotingParams.
*/

/** @deprecated */

export interface MsgUpdateParams {
authority: string;
/** The parameters to update. Each field must be set. */

params?: Params;
}
/**
* MsgUpdateParams is the Msg/UpdateParams request type.
* Deprecated since v6.x as is replaced by MsgUpdateDefaultQuotingParams.
*/

/** @deprecated */

export interface MsgUpdateParamsSDKType {
authority: string;
/** The parameters to update. Each field must be set. */

params?: ParamsSDKType;
}
/**
* MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type.
* Deprecated since v6.x as is replaced by MsgSetVaultParams.
*/

/** @deprecated */

export interface MsgSetVaultQuotingParams {
authority: string;
/** The vault to set quoting params of. */

vaultId?: VaultId;
/** The quoting parameters to set. Each field must be set. */

quotingParams?: QuotingParams;
}
/**
* MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type.
* Deprecated since v6.x as is replaced by MsgSetVaultParams.
*/

/** @deprecated */

export interface MsgSetVaultQuotingParamsSDKType {
authority: string;
/** The vault to set quoting params of. */

vault_id?: VaultIdSDKType;
/** The quoting parameters to set. Each field must be set. */

quoting_params?: QuotingParamsSDKType;
}

function createBaseMsgDepositToMegavault(): MsgDepositToMegavault {
return {
Expand Down Expand Up @@ -787,61 +819,6 @@ export const MsgUnlockSharesResponse = {

};

function createBaseMsgUpdateParams(): MsgUpdateParams {
return {
authority: "",
params: undefined
};
}

export const MsgUpdateParams = {
encode(message: MsgUpdateParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.authority !== "") {
writer.uint32(10).string(message.authority);
}

if (message.params !== undefined) {
Params.encode(message.params, writer.uint32(18).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateParams {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgUpdateParams();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.authority = reader.string();
break;

case 2:
message.params = Params.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<MsgUpdateParams>): MsgUpdateParams {
const message = createBaseMsgUpdateParams();
message.authority = object.authority ?? "";
message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
return message;
}

};

function createBaseMsgUpdateOperatorParams(): MsgUpdateOperatorParams {
return {
authority: "",
Expand Down Expand Up @@ -1127,4 +1104,124 @@ export const MsgRetrieveFromVaultResponse = {
return message;
}

};

function createBaseMsgUpdateParams(): MsgUpdateParams {
return {
authority: "",
params: undefined
};
}

export const MsgUpdateParams = {
encode(message: MsgUpdateParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.authority !== "") {
writer.uint32(10).string(message.authority);
}

if (message.params !== undefined) {
Params.encode(message.params, writer.uint32(18).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateParams {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgUpdateParams();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.authority = reader.string();
break;

case 2:
message.params = Params.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<MsgUpdateParams>): MsgUpdateParams {
const message = createBaseMsgUpdateParams();
message.authority = object.authority ?? "";
message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
return message;
}

};

function createBaseMsgSetVaultQuotingParams(): MsgSetVaultQuotingParams {
return {
authority: "",
vaultId: undefined,
quotingParams: undefined
};
}

export const MsgSetVaultQuotingParams = {
encode(message: MsgSetVaultQuotingParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.authority !== "") {
writer.uint32(10).string(message.authority);
}

if (message.vaultId !== undefined) {
VaultId.encode(message.vaultId, writer.uint32(18).fork()).ldelim();
}

if (message.quotingParams !== undefined) {
QuotingParams.encode(message.quotingParams, writer.uint32(26).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetVaultQuotingParams {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgSetVaultQuotingParams();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.authority = reader.string();
break;

case 2:
message.vaultId = VaultId.decode(reader, reader.uint32());
break;

case 3:
message.quotingParams = QuotingParams.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<MsgSetVaultQuotingParams>): MsgSetVaultQuotingParams {
const message = createBaseMsgSetVaultQuotingParams();
message.authority = object.authority ?? "";
message.vaultId = object.vaultId !== undefined && object.vaultId !== null ? VaultId.fromPartial(object.vaultId) : undefined;
message.quotingParams = object.quotingParams !== undefined && object.quotingParams !== null ? QuotingParams.fromPartial(object.quotingParams) : undefined;
return message;
}

};
39 changes: 27 additions & 12 deletions proto/dydxprotocol/vault/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,6 @@ message MsgUnlockSharesResponse {
NumShares unlocked_shares = 1 [ (gogoproto.nullable) = false ];
}

// MsgUpdateParams is the Msg/UpdateParams request type.
// Deprecated since v6.x as is replaced by MsgUpdateDefaultQuotingParams.
message MsgUpdateParams {
option deprecated = true;
// Authority is the address that controls the module.
option (cosmos.msg.v1.signer) = "authority";
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// The parameters to update. Each field must be set.
Params params = 2 [ (gogoproto.nullable) = false ];
}

// MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type.
message MsgUpdateOperatorParams {
// Authority is the address that controls the module.
Expand Down Expand Up @@ -214,3 +202,30 @@ message MsgRetrieveFromVault {

// MsgRetrieveFromVaultResponse is the Msg/RetrieveFromVault response type.
message MsgRetrieveFromVaultResponse {}

// MsgUpdateParams is the Msg/UpdateParams request type.
// Deprecated since v6.x as is replaced by MsgUpdateDefaultQuotingParams.
message MsgUpdateParams {
option deprecated = true;
// Authority is the address that controls the module.
option (cosmos.msg.v1.signer) = "authority";
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// The parameters to update. Each field must be set.
Params params = 2 [ (gogoproto.nullable) = false ];
}

// MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type.
// Deprecated since v6.x as is replaced by MsgSetVaultParams.
message MsgSetVaultQuotingParams {
option deprecated = true;
// Authority is the address that controls the module.
option (cosmos.msg.v1.signer) = "authority";
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// The vault to set quoting params of.
VaultId vault_id = 2 [ (gogoproto.nullable) = false ];

// The quoting parameters to set. Each field must be set.
QuotingParams quoting_params = 3 [ (gogoproto.nullable) = false ];
}
3 changes: 2 additions & 1 deletion protocol/app/msgs/all_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,14 @@ var (
"/dydxprotocol.vault.MsgRetrieveFromVaultResponse": {},
"/dydxprotocol.vault.MsgSetVaultParams": {},
"/dydxprotocol.vault.MsgSetVaultParamsResponse": {},
"/dydxprotocol.vault.MsgSetVaultQuotingParams": {}, // deprecated
"/dydxprotocol.vault.MsgUnlockShares": {},
"/dydxprotocol.vault.MsgUnlockSharesResponse": {},
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": {},
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": {},
"/dydxprotocol.vault.MsgUpdateOperatorParams": {},
"/dydxprotocol.vault.MsgUpdateOperatorParamsResponse": {},
"/dydxprotocol.vault.MsgUpdateParams": {},
"/dydxprotocol.vault.MsgUpdateParams": {}, // deprecated
"/dydxprotocol.vault.MsgWithdrawFromMegavault": {},
"/dydxprotocol.vault.MsgWithdrawFromMegavaultResponse": {},

Expand Down
3 changes: 3 additions & 0 deletions protocol/app/msgs/unsupported_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ var (
"/ibc.applications.interchain_accounts.controller.v1.MsgUpdateParamsResponse": nil,

// vault
// MsgSetVaultQuotingParams is deprecated since v6.x and replaced by MsgSetVaultParams.
// nolint:staticcheck
"/dydxprotocol.vault.MsgSetVaultQuotingParams": &vaulttypes.MsgSetVaultQuotingParams{},
// MsgUpdateParams is deprecated since v6.x and replaced by MsgUpdateDefaultQuotingParams.
// nolint:staticcheck
"/dydxprotocol.vault.MsgUpdateParams": &vaulttypes.MsgUpdateParams{},
Comment on lines +34 to 39
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Deprecated message types are still in use within the codebase.

The verification script identified multiple instances where the deprecated MsgSetVaultQuotingParams and MsgUpdateParams message types are still being utilized. These usages need to be updated to their respective replacement message types to ensure deprecated code is fully phased out.

Affected Areas:

  • protocol/x/vault/types/codec.go
  • protocol/x/vault/types/tx.pb.go
  • protocol/lib/ante/unsupported_msgs.go
  • protocol/app/msgs/all_msgs.go
  • protocol/app/msgs/internal_msgs.go
  • and several other files as detailed in the script output.

Please refactor these instances to use the updated message types as specified in the deprecation notes.

🔗 Analysis chain

Summary: Changes align with PR objectives and follow best practices.

The additions to the UnsupportedMsgSamples map correctly register the deprecated MsgSetVaultQuotingParams and MsgUpdateParams message types. This aligns with the PR objective of registering deprecated message types.

The changes follow best practices by:

  1. Clearly indicating the deprecation status and replacement messages.
  2. Using nolint:staticcheck to suppress unnecessary warnings for deprecated code.

These changes effectively communicate to developers that these message types should not be used in new code while maintaining backwards compatibility.

To ensure these message types are no longer used in the codebase, run the following script:

If the script returns any results, it might indicate areas of the codebase that need to be updated to use the new message types.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of deprecated message types

echo "Checking for MsgSetVaultQuotingParams usage:"
rg --type go "MsgSetVaultQuotingParams" --glob '!protocol/app/msgs/unsupported_msgs.go'

echo "Checking for MsgUpdateParams usage:"
rg --type go "MsgUpdateParams" --glob '!protocol/app/msgs/unsupported_msgs.go'

Length of output: 40267

Expand Down
1 change: 1 addition & 0 deletions protocol/app/msgs/unsupported_msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestUnsupportedMsgSamples_Key(t *testing.T) {
"/cosmos.gov.v1beta1.MsgSubmitProposal",
"/cosmos.gov.v1beta1.MsgSubmitProposalResponse",

"/dydxprotocol.vault.MsgSetVaultQuotingParams",
"/dydxprotocol.vault.MsgUpdateParams",

// ICA Controller messages
Expand Down
2 changes: 2 additions & 0 deletions protocol/lib/ante/nested_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func TestIsDydxMsg_Invalid(t *testing.T) {
appmsgs.NormalMsgsDydxCustom,
appmsgs.InternalMsgSamplesDydxCustom,
map[string]sdk.Msg{
// nolint:staticcheck
"/dydxprotocol.vault.MsgSetVaultQuotingParams": &vaulttypes.MsgSetVaultQuotingParams{},
// nolint:staticcheck
"/dydxprotocol.vault.MsgUpdateParams": &vaulttypes.MsgUpdateParams{},
},
Expand Down
2 changes: 2 additions & 0 deletions protocol/lib/ante/unsupported_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func IsUnsupportedMsg(msg sdk.Msg) bool {
// ------- dYdX custom modules
// vault
// nolint:staticcheck
*vaulttypes.MsgSetVaultQuotingParams,
// nolint:staticcheck
*vaulttypes.MsgUpdateParams:
return true
}
Expand Down
Loading
Loading