From b14f175eba5e452fe659bdc54de96f6a96f890d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Mon, 26 Feb 2024 11:02:50 +0100 Subject: [PATCH] added UpdateParam messge for the machine module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- docs/static/openapi.yml | 2 + proto/planetmintgo/machine/tx.proto | 20 + x/machine/client/cli/tx.go | 1 + x/machine/client/cli/tx_update_params.go | 47 ++ x/machine/keeper/msg_server_update_params.go | 24 + x/machine/module_simulation.go | 23 + x/machine/simulation/update_params.go | 29 ++ x/machine/types/codec.go | 4 + x/machine/types/message_update_params.go | 46 ++ x/machine/types/message_update_params_test.go | 40 ++ x/machine/types/tx.pb.go | 445 +++++++++++++++++- 11 files changed, 656 insertions(+), 25 deletions(-) create mode 100644 x/machine/client/cli/tx_update_params.go create mode 100644 x/machine/keeper/msg_server_update_params.go create mode 100644 x/machine/simulation/update_params.go create mode 100644 x/machine/types/message_update_params.go create mode 100644 x/machine/types/message_update_params_test.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 6a37337..4c5c954 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -77166,6 +77166,8 @@ definitions: type: object planetmintgo.machine.MsgRegisterTrustAnchorResponse: type: object + planetmintgo.machine.MsgUpdateParamsResponse: + type: object planetmintgo.machine.Params: type: object properties: diff --git a/proto/planetmintgo/machine/tx.proto b/proto/planetmintgo/machine/tx.proto index 0171977..722ad06 100644 --- a/proto/planetmintgo/machine/tx.proto +++ b/proto/planetmintgo/machine/tx.proto @@ -5,6 +5,11 @@ package planetmintgo.machine; import "planetmintgo/machine/machine.proto"; import "planetmintgo/machine/trust_anchor.proto"; import "planetmintgo/machine/liquid_asset.proto"; +import "planetmintgo/machine/params.proto"; +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; option go_package = "github.com/planetmint/planetmint-go/x/machine/types"; @@ -13,6 +18,7 @@ service Msg { rpc AttestMachine (MsgAttestMachine ) returns (MsgAttestMachineResponse ); rpc RegisterTrustAnchor (MsgRegisterTrustAnchor) returns (MsgRegisterTrustAnchorResponse); rpc NotarizeLiquidAsset (MsgNotarizeLiquidAsset) returns (MsgNotarizeLiquidAssetResponse); + rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse ); } message MsgAttestMachine { string creator = 1; @@ -35,3 +41,17 @@ message MsgNotarizeLiquidAsset { message MsgNotarizeLiquidAssetResponse {} +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/dao parameters to update. + + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +message MsgUpdateParamsResponse {} + diff --git a/x/machine/client/cli/tx.go b/x/machine/client/cli/tx.go index 2ede7a3..7984c91 100644 --- a/x/machine/client/cli/tx.go +++ b/x/machine/client/cli/tx.go @@ -27,6 +27,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdAttestMachine()) cmd.AddCommand(CmdRegisterTrustAnchor()) cmd.AddCommand(CmdNotarizeLiquidAsset()) + cmd.AddCommand(CmdUpdateParams()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/machine/client/cli/tx_update_params.go b/x/machine/client/cli/tx_update_params.go new file mode 100644 index 0000000..377bbe8 --- /dev/null +++ b/x/machine/client/cli/tx_update_params.go @@ -0,0 +1,47 @@ +package cli + +import ( + "strconv" + + "encoding/json" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/planetmint/planetmint-go/x/machine/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdUpdateParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-params [params]", + Short: "Broadcast message UpdateParams", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argParams := new(types.Params) + err = json.Unmarshal([]byte(args[0]), argParams) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUpdateParams( + clientCtx.GetFromAddress().String(), + argParams, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/machine/keeper/msg_server_update_params.go b/x/machine/keeper/msg_server_update_params.go new file mode 100644 index 0000000..1d445a7 --- /dev/null +++ b/x/machine/keeper/msg_server_update_params.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/planetmint/planetmint-go/x/machine/types" +) + +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Authority { + return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + if err := k.SetParams(ctx, msg.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/machine/module_simulation.go b/x/machine/module_simulation.go index bc176ad..64e5d24 100644 --- a/x/machine/module_simulation.go +++ b/x/machine/module_simulation.go @@ -35,6 +35,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgNotarizeLiquidAsset int = 100 + opWeightMsgUpdateParams = "op_weight_msg_update_params" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateParams int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -98,6 +102,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp machinesimulation.SimulateMsgNotarizeLiquidAsset(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgUpdateParams int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateParams, &weightMsgUpdateParams, nil, + func(_ *rand.Rand) { + weightMsgUpdateParams = defaultWeightMsgUpdateParams + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateParams, + machinesimulation.SimulateMsgUpdateParams(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations @@ -130,6 +145,14 @@ func (am AppModule) ProposalMsgs(_ module.SimulationState) []simtypes.WeightedPr return nil }, ), + simulation.NewWeightedProposalMsg( + opWeightMsgUpdateParams, + defaultWeightMsgUpdateParams, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + machinesimulation.SimulateMsgUpdateParams(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/machine/simulation/update_params.go b/x/machine/simulation/update_params.go new file mode 100644 index 0000000..9207509 --- /dev/null +++ b/x/machine/simulation/update_params.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/planetmint/planetmint-go/x/machine/keeper" + "github.com/planetmint/planetmint-go/x/machine/types" +) + +func SimulateMsgUpdateParams( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgUpdateParams{ + Authority: simAccount.Address.String(), + } + + // TODO: Handling the UpdateParams simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "UpdateParams simulation not implemented"), nil, nil + } +} diff --git a/x/machine/types/codec.go b/x/machine/types/codec.go index 31f2c2b..e93dc93 100644 --- a/x/machine/types/codec.go +++ b/x/machine/types/codec.go @@ -11,6 +11,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgAttestMachine{}, "machine/AttestMachine", nil) cdc.RegisterConcrete(&MsgRegisterTrustAnchor{}, "machine/RegisterTrustAnchor", nil) cdc.RegisterConcrete(&MsgNotarizeLiquidAsset{}, "machine/NotarizeLiquidAsset", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "machine/UpdateParams", nil) // this line is used by starport scaffolding # 2 } @@ -24,6 +25,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgNotarizeLiquidAsset{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParams{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/machine/types/message_update_params.go b/x/machine/types/message_update_params.go new file mode 100644 index 0000000..26174ca --- /dev/null +++ b/x/machine/types/message_update_params.go @@ -0,0 +1,46 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateParams = "update_params" + +var _ sdk.Msg = &MsgUpdateParams{} + +func NewMsgUpdateParams(authority string, params *Params) *MsgUpdateParams { + return &MsgUpdateParams{ + Authority: authority, + Params: params, + } +} + +func (msg *MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg *MsgUpdateParams) Type() string { + return TypeMsgUpdateParams +} + +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{authority} +} + +func (msg *MsgUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateParams) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address (%s)", err) + } + return nil +} diff --git a/x/machine/types/message_update_params_test.go b/x/machine/types/message_update_params_test.go new file mode 100644 index 0000000..061631a --- /dev/null +++ b/x/machine/types/message_update_params_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgUpdateParams_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateParams + err error + }{ + { + name: "invalid address", + msg: MsgUpdateParams{ + Authority: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateParams{ + Authority: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/machine/types/tx.pb.go b/x/machine/types/tx.pb.go index 77b62b6..d3b77f6 100644 --- a/x/machine/types/tx.pb.go +++ b/x/machine/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" @@ -291,6 +295,96 @@ func (m *MsgNotarizeLiquidAssetResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgNotarizeLiquidAssetResponse proto.InternalMessageInfo +type MsgUpdateParams struct { + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_85ac37e5c8e5251d, []int{6} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_85ac37e5c8e5251d, []int{7} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgAttestMachine)(nil), "planetmintgo.machine.MsgAttestMachine") proto.RegisterType((*MsgAttestMachineResponse)(nil), "planetmintgo.machine.MsgAttestMachineResponse") @@ -298,36 +392,49 @@ func init() { proto.RegisterType((*MsgRegisterTrustAnchorResponse)(nil), "planetmintgo.machine.MsgRegisterTrustAnchorResponse") proto.RegisterType((*MsgNotarizeLiquidAsset)(nil), "planetmintgo.machine.MsgNotarizeLiquidAsset") proto.RegisterType((*MsgNotarizeLiquidAssetResponse)(nil), "planetmintgo.machine.MsgNotarizeLiquidAssetResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "planetmintgo.machine.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "planetmintgo.machine.MsgUpdateParamsResponse") } func init() { proto.RegisterFile("planetmintgo/machine/tx.proto", fileDescriptor_85ac37e5c8e5251d) } var fileDescriptor_85ac37e5c8e5251d = []byte{ - // 377 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x4b, 0xc3, 0x30, - 0x18, 0x5e, 0x27, 0x38, 0xcc, 0x14, 0xa4, 0x8a, 0x94, 0xc2, 0xca, 0xec, 0x41, 0x77, 0xd0, 0x16, - 0x36, 0xc1, 0xf3, 0x14, 0x6f, 0xd6, 0x43, 0xf1, 0xe4, 0x65, 0x64, 0x35, 0x64, 0x81, 0x2d, 0xa9, - 0xc9, 0x3b, 0xdc, 0xfc, 0x15, 0xfe, 0x2c, 0x8f, 0x3b, 0x7a, 0x94, 0xcd, 0x1f, 0x22, 0xeb, 0x87, - 0xeb, 0x46, 0x56, 0xf4, 0xd4, 0x86, 0x3c, 0x5f, 0xef, 0xfb, 0x10, 0xd4, 0x88, 0x87, 0x98, 0x13, - 0x18, 0x31, 0x0e, 0x54, 0xf8, 0x23, 0x1c, 0x0d, 0x18, 0x27, 0x3e, 0x4c, 0xbc, 0x58, 0x0a, 0x10, - 0xe6, 0x71, 0xf1, 0xda, 0xcb, 0xae, 0x6d, 0x57, 0x4b, 0xca, 0xbe, 0x29, 0xd3, 0x3e, 0xd7, 0x0b, - 0xcb, 0xb1, 0x82, 0x1e, 0xe6, 0xd1, 0x40, 0xc8, 0x52, 0xe0, 0x90, 0xbd, 0x8c, 0xd9, 0x73, 0x0f, - 0x2b, 0x45, 0x20, 0x05, 0xba, 0x04, 0x1d, 0x06, 0x8a, 0x76, 0x01, 0x88, 0x82, 0x20, 0x85, 0x99, - 0x16, 0xaa, 0x45, 0x92, 0x60, 0x10, 0xd2, 0x32, 0x9a, 0x46, 0x6b, 0x2f, 0xcc, 0x8f, 0xe6, 0x35, - 0xaa, 0x65, 0x5a, 0x56, 0xb5, 0x69, 0xb4, 0xea, 0xed, 0x86, 0xa7, 0x9b, 0xc5, 0xcb, 0x94, 0xc2, - 0x1c, 0xed, 0xda, 0xc8, 0xda, 0xb4, 0x09, 0x89, 0x8a, 0x05, 0x57, 0xc4, 0x7d, 0x45, 0x27, 0x81, - 0xa2, 0x21, 0xa1, 0x4c, 0x01, 0x91, 0x8f, 0xcb, 0x61, 0xba, 0xc9, 0x2c, 0x25, 0x41, 0x6e, 0x51, - 0x1d, 0x56, 0xc0, 0x2c, 0xcc, 0xa9, 0x3e, 0x4c, 0x41, 0x31, 0x2c, 0xb2, 0xdc, 0x26, 0x72, 0xf4, - 0xc6, 0xbf, 0xd1, 0xa6, 0x49, 0xb4, 0x07, 0x01, 0x58, 0xb2, 0x37, 0x72, 0x9f, 0xac, 0xaf, 0xbb, - 0xdc, 0x5e, 0x49, 0xb4, 0x3b, 0xb4, 0xcf, 0x53, 0x02, 0x06, 0x26, 0x78, 0x79, 0xb6, 0x82, 0x64, - 0xb8, 0x46, 0xcb, 0xc2, 0x69, 0xac, 0xf3, 0x70, 0xed, 0xef, 0x2a, 0xda, 0x09, 0x14, 0x35, 0x29, - 0x3a, 0x58, 0xef, 0xef, 0x6c, 0x4b, 0x29, 0x1b, 0x05, 0xd8, 0xde, 0xdf, 0x70, 0xb9, 0xa1, 0x39, - 0x45, 0x47, 0xba, 0x96, 0x2e, 0xb6, 0xca, 0x68, 0xd0, 0xf6, 0xd5, 0x7f, 0xd0, 0x45, 0x6b, 0x5d, - 0x0b, 0xdb, 0xad, 0x35, 0xe8, 0x12, 0xeb, 0x92, 0x35, 0xdf, 0x04, 0x1f, 0x73, 0xc7, 0x98, 0xcd, - 0x1d, 0xe3, 0x6b, 0xee, 0x18, 0xef, 0x0b, 0xa7, 0x32, 0x5b, 0x38, 0x95, 0xcf, 0x85, 0x53, 0x79, - 0xea, 0x50, 0x06, 0x83, 0x71, 0xdf, 0x8b, 0xc4, 0xc8, 0x5f, 0x29, 0x17, 0x7e, 0x2f, 0xa9, 0xf0, - 0x27, 0xab, 0x67, 0x3a, 0x8d, 0x89, 0xea, 0xef, 0x26, 0xef, 0xae, 0xf3, 0x13, 0x00, 0x00, 0xff, - 0xff, 0x39, 0x1a, 0xee, 0x05, 0x24, 0x04, 0x00, 0x00, + // 553 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x1b, 0x26, 0x6d, 0xaa, 0x37, 0xfe, 0x85, 0x8a, 0x65, 0x11, 0x0b, 0x5d, 0x24, 0x60, + 0x9a, 0x68, 0x22, 0x36, 0x04, 0x12, 0x17, 0xd4, 0x22, 0x6e, 0x04, 0xa1, 0x00, 0x17, 0x2e, 0x95, + 0x97, 0x58, 0xae, 0xa5, 0x25, 0x0e, 0xb6, 0x0b, 0x2b, 0x47, 0x3e, 0x01, 0x67, 0x3e, 0x01, 0xc7, + 0x1d, 0xf8, 0x10, 0x13, 0xa7, 0x89, 0x13, 0x27, 0x84, 0xda, 0xc3, 0xbe, 0x06, 0x6a, 0xec, 0x2c, + 0x69, 0xe5, 0x46, 0xdd, 0x25, 0xb1, 0xf3, 0x3e, 0xef, 0xfb, 0xfc, 0xe4, 0x3c, 0x32, 0xd8, 0xce, + 0x8e, 0x60, 0x8a, 0x44, 0x42, 0x52, 0x81, 0xa9, 0x9f, 0xc0, 0x68, 0x40, 0x52, 0xe4, 0x8b, 0x63, + 0x2f, 0x63, 0x54, 0x50, 0xb3, 0x55, 0x2d, 0x7b, 0xaa, 0x6c, 0xbb, 0xda, 0x26, 0xf5, 0x96, 0x9d, + 0xf6, 0x03, 0xfd, 0x60, 0x36, 0xe4, 0xa2, 0x0f, 0xd3, 0x68, 0x40, 0x59, 0xad, 0xf0, 0x88, 0x7c, + 0x1c, 0x92, 0xb8, 0x0f, 0x39, 0x47, 0x42, 0x09, 0x77, 0xb4, 0xc2, 0x0c, 0x32, 0x98, 0x70, 0x25, + 0xb9, 0x09, 0x13, 0x92, 0x52, 0x3f, 0x7f, 0xaa, 0x4f, 0x2d, 0x4c, 0x31, 0xcd, 0x97, 0xfe, 0x74, + 0xa5, 0xbe, 0x6e, 0x45, 0x94, 0x27, 0x94, 0xf7, 0x65, 0x41, 0x6e, 0x54, 0x69, 0x53, 0xee, 0xfc, + 0x84, 0x63, 0xff, 0xd3, 0xa3, 0xe9, 0x4b, 0x16, 0x5c, 0x04, 0x6e, 0x04, 0x1c, 0x77, 0x85, 0x40, + 0x5c, 0x04, 0xd2, 0xdd, 0xb4, 0xc0, 0x5a, 0xc4, 0x10, 0x14, 0x94, 0x59, 0x46, 0xdb, 0xd8, 0x6d, + 0x86, 0xc5, 0xd6, 0x7c, 0x0a, 0xd6, 0x14, 0xa2, 0x75, 0xa5, 0x6d, 0xec, 0xae, 0xef, 0x6f, 0x7b, + 0xba, 0xb3, 0xf4, 0xd4, 0xa4, 0xb0, 0x50, 0xbb, 0x36, 0xb0, 0xe6, 0x6d, 0x42, 0xc4, 0x33, 0x9a, + 0x72, 0xe4, 0x7e, 0x06, 0xb7, 0x03, 0x8e, 0x43, 0x84, 0x09, 0x17, 0x88, 0xbd, 0x9b, 0x1e, 0x66, + 0x37, 0x3f, 0xcb, 0x1a, 0x90, 0x17, 0x60, 0x5d, 0x94, 0x42, 0x05, 0xb3, 0xa3, 0x87, 0xa9, 0x4c, + 0x0c, 0xab, 0x5d, 0x6e, 0x1b, 0x38, 0x7a, 0xe3, 0x0b, 0xb4, 0x51, 0x8e, 0xf6, 0x9a, 0x0a, 0xc8, + 0xc8, 0x17, 0xf4, 0x2a, 0xff, 0x7d, 0xdd, 0xe9, 0xdf, 0xab, 0x41, 0x7b, 0x09, 0x36, 0x52, 0xd9, + 0x00, 0x05, 0xa1, 0x69, 0x3d, 0x5b, 0x65, 0x64, 0x38, 0xd3, 0xa6, 0xe0, 0x34, 0xd6, 0x17, 0x70, + 0xdf, 0x0d, 0x70, 0x3d, 0xe0, 0xf8, 0x7d, 0x16, 0x43, 0x81, 0xde, 0xe4, 0x89, 0x31, 0x9f, 0x80, + 0x26, 0x1c, 0x8a, 0x01, 0x65, 0x44, 0x8c, 0x24, 0x58, 0xcf, 0xfa, 0xfd, 0xb3, 0xd3, 0x52, 0x61, + 0xe8, 0xc6, 0x31, 0x43, 0x9c, 0xbf, 0x15, 0x8c, 0xa4, 0x38, 0x2c, 0xa5, 0xe6, 0x73, 0xb0, 0x2a, + 0x33, 0xa7, 0x70, 0xef, 0xe8, 0x71, 0xa5, 0x4b, 0xaf, 0x79, 0xfa, 0xf7, 0x6e, 0xe3, 0xc7, 0xf9, + 0xc9, 0x9e, 0x11, 0xaa, 0xb6, 0x67, 0xd7, 0xbe, 0x9e, 0x9f, 0xec, 0x95, 0x03, 0xdd, 0x2d, 0xb0, + 0x39, 0xc7, 0x56, 0x70, 0xef, 0xff, 0x5a, 0x01, 0x2b, 0x01, 0xc7, 0x26, 0x06, 0x57, 0x67, 0x73, + 0x77, 0x7f, 0x41, 0x98, 0xe6, 0x82, 0x63, 0x7b, 0xcb, 0xe9, 0x0a, 0x43, 0x73, 0x04, 0x6e, 0xe9, + 0xd2, 0xf5, 0x70, 0xe1, 0x18, 0x8d, 0xda, 0x7e, 0x7c, 0x19, 0x75, 0xd5, 0x5a, 0x97, 0x9e, 0xc5, + 0xd6, 0x1a, 0x75, 0x8d, 0x75, 0x4d, 0x3c, 0xcc, 0x18, 0x6c, 0xcc, 0x44, 0xe3, 0xde, 0xc2, 0x29, + 0x55, 0x99, 0xdd, 0x59, 0x4a, 0x56, 0xb8, 0xf4, 0x82, 0xd3, 0xb1, 0x63, 0x9c, 0x8d, 0x1d, 0xe3, + 0xdf, 0xd8, 0x31, 0xbe, 0x4d, 0x9c, 0xc6, 0xd9, 0xc4, 0x69, 0xfc, 0x99, 0x38, 0x8d, 0x0f, 0x07, + 0x98, 0x88, 0xc1, 0xf0, 0xd0, 0x8b, 0x68, 0xe2, 0x97, 0x23, 0x2b, 0xcb, 0x0e, 0xa6, 0xfe, 0x71, + 0x79, 0x89, 0x8e, 0x32, 0xc4, 0x0f, 0x57, 0xf3, 0x5b, 0xe9, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x27, 0x5b, 0xe7, 0x57, 0xc2, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -345,6 +452,7 @@ type MsgClient interface { AttestMachine(ctx context.Context, in *MsgAttestMachine, opts ...grpc.CallOption) (*MsgAttestMachineResponse, error) RegisterTrustAnchor(ctx context.Context, in *MsgRegisterTrustAnchor, opts ...grpc.CallOption) (*MsgRegisterTrustAnchorResponse, error) NotarizeLiquidAsset(ctx context.Context, in *MsgNotarizeLiquidAsset, opts ...grpc.CallOption) (*MsgNotarizeLiquidAssetResponse, error) + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -382,11 +490,21 @@ func (c *msgClient) NotarizeLiquidAsset(ctx context.Context, in *MsgNotarizeLiqu return out, nil } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.machine.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { AttestMachine(context.Context, *MsgAttestMachine) (*MsgAttestMachineResponse, error) RegisterTrustAnchor(context.Context, *MsgRegisterTrustAnchor) (*MsgRegisterTrustAnchorResponse, error) NotarizeLiquidAsset(context.Context, *MsgNotarizeLiquidAsset) (*MsgNotarizeLiquidAssetResponse, error) + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -402,6 +520,9 @@ func (*UnimplementedMsgServer) RegisterTrustAnchor(ctx context.Context, req *Msg func (*UnimplementedMsgServer) NotarizeLiquidAsset(ctx context.Context, req *MsgNotarizeLiquidAsset) (*MsgNotarizeLiquidAssetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NotarizeLiquidAsset not implemented") } +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -461,6 +582,24 @@ func _Msg_NotarizeLiquidAsset_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.machine.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "planetmintgo.machine.Msg", HandlerType: (*MsgServer)(nil), @@ -477,6 +616,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "NotarizeLiquidAsset", Handler: _Msg_NotarizeLiquidAsset_Handler, }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "planetmintgo/machine/tx.proto", @@ -677,6 +820,69 @@ func (m *MsgNotarizeLiquidAssetResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) 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 @@ -766,6 +972,30 @@ func (m *MsgNotarizeLiquidAssetResponse) Size() (n int) { return n } +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) 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 } @@ -1276,6 +1506,171 @@ func (m *MsgNotarizeLiquidAssetResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 err := m.Params.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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: 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