From 7848f9c84931a686aac9aa1c473267d7fa44de58 Mon Sep 17 00:00:00 2001 From: Matee Ullah Malik Date: Thu, 29 Jan 2026 20:40:34 +0500 Subject: [PATCH 1/3] scaffold audit module --- app/app.go | 3 + app/app_config.go | 39 +- proto/lumera/audit/module/v1/module.proto | 15 + proto/lumera/audit/v1/genesis.proto | 17 + proto/lumera/audit/v1/params.proto | 13 + proto/lumera/audit/v1/query.proto | 30 + proto/lumera/audit/v1/tx.proto | 40 ++ x/audit/v1/keeper/genesis.go | 25 + x/audit/v1/keeper/genesis_test.go | 24 + x/audit/v1/keeper/keeper.go | 60 ++ x/audit/v1/keeper/keeper_test.go | 56 ++ x/audit/v1/keeper/msg_server.go | 17 + x/audit/v1/keeper/msg_update_params.go | 32 ++ x/audit/v1/keeper/msg_update_params_test.go | 68 +++ x/audit/v1/keeper/query.go | 17 + x/audit/v1/keeper/query_params.go | 26 + x/audit/v1/keeper/query_params_test.go | 22 + x/audit/v1/module/autocli.go | 35 ++ x/audit/v1/module/depinject.go | 62 ++ x/audit/v1/module/module.go | 143 +++++ x/audit/v1/module/module.pb.go | 323 +++++++++++ x/audit/v1/module/simulation.go | 34 ++ x/audit/v1/types/codec.go | 14 + x/audit/v1/types/errors.go | 12 + x/audit/v1/types/expected_keepers.go | 27 + x/audit/v1/types/genesis.go | 14 + x/audit/v1/types/genesis.pb.go | 322 +++++++++++ x/audit/v1/types/genesis_test.go | 37 ++ x/audit/v1/types/keys.go | 19 + x/audit/v1/types/params.go | 17 + x/audit/v1/types/params.pb.go | 287 ++++++++++ x/audit/v1/types/query.pb.go | 540 ++++++++++++++++++ x/audit/v1/types/query.pb.gw.go | 153 +++++ x/audit/v1/types/tx.pb.go | 598 ++++++++++++++++++++ x/audit/v1/types/types.go | 1 + 35 files changed, 3127 insertions(+), 15 deletions(-) create mode 100644 proto/lumera/audit/module/v1/module.proto create mode 100644 proto/lumera/audit/v1/genesis.proto create mode 100644 proto/lumera/audit/v1/params.proto create mode 100644 proto/lumera/audit/v1/query.proto create mode 100644 proto/lumera/audit/v1/tx.proto create mode 100644 x/audit/v1/keeper/genesis.go create mode 100644 x/audit/v1/keeper/genesis_test.go create mode 100644 x/audit/v1/keeper/keeper.go create mode 100644 x/audit/v1/keeper/keeper_test.go create mode 100644 x/audit/v1/keeper/msg_server.go create mode 100644 x/audit/v1/keeper/msg_update_params.go create mode 100644 x/audit/v1/keeper/msg_update_params_test.go create mode 100644 x/audit/v1/keeper/query.go create mode 100644 x/audit/v1/keeper/query_params.go create mode 100644 x/audit/v1/keeper/query_params_test.go create mode 100644 x/audit/v1/module/autocli.go create mode 100644 x/audit/v1/module/depinject.go create mode 100644 x/audit/v1/module/module.go create mode 100644 x/audit/v1/module/module.pb.go create mode 100644 x/audit/v1/module/simulation.go create mode 100644 x/audit/v1/types/codec.go create mode 100644 x/audit/v1/types/errors.go create mode 100644 x/audit/v1/types/expected_keepers.go create mode 100644 x/audit/v1/types/genesis.go create mode 100644 x/audit/v1/types/genesis.pb.go create mode 100644 x/audit/v1/types/genesis_test.go create mode 100644 x/audit/v1/types/keys.go create mode 100644 x/audit/v1/types/params.go create mode 100644 x/audit/v1/types/params.pb.go create mode 100644 x/audit/v1/types/query.pb.go create mode 100644 x/audit/v1/types/query.pb.gw.go create mode 100644 x/audit/v1/types/tx.pb.go create mode 100644 x/audit/v1/types/types.go diff --git a/app/app.go b/app/app.go index 2abad273..eb1a5598 100644 --- a/app/app.go +++ b/app/app.go @@ -81,6 +81,7 @@ import ( upgrades "github.com/LumeraProtocol/lumera/app/upgrades" appParams "github.com/LumeraProtocol/lumera/app/upgrades/params" actionmodulekeeper "github.com/LumeraProtocol/lumera/x/action/v1/keeper" + auditmodulekeeper "github.com/LumeraProtocol/lumera/x/audit/v1/keeper" claimmodulekeeper "github.com/LumeraProtocol/lumera/x/claim/keeper" lumeraidmodulekeeper "github.com/LumeraProtocol/lumera/x/lumeraid/keeper" sntypes "github.com/LumeraProtocol/lumera/x/supernode/v1/types" @@ -151,6 +152,7 @@ type App struct { ClaimKeeper claimmodulekeeper.Keeper SupernodeKeeper sntypes.SupernodeKeeper ActionKeeper actionmodulekeeper.Keeper + AuditKeeper auditmodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // simulation manager @@ -253,6 +255,7 @@ func New( &app.ClaimKeeper, &app.SupernodeKeeper, &app.ActionKeeper, + &app.AuditKeeper, // this line is used by starport scaffolding # stargate/app/keeperDefinition ); err != nil { panic(err) diff --git a/app/app_config.go b/app/app_config.go index ac883ea9..61d56fd4 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -3,8 +3,8 @@ package app import ( "time" - "github.com/cosmos/cosmos-sdk/runtime" "cosmossdk.io/depinject/appconfig" + "github.com/cosmos/cosmos-sdk/runtime" "google.golang.org/protobuf/types/known/durationpb" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" @@ -34,10 +34,13 @@ import ( evidencetypes "cosmossdk.io/x/evidence/types" "cosmossdk.io/x/feegrant" _ "cosmossdk.io/x/feegrant/module" // import for side-effects - _ "cosmossdk.io/x/upgrade" // import for side-effects + _ "cosmossdk.io/x/upgrade" // import for side-effects upgradetypes "cosmossdk.io/x/upgrade/types" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" actionmodulev1 "github.com/LumeraProtocol/lumera/x/action/v1/module" actionmoduletypes "github.com/LumeraProtocol/lumera/x/action/v1/types" + auditmodulev1 "github.com/LumeraProtocol/lumera/x/audit/v1/module" + auditmoduletypes "github.com/LumeraProtocol/lumera/x/audit/v1/types" claimmodulev1 "github.com/LumeraProtocol/lumera/x/claim/module" claimmoduletypes "github.com/LumeraProtocol/lumera/x/claim/types" lumeraidmodulev1 "github.com/LumeraProtocol/lumera/x/lumeraid/module" @@ -48,8 +51,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import for side-effects vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - _ "github.com/cosmos/cosmos-sdk/x/authz/module" // import for side-effects "github.com/cosmos/cosmos-sdk/x/authz" + _ "github.com/cosmos/cosmos-sdk/x/authz/module" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/bank" // import for side-effects banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" _ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects @@ -61,8 +64,8 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" _ "github.com/cosmos/cosmos-sdk/x/gov" // import for side-effects govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - _ "github.com/cosmos/cosmos-sdk/x/group/module" // import for side-effects "github.com/cosmos/cosmos-sdk/x/group" + _ "github.com/cosmos/cosmos-sdk/x/group/module" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" _ "github.com/cosmos/cosmos-sdk/x/params" // import for side-effects @@ -71,15 +74,14 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" _ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + pfmtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v10/packetforward/types" icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types" ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported" - ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" - pfmtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v10/packetforward/types" solomachine "github.com/cosmos/ibc-go/v10/modules/light-clients/06-solomachine" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" - lcfg "github.com/LumeraProtocol/lumera/config" + lcfg "github.com/LumeraProtocol/lumera/config" // this line is used by starport scaffolding # stargate/app/moduleImport ) @@ -110,18 +112,19 @@ var ( group.ModuleName, circuittypes.ModuleName, // ibc modules - ibcexported.ModuleName, // IBC core module - ibctransfertypes.ModuleName, // IBC transfer module - icatypes.ModuleName, // IBC interchain accounts module (host and controller) - pfmtypes.ModuleName, // IBC packet-forward-middleware - ibctm.ModuleName, // IBC Tendermint light client - solomachine.ModuleName, // IBC Solo Machine light client + ibcexported.ModuleName, // IBC core module + ibctransfertypes.ModuleName, // IBC transfer module + icatypes.ModuleName, // IBC interchain accounts module (host and controller) + pfmtypes.ModuleName, // IBC packet-forward-middleware + ibctm.ModuleName, // IBC Tendermint light client + solomachine.ModuleName, // IBC Solo Machine light client // chain modules lumeraidmoduletypes.ModuleName, wasmtypes.ModuleName, claimmoduletypes.ModuleName, supernodemoduletypes.ModuleName, actionmoduletypes.ModuleName, + auditmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } @@ -150,6 +153,7 @@ var ( claimmoduletypes.ModuleName, supernodemoduletypes.ModuleName, actionmoduletypes.ModuleName, + auditmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers } @@ -172,6 +176,7 @@ var ( claimmoduletypes.ModuleName, supernodemoduletypes.ModuleName, actionmoduletypes.ModuleName, + auditmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers } @@ -255,7 +260,7 @@ var ( }), }, { - Name: stakingtypes.ModuleName, + Name: stakingtypes.ModuleName, Config: appconfig.WrapAny(&stakingmodulev1.Module{ // NOTE: specifying a prefix is only necessary when using bech32 addresses // If not specfied, the auth Bech32Prefix appended with "valoper" and "valcons" is used by default @@ -342,6 +347,10 @@ var ( Name: actionmoduletypes.ModuleName, Config: appconfig.WrapAny(&actionmodulev1.Module{}), }, + { + Name: auditmoduletypes.ModuleName, + Config: appconfig.WrapAny(&auditmodulev1.Module{}), + }, // this line is used by starport scaffolding # stargate/app/moduleConfig }, }) diff --git a/proto/lumera/audit/module/v1/module.proto b/proto/lumera/audit/module/v1/module.proto new file mode 100644 index 00000000..ac17442c --- /dev/null +++ b/proto/lumera/audit/module/v1/module.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package lumera.audit.module.v1; + +import "cosmos/app/v1alpha1/module.proto"; + +option go_package = "x/audit/v1/module;audit"; + +// Module is the config object for the module. +message Module { + option (cosmos.app.v1alpha1.module) = {go_import: "github.com/LumeraProtocol/lumera/x/audit/v1"}; + + // authority defines the custom module authority. + // If not set, defaults to the governance module. + string authority = 1; +} diff --git a/proto/lumera/audit/v1/genesis.proto b/proto/lumera/audit/v1/genesis.proto new file mode 100644 index 00000000..8701b226 --- /dev/null +++ b/proto/lumera/audit/v1/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package lumera.audit.v1; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "lumera/audit/v1/params.proto"; + +option go_package = "x/audit/v1/types"; + +// GenesisState defines the audit module's genesis state. +message GenesisState { + // params defines all the parameters of the module. + Params params = 1 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} diff --git a/proto/lumera/audit/v1/params.proto b/proto/lumera/audit/v1/params.proto new file mode 100644 index 00000000..43b06c02 --- /dev/null +++ b/proto/lumera/audit/v1/params.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package lumera.audit.v1; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "x/audit/v1/types"; + +// Params defines the parameters for the module. +message Params { + option (amino.name) = "lumera/x/audit/Params"; + option (gogoproto.equal) = true; +} diff --git a/proto/lumera/audit/v1/query.proto b/proto/lumera/audit/v1/query.proto new file mode 100644 index 00000000..52bc1207 --- /dev/null +++ b/proto/lumera/audit/v1/query.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package lumera.audit.v1; + +import "amino/amino.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "lumera/audit/v1/params.proto"; + +option go_package = "x/audit/v1/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/LumeraProtocol/lumera/audit/v1/params"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} diff --git a/proto/lumera/audit/v1/tx.proto b/proto/lumera/audit/v1/tx.proto new file mode 100644 index 00000000..8ad099c7 --- /dev/null +++ b/proto/lumera/audit/v1/tx.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package lumera.audit.v1; + +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "lumera/audit/v1/params.proto"; + +option go_package = "x/audit/v1/types"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgUpdateParams is the Msg/UpdateParams request type. +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "lumera/x/audit/MsgUpdateParams"; + + // 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 module parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +message MsgUpdateParamsResponse {} diff --git a/x/audit/v1/keeper/genesis.go b/x/audit/v1/keeper/genesis.go new file mode 100644 index 00000000..c117faec --- /dev/null +++ b/x/audit/v1/keeper/genesis.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func (k Keeper) InitGenesis(ctx context.Context, genState types.GenesisState) error { + return k.Params.Set(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis. +func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) { + var err error + + genesis := types.DefaultGenesis() + genesis.Params, err = k.Params.Get(ctx) + if err != nil { + return nil, err + } + + return genesis, nil +} diff --git a/x/audit/v1/keeper/genesis_test.go b/x/audit/v1/keeper/genesis_test.go new file mode 100644 index 00000000..52e3e609 --- /dev/null +++ b/x/audit/v1/keeper/genesis_test.go @@ -0,0 +1,24 @@ +package keeper_test + +import ( + "testing" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" + + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + } + + f := initFixture(t) + err := f.keeper.InitGenesis(f.ctx, genesisState) + require.NoError(t, err) + got, err := f.keeper.ExportGenesis(f.ctx) + require.NoError(t, err) + require.NotNil(t, got) + + require.EqualExportedValues(t, genesisState.Params, got.Params) +} diff --git a/x/audit/v1/keeper/keeper.go b/x/audit/v1/keeper/keeper.go new file mode 100644 index 00000000..3b559228 --- /dev/null +++ b/x/audit/v1/keeper/keeper.go @@ -0,0 +1,60 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/collections" + "cosmossdk.io/core/address" + corestore "cosmossdk.io/core/store" + "github.com/cosmos/cosmos-sdk/codec" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +type Keeper struct { + storeService corestore.KVStoreService + cdc codec.Codec + addressCodec address.Codec + // Address capable of executing a MsgUpdateParams message. + // Typically, this should be the x/gov module account. + authority []byte + + Schema collections.Schema + Params collections.Item[types.Params] +} + +func NewKeeper( + storeService corestore.KVStoreService, + cdc codec.Codec, + addressCodec address.Codec, + authority []byte, + +) Keeper { + if _, err := addressCodec.BytesToString(authority); err != nil { + panic(fmt.Sprintf("invalid authority address %s: %s", authority, err)) + } + + sb := collections.NewSchemaBuilder(storeService) + + k := Keeper{ + storeService: storeService, + cdc: cdc, + addressCodec: addressCodec, + authority: authority, + + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + + return k +} + +// GetAuthority returns the module's authority. +func (k Keeper) GetAuthority() []byte { + return k.authority +} diff --git a/x/audit/v1/keeper/keeper_test.go b/x/audit/v1/keeper/keeper_test.go new file mode 100644 index 00000000..8bfa6e11 --- /dev/null +++ b/x/audit/v1/keeper/keeper_test.go @@ -0,0 +1,56 @@ +package keeper_test + +import ( + "context" + "testing" + + "cosmossdk.io/core/address" + storetypes "cosmossdk.io/store/types" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/LumeraProtocol/lumera/x/audit/v1/keeper" + module "github.com/LumeraProtocol/lumera/x/audit/v1/module" + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +type fixture struct { + ctx context.Context + keeper keeper.Keeper + addressCodec address.Codec +} + +func initFixture(t *testing.T) *fixture { + t.Helper() + + encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + addressCodec := addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) + storeKey := storetypes.NewKVStoreKey(types.StoreKey) + + storeService := runtime.NewKVStoreService(storeKey) + ctx := testutil.DefaultContextWithDB(t, storeKey, storetypes.NewTransientStoreKey("transient_test")).Ctx + + authority := authtypes.NewModuleAddress(types.GovModuleName) + + k := keeper.NewKeeper( + storeService, + encCfg.Codec, + addressCodec, + authority, + ) + + // Initialize params + if err := k.Params.Set(ctx, types.DefaultParams()); err != nil { + t.Fatalf("failed to set params: %v", err) + } + + return &fixture{ + ctx: ctx, + keeper: k, + addressCodec: addressCodec, + } +} diff --git a/x/audit/v1/keeper/msg_server.go b/x/audit/v1/keeper/msg_server.go new file mode 100644 index 00000000..ff01cdaf --- /dev/null +++ b/x/audit/v1/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/audit/v1/keeper/msg_update_params.go b/x/audit/v1/keeper/msg_update_params.go new file mode 100644 index 00000000..e402cd7b --- /dev/null +++ b/x/audit/v1/keeper/msg_update_params.go @@ -0,0 +1,32 @@ +package keeper + +import ( + "bytes" + "context" + + errorsmod "cosmossdk.io/errors" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +func (k msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + authority, err := k.addressCodec.StringToBytes(req.Authority) + if err != nil { + return nil, errorsmod.Wrap(err, "invalid authority address") + } + + if !bytes.Equal(k.GetAuthority(), authority) { + expectedAuthorityStr, _ := k.addressCodec.BytesToString(k.GetAuthority()) + return nil, errorsmod.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", expectedAuthorityStr, req.Authority) + } + + if err := req.Params.Validate(); err != nil { + return nil, err + } + + if err := k.Params.Set(ctx, req.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/audit/v1/keeper/msg_update_params_test.go b/x/audit/v1/keeper/msg_update_params_test.go new file mode 100644 index 00000000..fda62ef5 --- /dev/null +++ b/x/audit/v1/keeper/msg_update_params_test.go @@ -0,0 +1,68 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/LumeraProtocol/lumera/x/audit/v1/keeper" + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +func TestMsgUpdateParams(t *testing.T) { + f := initFixture(t) + ms := keeper.NewMsgServerImpl(f.keeper) + + params := types.DefaultParams() + require.NoError(t, f.keeper.Params.Set(f.ctx, params)) + + authorityStr, err := f.addressCodec.BytesToString(f.keeper.GetAuthority()) + require.NoError(t, err) + + // default params + testCases := []struct { + name string + input *types.MsgUpdateParams + expErr bool + expErrMsg string + }{ + { + name: "invalid authority", + input: &types.MsgUpdateParams{ + Authority: "invalid", + Params: params, + }, + expErr: true, + expErrMsg: "invalid authority", + }, + { + name: "send enabled param", + input: &types.MsgUpdateParams{ + Authority: authorityStr, + Params: types.Params{}, + }, + expErr: false, + }, + { + name: "all good", + input: &types.MsgUpdateParams{ + Authority: authorityStr, + Params: params, + }, + expErr: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + _, err := ms.UpdateParams(f.ctx, tc.input) + + if tc.expErr { + require.Error(t, err) + require.Contains(t, err.Error(), tc.expErrMsg) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/audit/v1/keeper/query.go b/x/audit/v1/keeper/query.go new file mode 100644 index 00000000..cd89f696 --- /dev/null +++ b/x/audit/v1/keeper/query.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +var _ types.QueryServer = queryServer{} + +// NewQueryServerImpl returns an implementation of the QueryServer interface +// for the provided Keeper. +func NewQueryServerImpl(k Keeper) types.QueryServer { + return queryServer{k} +} + +type queryServer struct { + k Keeper +} diff --git a/x/audit/v1/keeper/query_params.go b/x/audit/v1/keeper/query_params.go new file mode 100644 index 00000000..5e0b1d4f --- /dev/null +++ b/x/audit/v1/keeper/query_params.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "context" + "errors" + + "cosmossdk.io/collections" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +func (q queryServer) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + params, err := q.k.Params.Get(ctx) + if err != nil && !errors.Is(err, collections.ErrNotFound) { + return nil, status.Error(codes.Internal, "internal error") + } + + return &types.QueryParamsResponse{Params: params}, nil +} diff --git a/x/audit/v1/keeper/query_params_test.go b/x/audit/v1/keeper/query_params_test.go new file mode 100644 index 00000000..ad4fec44 --- /dev/null +++ b/x/audit/v1/keeper/query_params_test.go @@ -0,0 +1,22 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/LumeraProtocol/lumera/x/audit/v1/keeper" + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +func TestParamsQuery(t *testing.T) { + f := initFixture(t) + + qs := keeper.NewQueryServerImpl(f.keeper) + params := types.DefaultParams() + require.NoError(t, f.keeper.Params.Set(f.ctx, params)) + + response, err := qs.Params(f.ctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/audit/v1/module/autocli.go b/x/audit/v1/module/autocli.go new file mode 100644 index 00000000..67c4211e --- /dev/null +++ b/x/audit/v1/module/autocli.go @@ -0,0 +1,35 @@ +package audit + +import ( + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. +func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { + return &autocliv1.ModuleOptions{ + Query: &autocliv1.ServiceCommandDescriptor{ + Service: types.Query_serviceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Params", + Use: "params", + Short: "Shows the parameters of the module", + }, + // this line is used by ignite scaffolding # autocli/query + }, + }, + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: types.Msg_serviceDesc.ServiceName, + EnhanceCustomCommand: true, // only required if you want to use the custom command + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + // this line is used by ignite scaffolding # autocli/tx + }, + }, + } +} diff --git a/x/audit/v1/module/depinject.go b/x/audit/v1/module/depinject.go new file mode 100644 index 00000000..8b9ad1bf --- /dev/null +++ b/x/audit/v1/module/depinject.go @@ -0,0 +1,62 @@ +package audit + +import ( + "cosmossdk.io/core/address" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "github.com/cosmos/cosmos-sdk/codec" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/LumeraProtocol/lumera/x/audit/v1/keeper" + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.Register( + &Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *Module + StoreService store.KVStoreService + Cdc codec.Codec + AddressCodec address.Codec + + AuthKeeper types.AuthKeeper + BankKeeper types.BankKeeper +} + +type ModuleOutputs struct { + depinject.Out + + AuditKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + k := keeper.NewKeeper( + in.StoreService, + in.Cdc, + in.AddressCodec, + authority, + ) + m := NewAppModule(in.Cdc, k, in.AuthKeeper, in.BankKeeper) + + return ModuleOutputs{AuditKeeper: k, Module: m} +} diff --git a/x/audit/v1/module/module.go b/x/audit/v1/module/module.go new file mode 100644 index 00000000..23e4b84c --- /dev/null +++ b/x/audit/v1/module/module.go @@ -0,0 +1,143 @@ +package audit + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "google.golang.org/grpc" + + "github.com/LumeraProtocol/lumera/x/audit/v1/keeper" + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +var ( + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModule = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.HasEndBlocker = (*AppModule)(nil) +) + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + cdc codec.Codec + keeper keeper.Keeper + authKeeper types.AuthKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + authKeeper types.AuthKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + cdc: cdc, + keeper: keeper, + authKeeper: authKeeper, + bankKeeper: bankKeeper, + } +} + +// IsAppModule implements the appmodule.AppModule interface. +func (AppModule) IsAppModule() {} + +// Name returns the name of the module as a string. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec +func (AppModule) RegisterLegacyAminoCodec(*codec.LegacyAmino) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(clientCtx.CmdContext, mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message. +func (AppModule) RegisterInterfaces(registrar codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registrar) +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error { + types.RegisterMsgServer(registrar, keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(registrar, keeper.NewQueryServerImpl(am.keeper)) + + return nil +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. +// The default GenesisState need to be defined by the module developer and is primarily used for testing. +func (am AppModule) DefaultGenesis(codec.JSONCodec) json.RawMessage { + return am.cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form. +func (am AppModule) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := am.cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genState.Validate() +} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, gs json.RawMessage) { + var genState types.GenesisState + // Initialize global index to index in genesis state + if err := am.cdc.UnmarshalJSON(gs, &genState); err != nil { + panic(fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)) + } + + if err := am.keeper.InitGenesis(ctx, genState); err != nil { + panic(fmt.Errorf("failed to initialize %s genesis state: %w", types.ModuleName, err)) + } +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, _ codec.JSONCodec) json.RawMessage { + genState, err := am.keeper.ExportGenesis(ctx) + if err != nil { + panic(fmt.Errorf("failed to export %s genesis state: %w", types.ModuleName, err)) + } + + bz, err := am.cdc.MarshalJSON(genState) + if err != nil { + panic(fmt.Errorf("failed to marshal %s genesis state: %w", types.ModuleName, err)) + } + + return bz +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. +// It should be incremented on each consensus-breaking change introduced by the module. +// To avoid wrong/empty versions, the initial version should be set to 1. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block. +// The begin block implementation is optional. +func (am AppModule) BeginBlock(_ context.Context) error { + return nil +} + +// EndBlock contains the logic that is automatically triggered at the end of each block. +// The end block implementation is optional. +func (am AppModule) EndBlock(_ context.Context) error { + return nil +} diff --git a/x/audit/v1/module/module.pb.go b/x/audit/v1/module/module.pb.go new file mode 100644 index 00000000..97bc80a5 --- /dev/null +++ b/x/audit/v1/module/module.pb.go @@ -0,0 +1,323 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lumera/audit/module/v1/module.proto + +package audit + +import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Module is the config object for the module. +type Module struct { + // authority defines the custom module authority. + // If not set, defaults to the governance module. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (m *Module) Reset() { *m = Module{} } +func (m *Module) String() string { return proto.CompactTextString(m) } +func (*Module) ProtoMessage() {} +func (*Module) Descriptor() ([]byte, []int) { + return fileDescriptor_b5091c38baca1bc9, []int{0} +} +func (m *Module) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Module) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Module.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 *Module) XXX_Merge(src proto.Message) { + xxx_messageInfo_Module.Merge(m, src) +} +func (m *Module) XXX_Size() int { + return m.Size() +} +func (m *Module) XXX_DiscardUnknown() { + xxx_messageInfo_Module.DiscardUnknown(m) +} + +var xxx_messageInfo_Module proto.InternalMessageInfo + +func (m *Module) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func init() { + proto.RegisterType((*Module)(nil), "lumera.audit.module.v1.Module") +} + +func init() { + proto.RegisterFile("lumera/audit/module/v1/module.proto", fileDescriptor_b5091c38baca1bc9) +} + +var fileDescriptor_b5091c38baca1bc9 = []byte{ + // 199 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xce, 0x29, 0xcd, 0x4d, + 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0xd5, + 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xc4, 0x20, 0x8a, 0xf4, 0xc0, + 0x8a, 0xf4, 0xa0, 0x52, 0x65, 0x86, 0x52, 0x0a, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x89, + 0x05, 0x05, 0xfa, 0x65, 0x86, 0x89, 0x39, 0x05, 0x19, 0x89, 0xa8, 0x3a, 0x95, 0xa2, 0xb9, 0xd8, + 0x7c, 0xc1, 0x7c, 0x21, 0x19, 0x2e, 0xce, 0xc4, 0xd2, 0x92, 0x8c, 0xfc, 0xa2, 0xcc, 0x92, 0x4a, + 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x84, 0x80, 0x95, 0xf1, 0xae, 0x03, 0xd3, 0x6e, 0x31, + 0xea, 0x72, 0x69, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x80, + 0x2d, 0x0d, 0x00, 0x99, 0x93, 0x9c, 0x9f, 0xa3, 0x0f, 0x75, 0x68, 0x05, 0xd4, 0xa9, 0x65, 0x86, + 0x4e, 0x86, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, + 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x25, 0x8e, 0x50, 0x05, + 0x75, 0x8f, 0x35, 0x98, 0x9f, 0xc4, 0x06, 0x76, 0x96, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xf4, + 0x2a, 0x4c, 0xf4, 0xf7, 0x00, 0x00, 0x00, +} + +func (m *Module) 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 *Module) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Module) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintModule(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintModule(dAtA []byte, offset int, v uint64) int { + offset -= sovModule(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Module) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + return n +} + +func sovModule(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModule(x uint64) (n int) { + return sovModule(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Module) 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 ErrIntOverflowModule + } + 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: Module: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Module: 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 ErrIntOverflowModule + } + 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 ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModule(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, ErrIntOverflowModule + } + 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, ErrIntOverflowModule + } + 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, ErrIntOverflowModule + } + 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, ErrInvalidLengthModule + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModule + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModule + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModule = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModule = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModule = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/audit/v1/module/simulation.go b/x/audit/v1/module/simulation.go new file mode 100644 index 00000000..9097fc02 --- /dev/null +++ b/x/audit/v1/module/simulation.go @@ -0,0 +1,34 @@ +package audit + +import ( + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +// GenerateGenesisState creates a randomized GenState of the module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + auditGenesis := types.GenesisState{ + Params: types.DefaultParams(), + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&auditGenesis) +} + +// RegisterStoreDecoder registers a decoder. +func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + return operations +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{} +} diff --git a/x/audit/v1/types/codec.go b/x/audit/v1/types/codec.go new file mode 100644 index 00000000..56398f5e --- /dev/null +++ b/x/audit/v1/types/codec.go @@ -0,0 +1,14 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterInterfaces(registrar codectypes.InterfaceRegistry) { + registrar.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParams{}, + ) + msgservice.RegisterMsgServiceDesc(registrar, &_Msg_serviceDesc) +} diff --git a/x/audit/v1/types/errors.go b/x/audit/v1/types/errors.go new file mode 100644 index 00000000..c5703971 --- /dev/null +++ b/x/audit/v1/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + "cosmossdk.io/errors" +) + +// x/audit module sentinel errors +var ( + ErrInvalidSigner = errors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") +) diff --git a/x/audit/v1/types/expected_keepers.go b/x/audit/v1/types/expected_keepers.go new file mode 100644 index 00000000..b175461c --- /dev/null +++ b/x/audit/v1/types/expected_keepers.go @@ -0,0 +1,27 @@ +package types + +import ( + "context" + + "cosmossdk.io/core/address" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// AuthKeeper defines the expected interface for the Auth module. +type AuthKeeper interface { + AddressCodec() address.Codec + GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // only used for simulation + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface for the Bank module. +type BankKeeper interface { + SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} + +// ParamSubspace defines the expected Subspace interface for parameters. +type ParamSubspace interface { + Get(context.Context, []byte, interface{}) + Set(context.Context, []byte, interface{}) +} diff --git a/x/audit/v1/types/genesis.go b/x/audit/v1/types/genesis.go new file mode 100644 index 00000000..9d633ecd --- /dev/null +++ b/x/audit/v1/types/genesis.go @@ -0,0 +1,14 @@ +package types + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + return gs.Params.Validate() +} diff --git a/x/audit/v1/types/genesis.pb.go b/x/audit/v1/types/genesis.pb.go new file mode 100644 index 00000000..4f9da657 --- /dev/null +++ b/x/audit/v1/types/genesis.pb.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lumera/audit/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// GenesisState defines the audit module's genesis state. +type GenesisState struct { + // params defines all the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_a433cb4f206fdbad, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "lumera.audit.v1.GenesisState") +} + +func init() { proto.RegisterFile("lumera/audit/v1/genesis.proto", fileDescriptor_a433cb4f206fdbad) } + +var fileDescriptor_a433cb4f206fdbad = []byte{ + // 190 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x29, 0xcd, 0x4d, + 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, + 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x48, 0xeb, 0x81, 0xa5, + 0xf5, 0xca, 0x0c, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, + 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x65, 0xd0, 0x0d, 0x2e, 0x48, + 0x2c, 0x4a, 0xcc, 0x85, 0x9a, 0xab, 0xe4, 0xc5, 0xc5, 0xe3, 0x0e, 0xb1, 0x28, 0xb8, 0x24, 0xb1, + 0x24, 0x55, 0xc8, 0x8a, 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xae, + 0x87, 0x66, 0xb1, 0x5e, 0x00, 0x58, 0xda, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, + 0x68, 0x31, 0x06, 0x41, 0x75, 0x38, 0x69, 0x9d, 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, 0x40, 0x05, 0xc2, 0xfa, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xf5, 0xc6, + 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xca, 0xc9, 0xb9, 0xdd, 0xf7, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) 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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + 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 := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/audit/v1/types/genesis_test.go b/x/audit/v1/types/genesis_test.go new file mode 100644 index 00000000..45e1f286 --- /dev/null +++ b/x/audit/v1/types/genesis_test.go @@ -0,0 +1,37 @@ +package types_test + +import ( + "testing" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{}, + valid: true, + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/audit/v1/types/keys.go b/x/audit/v1/types/keys.go new file mode 100644 index 00000000..a1b552ea --- /dev/null +++ b/x/audit/v1/types/keys.go @@ -0,0 +1,19 @@ +package types + +import "cosmossdk.io/collections" + +const ( + // ModuleName defines the module name + ModuleName = "audit" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // GovModuleName duplicates the gov module's name to avoid a dependency with x/gov. + // It should be synced with the gov module's name if it is ever changed. + // See: https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/gov/types/keys.go#L9 + GovModuleName = "gov" +) + +// ParamsKey is the prefix to retrieve all Params +var ParamsKey = collections.NewPrefix("p_audit") diff --git a/x/audit/v1/types/params.go b/x/audit/v1/types/params.go new file mode 100644 index 00000000..d7e00501 --- /dev/null +++ b/x/audit/v1/types/params.go @@ -0,0 +1,17 @@ +package types + +// NewParams creates a new Params instance. +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters. +func DefaultParams() Params { + return NewParams() +} + +// Validate validates the set of params. +func (p Params) Validate() error { + + return nil +} diff --git a/x/audit/v1/types/params.pb.go b/x/audit/v1/types/params.pb.go new file mode 100644 index 00000000..f59d0ed9 --- /dev/null +++ b/x/audit/v1/types/params.pb.go @@ -0,0 +1,287 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lumera/audit/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3788ca0fc7eb9d86, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "lumera.audit.v1.Params") +} + +func init() { proto.RegisterFile("lumera/audit/v1/params.proto", fileDescriptor_3788ca0fc7eb9d86) } + +var fileDescriptor_3788ca0fc7eb9d86 = []byte{ + // 156 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0x29, 0xcd, 0x4d, + 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, + 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc8, 0xea, 0x81, 0x65, 0xf5, + 0xca, 0x0c, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x48, + 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0x34, 0xb8, 0xd8, 0x02, 0xc0, + 0x26, 0x59, 0xc9, 0xbd, 0x58, 0x20, 0xcf, 0xd8, 0xf5, 0x7c, 0x83, 0x96, 0x28, 0xd4, 0xaa, 0x0a, + 0xa8, 0x65, 0x10, 0x79, 0x27, 0xad, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, + 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, + 0x12, 0xa8, 0x40, 0x38, 0xab, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x6c, 0xb8, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0x11, 0x3c, 0x90, 0x9b, 0xb6, 0x00, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/audit/v1/types/query.pb.go b/x/audit/v1/types/query.pb.go new file mode 100644 index 00000000..5a15c8bb --- /dev/null +++ b/x/audit/v1/types/query.pb.go @@ -0,0 +1,540 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lumera/audit/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "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" + _ "google.golang.org/genproto/googleapis/api/annotations" + 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. +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 + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "lumera.audit.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "lumera.audit.v1.QueryParamsResponse") +} + +func init() { proto.RegisterFile("lumera/audit/v1/query.proto", fileDescriptor_e98945621bbc9485) } + +var fileDescriptor_e98945621bbc9485 = []byte{ + // 311 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0x29, 0xcd, 0x4d, + 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, + 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x48, 0xea, 0x81, 0x25, 0xf5, 0xca, + 0x0c, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x56, 0x72, + 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, 0x52, 0x62, 0x71, 0x2a, 0x44, 0xb3, 0x7e, 0x99, 0x61, 0x52, + 0x6a, 0x49, 0xa2, 0xa1, 0x7e, 0x41, 0x62, 0x7a, 0x66, 0x5e, 0x62, 0x49, 0x66, 0x7e, 0x1e, 0x54, + 0xad, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x65, 0xd2, 0xf3, 0xf3, + 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0xc0, 0x5a, 0x8a, + 0x61, 0xb2, 0xe8, 0x0e, 0x2c, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0xca, 0x2a, 0x89, 0x70, 0x09, 0x05, + 0x82, 0xec, 0x0c, 0x00, 0x0b, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0x05, 0x72, 0x09, + 0xa3, 0x88, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x59, 0x71, 0xb1, 0x41, 0x34, 0x4b, 0x30, + 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x89, 0xeb, 0xa1, 0xf9, 0x4f, 0x0f, 0xa2, 0xc1, 0x89, 0xf3, 0xc4, + 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, 0x41, 0x75, 0x18, 0xf5, 0x32, 0x72, 0xb1, + 0x82, 0xcd, 0x14, 0x6a, 0x66, 0xe4, 0x62, 0x83, 0xa8, 0x13, 0x52, 0xc6, 0x30, 0x00, 0xd3, 0x31, + 0x52, 0x2a, 0xf8, 0x15, 0x41, 0xdc, 0xa6, 0xa4, 0xd7, 0x74, 0xf9, 0xc9, 0x64, 0x26, 0x0d, 0x21, + 0x35, 0x7d, 0x1f, 0xb0, 0xea, 0x00, 0x90, 0xf7, 0x92, 0xf3, 0x73, 0xf4, 0xb1, 0x7b, 0xdf, 0x49, + 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x04, 0x2a, 0x10, 0x8a, 0x4b, + 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x61, 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x98, + 0x90, 0x3b, 0x43, 0xec, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/lumera.audit.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lumera.audit.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var Query_serviceDesc = _Query_serviceDesc +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lumera.audit.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lumera/audit/v1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/audit/v1/types/query.pb.gw.go b/x/audit/v1/types/query.pb.gw.go new file mode 100644 index 00000000..5cd0e465 --- /dev/null +++ b/x/audit/v1/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: lumera/audit/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"LumeraProtocol", "lumera", "audit", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/audit/v1/types/tx.pb.go b/x/audit/v1/types/tx.pb.go new file mode 100644 index 00000000..9ff1d809 --- /dev/null +++ b/x/audit/v1/types/tx.pb.go @@ -0,0 +1,598 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lumera/audit/v1/tx.proto + +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" + 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. +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 + +// MsgUpdateParams is the Msg/UpdateParams request type. +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"` + // params defines the module parameters to update. + // + // 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_4b5ba410ad359f63, []int{0} +} +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{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +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_4b5ba410ad359f63, []int{1} +} +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((*MsgUpdateParams)(nil), "lumera.audit.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "lumera.audit.v1.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("lumera/audit/v1/tx.proto", fileDescriptor_4b5ba410ad359f63) } + +var fileDescriptor_4b5ba410ad359f63 = []byte{ + // 326 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0x29, 0xcd, 0x4d, + 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc8, 0xe8, 0x81, 0x65, 0xf4, 0xca, 0x0c, 0xa5, 0x04, + 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x78, 0x72, 0x7e, 0x71, 0x6e, + 0x7e, 0xb1, 0x7e, 0x6e, 0x71, 0x3a, 0x48, 0x6f, 0x6e, 0x71, 0x3a, 0x54, 0x42, 0x12, 0x22, 0x11, + 0x0f, 0xe6, 0xe9, 0x43, 0x38, 0x50, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x88, 0x38, 0x88, 0x05, + 0x15, 0x95, 0x41, 0x77, 0x47, 0x41, 0x62, 0x51, 0x62, 0x2e, 0x54, 0x8f, 0xd2, 0x0e, 0x46, 0x2e, + 0x7e, 0xdf, 0xe2, 0xf4, 0xd0, 0x82, 0x94, 0xc4, 0x92, 0xd4, 0x00, 0xb0, 0x8c, 0x90, 0x19, 0x17, + 0x67, 0x62, 0x69, 0x49, 0x46, 0x7e, 0x51, 0x66, 0x49, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, + 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, 0xcb, 0x1c, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x83, + 0x4b, 0x8a, 0x32, 0xf3, 0xd2, 0x83, 0x10, 0x4a, 0x85, 0xac, 0xb8, 0xd8, 0x20, 0x66, 0x4b, 0x30, + 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x89, 0xeb, 0xa1, 0x79, 0x54, 0x0f, 0x62, 0x81, 0x13, 0xe7, 0x89, + 0x7b, 0xf2, 0x0c, 0x2b, 0x9e, 0x6f, 0xd0, 0x62, 0x0c, 0x82, 0xea, 0xb0, 0x32, 0x6c, 0x7a, 0xbe, + 0x41, 0x0b, 0x61, 0x56, 0xd7, 0xf3, 0x0d, 0x5a, 0x72, 0x50, 0x87, 0x57, 0x40, 0x9d, 0x8e, 0xe6, + 0x4c, 0x25, 0x49, 0x2e, 0x71, 0x34, 0xa1, 0xa0, 0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa3, + 0x0c, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x28, 0x2e, 0x1e, 0x14, 0x8f, 0x29, 0x60, 0x38, 0x08, + 0xcd, 0x00, 0x29, 0x0d, 0x42, 0x2a, 0x60, 0x56, 0x48, 0xb1, 0x36, 0x80, 0xdc, 0xef, 0xa4, 0x75, + 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, + 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x02, 0x15, 0x48, 0x51, 0x5f, 0x59, + 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x72, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xa3, + 0xb7, 0xf0, 0x1a, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// 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 { + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/lumera.audit.v1.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 { + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +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) +} + +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: "/lumera.audit.v1.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 = _Msg_serviceDesc +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lumera.audit.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lumera/audit/v1/tx.proto", +} + +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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 + 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/x/audit/v1/types/types.go b/x/audit/v1/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/audit/v1/types/types.go @@ -0,0 +1 @@ +package types From 86b8c31d7525cf5ce6a30991105d71c1a526a20b Mon Sep 17 00:00:00 2001 From: Matee Ullah Malik Date: Thu, 29 Jan 2026 22:01:09 +0500 Subject: [PATCH 2/3] audit: evidence tx + metadata --- proto/lumera/audit/v1/evidence.proto | 33 + proto/lumera/audit/v1/evidence_metadata.proto | 29 + proto/lumera/audit/v1/genesis.proto | 7 + proto/lumera/audit/v1/query.proto | 45 + proto/lumera/audit/v1/tx.proto | 24 +- x/audit/v1/keeper/evidence.go | 113 ++ x/audit/v1/keeper/genesis.go | 53 +- x/audit/v1/keeper/keeper.go | 26 +- .../v1/keeper/msg_server_submit_evidence.go | 16 + x/audit/v1/keeper/query_evidence.go | 143 ++ x/audit/v1/module/autocli.go | 6 + x/audit/v1/module/simulation.go | 20 + x/audit/v1/simulation/submit_evidence.go | 55 + x/audit/v1/types/codec.go | 4 + x/audit/v1/types/errors.go | 7 +- x/audit/v1/types/evidence.go | 16 + x/audit/v1/types/evidence.pb.go | 610 +++++++ x/audit/v1/types/evidence_metadata.pb.go | 640 +++++++ x/audit/v1/types/genesis.go | 3 +- x/audit/v1/types/genesis.pb.go | 122 +- x/audit/v1/types/keys.go | 12 + x/audit/v1/types/query.pb.go | 1473 ++++++++++++++++- x/audit/v1/types/query.pb.gw.go | 339 ++++ x/audit/v1/types/tx.pb.go | 626 ++++++- 24 files changed, 4348 insertions(+), 74 deletions(-) create mode 100644 proto/lumera/audit/v1/evidence.proto create mode 100644 proto/lumera/audit/v1/evidence_metadata.proto create mode 100644 x/audit/v1/keeper/evidence.go create mode 100644 x/audit/v1/keeper/msg_server_submit_evidence.go create mode 100644 x/audit/v1/keeper/query_evidence.go create mode 100644 x/audit/v1/simulation/submit_evidence.go create mode 100644 x/audit/v1/types/evidence.go create mode 100644 x/audit/v1/types/evidence.pb.go create mode 100644 x/audit/v1/types/evidence_metadata.pb.go diff --git a/proto/lumera/audit/v1/evidence.proto b/proto/lumera/audit/v1/evidence.proto new file mode 100644 index 00000000..c9ebc620 --- /dev/null +++ b/proto/lumera/audit/v1/evidence.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package lumera.audit.v1; + +import "cosmos_proto/cosmos.proto"; + +option go_package = "x/audit/v1/types"; + +// Evidence is a stable outer record that stores evidence about an audited subject. +// Type-specific fields are encoded into the `metadata` bytes field. +message Evidence { + // evidence_id is a chain-assigned unique identifier. + uint64 evidence_id = 1; + + // subject_address is the audited subject (e.g. supernode-related actor). + string subject_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // reporter_address is the submitter of the evidence. + string reporter_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // action_id optionally links this evidence to a specific action. + string action_id = 4; + + // evidence_type is a stable discriminator used to interpret metadata. + string evidence_type = 5; + + // metadata is protobuf-binary bytes of a type-specific Evidence metadata message. + bytes metadata = 6; + + // reported_height is the block height when the evidence was submitted. + uint64 reported_height = 7; +} + diff --git a/proto/lumera/audit/v1/evidence_metadata.proto b/proto/lumera/audit/v1/evidence_metadata.proto new file mode 100644 index 00000000..7fafc87f --- /dev/null +++ b/proto/lumera/audit/v1/evidence_metadata.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package lumera.audit.v1; + +import "cosmos_proto/cosmos.proto"; + +option go_package = "x/audit/v1/types"; + +// ExpirationEvidenceMetadata is metadata for evidence about an action expiring. +message ExpirationEvidenceMetadata { + // expiration_height is the height at which the action expired (if known). + uint64 expiration_height = 1; + + // reason is optional human-readable context. + string reason = 2; +} + +// FinalizationEvidenceMetadata is metadata for evidence about finalization behavior. +message FinalizationEvidenceMetadata { + // attempted_finalizer_address is the address that attempted finalization. + string attempted_finalizer_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // expected_finalizer_address is optional (if there is a known expected finalizer). + string expected_finalizer_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // reason is optional human-readable context. + string reason = 3; +} + diff --git a/proto/lumera/audit/v1/genesis.proto b/proto/lumera/audit/v1/genesis.proto index 8701b226..20aaaea0 100644 --- a/proto/lumera/audit/v1/genesis.proto +++ b/proto/lumera/audit/v1/genesis.proto @@ -3,6 +3,7 @@ package lumera.audit.v1; import "amino/amino.proto"; import "gogoproto/gogo.proto"; +import "lumera/audit/v1/evidence.proto"; import "lumera/audit/v1/params.proto"; option go_package = "x/audit/v1/types"; @@ -14,4 +15,10 @@ message GenesisState { (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + + // evidence defines the initial evidence records (optional). + repeated Evidence evidence = 2 [(gogoproto.nullable) = false]; + + // next_evidence_id is the next id to use for chain-assigned ids. + uint64 next_evidence_id = 3; } diff --git a/proto/lumera/audit/v1/query.proto b/proto/lumera/audit/v1/query.proto index 52bc1207..1de11f84 100644 --- a/proto/lumera/audit/v1/query.proto +++ b/proto/lumera/audit/v1/query.proto @@ -3,8 +3,10 @@ package lumera.audit.v1; import "amino/amino.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "lumera/audit/v1/evidence.proto"; import "lumera/audit/v1/params.proto"; option go_package = "x/audit/v1/types"; @@ -15,6 +17,21 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/LumeraProtocol/lumera/audit/v1/params"; } + + // EvidenceById queries a single evidence record by id. + rpc EvidenceById(QueryEvidenceByIdRequest) returns (QueryEvidenceByIdResponse) { + option (google.api.http).get = "/LumeraProtocol/lumera/audit/v1/evidence/{evidence_id}"; + } + + // EvidenceBySubject queries evidence records by subject address. + rpc EvidenceBySubject(QueryEvidenceBySubjectRequest) returns (QueryEvidenceBySubjectResponse) { + option (google.api.http).get = "/LumeraProtocol/lumera/audit/v1/evidence/by_subject/{subject_address}"; + } + + // EvidenceByAction queries evidence records by action id. + rpc EvidenceByAction(QueryEvidenceByActionRequest) returns (QueryEvidenceByActionResponse) { + option (google.api.http).get = "/LumeraProtocol/lumera/audit/v1/evidence/by_action/{action_id}"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -28,3 +45,31 @@ message QueryParamsResponse { (amino.dont_omitempty) = true ]; } + +message QueryEvidenceByIdRequest { + uint64 evidence_id = 1; +} + +message QueryEvidenceByIdResponse { + Evidence evidence = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +message QueryEvidenceBySubjectRequest { + string subject_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryEvidenceBySubjectResponse { + repeated Evidence evidence = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryEvidenceByActionRequest { + string action_id = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryEvidenceByActionResponse { + repeated Evidence evidence = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/proto/lumera/audit/v1/tx.proto b/proto/lumera/audit/v1/tx.proto index 8ad099c7..246fc280 100644 --- a/proto/lumera/audit/v1/tx.proto +++ b/proto/lumera/audit/v1/tx.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package lumera.audit.v1; import "amino/amino.proto"; @@ -16,6 +17,9 @@ service Msg { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // SubmitEvidence defines the SubmitEvidence RPC. + rpc SubmitEvidence(MsgSubmitEvidence) returns (MsgSubmitEvidenceResponse); } // MsgUpdateParams is the Msg/UpdateParams request type. @@ -27,7 +31,7 @@ message MsgUpdateParams { string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // params defines the module parameters to update. - // + // NOTE: All parameters must be supplied. Params params = 2 [ (gogoproto.nullable) = false, @@ -38,3 +42,21 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. message MsgUpdateParamsResponse {} + +// MsgSubmitEvidence defines the MsgSubmitEvidence message. +message MsgSubmitEvidence { + option (cosmos.msg.v1.signer) = "creator"; + string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string subject_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string evidence_type = 3; + string action_id = 4; + + // metadata is JSON for the type-specific Evidence metadata message. + // The chain stores protobuf-binary bytes derived from this JSON. + string metadata = 5; +} + +// MsgSubmitEvidenceResponse defines the MsgSubmitEvidenceResponse message. +message MsgSubmitEvidenceResponse { + uint64 evidence_id = 1; +} diff --git a/x/audit/v1/keeper/evidence.go b/x/audit/v1/keeper/evidence.go new file mode 100644 index 00000000..fb39c6d5 --- /dev/null +++ b/x/audit/v1/keeper/evidence.go @@ -0,0 +1,113 @@ +package keeper + +import ( + "context" + "fmt" + "strings" + + "cosmossdk.io/collections" + "cosmossdk.io/errors" + "github.com/LumeraProtocol/lumera/x/audit/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" + gogoproto "github.com/cosmos/gogoproto/proto" + "github.com/cosmos/gogoproto/jsonpb" +) + +func (k Keeper) CreateEvidence( + ctx context.Context, + reporterAddress string, + subjectAddress string, + actionID string, + evidenceType string, + metadataJSON string, +) (uint64, error) { + if _, err := k.addressCodec.StringToBytes(reporterAddress); err != nil { + return 0, errors.Wrap(types.ErrInvalidReporter, err.Error()) + } + + if _, err := k.addressCodec.StringToBytes(subjectAddress); err != nil { + return 0, errors.Wrap(types.ErrInvalidSubject, err.Error()) + } + + etype := types.CanonicalEvidenceType(evidenceType) + if etype == "" { + return 0, types.ErrInvalidEvidenceType + } + + metadataJSON = strings.TrimSpace(metadataJSON) + if metadataJSON == "" { + return 0, types.ErrInvalidMetadata + } + + if actionID == "" { + // For the initial supported evidence types (action expiration/finalization), action id is required. + switch etype { + case types.EvidenceTypeActionExpired, types.EvidenceTypeActionWrongFinalizer: + return 0, types.ErrInvalidActionID + } + } + + metadataBytes, err := marshalEvidenceMetadataJSON(etype, metadataJSON) + if err != nil { + return 0, errors.Wrap(types.ErrInvalidMetadata, err.Error()) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + reportedHeight := uint64(sdkCtx.BlockHeight()) + + evidenceID, err := k.EvidenceID.Next(ctx) + if err != nil { + return 0, err + } + + ev := types.Evidence{ + EvidenceId: evidenceID, + SubjectAddress: subjectAddress, + ReporterAddress: reporterAddress, + ActionId: actionID, + EvidenceType: etype, + Metadata: metadataBytes, + ReportedHeight: reportedHeight, + } + + if err := k.Evidences.Set(ctx, evidenceID, ev); err != nil { + return 0, err + } + + if err := k.BySubject.Set(ctx, collections.Join(subjectAddress, evidenceID)); err != nil { + return 0, err + } + if actionID != "" { + if err := k.ByActionID.Set(ctx, collections.Join(actionID, evidenceID)); err != nil { + return 0, err + } + } + + return evidenceID, nil +} + +func marshalEvidenceMetadataJSON(evidenceType string, metadataJSON string) ([]byte, error) { + u := &jsonpb.Unmarshaler{} + + switch evidenceType { + case types.EvidenceTypeActionExpired: + var m types.ExpirationEvidenceMetadata + if err := u.Unmarshal(strings.NewReader(metadataJSON), &m); err != nil { + return nil, fmt.Errorf("unmarshal ExpirationEvidenceMetadata: %w", err) + } + return gogoproto.Marshal(&m) + + case types.EvidenceTypeActionWrongFinalizer: + var m types.FinalizationEvidenceMetadata + if err := u.Unmarshal(strings.NewReader(metadataJSON), &m); err != nil { + return nil, fmt.Errorf("unmarshal FinalizationEvidenceMetadata: %w", err) + } + if strings.TrimSpace(m.AttemptedFinalizerAddress) == "" { + return nil, fmt.Errorf("attempted_finalizer_address is required") + } + return gogoproto.Marshal(&m) + + default: + return nil, fmt.Errorf("unsupported evidence_type: %s", evidenceType) + } +} diff --git a/x/audit/v1/keeper/genesis.go b/x/audit/v1/keeper/genesis.go index c117faec..cc235006 100644 --- a/x/audit/v1/keeper/genesis.go +++ b/x/audit/v1/keeper/genesis.go @@ -2,13 +2,47 @@ package keeper import ( "context" + "errors" + "cosmossdk.io/collections" "github.com/LumeraProtocol/lumera/x/audit/v1/types" ) // InitGenesis initializes the module's state from a provided genesis state. func (k Keeper) InitGenesis(ctx context.Context, genState types.GenesisState) error { - return k.Params.Set(ctx, genState.Params) + if err := k.Params.Set(ctx, genState.Params); err != nil { + return err + } + + var maxID uint64 + for _, ev := range genState.Evidence { + if err := k.Evidences.Set(ctx, ev.EvidenceId, ev); err != nil { + return err + } + if err := k.BySubject.Set(ctx, collections.Join(ev.SubjectAddress, ev.EvidenceId)); err != nil { + return err + } + if ev.ActionId != "" { + if err := k.ByActionID.Set(ctx, collections.Join(ev.ActionId, ev.EvidenceId)); err != nil { + return err + } + } + if ev.EvidenceId > maxID { + maxID = ev.EvidenceId + } + } + + nextID := genState.NextEvidenceId + if nextID == 0 && len(genState.Evidence) > 0 { + nextID = maxID + 1 + } + if nextID != 0 { + if err := k.EvidenceID.Set(ctx, nextID); err != nil { + return err + } + } + + return nil } // ExportGenesis returns the module's exported genesis. @@ -17,9 +51,26 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) genesis := types.DefaultGenesis() genesis.Params, err = k.Params.Get(ctx) + if err != nil { + if !errors.Is(err, collections.ErrNotFound) { + return nil, err + } + } + + evidence := make([]types.Evidence, 0) + if err := k.Evidences.Walk(ctx, nil, func(_ uint64, ev types.Evidence) (bool, error) { + evidence = append(evidence, ev) + return false, nil + }); err != nil { + return nil, err + } + genesis.Evidence = evidence + + nextID, err := k.EvidenceID.Peek(ctx) if err != nil { return nil, err } + genesis.NextEvidenceId = nextID return genesis, nil } diff --git a/x/audit/v1/keeper/keeper.go b/x/audit/v1/keeper/keeper.go index 3b559228..8a79fbb9 100644 --- a/x/audit/v1/keeper/keeper.go +++ b/x/audit/v1/keeper/keeper.go @@ -19,8 +19,12 @@ type Keeper struct { // Typically, this should be the x/gov module account. authority []byte - Schema collections.Schema - Params collections.Item[types.Params] + Schema collections.Schema + Params collections.Item[types.Params] + EvidenceID collections.Sequence + Evidences collections.Map[uint64, types.Evidence] + BySubject collections.KeySet[collections.Pair[string, uint64]] + ByActionID collections.KeySet[collections.Pair[string, uint64]] } func NewKeeper( @@ -42,7 +46,23 @@ func NewKeeper( addressCodec: addressCodec, authority: authority, - Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + EvidenceID: collections.NewSequence(sb, types.EvidenceIDKey, "evidence_id"), + Evidences: collections.NewMap(sb, types.EvidenceKey, "evidences", collections.Uint64Key, codec.CollValue[types.Evidence](cdc)), + BySubject: collections.NewKeySet( + sb, + types.EvidenceBySubjectKey, + "evidence_by_subject", + collections.PairKeyCodec(collections.StringKey, collections.Uint64Key), + collections.WithKeySetSecondaryIndex(), + ), + ByActionID: collections.NewKeySet( + sb, + types.EvidenceByActionKey, + "evidence_by_action", + collections.PairKeyCodec(collections.StringKey, collections.Uint64Key), + collections.WithKeySetSecondaryIndex(), + ), } schema, err := sb.Build() diff --git a/x/audit/v1/keeper/msg_server_submit_evidence.go b/x/audit/v1/keeper/msg_server_submit_evidence.go new file mode 100644 index 00000000..8bd90d0b --- /dev/null +++ b/x/audit/v1/keeper/msg_server_submit_evidence.go @@ -0,0 +1,16 @@ +package keeper + +import ( + "context" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" +) + +func (k msgServer) SubmitEvidence(ctx context.Context, msg *types.MsgSubmitEvidence) (*types.MsgSubmitEvidenceResponse, error) { + evidenceID, err := k.Keeper.CreateEvidence(ctx, msg.Creator, msg.SubjectAddress, msg.ActionId, msg.EvidenceType, msg.Metadata) + if err != nil { + return nil, err + } + + return &types.MsgSubmitEvidenceResponse{EvidenceId: evidenceID}, nil +} diff --git a/x/audit/v1/keeper/query_evidence.go b/x/audit/v1/keeper/query_evidence.go new file mode 100644 index 00000000..d40ed965 --- /dev/null +++ b/x/audit/v1/keeper/query_evidence.go @@ -0,0 +1,143 @@ +package keeper + +import ( + "context" + "errors" + + "cosmossdk.io/collections" + + "github.com/LumeraProtocol/lumera/x/audit/v1/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (q queryServer) EvidenceById(ctx context.Context, req *types.QueryEvidenceByIdRequest) (*types.QueryEvidenceByIdResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ev, err := q.k.Evidences.Get(ctx, req.EvidenceId) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + return nil, status.Error(codes.NotFound, "evidence not found") + } + return nil, status.Error(codes.Internal, "internal error") + } + + return &types.QueryEvidenceByIdResponse{Evidence: ev}, nil +} + +func (q queryServer) EvidenceBySubject(ctx context.Context, req *types.QueryEvidenceBySubjectRequest) (*types.QueryEvidenceBySubjectResponse, error) { + if req == nil || req.SubjectAddress == "" { + return nil, status.Error(codes.InvalidArgument, "subject_address is required") + } + + if _, err := q.k.addressCodec.StringToBytes(req.SubjectAddress); err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid subject_address") + } + + keys, pageRes, err := paginatePrefixedPairs(ctx, q.k.BySubject, req.Pagination, req.SubjectAddress) + if err != nil { + return nil, err + } + + evidence := make([]types.Evidence, 0, len(keys)) + for _, id := range keys { + ev, err := q.k.Evidences.Get(ctx, id) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + continue + } + return nil, status.Error(codes.Internal, "internal error") + } + evidence = append(evidence, ev) + } + + return &types.QueryEvidenceBySubjectResponse{Evidence: evidence, Pagination: pageRes}, nil +} + +func (q queryServer) EvidenceByAction(ctx context.Context, req *types.QueryEvidenceByActionRequest) (*types.QueryEvidenceByActionResponse, error) { + if req == nil || req.ActionId == "" { + return nil, status.Error(codes.InvalidArgument, "action_id is required") + } + + keys, pageRes, err := paginatePrefixedPairs(ctx, q.k.ByActionID, req.Pagination, req.ActionId) + if err != nil { + return nil, err + } + + evidence := make([]types.Evidence, 0, len(keys)) + for _, id := range keys { + ev, err := q.k.Evidences.Get(ctx, id) + if err != nil { + if errors.Is(err, collections.ErrNotFound) { + continue + } + return nil, status.Error(codes.Internal, "internal error") + } + evidence = append(evidence, ev) + } + + return &types.QueryEvidenceByActionResponse{Evidence: evidence, Pagination: pageRes}, nil +} + +func paginatePrefixedPairs( + ctx context.Context, + idx collections.KeySet[collections.Pair[string, uint64]], + pageReq *query.PageRequest, + prefix string, +) ([]uint64, *query.PageResponse, error) { + var ( + offset uint64 + limit uint64 = 100 + total uint64 + ) + if pageReq != nil { + offset = pageReq.Offset + if pageReq.Limit != 0 { + limit = pageReq.Limit + } + } + + // Count total if requested. + if pageReq != nil && pageReq.CountTotal { + rng := collections.NewPrefixedPairRange[string, uint64](prefix) + iter, err := idx.Iterate(ctx, rng) + if err != nil { + return nil, nil, status.Error(codes.Internal, "internal error") + } + for ; iter.Valid(); iter.Next() { + total++ + } + if err := iter.Close(); err != nil { + return nil, nil, status.Error(codes.Internal, "internal error") + } + } + + rng := collections.NewPrefixedPairRange[string, uint64](prefix) + iter, err := idx.Iterate(ctx, rng) + if err != nil { + return nil, nil, status.Error(codes.Internal, "internal error") + } + defer func() { _ = iter.Close() }() + + ids := make([]uint64, 0) + var skipped uint64 + for ; iter.Valid(); iter.Next() { + key, err := iter.Key() + if err != nil { + return nil, nil, status.Error(codes.Internal, "internal error") + } + if skipped < offset { + skipped++ + continue + } + if uint64(len(ids)) >= limit { + break + } + ids = append(ids, key.K2()) + } + + return ids, &query.PageResponse{Total: total}, nil +} diff --git a/x/audit/v1/module/autocli.go b/x/audit/v1/module/autocli.go index 67c4211e..39e2b96b 100644 --- a/x/audit/v1/module/autocli.go +++ b/x/audit/v1/module/autocli.go @@ -28,6 +28,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcMethod: "UpdateParams", Skip: true, // skipped because authority gated }, + { + RpcMethod: "SubmitEvidence", + Use: "submit-evidence [subject-address] [evidence-type] [action-id] [metadata]", + Short: "Send a submit-evidence tx", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "subject_address"}, {ProtoField: "evidence_type"}, {ProtoField: "action_id"}, {ProtoField: "metadata"}}, + }, // this line is used by ignite scaffolding # autocli/tx }, }, diff --git a/x/audit/v1/module/simulation.go b/x/audit/v1/module/simulation.go index 9097fc02..f3832b9f 100644 --- a/x/audit/v1/module/simulation.go +++ b/x/audit/v1/module/simulation.go @@ -1,9 +1,13 @@ package audit import ( + "math/rand" + "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + auditsimulation "github.com/LumeraProtocol/lumera/x/audit/v1/simulation" "github.com/LumeraProtocol/lumera/x/audit/v1/types" ) @@ -25,6 +29,22 @@ func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} // WeightedOperations returns the all the gov module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + const ( + opWeightMsgSubmitEvidence = "op_weight_msg_audit" + defaultWeightMsgSubmitEvidence int = 100 + ) + + var weightMsgSubmitEvidence int + simState.AppParams.GetOrGenerate(opWeightMsgSubmitEvidence, &weightMsgSubmitEvidence, nil, + func(_ *rand.Rand) { + weightMsgSubmitEvidence = defaultWeightMsgSubmitEvidence + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgSubmitEvidence, + auditsimulation.SimulateMsgSubmitEvidence(am.authKeeper, am.bankKeeper, am.keeper, simState.TxConfig), + )) + return operations } diff --git a/x/audit/v1/simulation/submit_evidence.go b/x/audit/v1/simulation/submit_evidence.go new file mode 100644 index 00000000..4f7ec878 --- /dev/null +++ b/x/audit/v1/simulation/submit_evidence.go @@ -0,0 +1,55 @@ +package simulation + +import ( + "encoding/json" + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/LumeraProtocol/lumera/x/audit/v1/keeper" + "github.com/LumeraProtocol/lumera/x/audit/v1/types" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +func SimulateMsgSubmitEvidence( + ak types.AuthKeeper, + bk types.BankKeeper, + k keeper.Keeper, + txGen client.TxConfig, +) 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) + subjectAccount, _ := simtypes.RandomAcc(r, accs) + + metadataBz, _ := json.Marshal(types.ExpirationEvidenceMetadata{ + ExpirationHeight: uint64(ctx.BlockHeight()), + Reason: "simulation", + }) + + msg := &types.MsgSubmitEvidence{ + Creator: simAccount.Address.String(), + SubjectAddress: subjectAccount.Address.String(), + EvidenceType: types.EvidenceTypeActionExpired, + ActionId: "sim-action-id", + Metadata: string(metadataBz), + } + + return simulation.GenAndDeliverTxWithRandFees(simulation.OperationInput{ + R: r, + App: app, + TxGen: txGen, + Cdc: (*codec.ProtoCodec)(nil), + Msg: msg, + Context: ctx, + SimAccount: simAccount, + AccountKeeper: ak, + Bankkeeper: bk, + ModuleName: types.ModuleName, + }) + } +} diff --git a/x/audit/v1/types/codec.go b/x/audit/v1/types/codec.go index 56398f5e..8a3a2bb4 100644 --- a/x/audit/v1/types/codec.go +++ b/x/audit/v1/types/codec.go @@ -7,6 +7,10 @@ import ( ) func RegisterInterfaces(registrar codectypes.InterfaceRegistry) { + registrar.RegisterImplementations((*sdk.Msg)(nil), + &MsgSubmitEvidence{}, + ) + registrar.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateParams{}, ) diff --git a/x/audit/v1/types/errors.go b/x/audit/v1/types/errors.go index c5703971..fbaf34d8 100644 --- a/x/audit/v1/types/errors.go +++ b/x/audit/v1/types/errors.go @@ -8,5 +8,10 @@ import ( // x/audit module sentinel errors var ( - ErrInvalidSigner = errors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrInvalidSigner = errors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrInvalidEvidenceType = errors.Register(ModuleName, 1101, "invalid evidence type") + ErrInvalidMetadata = errors.Register(ModuleName, 1102, "invalid evidence metadata") + ErrInvalidSubject = errors.Register(ModuleName, 1103, "invalid subject address") + ErrInvalidReporter = errors.Register(ModuleName, 1104, "invalid reporter address") + ErrInvalidActionID = errors.Register(ModuleName, 1105, "invalid action id") ) diff --git a/x/audit/v1/types/evidence.go b/x/audit/v1/types/evidence.go new file mode 100644 index 00000000..746e6ae9 --- /dev/null +++ b/x/audit/v1/types/evidence.go @@ -0,0 +1,16 @@ +package types + +import "strings" + +const ( + // EvidenceTypeActionExpired is evidence that an action expired. + EvidenceTypeActionExpired = "ACTION_EXPIRED" + + // EvidenceTypeActionWrongFinalizer is evidence that an unexpected actor attempted action finalization. + EvidenceTypeActionWrongFinalizer = "ACTION_WRONG_FINALIZER" +) + +func CanonicalEvidenceType(t string) string { + return strings.ToUpper(strings.TrimSpace(t)) +} + diff --git a/x/audit/v1/types/evidence.pb.go b/x/audit/v1/types/evidence.pb.go new file mode 100644 index 00000000..a7370fdb --- /dev/null +++ b/x/audit/v1/types/evidence.pb.go @@ -0,0 +1,610 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lumera/audit/v1/evidence.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Evidence is a stable outer record that stores evidence about an audited subject. +// Type-specific fields are encoded into the `metadata` bytes field. +type Evidence struct { + // evidence_id is a chain-assigned unique identifier. + EvidenceId uint64 `protobuf:"varint,1,opt,name=evidence_id,json=evidenceId,proto3" json:"evidence_id,omitempty"` + // subject_address is the audited subject (e.g. supernode-related actor). + SubjectAddress string `protobuf:"bytes,2,opt,name=subject_address,json=subjectAddress,proto3" json:"subject_address,omitempty"` + // reporter_address is the submitter of the evidence. + ReporterAddress string `protobuf:"bytes,3,opt,name=reporter_address,json=reporterAddress,proto3" json:"reporter_address,omitempty"` + // action_id optionally links this evidence to a specific action. + ActionId string `protobuf:"bytes,4,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"` + // evidence_type is a stable discriminator used to interpret metadata. + EvidenceType string `protobuf:"bytes,5,opt,name=evidence_type,json=evidenceType,proto3" json:"evidence_type,omitempty"` + // metadata is protobuf-binary bytes of a type-specific Evidence metadata message. + Metadata []byte `protobuf:"bytes,6,opt,name=metadata,proto3" json:"metadata,omitempty"` + // reported_height is the block height when the evidence was submitted. + ReportedHeight uint64 `protobuf:"varint,7,opt,name=reported_height,json=reportedHeight,proto3" json:"reported_height,omitempty"` +} + +func (m *Evidence) Reset() { *m = Evidence{} } +func (m *Evidence) String() string { return proto.CompactTextString(m) } +func (*Evidence) ProtoMessage() {} +func (*Evidence) Descriptor() ([]byte, []int) { + return fileDescriptor_449f638e48abdbaa, []int{0} +} +func (m *Evidence) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Evidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Evidence.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 *Evidence) XXX_Merge(src proto.Message) { + xxx_messageInfo_Evidence.Merge(m, src) +} +func (m *Evidence) XXX_Size() int { + return m.Size() +} +func (m *Evidence) XXX_DiscardUnknown() { + xxx_messageInfo_Evidence.DiscardUnknown(m) +} + +var xxx_messageInfo_Evidence proto.InternalMessageInfo + +func (m *Evidence) GetEvidenceId() uint64 { + if m != nil { + return m.EvidenceId + } + return 0 +} + +func (m *Evidence) GetSubjectAddress() string { + if m != nil { + return m.SubjectAddress + } + return "" +} + +func (m *Evidence) GetReporterAddress() string { + if m != nil { + return m.ReporterAddress + } + return "" +} + +func (m *Evidence) GetActionId() string { + if m != nil { + return m.ActionId + } + return "" +} + +func (m *Evidence) GetEvidenceType() string { + if m != nil { + return m.EvidenceType + } + return "" +} + +func (m *Evidence) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +func (m *Evidence) GetReportedHeight() uint64 { + if m != nil { + return m.ReportedHeight + } + return 0 +} + +func init() { + proto.RegisterType((*Evidence)(nil), "lumera.audit.v1.Evidence") +} + +func init() { proto.RegisterFile("lumera/audit/v1/evidence.proto", fileDescriptor_449f638e48abdbaa) } + +var fileDescriptor_449f638e48abdbaa = []byte{ + // 307 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4e, 0x02, 0x31, + 0x10, 0x86, 0x29, 0x22, 0x42, 0x45, 0x20, 0x8d, 0x87, 0x8a, 0x49, 0x25, 0x7a, 0x90, 0x98, 0xc8, + 0x86, 0xf8, 0x04, 0x60, 0x4c, 0xe4, 0xba, 0x7a, 0xf2, 0xb2, 0x29, 0xdb, 0x09, 0xd4, 0x08, 0xdd, + 0xb4, 0x85, 0xc8, 0x5b, 0xf8, 0x30, 0x9e, 0x7c, 0x02, 0x8f, 0xc4, 0x93, 0x47, 0x03, 0x2f, 0x62, + 0xb6, 0xbb, 0x5d, 0x8f, 0x1e, 0xe7, 0xfb, 0xe7, 0xff, 0x3b, 0x9d, 0xc1, 0xec, 0x65, 0x39, 0x07, + 0xcd, 0x03, 0xbe, 0x14, 0xd2, 0x06, 0xab, 0x41, 0x00, 0x2b, 0x29, 0x60, 0x11, 0x43, 0x3f, 0xd1, + 0xca, 0x2a, 0xd2, 0xca, 0xf4, 0xbe, 0xd3, 0xfb, 0xab, 0x41, 0xe7, 0x24, 0x56, 0x66, 0xae, 0x4c, + 0xe4, 0xe4, 0x20, 0x2b, 0xb2, 0xde, 0xf3, 0x8f, 0x32, 0xae, 0xdd, 0xe5, 0x76, 0x72, 0x86, 0x0f, + 0x7d, 0x54, 0x24, 0x05, 0x45, 0x5d, 0xd4, 0xab, 0x84, 0xd8, 0xa3, 0xb1, 0x20, 0x43, 0xdc, 0x32, + 0xcb, 0xc9, 0x33, 0xc4, 0x36, 0xe2, 0x42, 0x68, 0x30, 0x86, 0x96, 0xbb, 0xa8, 0x57, 0x1f, 0xd1, + 0xaf, 0xf7, 0xeb, 0xe3, 0x3c, 0x78, 0x98, 0x29, 0x0f, 0x56, 0xcb, 0xc5, 0x34, 0x6c, 0xe6, 0x86, + 0x9c, 0x92, 0x5b, 0xdc, 0xd6, 0x90, 0x28, 0x6d, 0x41, 0x17, 0x19, 0x7b, 0xff, 0x64, 0xb4, 0xbc, + 0xc3, 0x87, 0x9c, 0xe2, 0x3a, 0x8f, 0xad, 0x54, 0x8b, 0x74, 0xcc, 0x4a, 0xea, 0x0e, 0x6b, 0x19, + 0x18, 0x0b, 0x72, 0x81, 0x8f, 0x8a, 0x5f, 0xd8, 0x75, 0x02, 0x74, 0xdf, 0x35, 0x34, 0x3c, 0x7c, + 0x5c, 0x27, 0x40, 0x3a, 0xb8, 0x36, 0x07, 0xcb, 0x05, 0xb7, 0x9c, 0x56, 0xbb, 0xa8, 0xd7, 0x08, + 0x8b, 0x9a, 0x5c, 0x62, 0xff, 0xa0, 0x88, 0x66, 0x20, 0xa7, 0x33, 0x4b, 0x0f, 0xdc, 0x2a, 0x9a, + 0x1e, 0xdf, 0x3b, 0x3a, 0xba, 0xfa, 0xdc, 0x32, 0xb4, 0xd9, 0x32, 0xf4, 0xb3, 0x65, 0xe8, 0x6d, + 0xc7, 0x4a, 0x9b, 0x1d, 0x2b, 0x7d, 0xef, 0x58, 0xe9, 0xa9, 0xfd, 0xfa, 0x77, 0x9d, 0x74, 0x06, + 0x33, 0xa9, 0xba, 0x7d, 0xdf, 0xfc, 0x06, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x5e, 0x78, 0x85, 0xbd, + 0x01, 0x00, 0x00, +} + +func (m *Evidence) 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 *Evidence) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ReportedHeight != 0 { + i = encodeVarintEvidence(dAtA, i, uint64(m.ReportedHeight)) + i-- + dAtA[i] = 0x38 + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintEvidence(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x32 + } + if len(m.EvidenceType) > 0 { + i -= len(m.EvidenceType) + copy(dAtA[i:], m.EvidenceType) + i = encodeVarintEvidence(dAtA, i, uint64(len(m.EvidenceType))) + i-- + dAtA[i] = 0x2a + } + if len(m.ActionId) > 0 { + i -= len(m.ActionId) + copy(dAtA[i:], m.ActionId) + i = encodeVarintEvidence(dAtA, i, uint64(len(m.ActionId))) + i-- + dAtA[i] = 0x22 + } + if len(m.ReporterAddress) > 0 { + i -= len(m.ReporterAddress) + copy(dAtA[i:], m.ReporterAddress) + i = encodeVarintEvidence(dAtA, i, uint64(len(m.ReporterAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.SubjectAddress) > 0 { + i -= len(m.SubjectAddress) + copy(dAtA[i:], m.SubjectAddress) + i = encodeVarintEvidence(dAtA, i, uint64(len(m.SubjectAddress))) + i-- + dAtA[i] = 0x12 + } + if m.EvidenceId != 0 { + i = encodeVarintEvidence(dAtA, i, uint64(m.EvidenceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintEvidence(dAtA []byte, offset int, v uint64) int { + offset -= sovEvidence(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Evidence) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EvidenceId != 0 { + n += 1 + sovEvidence(uint64(m.EvidenceId)) + } + l = len(m.SubjectAddress) + if l > 0 { + n += 1 + l + sovEvidence(uint64(l)) + } + l = len(m.ReporterAddress) + if l > 0 { + n += 1 + l + sovEvidence(uint64(l)) + } + l = len(m.ActionId) + if l > 0 { + n += 1 + l + sovEvidence(uint64(l)) + } + l = len(m.EvidenceType) + if l > 0 { + n += 1 + l + sovEvidence(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovEvidence(uint64(l)) + } + if m.ReportedHeight != 0 { + n += 1 + sovEvidence(uint64(m.ReportedHeight)) + } + return n +} + +func sovEvidence(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvidence(x uint64) (n int) { + return sovEvidence(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Evidence) 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 ErrIntOverflowEvidence + } + 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: Evidence: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Evidence: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EvidenceId", wireType) + } + m.EvidenceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EvidenceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + 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 ErrInvalidLengthEvidence + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidence + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubjectAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReporterAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + 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 ErrInvalidLengthEvidence + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidence + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReporterAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ActionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + 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 ErrInvalidLengthEvidence + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidence + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ActionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvidenceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + 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 ErrInvalidLengthEvidence + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidence + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EvidenceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvidence + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvidence + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReportedHeight", wireType) + } + m.ReportedHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidence + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReportedHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvidence(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvidence + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvidence(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, ErrIntOverflowEvidence + } + 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, ErrIntOverflowEvidence + } + 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, ErrIntOverflowEvidence + } + 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, ErrInvalidLengthEvidence + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvidence + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvidence + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvidence = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvidence = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvidence = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/audit/v1/types/evidence_metadata.pb.go b/x/audit/v1/types/evidence_metadata.pb.go new file mode 100644 index 00000000..c6096b04 --- /dev/null +++ b/x/audit/v1/types/evidence_metadata.pb.go @@ -0,0 +1,640 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lumera/audit/v1/evidence_metadata.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// ExpirationEvidenceMetadata is metadata for evidence about an action expiring. +type ExpirationEvidenceMetadata struct { + // expiration_height is the height at which the action expired (if known). + ExpirationHeight uint64 `protobuf:"varint,1,opt,name=expiration_height,json=expirationHeight,proto3" json:"expiration_height,omitempty"` + // reason is optional human-readable context. + Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"` +} + +func (m *ExpirationEvidenceMetadata) Reset() { *m = ExpirationEvidenceMetadata{} } +func (m *ExpirationEvidenceMetadata) String() string { return proto.CompactTextString(m) } +func (*ExpirationEvidenceMetadata) ProtoMessage() {} +func (*ExpirationEvidenceMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_09b57e4c2349ab91, []int{0} +} +func (m *ExpirationEvidenceMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExpirationEvidenceMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExpirationEvidenceMetadata.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 *ExpirationEvidenceMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExpirationEvidenceMetadata.Merge(m, src) +} +func (m *ExpirationEvidenceMetadata) XXX_Size() int { + return m.Size() +} +func (m *ExpirationEvidenceMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_ExpirationEvidenceMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_ExpirationEvidenceMetadata proto.InternalMessageInfo + +func (m *ExpirationEvidenceMetadata) GetExpirationHeight() uint64 { + if m != nil { + return m.ExpirationHeight + } + return 0 +} + +func (m *ExpirationEvidenceMetadata) GetReason() string { + if m != nil { + return m.Reason + } + return "" +} + +// FinalizationEvidenceMetadata is metadata for evidence about finalization behavior. +type FinalizationEvidenceMetadata struct { + // attempted_finalizer_address is the address that attempted finalization. + AttemptedFinalizerAddress string `protobuf:"bytes,1,opt,name=attempted_finalizer_address,json=attemptedFinalizerAddress,proto3" json:"attempted_finalizer_address,omitempty"` + // expected_finalizer_address is optional (if there is a known expected finalizer). + ExpectedFinalizerAddress string `protobuf:"bytes,2,opt,name=expected_finalizer_address,json=expectedFinalizerAddress,proto3" json:"expected_finalizer_address,omitempty"` + // reason is optional human-readable context. + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` +} + +func (m *FinalizationEvidenceMetadata) Reset() { *m = FinalizationEvidenceMetadata{} } +func (m *FinalizationEvidenceMetadata) String() string { return proto.CompactTextString(m) } +func (*FinalizationEvidenceMetadata) ProtoMessage() {} +func (*FinalizationEvidenceMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_09b57e4c2349ab91, []int{1} +} +func (m *FinalizationEvidenceMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalizationEvidenceMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalizationEvidenceMetadata.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 *FinalizationEvidenceMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalizationEvidenceMetadata.Merge(m, src) +} +func (m *FinalizationEvidenceMetadata) XXX_Size() int { + return m.Size() +} +func (m *FinalizationEvidenceMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_FinalizationEvidenceMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalizationEvidenceMetadata proto.InternalMessageInfo + +func (m *FinalizationEvidenceMetadata) GetAttemptedFinalizerAddress() string { + if m != nil { + return m.AttemptedFinalizerAddress + } + return "" +} + +func (m *FinalizationEvidenceMetadata) GetExpectedFinalizerAddress() string { + if m != nil { + return m.ExpectedFinalizerAddress + } + return "" +} + +func (m *FinalizationEvidenceMetadata) GetReason() string { + if m != nil { + return m.Reason + } + return "" +} + +func init() { + proto.RegisterType((*ExpirationEvidenceMetadata)(nil), "lumera.audit.v1.ExpirationEvidenceMetadata") + proto.RegisterType((*FinalizationEvidenceMetadata)(nil), "lumera.audit.v1.FinalizationEvidenceMetadata") +} + +func init() { + proto.RegisterFile("lumera/audit/v1/evidence_metadata.proto", fileDescriptor_09b57e4c2349ab91) +} + +var fileDescriptor_09b57e4c2349ab91 = []byte{ + // 295 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcf, 0x29, 0xcd, 0x4d, + 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0xcb, 0x4c, + 0x49, 0xcd, 0x4b, 0x4e, 0x8d, 0xcf, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0xd4, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x28, 0xd4, 0x03, 0x2b, 0xd4, 0x2b, 0x33, 0x94, 0x92, 0x4c, + 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x8e, 0x07, 0x4b, 0xeb, 0x43, 0x38, 0x10, 0xb5, 0x4a, 0x89, 0x5c, + 0x52, 0xae, 0x15, 0x05, 0x99, 0x45, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xae, 0x50, 0x03, 0x7d, 0xa1, + 0xe6, 0x09, 0x69, 0x73, 0x09, 0xa6, 0xc2, 0x65, 0xe3, 0x33, 0x52, 0x33, 0xd3, 0x33, 0x4a, 0x24, + 0x18, 0x15, 0x18, 0x35, 0x58, 0x82, 0x04, 0x10, 0x12, 0x1e, 0x60, 0x71, 0x21, 0x31, 0x2e, 0xb6, + 0xa2, 0xd4, 0xc4, 0xe2, 0xfc, 0x3c, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x28, 0x4f, 0xe9, + 0x05, 0x23, 0x97, 0x8c, 0x5b, 0x66, 0x5e, 0x62, 0x4e, 0x66, 0x15, 0x76, 0x5b, 0x22, 0xb8, 0xa4, + 0x13, 0x4b, 0x4a, 0x52, 0x73, 0x0b, 0x4a, 0x52, 0x53, 0xe2, 0xd3, 0x20, 0x2a, 0x53, 0x8b, 0xe2, + 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0xc1, 0xf6, 0x71, 0x3a, 0x49, 0x5c, 0xda, 0xa2, 0x2b, + 0x02, 0x75, 0xba, 0x23, 0x44, 0x26, 0xb8, 0xa4, 0x28, 0x33, 0x2f, 0x3d, 0x48, 0x12, 0xae, 0xd9, + 0x0d, 0xa6, 0x17, 0xaa, 0x40, 0x28, 0x8c, 0x4b, 0x2a, 0xb5, 0xa2, 0x20, 0x35, 0x19, 0xbb, 0xc1, + 0x4c, 0x04, 0x0c, 0x96, 0x80, 0xe9, 0xc5, 0x30, 0x17, 0xe1, 0x55, 0x66, 0x64, 0xaf, 0x3a, 0x69, + 0x9d, 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, 0x40, 0x05, 0x22, 0xde, 0x4a, + 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x11, 0x60, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x0c, + 0xfa, 0x2c, 0xf1, 0xd7, 0x01, 0x00, 0x00, +} + +func (m *ExpirationEvidenceMetadata) 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 *ExpirationEvidenceMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExpirationEvidenceMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Reason) > 0 { + i -= len(m.Reason) + copy(dAtA[i:], m.Reason) + i = encodeVarintEvidenceMetadata(dAtA, i, uint64(len(m.Reason))) + i-- + dAtA[i] = 0x12 + } + if m.ExpirationHeight != 0 { + i = encodeVarintEvidenceMetadata(dAtA, i, uint64(m.ExpirationHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *FinalizationEvidenceMetadata) 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 *FinalizationEvidenceMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FinalizationEvidenceMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Reason) > 0 { + i -= len(m.Reason) + copy(dAtA[i:], m.Reason) + i = encodeVarintEvidenceMetadata(dAtA, i, uint64(len(m.Reason))) + i-- + dAtA[i] = 0x1a + } + if len(m.ExpectedFinalizerAddress) > 0 { + i -= len(m.ExpectedFinalizerAddress) + copy(dAtA[i:], m.ExpectedFinalizerAddress) + i = encodeVarintEvidenceMetadata(dAtA, i, uint64(len(m.ExpectedFinalizerAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.AttemptedFinalizerAddress) > 0 { + i -= len(m.AttemptedFinalizerAddress) + copy(dAtA[i:], m.AttemptedFinalizerAddress) + i = encodeVarintEvidenceMetadata(dAtA, i, uint64(len(m.AttemptedFinalizerAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvidenceMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovEvidenceMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ExpirationEvidenceMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ExpirationHeight != 0 { + n += 1 + sovEvidenceMetadata(uint64(m.ExpirationHeight)) + } + l = len(m.Reason) + if l > 0 { + n += 1 + l + sovEvidenceMetadata(uint64(l)) + } + return n +} + +func (m *FinalizationEvidenceMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AttemptedFinalizerAddress) + if l > 0 { + n += 1 + l + sovEvidenceMetadata(uint64(l)) + } + l = len(m.ExpectedFinalizerAddress) + if l > 0 { + n += 1 + l + sovEvidenceMetadata(uint64(l)) + } + l = len(m.Reason) + if l > 0 { + n += 1 + l + sovEvidenceMetadata(uint64(l)) + } + return n +} + +func sovEvidenceMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvidenceMetadata(x uint64) (n int) { + return sovEvidenceMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ExpirationEvidenceMetadata) 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 ErrIntOverflowEvidenceMetadata + } + 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: ExpirationEvidenceMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExpirationEvidenceMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpirationHeight", wireType) + } + m.ExpirationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidenceMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExpirationHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidenceMetadata + } + 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 ErrInvalidLengthEvidenceMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidenceMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reason = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvidenceMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvidenceMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FinalizationEvidenceMetadata) 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 ErrIntOverflowEvidenceMetadata + } + 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: FinalizationEvidenceMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalizationEvidenceMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AttemptedFinalizerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidenceMetadata + } + 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 ErrInvalidLengthEvidenceMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidenceMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AttemptedFinalizerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpectedFinalizerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidenceMetadata + } + 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 ErrInvalidLengthEvidenceMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidenceMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExpectedFinalizerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvidenceMetadata + } + 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 ErrInvalidLengthEvidenceMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvidenceMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reason = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvidenceMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvidenceMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvidenceMetadata(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, ErrIntOverflowEvidenceMetadata + } + 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, ErrIntOverflowEvidenceMetadata + } + 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, ErrIntOverflowEvidenceMetadata + } + 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, ErrInvalidLengthEvidenceMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvidenceMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvidenceMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvidenceMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvidenceMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvidenceMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/audit/v1/types/genesis.go b/x/audit/v1/types/genesis.go index 9d633ecd..0a143c1f 100644 --- a/x/audit/v1/types/genesis.go +++ b/x/audit/v1/types/genesis.go @@ -3,7 +3,8 @@ package types // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - Params: DefaultParams(), + Params: DefaultParams(), + Evidence: []Evidence{}, } } diff --git a/x/audit/v1/types/genesis.pb.go b/x/audit/v1/types/genesis.pb.go index 4f9da657..dda990f6 100644 --- a/x/audit/v1/types/genesis.pb.go +++ b/x/audit/v1/types/genesis.pb.go @@ -28,6 +28,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // params defines all the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // evidence defines the initial evidence records (optional). + Evidence []Evidence `protobuf:"bytes,2,rep,name=evidence,proto3" json:"evidence"` + // next_evidence_id is the next id to use for chain-assigned ids. + NextEvidenceId uint64 `protobuf:"varint,3,opt,name=next_evidence_id,json=nextEvidenceId,proto3" json:"next_evidence_id,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -70,6 +74,20 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetEvidence() []Evidence { + if m != nil { + return m.Evidence + } + return nil +} + +func (m *GenesisState) GetNextEvidenceId() uint64 { + if m != nil { + return m.NextEvidenceId + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "lumera.audit.v1.GenesisState") } @@ -77,19 +95,24 @@ func init() { func init() { proto.RegisterFile("lumera/audit/v1/genesis.proto", fileDescriptor_a433cb4f206fdbad) } var fileDescriptor_a433cb4f206fdbad = []byte{ - // 190 bytes of a gzipped FileDescriptorProto + // 258 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x29, 0xcd, 0x4d, 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x48, 0xeb, 0x81, 0xa5, 0xf5, 0xca, 0x0c, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, - 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x65, 0xd0, 0x0d, 0x2e, 0x48, - 0x2c, 0x4a, 0xcc, 0x85, 0x9a, 0xab, 0xe4, 0xc5, 0xc5, 0xe3, 0x0e, 0xb1, 0x28, 0xb8, 0x24, 0xb1, - 0x24, 0x55, 0xc8, 0x8a, 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xae, - 0x87, 0x66, 0xb1, 0x5e, 0x00, 0x58, 0xda, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, - 0x68, 0x31, 0x06, 0x41, 0x75, 0x38, 0x69, 0x9d, 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, 0x40, 0x05, 0xc2, 0xfa, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xf5, 0xc6, - 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xca, 0xc9, 0xb9, 0xdd, 0xf7, 0x00, 0x00, 0x00, + 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0xe5, 0xd0, 0x0d, 0x4e, 0x2d, + 0xcb, 0x4c, 0x49, 0xcd, 0x4b, 0x4e, 0x85, 0xca, 0xcb, 0xa0, 0xcb, 0x17, 0x24, 0x16, 0x25, 0xe6, + 0x42, 0xed, 0x55, 0xda, 0xc8, 0xc8, 0xc5, 0xe3, 0x0e, 0x71, 0x49, 0x70, 0x49, 0x62, 0x49, 0xaa, + 0x90, 0x15, 0x17, 0x1b, 0x44, 0x81, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xb8, 0x1e, 0x9a, + 0xcb, 0xf4, 0x02, 0xc0, 0xd2, 0x4e, 0x9c, 0x27, 0xee, 0xc9, 0x33, 0xac, 0x78, 0xbe, 0x41, 0x8b, + 0x31, 0x08, 0xaa, 0x43, 0xc8, 0x9a, 0x8b, 0x03, 0x66, 0xb9, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, + 0x91, 0x24, 0x86, 0x6e, 0x57, 0xa8, 0x02, 0x27, 0x16, 0x90, 0xfe, 0x20, 0xb8, 0x06, 0x21, 0x0d, + 0x2e, 0x81, 0xbc, 0xd4, 0x8a, 0x92, 0x78, 0x98, 0x40, 0x7c, 0x66, 0x8a, 0x04, 0xb3, 0x02, 0xa3, + 0x06, 0x4b, 0x10, 0x1f, 0x48, 0x1c, 0xa6, 0xcf, 0x33, 0xc5, 0x49, 0xeb, 0xc4, 0x23, 0x39, 0xc6, + 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, + 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x04, 0x2a, 0x10, 0xde, 0x2c, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, + 0x62, 0x03, 0x7b, 0xd3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x3c, 0x0f, 0xc3, 0x7f, 0x01, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -112,6 +135,25 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NextEvidenceId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextEvidenceId)) + i-- + dAtA[i] = 0x18 + } + if len(m.Evidence) > 0 { + for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Evidence[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -144,6 +186,15 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.Evidence) > 0 { + for _, e := range m.Evidence { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.NextEvidenceId != 0 { + n += 1 + sovGenesis(uint64(m.NextEvidenceId)) + } return n } @@ -215,6 +266,59 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Evidence = append(m.Evidence, Evidence{}) + if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextEvidenceId", wireType) + } + m.NextEvidenceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextEvidenceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/audit/v1/types/keys.go b/x/audit/v1/types/keys.go index a1b552ea..57c4f86b 100644 --- a/x/audit/v1/types/keys.go +++ b/x/audit/v1/types/keys.go @@ -17,3 +17,15 @@ const ( // ParamsKey is the prefix to retrieve all Params var ParamsKey = collections.NewPrefix("p_audit") + +// EvidenceIDKey is the prefix for the evidence id sequence. +var EvidenceIDKey = collections.NewPrefix(1) + +// EvidenceKey is the prefix for stored Evidence records. +var EvidenceKey = collections.NewPrefix(2) + +// EvidenceBySubjectKey is the prefix for the secondary index (subject_address, evidence_id). +var EvidenceBySubjectKey = collections.NewPrefix(3) + +// EvidenceByActionKey is the prefix for the secondary index (action_id, evidence_id). +var EvidenceByActionKey = collections.NewPrefix(4) diff --git a/x/audit/v1/types/query.pb.go b/x/audit/v1/types/query.pb.go index 5a15c8bb..5915d293 100644 --- a/x/audit/v1/types/query.pb.go +++ b/x/audit/v1/types/query.pb.go @@ -6,7 +6,8 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/cosmos-proto" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -114,35 +115,359 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +type QueryEvidenceByIdRequest struct { + EvidenceId uint64 `protobuf:"varint,1,opt,name=evidence_id,json=evidenceId,proto3" json:"evidence_id,omitempty"` +} + +func (m *QueryEvidenceByIdRequest) Reset() { *m = QueryEvidenceByIdRequest{} } +func (m *QueryEvidenceByIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceByIdRequest) ProtoMessage() {} +func (*QueryEvidenceByIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{2} +} +func (m *QueryEvidenceByIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceByIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceByIdRequest.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 *QueryEvidenceByIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceByIdRequest.Merge(m, src) +} +func (m *QueryEvidenceByIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceByIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceByIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEvidenceByIdRequest proto.InternalMessageInfo + +func (m *QueryEvidenceByIdRequest) GetEvidenceId() uint64 { + if m != nil { + return m.EvidenceId + } + return 0 +} + +type QueryEvidenceByIdResponse struct { + Evidence Evidence `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence"` +} + +func (m *QueryEvidenceByIdResponse) Reset() { *m = QueryEvidenceByIdResponse{} } +func (m *QueryEvidenceByIdResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceByIdResponse) ProtoMessage() {} +func (*QueryEvidenceByIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{3} +} +func (m *QueryEvidenceByIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceByIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceByIdResponse.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 *QueryEvidenceByIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceByIdResponse.Merge(m, src) +} +func (m *QueryEvidenceByIdResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceByIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceByIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEvidenceByIdResponse proto.InternalMessageInfo + +func (m *QueryEvidenceByIdResponse) GetEvidence() Evidence { + if m != nil { + return m.Evidence + } + return Evidence{} +} + +type QueryEvidenceBySubjectRequest struct { + SubjectAddress string `protobuf:"bytes,1,opt,name=subject_address,json=subjectAddress,proto3" json:"subject_address,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryEvidenceBySubjectRequest) Reset() { *m = QueryEvidenceBySubjectRequest{} } +func (m *QueryEvidenceBySubjectRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceBySubjectRequest) ProtoMessage() {} +func (*QueryEvidenceBySubjectRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{4} +} +func (m *QueryEvidenceBySubjectRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceBySubjectRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceBySubjectRequest.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 *QueryEvidenceBySubjectRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceBySubjectRequest.Merge(m, src) +} +func (m *QueryEvidenceBySubjectRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceBySubjectRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceBySubjectRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEvidenceBySubjectRequest proto.InternalMessageInfo + +func (m *QueryEvidenceBySubjectRequest) GetSubjectAddress() string { + if m != nil { + return m.SubjectAddress + } + return "" +} + +func (m *QueryEvidenceBySubjectRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryEvidenceBySubjectResponse struct { + Evidence []Evidence `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryEvidenceBySubjectResponse) Reset() { *m = QueryEvidenceBySubjectResponse{} } +func (m *QueryEvidenceBySubjectResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceBySubjectResponse) ProtoMessage() {} +func (*QueryEvidenceBySubjectResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{5} +} +func (m *QueryEvidenceBySubjectResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceBySubjectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceBySubjectResponse.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 *QueryEvidenceBySubjectResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceBySubjectResponse.Merge(m, src) +} +func (m *QueryEvidenceBySubjectResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceBySubjectResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceBySubjectResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEvidenceBySubjectResponse proto.InternalMessageInfo + +func (m *QueryEvidenceBySubjectResponse) GetEvidence() []Evidence { + if m != nil { + return m.Evidence + } + return nil +} + +func (m *QueryEvidenceBySubjectResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryEvidenceByActionRequest struct { + ActionId string `protobuf:"bytes,1,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryEvidenceByActionRequest) Reset() { *m = QueryEvidenceByActionRequest{} } +func (m *QueryEvidenceByActionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceByActionRequest) ProtoMessage() {} +func (*QueryEvidenceByActionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{6} +} +func (m *QueryEvidenceByActionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceByActionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceByActionRequest.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 *QueryEvidenceByActionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceByActionRequest.Merge(m, src) +} +func (m *QueryEvidenceByActionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceByActionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceByActionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEvidenceByActionRequest proto.InternalMessageInfo + +func (m *QueryEvidenceByActionRequest) GetActionId() string { + if m != nil { + return m.ActionId + } + return "" +} + +func (m *QueryEvidenceByActionRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryEvidenceByActionResponse struct { + Evidence []Evidence `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryEvidenceByActionResponse) Reset() { *m = QueryEvidenceByActionResponse{} } +func (m *QueryEvidenceByActionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceByActionResponse) ProtoMessage() {} +func (*QueryEvidenceByActionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e98945621bbc9485, []int{7} +} +func (m *QueryEvidenceByActionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEvidenceByActionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceByActionResponse.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 *QueryEvidenceByActionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceByActionResponse.Merge(m, src) +} +func (m *QueryEvidenceByActionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceByActionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceByActionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEvidenceByActionResponse proto.InternalMessageInfo + +func (m *QueryEvidenceByActionResponse) GetEvidence() []Evidence { + if m != nil { + return m.Evidence + } + return nil +} + +func (m *QueryEvidenceByActionResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "lumera.audit.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "lumera.audit.v1.QueryParamsResponse") + proto.RegisterType((*QueryEvidenceByIdRequest)(nil), "lumera.audit.v1.QueryEvidenceByIdRequest") + proto.RegisterType((*QueryEvidenceByIdResponse)(nil), "lumera.audit.v1.QueryEvidenceByIdResponse") + proto.RegisterType((*QueryEvidenceBySubjectRequest)(nil), "lumera.audit.v1.QueryEvidenceBySubjectRequest") + proto.RegisterType((*QueryEvidenceBySubjectResponse)(nil), "lumera.audit.v1.QueryEvidenceBySubjectResponse") + proto.RegisterType((*QueryEvidenceByActionRequest)(nil), "lumera.audit.v1.QueryEvidenceByActionRequest") + proto.RegisterType((*QueryEvidenceByActionResponse)(nil), "lumera.audit.v1.QueryEvidenceByActionResponse") } func init() { proto.RegisterFile("lumera/audit/v1/query.proto", fileDescriptor_e98945621bbc9485) } var fileDescriptor_e98945621bbc9485 = []byte{ - // 311 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0x29, 0xcd, 0x4d, - 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, - 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x48, 0xea, 0x81, 0x25, 0xf5, 0xca, - 0x0c, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x56, 0x72, - 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, 0x52, 0x62, 0x71, 0x2a, 0x44, 0xb3, 0x7e, 0x99, 0x61, 0x52, - 0x6a, 0x49, 0xa2, 0xa1, 0x7e, 0x41, 0x62, 0x7a, 0x66, 0x5e, 0x62, 0x49, 0x66, 0x7e, 0x1e, 0x54, - 0xad, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x65, 0xd2, 0xf3, 0xf3, - 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0xc0, 0x5a, 0x8a, - 0x61, 0xb2, 0xe8, 0x0e, 0x2c, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0xca, 0x2a, 0x89, 0x70, 0x09, 0x05, - 0x82, 0xec, 0x0c, 0x00, 0x0b, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0x05, 0x72, 0x09, - 0xa3, 0x88, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x59, 0x71, 0xb1, 0x41, 0x34, 0x4b, 0x30, - 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x89, 0xeb, 0xa1, 0xf9, 0x4f, 0x0f, 0xa2, 0xc1, 0x89, 0xf3, 0xc4, - 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, 0x41, 0x75, 0x18, 0xf5, 0x32, 0x72, 0xb1, - 0x82, 0xcd, 0x14, 0x6a, 0x66, 0xe4, 0x62, 0x83, 0xa8, 0x13, 0x52, 0xc6, 0x30, 0x00, 0xd3, 0x31, - 0x52, 0x2a, 0xf8, 0x15, 0x41, 0xdc, 0xa6, 0xa4, 0xd7, 0x74, 0xf9, 0xc9, 0x64, 0x26, 0x0d, 0x21, - 0x35, 0x7d, 0x1f, 0xb0, 0xea, 0x00, 0x90, 0xf7, 0x92, 0xf3, 0x73, 0xf4, 0xb1, 0x7b, 0xdf, 0x49, - 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, - 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x04, 0x2a, 0x10, 0x8a, 0x4b, - 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x61, 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x98, - 0x90, 0x3b, 0x43, 0xec, 0x01, 0x00, 0x00, + // 661 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0xcf, 0x6b, 0x13, 0x41, + 0x14, 0xc7, 0x33, 0xb5, 0x2d, 0xcd, 0x54, 0x6c, 0x3b, 0x16, 0x4c, 0xb7, 0x75, 0x2b, 0xab, 0xd4, + 0x1a, 0xe8, 0x0e, 0xa9, 0x20, 0x62, 0xa1, 0x34, 0x81, 0xb6, 0x04, 0x14, 0xd2, 0xed, 0x4d, 0x90, + 0x30, 0xc9, 0x0e, 0xcb, 0x4a, 0xb2, 0xb3, 0xdd, 0xdd, 0x04, 0x43, 0xc8, 0xc5, 0xfe, 0x03, 0x82, + 0x7f, 0x43, 0x45, 0x3c, 0x79, 0x10, 0xc4, 0xb3, 0x97, 0x1e, 0x8b, 0x5e, 0x3c, 0x89, 0x24, 0x82, + 0xff, 0x86, 0xec, 0xcc, 0x6c, 0x7e, 0x6c, 0x62, 0x13, 0xc1, 0x83, 0x97, 0xd2, 0x7d, 0xef, 0x7d, + 0x67, 0x3e, 0xf3, 0x9d, 0xf7, 0x26, 0x70, 0xb5, 0x52, 0xab, 0x52, 0x8f, 0x60, 0x52, 0x33, 0xed, + 0x00, 0xd7, 0x33, 0xf8, 0xa4, 0x46, 0xbd, 0x86, 0xee, 0x7a, 0x2c, 0x60, 0x68, 0x41, 0x24, 0x75, + 0x9e, 0xd4, 0xeb, 0x19, 0x65, 0x89, 0x54, 0x6d, 0x87, 0x61, 0xfe, 0x57, 0xd4, 0x28, 0xe9, 0x32, + 0xf3, 0xab, 0xcc, 0xc7, 0x25, 0xe2, 0x53, 0x21, 0xc6, 0xf5, 0x4c, 0x89, 0x06, 0x24, 0x83, 0x5d, + 0x62, 0xd9, 0x0e, 0x09, 0x6c, 0xe6, 0xc8, 0xda, 0x15, 0x51, 0x5b, 0xe4, 0x5f, 0x58, 0x7c, 0xc8, + 0xd4, 0xb2, 0xc5, 0x2c, 0x26, 0xe2, 0xe1, 0x7f, 0x32, 0xba, 0x66, 0x31, 0x66, 0x55, 0x28, 0x26, + 0xae, 0x8d, 0x89, 0xe3, 0xb0, 0x80, 0xaf, 0x16, 0x69, 0xd4, 0x38, 0x3b, 0xad, 0xdb, 0x26, 0x75, + 0xca, 0x34, 0x52, 0xc7, 0xf3, 0x2e, 0xf1, 0x48, 0x55, 0xaa, 0xb5, 0x65, 0x88, 0x8e, 0x42, 0xdc, + 0x02, 0x0f, 0x1a, 0xf4, 0xa4, 0x46, 0xfd, 0x40, 0x3b, 0x82, 0xd7, 0x07, 0xa2, 0xbe, 0xcb, 0x1c, + 0x9f, 0xa2, 0x47, 0x70, 0x56, 0x88, 0x53, 0xe0, 0x16, 0xd8, 0x9c, 0xdf, 0xbe, 0xa1, 0xc7, 0xac, + 0xd1, 0x85, 0x20, 0x97, 0x3c, 0xff, 0xbe, 0x9e, 0x78, 0xfb, 0xeb, 0x7d, 0x1a, 0x18, 0x52, 0xa1, + 0xed, 0xc0, 0x14, 0x5f, 0x72, 0x5f, 0xd2, 0xe5, 0x1a, 0x79, 0x53, 0x6e, 0x87, 0xd6, 0xe1, 0x7c, + 0x04, 0x5d, 0xb4, 0x4d, 0xbe, 0xf8, 0xb4, 0x01, 0xa3, 0x50, 0xde, 0xd4, 0x9e, 0xc1, 0x95, 0x11, + 0x62, 0x49, 0xb5, 0x07, 0xe7, 0xa2, 0x52, 0xc9, 0xb5, 0x32, 0xc4, 0xd5, 0x15, 0xf6, 0x91, 0x75, + 0x55, 0xda, 0x3b, 0x00, 0x6f, 0xc6, 0xd6, 0x3f, 0xae, 0x95, 0x9e, 0xd3, 0x72, 0x10, 0x11, 0x66, + 0xe1, 0x82, 0x2f, 0x22, 0x45, 0x62, 0x9a, 0x1e, 0xf5, 0x85, 0x05, 0xc9, 0x5c, 0xea, 0xcb, 0x87, + 0xad, 0x65, 0x79, 0x87, 0x59, 0x91, 0x39, 0x0e, 0x3c, 0xdb, 0xb1, 0x8c, 0x6b, 0x52, 0x20, 0xa3, + 0xe8, 0x00, 0xc2, 0x5e, 0x2b, 0xa4, 0xa6, 0x38, 0xe8, 0x86, 0x2e, 0xa5, 0x61, 0xdf, 0xe8, 0xa2, + 0xe9, 0x64, 0xdf, 0xe8, 0x05, 0x62, 0x51, 0xb9, 0xbd, 0xd1, 0xa7, 0xd4, 0xde, 0x00, 0xa8, 0xfe, + 0x09, 0x56, 0x3a, 0xb2, 0x33, 0xe0, 0xc8, 0x95, 0xcb, 0x1d, 0x99, 0x0e, 0x1d, 0xe9, 0x99, 0x81, + 0x0e, 0x47, 0x70, 0xde, 0x1d, 0xcb, 0x29, 0x76, 0x1e, 0x00, 0x3d, 0x05, 0x70, 0x2d, 0x06, 0x9a, + 0x2d, 0x87, 0x99, 0xc8, 0xd4, 0x55, 0x98, 0x24, 0x3c, 0x10, 0x5d, 0x7a, 0xd2, 0x98, 0x13, 0x81, + 0xbc, 0xf9, 0xcf, 0xec, 0x3a, 0x1b, 0xbe, 0xdb, 0x88, 0xe2, 0x7f, 0x72, 0x6b, 0xfb, 0xe3, 0x0c, + 0x9c, 0xe1, 0x9c, 0xe8, 0x14, 0xc0, 0x59, 0x31, 0x47, 0xe8, 0xf6, 0x10, 0xc8, 0xf0, 0xb0, 0x2a, + 0x77, 0x2e, 0x2f, 0x12, 0x7b, 0x69, 0xfa, 0xcb, 0xaf, 0x3f, 0x5f, 0x4f, 0x6d, 0xa2, 0x0d, 0xfc, + 0x98, 0x57, 0x17, 0xc2, 0xf1, 0x2f, 0xb3, 0x0a, 0x1e, 0xfd, 0x3c, 0xa0, 0x33, 0x00, 0xaf, 0xf6, + 0x8f, 0x1b, 0xba, 0x37, 0x7a, 0x9b, 0x11, 0xf3, 0xac, 0xa4, 0x27, 0x29, 0x95, 0x5c, 0xbb, 0x9c, + 0xeb, 0x21, 0x7a, 0x30, 0x8e, 0x2b, 0xb2, 0x1c, 0x37, 0xfb, 0xde, 0x8a, 0x16, 0xfa, 0x0c, 0xe0, + 0xd2, 0xd0, 0x24, 0x20, 0x7d, 0x1c, 0xc1, 0xe0, 0x7c, 0x2b, 0x78, 0xe2, 0x7a, 0x89, 0xfd, 0x84, + 0x63, 0x1f, 0xa2, 0xfd, 0x89, 0xb1, 0x4b, 0x8d, 0xa2, 0x7c, 0x11, 0x70, 0x33, 0xf6, 0x96, 0xb4, + 0xd0, 0x27, 0x00, 0x17, 0xe3, 0x0d, 0x8a, 0xb6, 0xc6, 0x41, 0x0d, 0x8c, 0x93, 0xa2, 0x4f, 0x5a, + 0x2e, 0x8f, 0x70, 0xc0, 0x8f, 0xb0, 0x87, 0x76, 0xff, 0xe6, 0x08, 0x62, 0x3e, 0x71, 0xb3, 0x3b, + 0xb8, 0xad, 0x5c, 0xfa, 0xbc, 0xad, 0x82, 0x8b, 0xb6, 0x0a, 0x7e, 0xb4, 0x55, 0xf0, 0xaa, 0xa3, + 0x26, 0x2e, 0x3a, 0x6a, 0xe2, 0x5b, 0x47, 0x4d, 0x3c, 0x5d, 0x7c, 0xd1, 0x5b, 0x24, 0x68, 0xb8, + 0xd4, 0x2f, 0xcd, 0xf2, 0x5f, 0x9d, 0xfb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x15, 0xdd, + 0x48, 0x71, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -159,6 +484,12 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // EvidenceById queries a single evidence record by id. + EvidenceById(ctx context.Context, in *QueryEvidenceByIdRequest, opts ...grpc.CallOption) (*QueryEvidenceByIdResponse, error) + // EvidenceBySubject queries evidence records by subject address. + EvidenceBySubject(ctx context.Context, in *QueryEvidenceBySubjectRequest, opts ...grpc.CallOption) (*QueryEvidenceBySubjectResponse, error) + // EvidenceByAction queries evidence records by action id. + EvidenceByAction(ctx context.Context, in *QueryEvidenceByActionRequest, opts ...grpc.CallOption) (*QueryEvidenceByActionResponse, error) } type queryClient struct { @@ -178,10 +509,43 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) EvidenceById(ctx context.Context, in *QueryEvidenceByIdRequest, opts ...grpc.CallOption) (*QueryEvidenceByIdResponse, error) { + out := new(QueryEvidenceByIdResponse) + err := c.cc.Invoke(ctx, "/lumera.audit.v1.Query/EvidenceById", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) EvidenceBySubject(ctx context.Context, in *QueryEvidenceBySubjectRequest, opts ...grpc.CallOption) (*QueryEvidenceBySubjectResponse, error) { + out := new(QueryEvidenceBySubjectResponse) + err := c.cc.Invoke(ctx, "/lumera.audit.v1.Query/EvidenceBySubject", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) EvidenceByAction(ctx context.Context, in *QueryEvidenceByActionRequest, opts ...grpc.CallOption) (*QueryEvidenceByActionResponse, error) { + out := new(QueryEvidenceByActionResponse) + err := c.cc.Invoke(ctx, "/lumera.audit.v1.Query/EvidenceByAction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // EvidenceById queries a single evidence record by id. + EvidenceById(context.Context, *QueryEvidenceByIdRequest) (*QueryEvidenceByIdResponse, error) + // EvidenceBySubject queries evidence records by subject address. + EvidenceBySubject(context.Context, *QueryEvidenceBySubjectRequest) (*QueryEvidenceBySubjectResponse, error) + // EvidenceByAction queries evidence records by action id. + EvidenceByAction(context.Context, *QueryEvidenceByActionRequest) (*QueryEvidenceByActionResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -191,6 +555,15 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) EvidenceById(ctx context.Context, req *QueryEvidenceByIdRequest) (*QueryEvidenceByIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EvidenceById not implemented") +} +func (*UnimplementedQueryServer) EvidenceBySubject(ctx context.Context, req *QueryEvidenceBySubjectRequest) (*QueryEvidenceBySubjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EvidenceBySubject not implemented") +} +func (*UnimplementedQueryServer) EvidenceByAction(ctx context.Context, req *QueryEvidenceByActionRequest) (*QueryEvidenceByActionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EvidenceByAction not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -214,6 +587,60 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_EvidenceById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEvidenceByIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EvidenceById(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lumera.audit.v1.Query/EvidenceById", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EvidenceById(ctx, req.(*QueryEvidenceByIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_EvidenceBySubject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEvidenceBySubjectRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EvidenceBySubject(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lumera.audit.v1.Query/EvidenceBySubject", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EvidenceBySubject(ctx, req.(*QueryEvidenceBySubjectRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_EvidenceByAction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEvidenceByActionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EvidenceByAction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lumera.audit.v1.Query/EvidenceByAction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EvidenceByAction(ctx, req.(*QueryEvidenceByActionRequest)) + } + return interceptor(ctx, in, info, handler) +} + var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "lumera.audit.v1.Query", @@ -223,6 +650,18 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "EvidenceById", + Handler: _Query_EvidenceById_Handler, + }, + { + MethodName: "EvidenceBySubject", + Handler: _Query_EvidenceBySubject_Handler, + }, + { + MethodName: "EvidenceByAction", + Handler: _Query_EvidenceByAction_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "lumera/audit/v1/query.proto", @@ -284,20 +723,263 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryEvidenceByIdRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 + +func (m *QueryEvidenceByIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceByIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EvidenceId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EvidenceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryEvidenceByIdResponse) 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 *QueryEvidenceByIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceByIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryEvidenceBySubjectRequest) 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 *QueryEvidenceBySubjectRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceBySubjectRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.SubjectAddress) > 0 { + i -= len(m.SubjectAddress) + copy(dAtA[i:], m.SubjectAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SubjectAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryEvidenceBySubjectResponse) 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 *QueryEvidenceBySubjectResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceBySubjectResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Evidence) > 0 { + for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Evidence[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryEvidenceByActionRequest) 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 *QueryEvidenceByActionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceByActionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ActionId) > 0 { + i -= len(m.ActionId) + copy(dAtA[i:], m.ActionId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ActionId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryEvidenceByActionResponse) 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 *QueryEvidenceByActionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceByActionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Evidence) > 0 { + for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Evidence[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 } var l int _ = l @@ -315,6 +997,101 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryEvidenceByIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EvidenceId != 0 { + n += 1 + sovQuery(uint64(m.EvidenceId)) + } + return n +} + +func (m *QueryEvidenceByIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Evidence.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryEvidenceBySubjectRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SubjectAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryEvidenceBySubjectResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Evidence) > 0 { + for _, e := range m.Evidence { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryEvidenceByActionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ActionId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryEvidenceByActionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Evidence) > 0 { + for _, e := range m.Evidence { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -454,6 +1231,634 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryEvidenceByIdRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEvidenceByIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEvidenceByIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EvidenceId", wireType) + } + m.EvidenceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EvidenceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEvidenceByIdResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEvidenceByIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEvidenceByIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEvidenceBySubjectRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEvidenceBySubjectRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEvidenceBySubjectRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubjectAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEvidenceBySubjectResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEvidenceBySubjectResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEvidenceBySubjectResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Evidence = append(m.Evidence, Evidence{}) + if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEvidenceByActionRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEvidenceByActionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEvidenceByActionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ActionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ActionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEvidenceByActionResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryEvidenceByActionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEvidenceByActionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Evidence = append(m.Evidence, Evidence{}) + if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/audit/v1/types/query.pb.gw.go b/x/audit/v1/types/query.pb.gw.go index 5cd0e465..46194ed2 100644 --- a/x/audit/v1/types/query.pb.gw.go +++ b/x/audit/v1/types/query.pb.gw.go @@ -51,6 +51,204 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_EvidenceById_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEvidenceByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["evidence_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "evidence_id") + } + + protoReq.EvidenceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "evidence_id", err) + } + + msg, err := client.EvidenceById(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EvidenceById_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEvidenceByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["evidence_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "evidence_id") + } + + protoReq.EvidenceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "evidence_id", err) + } + + msg, err := server.EvidenceById(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_EvidenceBySubject_0 = &utilities.DoubleArray{Encoding: map[string]int{"subject_address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_EvidenceBySubject_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEvidenceBySubjectRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subject_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subject_address") + } + + protoReq.SubjectAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subject_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EvidenceBySubject_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.EvidenceBySubject(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EvidenceBySubject_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEvidenceBySubjectRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subject_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subject_address") + } + + protoReq.SubjectAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subject_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EvidenceBySubject_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.EvidenceBySubject(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_EvidenceByAction_0 = &utilities.DoubleArray{Encoding: map[string]int{"action_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_EvidenceByAction_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEvidenceByActionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["action_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "action_id") + } + + protoReq.ActionId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "action_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EvidenceByAction_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.EvidenceByAction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EvidenceByAction_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEvidenceByActionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["action_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "action_id") + } + + protoReq.ActionId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "action_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EvidenceByAction_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.EvidenceByAction(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -80,6 +278,75 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_EvidenceById_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_EvidenceById_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EvidenceById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EvidenceBySubject_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_EvidenceBySubject_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EvidenceBySubject_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EvidenceByAction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_EvidenceByAction_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EvidenceByAction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +408,85 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_EvidenceById_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_EvidenceById_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EvidenceById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EvidenceBySubject_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_EvidenceBySubject_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EvidenceBySubject_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EvidenceByAction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_EvidenceByAction_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_EvidenceByAction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"LumeraProtocol", "lumera", "audit", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_EvidenceById_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"LumeraProtocol", "lumera", "audit", "v1", "evidence", "evidence_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_EvidenceBySubject_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"LumeraProtocol", "lumera", "audit", "v1", "evidence", "by_subject", "subject_address"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_EvidenceByAction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"LumeraProtocol", "lumera", "audit", "v1", "evidence", "by_action", "action_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_EvidenceById_0 = runtime.ForwardResponseMessage + + forward_Query_EvidenceBySubject_0 = runtime.ForwardResponseMessage + + forward_Query_EvidenceByAction_0 = runtime.ForwardResponseMessage ) diff --git a/x/audit/v1/types/tx.pb.go b/x/audit/v1/types/tx.pb.go index 9ff1d809..c4ad7206 100644 --- a/x/audit/v1/types/tx.pb.go +++ b/x/audit/v1/types/tx.pb.go @@ -35,8 +35,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package 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"` - // params defines the module parameters to update. - // // NOTE: All parameters must be supplied. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } @@ -126,36 +124,172 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgSubmitEvidence defines the MsgSubmitEvidence message. +type MsgSubmitEvidence struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + SubjectAddress string `protobuf:"bytes,2,opt,name=subject_address,json=subjectAddress,proto3" json:"subject_address,omitempty"` + EvidenceType string `protobuf:"bytes,3,opt,name=evidence_type,json=evidenceType,proto3" json:"evidence_type,omitempty"` + ActionId string `protobuf:"bytes,4,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"` + // metadata is JSON for the type-specific Evidence metadata message. + // The chain stores protobuf-binary bytes derived from this JSON. + Metadata string `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgSubmitEvidence) Reset() { *m = MsgSubmitEvidence{} } +func (m *MsgSubmitEvidence) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitEvidence) ProtoMessage() {} +func (*MsgSubmitEvidence) Descriptor() ([]byte, []int) { + return fileDescriptor_4b5ba410ad359f63, []int{2} +} +func (m *MsgSubmitEvidence) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitEvidence.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 *MsgSubmitEvidence) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitEvidence.Merge(m, src) +} +func (m *MsgSubmitEvidence) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitEvidence) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitEvidence.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitEvidence proto.InternalMessageInfo + +func (m *MsgSubmitEvidence) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgSubmitEvidence) GetSubjectAddress() string { + if m != nil { + return m.SubjectAddress + } + return "" +} + +func (m *MsgSubmitEvidence) GetEvidenceType() string { + if m != nil { + return m.EvidenceType + } + return "" +} + +func (m *MsgSubmitEvidence) GetActionId() string { + if m != nil { + return m.ActionId + } + return "" +} + +func (m *MsgSubmitEvidence) GetMetadata() string { + if m != nil { + return m.Metadata + } + return "" +} + +// MsgSubmitEvidenceResponse defines the MsgSubmitEvidenceResponse message. +type MsgSubmitEvidenceResponse struct { + EvidenceId uint64 `protobuf:"varint,1,opt,name=evidence_id,json=evidenceId,proto3" json:"evidence_id,omitempty"` +} + +func (m *MsgSubmitEvidenceResponse) Reset() { *m = MsgSubmitEvidenceResponse{} } +func (m *MsgSubmitEvidenceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitEvidenceResponse) ProtoMessage() {} +func (*MsgSubmitEvidenceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4b5ba410ad359f63, []int{3} +} +func (m *MsgSubmitEvidenceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitEvidenceResponse.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 *MsgSubmitEvidenceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitEvidenceResponse.Merge(m, src) +} +func (m *MsgSubmitEvidenceResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitEvidenceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitEvidenceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitEvidenceResponse proto.InternalMessageInfo + +func (m *MsgSubmitEvidenceResponse) GetEvidenceId() uint64 { + if m != nil { + return m.EvidenceId + } + return 0 +} + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "lumera.audit.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "lumera.audit.v1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgSubmitEvidence)(nil), "lumera.audit.v1.MsgSubmitEvidence") + proto.RegisterType((*MsgSubmitEvidenceResponse)(nil), "lumera.audit.v1.MsgSubmitEvidenceResponse") } func init() { proto.RegisterFile("lumera/audit/v1/tx.proto", fileDescriptor_4b5ba410ad359f63) } var fileDescriptor_4b5ba410ad359f63 = []byte{ - // 326 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0x29, 0xcd, 0x4d, - 0x2d, 0x4a, 0xd4, 0x4f, 0x2c, 0x4d, 0xc9, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc8, 0xe8, 0x81, 0x65, 0xf4, 0xca, 0x0c, 0xa5, 0x04, - 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x78, 0x72, 0x7e, 0x71, 0x6e, - 0x7e, 0xb1, 0x7e, 0x6e, 0x71, 0x3a, 0x48, 0x6f, 0x6e, 0x71, 0x3a, 0x54, 0x42, 0x12, 0x22, 0x11, - 0x0f, 0xe6, 0xe9, 0x43, 0x38, 0x50, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x88, 0x38, 0x88, 0x05, - 0x15, 0x95, 0x41, 0x77, 0x47, 0x41, 0x62, 0x51, 0x62, 0x2e, 0x54, 0x8f, 0xd2, 0x0e, 0x46, 0x2e, - 0x7e, 0xdf, 0xe2, 0xf4, 0xd0, 0x82, 0x94, 0xc4, 0x92, 0xd4, 0x00, 0xb0, 0x8c, 0x90, 0x19, 0x17, - 0x67, 0x62, 0x69, 0x49, 0x46, 0x7e, 0x51, 0x66, 0x49, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, - 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, 0xcb, 0x1c, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x83, - 0x4b, 0x8a, 0x32, 0xf3, 0xd2, 0x83, 0x10, 0x4a, 0x85, 0xac, 0xb8, 0xd8, 0x20, 0x66, 0x4b, 0x30, - 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x89, 0xeb, 0xa1, 0x79, 0x54, 0x0f, 0x62, 0x81, 0x13, 0xe7, 0x89, - 0x7b, 0xf2, 0x0c, 0x2b, 0x9e, 0x6f, 0xd0, 0x62, 0x0c, 0x82, 0xea, 0xb0, 0x32, 0x6c, 0x7a, 0xbe, - 0x41, 0x0b, 0x61, 0x56, 0xd7, 0xf3, 0x0d, 0x5a, 0x72, 0x50, 0x87, 0x57, 0x40, 0x9d, 0x8e, 0xe6, - 0x4c, 0x25, 0x49, 0x2e, 0x71, 0x34, 0xa1, 0xa0, 0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa3, - 0x0c, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x28, 0x2e, 0x1e, 0x14, 0x8f, 0x29, 0x60, 0x38, 0x08, - 0xcd, 0x00, 0x29, 0x0d, 0x42, 0x2a, 0x60, 0x56, 0x48, 0xb1, 0x36, 0x80, 0xdc, 0xef, 0xa4, 0x75, - 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, - 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x02, 0x15, 0x48, 0x51, 0x5f, 0x59, - 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x72, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xa3, - 0xb7, 0xf0, 0x1a, 0x02, 0x00, 0x00, + // 494 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x3d, 0x6f, 0xd3, 0x40, + 0x18, 0xce, 0xd1, 0x0f, 0x9a, 0x6b, 0x68, 0xe8, 0xa9, 0x52, 0x1c, 0x83, 0xdc, 0xc8, 0x2c, 0x91, + 0x25, 0x6c, 0x25, 0x48, 0x0c, 0x11, 0x4b, 0x23, 0x31, 0x74, 0x88, 0x84, 0x5c, 0x58, 0xba, 0x84, + 0x8b, 0xef, 0x64, 0x0e, 0x61, 0x9f, 0xe5, 0x3b, 0x47, 0xc9, 0x86, 0x18, 0x99, 0xf8, 0x19, 0x8c, + 0x19, 0x18, 0xf8, 0x09, 0x15, 0x53, 0xc5, 0xc4, 0x84, 0x50, 0x32, 0xe4, 0x1f, 0x30, 0x23, 0xfb, + 0xce, 0x2d, 0x75, 0x11, 0x59, 0x2c, 0xdf, 0xf3, 0x71, 0xef, 0xf3, 0xbe, 0x77, 0x07, 0x8d, 0x77, + 0x59, 0x44, 0x53, 0xec, 0xe1, 0x8c, 0x30, 0xe9, 0x4d, 0x7b, 0x9e, 0x9c, 0xb9, 0x49, 0xca, 0x25, + 0x47, 0x4d, 0xc5, 0xb8, 0x05, 0xe3, 0x4e, 0x7b, 0xe6, 0x21, 0x8e, 0x58, 0xcc, 0xbd, 0xe2, 0xab, + 0x34, 0x66, 0x2b, 0xe0, 0x22, 0xe2, 0xc2, 0x8b, 0x44, 0x98, 0x7b, 0x23, 0x11, 0x6a, 0xa2, 0xad, + 0x88, 0x71, 0xb1, 0xf2, 0xd4, 0x42, 0x53, 0x47, 0x21, 0x0f, 0xb9, 0xc2, 0xf3, 0x3f, 0x8d, 0x3e, + 0xac, 0xe6, 0x48, 0x70, 0x8a, 0x23, 0xed, 0xb1, 0xbf, 0x02, 0xd8, 0x1c, 0x89, 0xf0, 0x55, 0x42, + 0xb0, 0xa4, 0x2f, 0x0a, 0x06, 0x3d, 0x85, 0x75, 0x9c, 0xc9, 0x37, 0x3c, 0x65, 0x72, 0x6e, 0x80, + 0x0e, 0xe8, 0xd6, 0x87, 0xc6, 0xf7, 0x2f, 0x8f, 0x8f, 0x74, 0xb1, 0x13, 0x42, 0x52, 0x2a, 0xc4, + 0x99, 0x4c, 0x59, 0x1c, 0xfa, 0xd7, 0x52, 0x34, 0x80, 0xbb, 0x6a, 0x6f, 0xe3, 0x4e, 0x07, 0x74, + 0xf7, 0xfb, 0x2d, 0xb7, 0xd2, 0xa8, 0xab, 0x0a, 0x0c, 0xeb, 0x17, 0x3f, 0x8f, 0x6b, 0x9f, 0xd7, + 0x0b, 0x07, 0xf8, 0xda, 0x31, 0xe8, 0x7d, 0x58, 0x2f, 0x9c, 0xeb, 0xbd, 0x3e, 0xae, 0x17, 0x8e, + 0xa5, 0x83, 0xcf, 0x74, 0xf4, 0x4a, 0x4c, 0xbb, 0x0d, 0x5b, 0x15, 0xc8, 0xa7, 0x22, 0xe1, 0xb1, + 0xa0, 0xf6, 0x6f, 0x00, 0x0f, 0x47, 0x22, 0x3c, 0xcb, 0x26, 0x11, 0x93, 0xcf, 0xa7, 0x8c, 0xd0, + 0x38, 0xa0, 0xa8, 0x0f, 0xef, 0x06, 0x29, 0xc5, 0x92, 0xa7, 0x1b, 0xbb, 0x2a, 0x85, 0xe8, 0x04, + 0x36, 0x45, 0x36, 0x79, 0x4b, 0x03, 0x39, 0xc6, 0x4a, 0x51, 0x34, 0xf7, 0x3f, 0xef, 0x81, 0x36, + 0x68, 0x14, 0x3d, 0x82, 0xf7, 0xa8, 0x8e, 0x30, 0x96, 0xf3, 0x84, 0x1a, 0x5b, 0xf9, 0x06, 0x7e, + 0xa3, 0x04, 0x5f, 0xce, 0x13, 0x8a, 0x1e, 0xc0, 0x3a, 0x0e, 0x24, 0xe3, 0xf1, 0x98, 0x11, 0x63, + 0xbb, 0x10, 0xec, 0x29, 0xe0, 0x94, 0x20, 0x13, 0xee, 0x45, 0x54, 0x62, 0x82, 0x25, 0x36, 0x76, + 0x14, 0x57, 0xae, 0x07, 0x8d, 0x7c, 0x70, 0x65, 0x5c, 0xfb, 0x19, 0x6c, 0xdf, 0xea, 0xbb, 0x9c, + 0x0a, 0x3a, 0x86, 0xfb, 0x57, 0x41, 0x18, 0x29, 0x66, 0xb0, 0xed, 0xc3, 0x12, 0x3a, 0x25, 0xfd, + 0x6f, 0x00, 0x6e, 0x8d, 0x44, 0x88, 0xce, 0x61, 0xe3, 0xc6, 0x85, 0xe8, 0xdc, 0x3a, 0xc8, 0xca, + 0xe0, 0xcd, 0xee, 0x26, 0xc5, 0x55, 0x88, 0xd7, 0xf0, 0xa0, 0x72, 0x2c, 0xf6, 0xbf, 0xbc, 0x37, + 0x35, 0xa6, 0xb3, 0x59, 0x53, 0x56, 0x30, 0x77, 0xde, 0xe7, 0x37, 0x6b, 0xe8, 0x5c, 0x2c, 0x2d, + 0x70, 0xb9, 0xb4, 0xc0, 0xaf, 0xa5, 0x05, 0x3e, 0xad, 0xac, 0xda, 0xe5, 0xca, 0xaa, 0xfd, 0x58, + 0x59, 0xb5, 0xf3, 0xfb, 0xb3, 0xbf, 0x1e, 0xe5, 0x3c, 0xa1, 0x62, 0xb2, 0x5b, 0x3c, 0x86, 0x27, + 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x1a, 0x37, 0xed, 0xb4, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -173,6 +307,8 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // SubmitEvidence defines the SubmitEvidence RPC. + SubmitEvidence(ctx context.Context, in *MsgSubmitEvidence, opts ...grpc.CallOption) (*MsgSubmitEvidenceResponse, error) } type msgClient struct { @@ -192,11 +328,22 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) SubmitEvidence(ctx context.Context, in *MsgSubmitEvidence, opts ...grpc.CallOption) (*MsgSubmitEvidenceResponse, error) { + out := new(MsgSubmitEvidenceResponse) + err := c.cc.Invoke(ctx, "/lumera.audit.v1.Msg/SubmitEvidence", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // SubmitEvidence defines the SubmitEvidence RPC. + SubmitEvidence(context.Context, *MsgSubmitEvidence) (*MsgSubmitEvidenceResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -206,6 +353,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) SubmitEvidence(ctx context.Context, req *MsgSubmitEvidence) (*MsgSubmitEvidenceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitEvidence not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -229,6 +379,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_SubmitEvidence_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitEvidence) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitEvidence(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lumera.audit.v1.Msg/SubmitEvidence", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitEvidence(ctx, req.(*MsgSubmitEvidence)) + } + return interceptor(ctx, in, info, handler) +} + var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "lumera.audit.v1.Msg", @@ -238,6 +406,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "SubmitEvidence", + Handler: _Msg_SubmitEvidence_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "lumera/audit/v1/tx.proto", @@ -306,6 +478,92 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgSubmitEvidence) 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 *MsgSubmitEvidence) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x2a + } + if len(m.ActionId) > 0 { + i -= len(m.ActionId) + copy(dAtA[i:], m.ActionId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ActionId))) + i-- + dAtA[i] = 0x22 + } + if len(m.EvidenceType) > 0 { + i -= len(m.EvidenceType) + copy(dAtA[i:], m.EvidenceType) + i = encodeVarintTx(dAtA, i, uint64(len(m.EvidenceType))) + i-- + dAtA[i] = 0x1a + } + if len(m.SubjectAddress) > 0 { + i -= len(m.SubjectAddress) + copy(dAtA[i:], m.SubjectAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SubjectAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitEvidenceResponse) 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 *MsgSubmitEvidenceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitEvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EvidenceId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.EvidenceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -341,6 +599,47 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgSubmitEvidence) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SubjectAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.EvidenceType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ActionId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSubmitEvidenceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EvidenceId != 0 { + n += 1 + sovTx(uint64(m.EvidenceId)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -512,6 +811,285 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSubmitEvidence) 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: MsgSubmitEvidence: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitEvidence: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectAddress", 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.SubjectAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvidenceType", 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.EvidenceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ActionId", 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.ActionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", 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.Metadata = string(dAtA[iNdEx:postIndex]) + 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 *MsgSubmitEvidenceResponse) 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: MsgSubmitEvidenceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitEvidenceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EvidenceId", wireType) + } + m.EvidenceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EvidenceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 From d72bb33062edbf56fb489cefec8308e034c8af26 Mon Sep 17 00:00:00 2001 From: Matee Ullah Malik Date: Fri, 30 Jan 2026 18:17:14 +0500 Subject: [PATCH 3/3] audit: make evidence type enum --- proto/lumera/audit/v1/evidence.proto | 9 +- proto/lumera/audit/v1/tx.proto | 3 +- x/audit/v1/keeper/evidence.go | 31 +++--- x/audit/v1/simulation/submit_evidence.go | 2 +- x/audit/v1/types/evidence.go | 16 ---- x/audit/v1/types/evidence.pb.go | 114 +++++++++++++---------- x/audit/v1/types/tx.pb.go | 109 ++++++++++------------ 7 files changed, 138 insertions(+), 146 deletions(-) delete mode 100644 x/audit/v1/types/evidence.go diff --git a/proto/lumera/audit/v1/evidence.proto b/proto/lumera/audit/v1/evidence.proto index c9ebc620..c4483774 100644 --- a/proto/lumera/audit/v1/evidence.proto +++ b/proto/lumera/audit/v1/evidence.proto @@ -6,6 +6,12 @@ import "cosmos_proto/cosmos.proto"; option go_package = "x/audit/v1/types"; +enum EvidenceType { + EVIDENCE_TYPE_UNSPECIFIED = 0; + EVIDENCE_TYPE_ACTION_WRONG_FINALIZATION = 1; + EVIDENCE_TYPE_ACTION_EXPIRED = 2; +} + // Evidence is a stable outer record that stores evidence about an audited subject. // Type-specific fields are encoded into the `metadata` bytes field. message Evidence { @@ -22,7 +28,7 @@ message Evidence { string action_id = 4; // evidence_type is a stable discriminator used to interpret metadata. - string evidence_type = 5; + EvidenceType evidence_type = 5; // metadata is protobuf-binary bytes of a type-specific Evidence metadata message. bytes metadata = 6; @@ -30,4 +36,3 @@ message Evidence { // reported_height is the block height when the evidence was submitted. uint64 reported_height = 7; } - diff --git a/proto/lumera/audit/v1/tx.proto b/proto/lumera/audit/v1/tx.proto index 246fc280..2946d3a0 100644 --- a/proto/lumera/audit/v1/tx.proto +++ b/proto/lumera/audit/v1/tx.proto @@ -6,6 +6,7 @@ import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; +import "lumera/audit/v1/evidence.proto"; import "lumera/audit/v1/params.proto"; option go_package = "x/audit/v1/types"; @@ -48,7 +49,7 @@ message MsgSubmitEvidence { option (cosmos.msg.v1.signer) = "creator"; string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; string subject_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string evidence_type = 3; + EvidenceType evidence_type = 3; string action_id = 4; // metadata is JSON for the type-specific Evidence metadata message. diff --git a/x/audit/v1/keeper/evidence.go b/x/audit/v1/keeper/evidence.go index fb39c6d5..c312e8fe 100644 --- a/x/audit/v1/keeper/evidence.go +++ b/x/audit/v1/keeper/evidence.go @@ -18,7 +18,7 @@ func (k Keeper) CreateEvidence( reporterAddress string, subjectAddress string, actionID string, - evidenceType string, + evidenceType types.EvidenceType, metadataJSON string, ) (uint64, error) { if _, err := k.addressCodec.StringToBytes(reporterAddress); err != nil { @@ -29,8 +29,7 @@ func (k Keeper) CreateEvidence( return 0, errors.Wrap(types.ErrInvalidSubject, err.Error()) } - etype := types.CanonicalEvidenceType(evidenceType) - if etype == "" { + if evidenceType == types.EvidenceType_EVIDENCE_TYPE_UNSPECIFIED { return 0, types.ErrInvalidEvidenceType } @@ -41,13 +40,13 @@ func (k Keeper) CreateEvidence( if actionID == "" { // For the initial supported evidence types (action expiration/finalization), action id is required. - switch etype { - case types.EvidenceTypeActionExpired, types.EvidenceTypeActionWrongFinalizer: + switch evidenceType { + case types.EvidenceType_EVIDENCE_TYPE_ACTION_EXPIRED, types.EvidenceType_EVIDENCE_TYPE_ACTION_WRONG_FINALIZATION: return 0, types.ErrInvalidActionID } } - metadataBytes, err := marshalEvidenceMetadataJSON(etype, metadataJSON) + metadataBytes, err := marshalEvidenceMetadataJSON(evidenceType, metadataJSON) if err != nil { return 0, errors.Wrap(types.ErrInvalidMetadata, err.Error()) } @@ -61,13 +60,13 @@ func (k Keeper) CreateEvidence( } ev := types.Evidence{ - EvidenceId: evidenceID, - SubjectAddress: subjectAddress, + EvidenceId: evidenceID, + SubjectAddress: subjectAddress, ReporterAddress: reporterAddress, - ActionId: actionID, - EvidenceType: etype, - Metadata: metadataBytes, - ReportedHeight: reportedHeight, + ActionId: actionID, + EvidenceType: evidenceType, + Metadata: metadataBytes, + ReportedHeight: reportedHeight, } if err := k.Evidences.Set(ctx, evidenceID, ev); err != nil { @@ -86,18 +85,18 @@ func (k Keeper) CreateEvidence( return evidenceID, nil } -func marshalEvidenceMetadataJSON(evidenceType string, metadataJSON string) ([]byte, error) { +func marshalEvidenceMetadataJSON(evidenceType types.EvidenceType, metadataJSON string) ([]byte, error) { u := &jsonpb.Unmarshaler{} switch evidenceType { - case types.EvidenceTypeActionExpired: + case types.EvidenceType_EVIDENCE_TYPE_ACTION_EXPIRED: var m types.ExpirationEvidenceMetadata if err := u.Unmarshal(strings.NewReader(metadataJSON), &m); err != nil { return nil, fmt.Errorf("unmarshal ExpirationEvidenceMetadata: %w", err) } return gogoproto.Marshal(&m) - case types.EvidenceTypeActionWrongFinalizer: + case types.EvidenceType_EVIDENCE_TYPE_ACTION_WRONG_FINALIZATION: var m types.FinalizationEvidenceMetadata if err := u.Unmarshal(strings.NewReader(metadataJSON), &m); err != nil { return nil, fmt.Errorf("unmarshal FinalizationEvidenceMetadata: %w", err) @@ -108,6 +107,6 @@ func marshalEvidenceMetadataJSON(evidenceType string, metadataJSON string) ([]by return gogoproto.Marshal(&m) default: - return nil, fmt.Errorf("unsupported evidence_type: %s", evidenceType) + return nil, fmt.Errorf("unsupported evidence_type: %s", evidenceType.String()) } } diff --git a/x/audit/v1/simulation/submit_evidence.go b/x/audit/v1/simulation/submit_evidence.go index 4f7ec878..0705c432 100644 --- a/x/audit/v1/simulation/submit_evidence.go +++ b/x/audit/v1/simulation/submit_evidence.go @@ -34,7 +34,7 @@ func SimulateMsgSubmitEvidence( msg := &types.MsgSubmitEvidence{ Creator: simAccount.Address.String(), SubjectAddress: subjectAccount.Address.String(), - EvidenceType: types.EvidenceTypeActionExpired, + EvidenceType: types.EvidenceType_EVIDENCE_TYPE_ACTION_EXPIRED, ActionId: "sim-action-id", Metadata: string(metadataBz), } diff --git a/x/audit/v1/types/evidence.go b/x/audit/v1/types/evidence.go deleted file mode 100644 index 746e6ae9..00000000 --- a/x/audit/v1/types/evidence.go +++ /dev/null @@ -1,16 +0,0 @@ -package types - -import "strings" - -const ( - // EvidenceTypeActionExpired is evidence that an action expired. - EvidenceTypeActionExpired = "ACTION_EXPIRED" - - // EvidenceTypeActionWrongFinalizer is evidence that an unexpected actor attempted action finalization. - EvidenceTypeActionWrongFinalizer = "ACTION_WRONG_FINALIZER" -) - -func CanonicalEvidenceType(t string) string { - return strings.ToUpper(strings.TrimSpace(t)) -} - diff --git a/x/audit/v1/types/evidence.pb.go b/x/audit/v1/types/evidence.pb.go index a7370fdb..9e718f4e 100644 --- a/x/audit/v1/types/evidence.pb.go +++ b/x/audit/v1/types/evidence.pb.go @@ -23,6 +23,34 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type EvidenceType int32 + +const ( + EvidenceType_EVIDENCE_TYPE_UNSPECIFIED EvidenceType = 0 + EvidenceType_EVIDENCE_TYPE_ACTION_WRONG_FINALIZATION EvidenceType = 1 + EvidenceType_EVIDENCE_TYPE_ACTION_EXPIRED EvidenceType = 2 +) + +var EvidenceType_name = map[int32]string{ + 0: "EVIDENCE_TYPE_UNSPECIFIED", + 1: "EVIDENCE_TYPE_ACTION_WRONG_FINALIZATION", + 2: "EVIDENCE_TYPE_ACTION_EXPIRED", +} + +var EvidenceType_value = map[string]int32{ + "EVIDENCE_TYPE_UNSPECIFIED": 0, + "EVIDENCE_TYPE_ACTION_WRONG_FINALIZATION": 1, + "EVIDENCE_TYPE_ACTION_EXPIRED": 2, +} + +func (x EvidenceType) String() string { + return proto.EnumName(EvidenceType_name, int32(x)) +} + +func (EvidenceType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_449f638e48abdbaa, []int{0} +} + // Evidence is a stable outer record that stores evidence about an audited subject. // Type-specific fields are encoded into the `metadata` bytes field. type Evidence struct { @@ -35,7 +63,7 @@ type Evidence struct { // action_id optionally links this evidence to a specific action. ActionId string `protobuf:"bytes,4,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"` // evidence_type is a stable discriminator used to interpret metadata. - EvidenceType string `protobuf:"bytes,5,opt,name=evidence_type,json=evidenceType,proto3" json:"evidence_type,omitempty"` + EvidenceType EvidenceType `protobuf:"varint,5,opt,name=evidence_type,json=evidenceType,proto3,enum=lumera.audit.v1.EvidenceType" json:"evidence_type,omitempty"` // metadata is protobuf-binary bytes of a type-specific Evidence metadata message. Metadata []byte `protobuf:"bytes,6,opt,name=metadata,proto3" json:"metadata,omitempty"` // reported_height is the block height when the evidence was submitted. @@ -103,11 +131,11 @@ func (m *Evidence) GetActionId() string { return "" } -func (m *Evidence) GetEvidenceType() string { +func (m *Evidence) GetEvidenceType() EvidenceType { if m != nil { return m.EvidenceType } - return "" + return EvidenceType_EVIDENCE_TYPE_UNSPECIFIED } func (m *Evidence) GetMetadata() []byte { @@ -125,33 +153,39 @@ func (m *Evidence) GetReportedHeight() uint64 { } func init() { + proto.RegisterEnum("lumera.audit.v1.EvidenceType", EvidenceType_name, EvidenceType_value) proto.RegisterType((*Evidence)(nil), "lumera.audit.v1.Evidence") } func init() { proto.RegisterFile("lumera/audit/v1/evidence.proto", fileDescriptor_449f638e48abdbaa) } var fileDescriptor_449f638e48abdbaa = []byte{ - // 307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4e, 0x02, 0x31, - 0x10, 0x86, 0x29, 0x22, 0x42, 0x45, 0x20, 0x8d, 0x87, 0x8a, 0x49, 0x25, 0x7a, 0x90, 0x98, 0xc8, - 0x86, 0xf8, 0x04, 0x60, 0x4c, 0xe4, 0xba, 0x7a, 0xf2, 0xb2, 0x29, 0xdb, 0x09, 0xd4, 0x08, 0xdd, - 0xb4, 0x85, 0xc8, 0x5b, 0xf8, 0x30, 0x9e, 0x7c, 0x02, 0x8f, 0xc4, 0x93, 0x47, 0x03, 0x2f, 0x62, - 0xb6, 0xbb, 0x5d, 0x8f, 0x1e, 0xe7, 0xfb, 0xe7, 0xff, 0x3b, 0x9d, 0xc1, 0xec, 0x65, 0x39, 0x07, - 0xcd, 0x03, 0xbe, 0x14, 0xd2, 0x06, 0xab, 0x41, 0x00, 0x2b, 0x29, 0x60, 0x11, 0x43, 0x3f, 0xd1, - 0xca, 0x2a, 0xd2, 0xca, 0xf4, 0xbe, 0xd3, 0xfb, 0xab, 0x41, 0xe7, 0x24, 0x56, 0x66, 0xae, 0x4c, - 0xe4, 0xe4, 0x20, 0x2b, 0xb2, 0xde, 0xf3, 0x8f, 0x32, 0xae, 0xdd, 0xe5, 0x76, 0x72, 0x86, 0x0f, - 0x7d, 0x54, 0x24, 0x05, 0x45, 0x5d, 0xd4, 0xab, 0x84, 0xd8, 0xa3, 0xb1, 0x20, 0x43, 0xdc, 0x32, - 0xcb, 0xc9, 0x33, 0xc4, 0x36, 0xe2, 0x42, 0x68, 0x30, 0x86, 0x96, 0xbb, 0xa8, 0x57, 0x1f, 0xd1, - 0xaf, 0xf7, 0xeb, 0xe3, 0x3c, 0x78, 0x98, 0x29, 0x0f, 0x56, 0xcb, 0xc5, 0x34, 0x6c, 0xe6, 0x86, - 0x9c, 0x92, 0x5b, 0xdc, 0xd6, 0x90, 0x28, 0x6d, 0x41, 0x17, 0x19, 0x7b, 0xff, 0x64, 0xb4, 0xbc, - 0xc3, 0x87, 0x9c, 0xe2, 0x3a, 0x8f, 0xad, 0x54, 0x8b, 0x74, 0xcc, 0x4a, 0xea, 0x0e, 0x6b, 0x19, - 0x18, 0x0b, 0x72, 0x81, 0x8f, 0x8a, 0x5f, 0xd8, 0x75, 0x02, 0x74, 0xdf, 0x35, 0x34, 0x3c, 0x7c, - 0x5c, 0x27, 0x40, 0x3a, 0xb8, 0x36, 0x07, 0xcb, 0x05, 0xb7, 0x9c, 0x56, 0xbb, 0xa8, 0xd7, 0x08, - 0x8b, 0x9a, 0x5c, 0x62, 0xff, 0xa0, 0x88, 0x66, 0x20, 0xa7, 0x33, 0x4b, 0x0f, 0xdc, 0x2a, 0x9a, - 0x1e, 0xdf, 0x3b, 0x3a, 0xba, 0xfa, 0xdc, 0x32, 0xb4, 0xd9, 0x32, 0xf4, 0xb3, 0x65, 0xe8, 0x6d, - 0xc7, 0x4a, 0x9b, 0x1d, 0x2b, 0x7d, 0xef, 0x58, 0xe9, 0xa9, 0xfd, 0xfa, 0x77, 0x9d, 0x74, 0x06, - 0x33, 0xa9, 0xba, 0x7d, 0xdf, 0xfc, 0x06, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x5e, 0x78, 0x85, 0xbd, - 0x01, 0x00, 0x00, + // 399 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcf, 0xae, 0xd2, 0x40, + 0x14, 0xc6, 0x3b, 0x78, 0xbd, 0xc2, 0x88, 0xd0, 0x4c, 0x5c, 0x14, 0x94, 0xda, 0xb8, 0xa1, 0xc1, + 0xd8, 0x06, 0x7d, 0x82, 0x52, 0x06, 0x9d, 0xc4, 0x14, 0x52, 0xf0, 0x1f, 0x9b, 0x49, 0xe9, 0x4c, + 0xa0, 0x46, 0x68, 0xd3, 0x0e, 0x44, 0x12, 0x1f, 0xc2, 0x87, 0xf1, 0x21, 0x5c, 0x12, 0x57, 0xba, + 0x33, 0xf0, 0x22, 0xa6, 0xff, 0x10, 0x8d, 0xc9, 0x5d, 0x9e, 0xdf, 0x37, 0xdf, 0x37, 0xe7, 0x9c, + 0x1c, 0xa8, 0x7e, 0xdc, 0xae, 0x79, 0xec, 0x99, 0xde, 0x96, 0x05, 0xc2, 0xdc, 0xf5, 0x4d, 0xbe, + 0x0b, 0x18, 0xdf, 0xf8, 0xdc, 0x88, 0xe2, 0x50, 0x84, 0xa8, 0x99, 0xeb, 0x46, 0xa6, 0x1b, 0xbb, + 0x7e, 0xbb, 0xe5, 0x87, 0xc9, 0x3a, 0x4c, 0x68, 0x26, 0x9b, 0x79, 0x91, 0xbf, 0x7d, 0xfc, 0xb3, + 0x02, 0xab, 0xb8, 0xb0, 0xa3, 0x47, 0xf0, 0x6e, 0x19, 0x45, 0x03, 0xa6, 0x00, 0x0d, 0xe8, 0x57, + 0x2e, 0x2c, 0x11, 0x61, 0xc8, 0x82, 0xcd, 0x64, 0xbb, 0xf8, 0xc0, 0x7d, 0x41, 0x3d, 0xc6, 0x62, + 0x9e, 0x24, 0x4a, 0x45, 0x03, 0x7a, 0x6d, 0xa0, 0x7c, 0xff, 0xfa, 0xf4, 0x7e, 0x11, 0x6c, 0xe5, + 0xca, 0x54, 0xc4, 0xc1, 0x66, 0xe9, 0x36, 0x0a, 0x43, 0x41, 0x91, 0x0d, 0xe5, 0x98, 0x47, 0x61, + 0x2c, 0x78, 0x7c, 0xce, 0xb8, 0x75, 0x43, 0x46, 0xb3, 0x74, 0x94, 0x21, 0x0f, 0x60, 0xcd, 0xf3, + 0x45, 0x10, 0x6e, 0xd2, 0x36, 0xaf, 0x52, 0xb7, 0x5b, 0xcd, 0x01, 0x61, 0x68, 0x00, 0xef, 0x9d, + 0xa7, 0x10, 0xfb, 0x88, 0x2b, 0xb7, 0x35, 0xa0, 0x37, 0x9e, 0x75, 0x8c, 0x7f, 0xd6, 0x62, 0x94, + 0x73, 0xcf, 0xf6, 0x11, 0x77, 0xeb, 0xfc, 0xa2, 0x42, 0x6d, 0x58, 0x5d, 0x73, 0xe1, 0x31, 0x4f, + 0x78, 0xca, 0xb5, 0x06, 0xf4, 0xba, 0x7b, 0xae, 0x51, 0x17, 0x96, 0xfd, 0x30, 0xba, 0xe2, 0xc1, + 0x72, 0x25, 0x94, 0x3b, 0xd9, 0xa6, 0x1a, 0x25, 0x7e, 0x99, 0xd1, 0xde, 0x67, 0x58, 0xbf, 0xfc, + 0x02, 0x75, 0x60, 0x0b, 0xbf, 0x21, 0x43, 0xec, 0xd8, 0x98, 0xce, 0xde, 0x4f, 0x30, 0x7d, 0xed, + 0x4c, 0x27, 0xd8, 0x26, 0x23, 0x82, 0x87, 0xb2, 0x84, 0x9e, 0xc0, 0xee, 0xdf, 0xb2, 0x65, 0xcf, + 0xc8, 0xd8, 0xa1, 0x6f, 0xdd, 0xb1, 0xf3, 0x82, 0x8e, 0x88, 0x63, 0xbd, 0x22, 0x73, 0x2b, 0x45, + 0x32, 0x40, 0x1a, 0x7c, 0xf8, 0xdf, 0xc7, 0xf8, 0xdd, 0x84, 0xb8, 0x78, 0x28, 0x57, 0x06, 0xbd, + 0x6f, 0x47, 0x15, 0x1c, 0x8e, 0x2a, 0xf8, 0x75, 0x54, 0xc1, 0x97, 0x93, 0x2a, 0x1d, 0x4e, 0xaa, + 0xf4, 0xe3, 0xa4, 0x4a, 0x73, 0xf9, 0xd3, 0x9f, 0xd3, 0x49, 0x17, 0x94, 0x2c, 0xae, 0xb3, 0x63, + 0x78, 0xfe, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x70, 0x39, 0x05, 0x5a, 0x02, 0x00, 0x00, } func (m *Evidence) Marshal() (dAtA []byte, err error) { @@ -186,12 +220,10 @@ func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 } - if len(m.EvidenceType) > 0 { - i -= len(m.EvidenceType) - copy(dAtA[i:], m.EvidenceType) - i = encodeVarintEvidence(dAtA, i, uint64(len(m.EvidenceType))) + if m.EvidenceType != 0 { + i = encodeVarintEvidence(dAtA, i, uint64(m.EvidenceType)) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x28 } if len(m.ActionId) > 0 { i -= len(m.ActionId) @@ -254,9 +286,8 @@ func (m *Evidence) Size() (n int) { if l > 0 { n += 1 + l + sovEvidence(uint64(l)) } - l = len(m.EvidenceType) - if l > 0 { - n += 1 + l + sovEvidence(uint64(l)) + if m.EvidenceType != 0 { + n += 1 + sovEvidence(uint64(m.EvidenceType)) } l = len(m.Metadata) if l > 0 { @@ -419,10 +450,10 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { m.ActionId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EvidenceType", wireType) } - var stringLen uint64 + m.EvidenceType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvidence @@ -432,24 +463,11 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.EvidenceType |= EvidenceType(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvidence - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvidence - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EvidenceType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) diff --git a/x/audit/v1/types/tx.pb.go b/x/audit/v1/types/tx.pb.go index c4ad7206..51c52274 100644 --- a/x/audit/v1/types/tx.pb.go +++ b/x/audit/v1/types/tx.pb.go @@ -126,10 +126,10 @@ var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo // MsgSubmitEvidence defines the MsgSubmitEvidence message. type MsgSubmitEvidence struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - SubjectAddress string `protobuf:"bytes,2,opt,name=subject_address,json=subjectAddress,proto3" json:"subject_address,omitempty"` - EvidenceType string `protobuf:"bytes,3,opt,name=evidence_type,json=evidenceType,proto3" json:"evidence_type,omitempty"` - ActionId string `protobuf:"bytes,4,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + SubjectAddress string `protobuf:"bytes,2,opt,name=subject_address,json=subjectAddress,proto3" json:"subject_address,omitempty"` + EvidenceType EvidenceType `protobuf:"varint,3,opt,name=evidence_type,json=evidenceType,proto3,enum=lumera.audit.v1.EvidenceType" json:"evidence_type,omitempty"` + ActionId string `protobuf:"bytes,4,opt,name=action_id,json=actionId,proto3" json:"action_id,omitempty"` // metadata is JSON for the type-specific Evidence metadata message. // The chain stores protobuf-binary bytes derived from this JSON. Metadata string `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` @@ -182,11 +182,11 @@ func (m *MsgSubmitEvidence) GetSubjectAddress() string { return "" } -func (m *MsgSubmitEvidence) GetEvidenceType() string { +func (m *MsgSubmitEvidence) GetEvidenceType() EvidenceType { if m != nil { return m.EvidenceType } - return "" + return EvidenceType_EVIDENCE_TYPE_UNSPECIFIED } func (m *MsgSubmitEvidence) GetActionId() string { @@ -258,38 +258,39 @@ func init() { func init() { proto.RegisterFile("lumera/audit/v1/tx.proto", fileDescriptor_4b5ba410ad359f63) } var fileDescriptor_4b5ba410ad359f63 = []byte{ - // 494 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xce, 0xd1, 0x0f, 0x9a, 0x6b, 0x68, 0xe8, 0xa9, 0x52, 0x1c, 0x83, 0xdc, 0xc8, 0x2c, 0x91, - 0x25, 0x6c, 0x25, 0x48, 0x0c, 0x11, 0x4b, 0x23, 0x31, 0x74, 0x88, 0x84, 0x5c, 0x58, 0xba, 0x84, - 0x8b, 0xef, 0x64, 0x0e, 0x61, 0x9f, 0xe5, 0x3b, 0x47, 0xc9, 0x86, 0x18, 0x99, 0xf8, 0x19, 0x8c, - 0x19, 0x18, 0xf8, 0x09, 0x15, 0x53, 0xc5, 0xc4, 0x84, 0x50, 0x32, 0xe4, 0x1f, 0x30, 0x23, 0xfb, - 0xce, 0x2d, 0x75, 0x11, 0x59, 0x2c, 0xdf, 0xf3, 0x71, 0xef, 0xf3, 0xbe, 0x77, 0x07, 0x8d, 0x77, - 0x59, 0x44, 0x53, 0xec, 0xe1, 0x8c, 0x30, 0xe9, 0x4d, 0x7b, 0x9e, 0x9c, 0xb9, 0x49, 0xca, 0x25, - 0x47, 0x4d, 0xc5, 0xb8, 0x05, 0xe3, 0x4e, 0x7b, 0xe6, 0x21, 0x8e, 0x58, 0xcc, 0xbd, 0xe2, 0xab, - 0x34, 0x66, 0x2b, 0xe0, 0x22, 0xe2, 0xc2, 0x8b, 0x44, 0x98, 0x7b, 0x23, 0x11, 0x6a, 0xa2, 0xad, - 0x88, 0x71, 0xb1, 0xf2, 0xd4, 0x42, 0x53, 0x47, 0x21, 0x0f, 0xb9, 0xc2, 0xf3, 0x3f, 0x8d, 0x3e, - 0xac, 0xe6, 0x48, 0x70, 0x8a, 0x23, 0xed, 0xb1, 0xbf, 0x02, 0xd8, 0x1c, 0x89, 0xf0, 0x55, 0x42, - 0xb0, 0xa4, 0x2f, 0x0a, 0x06, 0x3d, 0x85, 0x75, 0x9c, 0xc9, 0x37, 0x3c, 0x65, 0x72, 0x6e, 0x80, - 0x0e, 0xe8, 0xd6, 0x87, 0xc6, 0xf7, 0x2f, 0x8f, 0x8f, 0x74, 0xb1, 0x13, 0x42, 0x52, 0x2a, 0xc4, - 0x99, 0x4c, 0x59, 0x1c, 0xfa, 0xd7, 0x52, 0x34, 0x80, 0xbb, 0x6a, 0x6f, 0xe3, 0x4e, 0x07, 0x74, - 0xf7, 0xfb, 0x2d, 0xb7, 0xd2, 0xa8, 0xab, 0x0a, 0x0c, 0xeb, 0x17, 0x3f, 0x8f, 0x6b, 0x9f, 0xd7, - 0x0b, 0x07, 0xf8, 0xda, 0x31, 0xe8, 0x7d, 0x58, 0x2f, 0x9c, 0xeb, 0xbd, 0x3e, 0xae, 0x17, 0x8e, - 0xa5, 0x83, 0xcf, 0x74, 0xf4, 0x4a, 0x4c, 0xbb, 0x0d, 0x5b, 0x15, 0xc8, 0xa7, 0x22, 0xe1, 0xb1, - 0xa0, 0xf6, 0x6f, 0x00, 0x0f, 0x47, 0x22, 0x3c, 0xcb, 0x26, 0x11, 0x93, 0xcf, 0xa7, 0x8c, 0xd0, - 0x38, 0xa0, 0xa8, 0x0f, 0xef, 0x06, 0x29, 0xc5, 0x92, 0xa7, 0x1b, 0xbb, 0x2a, 0x85, 0xe8, 0x04, - 0x36, 0x45, 0x36, 0x79, 0x4b, 0x03, 0x39, 0xc6, 0x4a, 0x51, 0x34, 0xf7, 0x3f, 0xef, 0x81, 0x36, - 0x68, 0x14, 0x3d, 0x82, 0xf7, 0xa8, 0x8e, 0x30, 0x96, 0xf3, 0x84, 0x1a, 0x5b, 0xf9, 0x06, 0x7e, - 0xa3, 0x04, 0x5f, 0xce, 0x13, 0x8a, 0x1e, 0xc0, 0x3a, 0x0e, 0x24, 0xe3, 0xf1, 0x98, 0x11, 0x63, - 0xbb, 0x10, 0xec, 0x29, 0xe0, 0x94, 0x20, 0x13, 0xee, 0x45, 0x54, 0x62, 0x82, 0x25, 0x36, 0x76, - 0x14, 0x57, 0xae, 0x07, 0x8d, 0x7c, 0x70, 0x65, 0x5c, 0xfb, 0x19, 0x6c, 0xdf, 0xea, 0xbb, 0x9c, - 0x0a, 0x3a, 0x86, 0xfb, 0x57, 0x41, 0x18, 0x29, 0x66, 0xb0, 0xed, 0xc3, 0x12, 0x3a, 0x25, 0xfd, - 0x6f, 0x00, 0x6e, 0x8d, 0x44, 0x88, 0xce, 0x61, 0xe3, 0xc6, 0x85, 0xe8, 0xdc, 0x3a, 0xc8, 0xca, - 0xe0, 0xcd, 0xee, 0x26, 0xc5, 0x55, 0x88, 0xd7, 0xf0, 0xa0, 0x72, 0x2c, 0xf6, 0xbf, 0xbc, 0x37, - 0x35, 0xa6, 0xb3, 0x59, 0x53, 0x56, 0x30, 0x77, 0xde, 0xe7, 0x37, 0x6b, 0xe8, 0x5c, 0x2c, 0x2d, - 0x70, 0xb9, 0xb4, 0xc0, 0xaf, 0xa5, 0x05, 0x3e, 0xad, 0xac, 0xda, 0xe5, 0xca, 0xaa, 0xfd, 0x58, - 0x59, 0xb5, 0xf3, 0xfb, 0xb3, 0xbf, 0x1e, 0xe5, 0x3c, 0xa1, 0x62, 0xb2, 0x5b, 0x3c, 0x86, 0x27, - 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x1a, 0x37, 0xed, 0xb4, 0x03, 0x00, 0x00, + // 510 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x3f, 0x8f, 0xd3, 0x30, + 0x1c, 0xad, 0xef, 0x1f, 0x57, 0x5f, 0x69, 0x39, 0xeb, 0xa4, 0xa6, 0x01, 0x72, 0x55, 0xa6, 0x2a, + 0x12, 0x89, 0x5a, 0x24, 0x86, 0x8a, 0xe5, 0x2a, 0x31, 0xdc, 0x50, 0x09, 0xe5, 0x60, 0xb9, 0xa5, + 0xb8, 0xb1, 0x15, 0x82, 0x48, 0x1c, 0xc5, 0x4e, 0xd5, 0x6e, 0x88, 0x91, 0x89, 0x85, 0xef, 0xc0, + 0xd8, 0x81, 0x81, 0x8f, 0x70, 0x62, 0x3a, 0x31, 0x31, 0x21, 0xd4, 0x0e, 0xfd, 0x1a, 0x28, 0xb1, + 0x73, 0x77, 0x4d, 0x11, 0x5d, 0xa2, 0xfc, 0xde, 0x7b, 0x3f, 0xfb, 0xfd, 0x9e, 0x6d, 0xa8, 0xbd, + 0x4f, 0x43, 0x9a, 0x60, 0x07, 0xa7, 0x24, 0x10, 0xce, 0xa4, 0xeb, 0x88, 0xa9, 0x1d, 0x27, 0x4c, + 0x30, 0xd4, 0x90, 0x8c, 0x9d, 0x33, 0xf6, 0xa4, 0xab, 0x1f, 0xe3, 0x30, 0x88, 0x98, 0x93, 0x7f, + 0xa5, 0x46, 0x6f, 0x7a, 0x8c, 0x87, 0x8c, 0x3b, 0x21, 0xf7, 0xb3, 0xde, 0x90, 0xfb, 0x8a, 0x68, + 0x49, 0x62, 0x94, 0x57, 0x8e, 0x2c, 0x14, 0x75, 0xe2, 0x33, 0x9f, 0x49, 0x3c, 0xfb, 0x53, 0xa8, + 0x51, 0xf6, 0x41, 0x27, 0x01, 0xa1, 0x91, 0x47, 0x15, 0xff, 0xa8, 0xcc, 0xc7, 0x38, 0xc1, 0xa1, + 0x5a, 0xd3, 0xfc, 0x0e, 0x60, 0x63, 0xc8, 0xfd, 0xd7, 0x31, 0xc1, 0x82, 0xbe, 0xcc, 0x19, 0xf4, + 0x0c, 0x56, 0x71, 0x2a, 0xde, 0xb2, 0x24, 0x10, 0x33, 0x0d, 0xb4, 0x41, 0xa7, 0x3a, 0xd0, 0x7e, + 0x7e, 0x7b, 0x72, 0xa2, 0xcc, 0x9c, 0x11, 0x92, 0x50, 0xce, 0x2f, 0x44, 0x12, 0x44, 0xbe, 0x7b, + 0x2b, 0x45, 0x7d, 0x78, 0x20, 0xd7, 0xd6, 0x76, 0xda, 0xa0, 0x73, 0xd4, 0x6b, 0xda, 0xa5, 0x20, + 0x6c, 0xb9, 0xc1, 0xa0, 0x7a, 0xf5, 0xfb, 0xb4, 0xf2, 0x75, 0x35, 0xb7, 0x80, 0xab, 0x3a, 0xfa, + 0xdd, 0x8f, 0xab, 0xb9, 0x75, 0xbb, 0xd6, 0xa7, 0xd5, 0xdc, 0x2a, 0x06, 0x9b, 0x2a, 0xeb, 0x25, + 0x9b, 0x66, 0x0b, 0x36, 0x4b, 0x90, 0x4b, 0x79, 0xcc, 0x22, 0x4e, 0xcd, 0x2f, 0x3b, 0xf0, 0x78, + 0xc8, 0xfd, 0x8b, 0x74, 0x1c, 0x06, 0xe2, 0x85, 0xca, 0x03, 0xf5, 0xe0, 0x3d, 0x2f, 0xa1, 0x58, + 0xb0, 0x64, 0xeb, 0x54, 0x85, 0x10, 0x9d, 0xc1, 0x06, 0x4f, 0xc7, 0xef, 0xa8, 0x27, 0x46, 0x58, + 0x2a, 0xf2, 0xe1, 0xfe, 0xd7, 0x5b, 0x57, 0x0d, 0x0a, 0x45, 0x03, 0x78, 0xbf, 0x38, 0x92, 0x91, + 0x98, 0xc5, 0x54, 0xdb, 0x6d, 0x83, 0x4e, 0xbd, 0xf7, 0x78, 0x23, 0x9d, 0xc2, 0xe8, 0xab, 0x59, + 0x4c, 0xdd, 0x1a, 0xbd, 0x53, 0xa1, 0x87, 0xb0, 0x8a, 0x3d, 0x11, 0xb0, 0x68, 0x14, 0x10, 0x6d, + 0x2f, 0x33, 0xe0, 0x1e, 0x4a, 0xe0, 0x9c, 0x20, 0x1d, 0x1e, 0x86, 0x54, 0x60, 0x82, 0x05, 0xd6, + 0xf6, 0x25, 0x57, 0xd4, 0xfd, 0x5a, 0x96, 0x6b, 0x31, 0x8d, 0xf9, 0x1c, 0xb6, 0x36, 0x62, 0x29, + 0x42, 0x43, 0xa7, 0xf0, 0xe8, 0xc6, 0x67, 0x40, 0xf2, 0x88, 0xf6, 0x5c, 0x58, 0x40, 0xe7, 0xa4, + 0xf7, 0x03, 0xc0, 0xdd, 0x21, 0xf7, 0xd1, 0x25, 0xac, 0xad, 0xdd, 0x97, 0xf6, 0xc6, 0x24, 0xa5, + 0x73, 0xd1, 0x3b, 0xdb, 0x14, 0x37, 0x26, 0xde, 0xc0, 0x7a, 0xe9, 0xd4, 0xcc, 0x7f, 0xf5, 0xae, + 0x6b, 0x74, 0x6b, 0xbb, 0xa6, 0xd8, 0x41, 0xdf, 0xff, 0x90, 0x5d, 0xbc, 0x81, 0x75, 0xb5, 0x30, + 0xc0, 0xf5, 0xc2, 0x00, 0x7f, 0x16, 0x06, 0xf8, 0xbc, 0x34, 0x2a, 0xd7, 0x4b, 0xa3, 0xf2, 0x6b, + 0x69, 0x54, 0x2e, 0x1f, 0x4c, 0xef, 0xbc, 0xe9, 0x59, 0x4c, 0xf9, 0xf8, 0x20, 0x7f, 0x2b, 0x4f, + 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x41, 0x92, 0x2e, 0xf3, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -512,12 +513,10 @@ func (m *MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if len(m.EvidenceType) > 0 { - i -= len(m.EvidenceType) - copy(dAtA[i:], m.EvidenceType) - i = encodeVarintTx(dAtA, i, uint64(len(m.EvidenceType))) + if m.EvidenceType != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.EvidenceType)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x18 } if len(m.SubjectAddress) > 0 { i -= len(m.SubjectAddress) @@ -613,9 +612,8 @@ func (m *MsgSubmitEvidence) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.EvidenceType) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.EvidenceType != 0 { + n += 1 + sovTx(uint64(m.EvidenceType)) } l = len(m.ActionId) if l > 0 { @@ -905,10 +903,10 @@ func (m *MsgSubmitEvidence) Unmarshal(dAtA []byte) error { m.SubjectAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EvidenceType", wireType) } - var stringLen uint64 + m.EvidenceType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -918,24 +916,11 @@ func (m *MsgSubmitEvidence) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.EvidenceType |= EvidenceType(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.EvidenceType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ActionId", wireType)