Skip to content

Commit

Permalink
register deprecated vault MsgUpdateParams (#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqin7 authored Aug 28, 2024
1 parent dadd984 commit 9f207d5
Show file tree
Hide file tree
Showing 9 changed files with 390 additions and 40 deletions.
83 changes: 82 additions & 1 deletion indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VaultId, VaultIdSDKType } from "./vault";
import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount";
import { QuotingParams, QuotingParamsSDKType } from "./params";
import { QuotingParams, QuotingParamsSDKType, Params, ParamsSDKType } from "./params";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/**
Expand Down Expand Up @@ -107,6 +107,32 @@ export interface MsgSetVaultQuotingParamsResponse {}
*/

export interface MsgSetVaultQuotingParamsResponseSDKType {}
/**
* 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;
}

function createBaseMsgDepositToVault(): MsgDepositToVault {
return {
Expand Down Expand Up @@ -393,4 +419,59 @@ export const MsgSetVaultQuotingParamsResponse = {
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;
}

};
12 changes: 12 additions & 0 deletions proto/dydxprotocol/vault/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@ message MsgSetVaultQuotingParams {
// MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response
// type.
message MsgSetVaultQuotingParamsResponse {}

// 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 ];
}
1 change: 1 addition & 0 deletions protocol/app/msgs/all_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ var (
"/dydxprotocol.vault.MsgSetVaultQuotingParamsResponse": {},
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": {},
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": {},
"/dydxprotocol.vault.MsgUpdateParams": {},

// vest
"/dydxprotocol.vest.MsgSetVestEntry": {},
Expand Down
6 changes: 6 additions & 0 deletions protocol/app/msgs/unsupported_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govbeta "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"
)

var (
Expand All @@ -28,5 +29,10 @@ var (
"/ibc.applications.interchain_accounts.controller.v1.MsgUpdateParams": &icacontrollertypes.
MsgUpdateParams{},
"/ibc.applications.interchain_accounts.controller.v1.MsgUpdateParamsResponse": nil,

// vault
// MsgUpdateParams is deprecated since v6.x and replaced by MsgUpdateDefaultQuotingParams.
// nolint:staticcheck
"/dydxprotocol.vault.MsgUpdateParams": &vaulttypes.MsgUpdateParams{},
}
)
2 changes: 2 additions & 0 deletions protocol/app/msgs/unsupported_msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func TestUnsupportedMsgSamples_Key(t *testing.T) {
"/cosmos.gov.v1beta1.MsgSubmitProposal",
"/cosmos.gov.v1beta1.MsgSubmitProposalResponse",

"/dydxprotocol.vault.MsgUpdateParams",

// ICA Controller messages
"/ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount",
"/ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccountResponse",
Expand Down
5 changes: 5 additions & 0 deletions protocol/lib/ante/nested_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/dydxprotocol/v4-chain/protocol/lib"
"github.com/dydxprotocol/v4-chain/protocol/lib/ante"
testmsgs "github.com/dydxprotocol/v4-chain/protocol/testutil/msgs"
vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -70,6 +71,10 @@ func TestIsDydxMsg_Invalid(t *testing.T) {
appmsgs.AppInjectedMsgSamples,
appmsgs.NormalMsgsDydxCustom,
appmsgs.InternalMsgSamplesDydxCustom,
map[string]sdk.Msg{
// nolint:staticcheck
"/dydxprotocol.vault.MsgUpdateParams": &vaulttypes.MsgUpdateParams{},
},
)
allMsgsMinusDydx := lib.MergeAllMapsMustHaveDistinctKeys(appmsgs.AllowMsgs, appmsgs.DisallowMsgs)
for key := range allDydxMsgs {
Expand Down
7 changes: 6 additions & 1 deletion protocol/lib/ante/unsupported_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govbeta "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"
)

// IsUnsupportedMsg returns true if the msg is unsupported by the app.
Expand All @@ -18,7 +19,11 @@ func IsUnsupportedMsg(msg sdk.Msg) bool {
// ------- CosmosSDK default modules
// gov
*govbeta.MsgSubmitProposal,
*gov.MsgCancelProposal:
*gov.MsgCancelProposal,
// ------- dYdX custom modules
// vault
// nolint:staticcheck
*vaulttypes.MsgUpdateParams:
return true
}
return false
Expand Down
8 changes: 8 additions & 0 deletions protocol/x/vault/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/cosmos/gogoproto/proto"
"github.com/dydxprotocol/v4-chain/protocol/app/module"
)

func RegisterCodec(cdc *codec.LegacyAmino) {}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
// Register deprecated MsgUpdateParams as it's not part of msg service.
registry.RegisterInterface(
"/"+proto.MessageName(&MsgUpdateParams{}),
(*sdk.Msg)(nil),
&MsgUpdateParams{},
)
}

var (
Expand Down
Loading

0 comments on commit 9f207d5

Please sign in to comment.