diff --git a/app/app.go b/app/app.go index a1489ad06..98ed9aec4 100644 --- a/app/app.go +++ b/app/app.go @@ -120,6 +120,7 @@ import ( disputemodule "github.com/tellor-io/layer/x/dispute" disputemodulekeeper "github.com/tellor-io/layer/x/dispute/keeper" disputemoduletypes "github.com/tellor-io/layer/x/dispute/types" + // this line is used by starport scaffolding # stargate/app/moduleImport appparams "github.com/tellor-io/layer/app/params" @@ -197,6 +198,7 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, oraclemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, + disputemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, // this line is used by starport scaffolding # stargate/app/maccPerms } ) @@ -562,9 +564,11 @@ func New( keys[disputemoduletypes.MemStoreKey], app.GetSubspace(disputemoduletypes.ModuleName), + app.BankKeeper, + app.OracleKeeper, app.StakingKeeper, ) - disputeModule := disputemodule.NewAppModule(appCodec, app.DisputeKeeper, app.AccountKeeper, app.BankKeeper) + disputeModule := disputemodule.NewAppModule(appCodec, app.DisputeKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper) // this line is used by starport scaffolding # stargate/app/keeperDefinition diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index be2f40ed4..64cf0a4bc 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -46437,6 +46437,200 @@ paths: } tags: - Query + /tellor-io/layer/dispute/get_dispute_by_id/{id}: + get: + summary: Queries a list of GetDisputeById items. + operationId: LayerDisputeGetDisputeById + responses: + '200': + description: A successful response. + schema: + type: object + properties: + dispute: + type: object + properties: + hashId: + type: string + format: byte + title: represents the hash of Report+category + disputeId: + type: string + format: uint64 + category: + type: string + enum: + - INVALID + - WARNING + - MINOR + - MAJOR + default: INVALID + disputeFee: + type: string + format: uint64 + burnAmount: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + startTime: + type: string + format: int64 + endTime: + type: string + format: int64 + block: + type: string + format: int64 + status: + type: string + enum: + - PREVOTE + - VOTING + - RESOLVED + - UNRESOLVED + - FAILED + default: PREVOTE + title: |- + - PREVOTE: CURRENTLY IN WAITING PERIOD + - VOTING: VOTING IN PROGRESS + - RESOLVED: VOTING CONCLUDED AND QUORUM REACHED + - UNRESOLVED: VOTING FAILED TO REACH QUORUM + - FAILED: FEES NOT MET TO BEGIN VOTING + report: + type: object + properties: + reporter: + type: string + qid: + type: string + value: + type: string + timestamp: + type: string + format: uint64 + feePayers: + type: array + items: + type: object + properties: + disputer: + type: string + format: byte + title: sdk.AccAddress type + amount: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + feeTotal: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + round: + type: string + format: uint64 + prevDisputeIds: + type: array + items: + type: string + format: uint64 + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: id + in: path + required: true + type: string + format: uint64 + tags: + - Query + /tellor-io/layer/dispute/get_open_disputes: + get: + summary: Queries a list of GetOpenDisputes items. + operationId: LayerDisputeGetOpenDisputes + responses: + '200': + description: A successful response. + schema: + type: object + properties: + openDisputes: + type: object + properties: + disputes: + type: array + items: + type: string + format: uint64 + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query /tellor-io/layer/dispute/params: get: summary: Parameters queries the parameters of the module. @@ -75518,9 +75712,319 @@ definitions: description: |- Version defines the versioning scheme used to negotiate the IBC verison in the connection handshake. + layer.dispute.Dispute: + type: object + properties: + hashId: + type: string + format: byte + title: represents the hash of Report+category + disputeId: + type: string + format: uint64 + category: + type: string + enum: + - INVALID + - WARNING + - MINOR + - MAJOR + default: INVALID + disputeFee: + type: string + format: uint64 + burnAmount: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + startTime: + type: string + format: int64 + endTime: + type: string + format: int64 + block: + type: string + format: int64 + status: + type: string + enum: + - PREVOTE + - VOTING + - RESOLVED + - UNRESOLVED + - FAILED + default: PREVOTE + title: |- + - PREVOTE: CURRENTLY IN WAITING PERIOD + - VOTING: VOTING IN PROGRESS + - RESOLVED: VOTING CONCLUDED AND QUORUM REACHED + - UNRESOLVED: VOTING FAILED TO REACH QUORUM + - FAILED: FEES NOT MET TO BEGIN VOTING + report: + type: object + properties: + reporter: + type: string + qid: + type: string + value: + type: string + timestamp: + type: string + format: uint64 + feePayers: + type: array + items: + type: object + properties: + disputer: + type: string + format: byte + title: sdk.AccAddress type + amount: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + feeTotal: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + round: + type: string + format: uint64 + prevDisputeIds: + type: array + items: + type: string + format: uint64 + layer.dispute.DisputeCategory: + type: string + enum: + - INVALID + - WARNING + - MINOR + - MAJOR + default: INVALID + layer.dispute.DisputeStatus: + type: string + enum: + - PREVOTE + - VOTING + - RESOLVED + - UNRESOLVED + - FAILED + default: PREVOTE + title: |- + - PREVOTE: CURRENTLY IN WAITING PERIOD + - VOTING: VOTING IN PROGRESS + - RESOLVED: VOTING CONCLUDED AND QUORUM REACHED + - UNRESOLVED: VOTING FAILED TO REACH QUORUM + - FAILED: FEES NOT MET TO BEGIN VOTING + layer.dispute.MicroReport: + type: object + properties: + reporter: + type: string + qid: + type: string + value: + type: string + timestamp: + type: string + format: uint64 + layer.dispute.MsgProposeDisputeResponse: + type: object + layer.dispute.OpenDisputes: + type: object + properties: + disputes: + type: array + items: + type: string + format: uint64 layer.dispute.Params: type: object description: Params defines the parameters for the module. + layer.dispute.PaymentInfo: + type: object + properties: + disputer: + type: string + format: byte + title: sdk.AccAddress type + amount: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + layer.dispute.QueryGetDisputeByIdResponse: + type: object + properties: + dispute: + type: object + properties: + hashId: + type: string + format: byte + title: represents the hash of Report+category + disputeId: + type: string + format: uint64 + category: + type: string + enum: + - INVALID + - WARNING + - MINOR + - MAJOR + default: INVALID + disputeFee: + type: string + format: uint64 + burnAmount: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + startTime: + type: string + format: int64 + endTime: + type: string + format: int64 + block: + type: string + format: int64 + status: + type: string + enum: + - PREVOTE + - VOTING + - RESOLVED + - UNRESOLVED + - FAILED + default: PREVOTE + title: |- + - PREVOTE: CURRENTLY IN WAITING PERIOD + - VOTING: VOTING IN PROGRESS + - RESOLVED: VOTING CONCLUDED AND QUORUM REACHED + - UNRESOLVED: VOTING FAILED TO REACH QUORUM + - FAILED: FEES NOT MET TO BEGIN VOTING + report: + type: object + properties: + reporter: + type: string + qid: + type: string + value: + type: string + timestamp: + type: string + format: uint64 + feePayers: + type: array + items: + type: object + properties: + disputer: + type: string + format: byte + title: sdk.AccAddress type + amount: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + feeTotal: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + round: + type: string + format: uint64 + prevDisputeIds: + type: array + items: + type: string + format: uint64 + layer.dispute.QueryGetOpenDisputesResponse: + type: object + properties: + openDisputes: + type: object + properties: + disputes: + type: array + items: + type: string + format: uint64 layer.dispute.QueryParamsResponse: type: object properties: diff --git a/go.mod b/go.mod index aebe1b298..3f6a40814 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.19 require ( cosmossdk.io/api v0.3.1 + cosmossdk.io/math v1.0.1 github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-sdk v0.47.3 @@ -18,7 +19,6 @@ require ( github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 google.golang.org/grpc v1.56.2 gopkg.in/yaml.v2 v2.4.0 @@ -34,7 +34,6 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 // indirect cosmossdk.io/errors v1.0.0 // indirect cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca // indirect - cosmossdk.io/math v1.0.1 // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -155,6 +154,7 @@ require ( go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect + golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/net v0.12.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect golang.org/x/sync v0.3.0 // indirect diff --git a/proto/layer/dispute/dispute.proto b/proto/layer/dispute/dispute.proto index e02ceb4c3..88c9a3dae 100644 --- a/proto/layer/dispute/dispute.proto +++ b/proto/layer/dispute/dispute.proto @@ -12,15 +12,16 @@ message Dispute { uint64 disputeId = 2; DisputeCategory category = 3; uint64 disputeFee = 4; - uint64 startTime = 5; - uint64 endTime = 6; - uint64 block = 7; - DisputeStatus status = 8; - MicroReport report = 9; - repeated PaymentInfo feePayers = 10 [(gogoproto.nullable) = false]; - cosmos.base.v1beta1.Coin feeTotal = 11 [(gogoproto.nullable) = false]; - uint64 round = 12; - repeated uint64 prevDisputeIds = 13; + cosmos.base.v1beta1.Coin burnAmount = 5 [(gogoproto.nullable) = false]; + int64 startTime = 6; + int64 endTime = 7; + int64 block = 8; + DisputeStatus status = 9; + MicroReport report = 10; + repeated PaymentInfo feePayers = 11 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin feeTotal = 12 [(gogoproto.nullable) = false]; + uint64 round = 13; + repeated uint64 prevDisputeIds = 14; } enum DisputeCategory { diff --git a/proto/layer/dispute/open_disputes.proto b/proto/layer/dispute/open_disputes.proto new file mode 100644 index 000000000..aab1411f5 --- /dev/null +++ b/proto/layer/dispute/open_disputes.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package layer.dispute; + +option go_package = "github.com/tellor-io/layer/x/dispute/types"; + +message OpenDisputes { + + repeated uint64 disputes = 1; +} diff --git a/proto/layer/dispute/query.proto b/proto/layer/dispute/query.proto index cbd23f277..c0cd7519a 100644 --- a/proto/layer/dispute/query.proto +++ b/proto/layer/dispute/query.proto @@ -1,26 +1,58 @@ syntax = "proto3"; + package layer.dispute; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "layer/dispute/params.proto"; +import "layer/dispute/open_disputes.proto"; +import "layer/dispute/dispute.proto"; option go_package = "github.com/tellor-io/layer/x/dispute/types"; // Query defines the gRPC querier service. service Query { + // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/tellor-io/layer/dispute/params"; + + } + + // Queries a list of GetOpenDisputes items. + rpc GetOpenDisputes (QueryGetOpenDisputesRequest) returns (QueryGetOpenDisputesResponse) { + option (google.api.http).get = "/tellor-io/layer/dispute/get_open_disputes"; + + } + + // Queries a list of GetDisputeById items. + rpc GetDisputeById (QueryGetDisputeByIdRequest) returns (QueryGetDisputeByIdResponse) { + option (google.api.http).get = "/tellor-io/layer/dispute/get_dispute_by_id/{id}"; + } } - // 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]; -} \ No newline at end of file +} + +message QueryGetOpenDisputesRequest {} + +message QueryGetOpenDisputesResponse { + OpenDisputes openDisputes = 1; +} + +message QueryGetDisputeByIdRequest { + uint64 id = 1; +} + +message QueryGetDisputeByIdResponse { + Dispute dispute = 1; +} + diff --git a/proto/layer/dispute/tx.proto b/proto/layer/dispute/tx.proto index cc71628c5..6d997da5b 100644 --- a/proto/layer/dispute/tx.proto +++ b/proto/layer/dispute/tx.proto @@ -1,7 +1,24 @@ syntax = "proto3"; + package layer.dispute; +import "gogoproto/gogo.proto"; +import "layer/dispute/dispute.proto"; +import "cosmos/base/v1beta1/coin.proto"; + option go_package = "github.com/tellor-io/layer/x/dispute/types"; // Msg defines the Msg service. -service Msg {} \ No newline at end of file +service Msg { + rpc ProposeDispute (MsgProposeDispute) returns (MsgProposeDisputeResponse); +} +message MsgProposeDispute { + string creator = 1; + MicroReport report = 2; + DisputeCategory category = 3; + cosmos.base.v1beta1.Coin fee = 4 [(gogoproto.nullable) = false]; + bool payFromBond = 5; // optional, where funds come from +} + +message MsgProposeDisputeResponse {} + diff --git a/x/dispute/client/cli/query.go b/x/dispute/client/cli/query.go index f016bbeec..c90288f33 100644 --- a/x/dispute/client/cli/query.go +++ b/x/dispute/client/cli/query.go @@ -25,6 +25,10 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdGetOpenDisputes()) + + cmd.AddCommand(CmdGetDisputeById()) + // this line is used by starport scaffolding # 1 return cmd diff --git a/x/dispute/client/cli/query_get_dispute_by_id.go b/x/dispute/client/cli/query_get_dispute_by_id.go new file mode 100644 index 000000000..e549f1610 --- /dev/null +++ b/x/dispute/client/cli/query_get_dispute_by_id.go @@ -0,0 +1,50 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cast" + "github.com/spf13/cobra" + "github.com/tellor-io/layer/x/dispute/types" +) + +var _ = strconv.Itoa(0) + +func CmdGetDisputeById() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-dispute-by-id [id]", + Short: "Query getDisputeById", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqId, err := cast.ToUint64E(args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetDisputeByIdRequest{ + + Id: reqId, + } + + res, err := queryClient.GetDisputeById(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dispute/client/cli/query_get_open_disputes.go b/x/dispute/client/cli/query_get_open_disputes.go new file mode 100644 index 000000000..dd5dce211 --- /dev/null +++ b/x/dispute/client/cli/query_get_open_disputes.go @@ -0,0 +1,42 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/tellor-io/layer/x/dispute/types" +) + +var _ = strconv.Itoa(0) + +func CmdGetOpenDisputes() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-open-disputes", + Short: "Query getOpenDisputes", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetOpenDisputesRequest{} + + res, err := queryClient.GetOpenDisputes(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dispute/client/cli/tx.go b/x/dispute/client/cli/tx.go index f675ca7ea..695197a72 100644 --- a/x/dispute/client/cli/tx.go +++ b/x/dispute/client/cli/tx.go @@ -30,6 +30,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdProposeDispute()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/dispute/client/cli/tx_propose_dispute.go b/x/dispute/client/cli/tx_propose_dispute.go new file mode 100644 index 000000000..82d5a0b6c --- /dev/null +++ b/x/dispute/client/cli/tx_propose_dispute.go @@ -0,0 +1,62 @@ +package cli + +import ( + "strconv" + + "encoding/json" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cast" + "github.com/spf13/cobra" + "github.com/tellor-io/layer/x/dispute/types" +) + +var _ = strconv.Itoa(0) + +func CmdProposeDispute() *cobra.Command { + cmd := &cobra.Command{ + Use: "propose-dispute [report] [category] [fee]", + Short: "Broadcast message proposeDispute", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argReport := new(types.MicroReport) + err = json.Unmarshal([]byte(args[0]), argReport) + if err != nil { + return err + } + argCategory := types.DisputeCategory(cast.ToInt32(args[1])) + argFee, err := sdk.ParseCoinNormalized(args[2]) + if err != nil { + return err + } + argPayOption, err := strconv.ParseBool(args[3]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgProposeDispute( + clientCtx.GetFromAddress().String(), + argReport, + argCategory, + argFee, + argPayOption, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dispute/keeper/keeper.go b/x/dispute/keeper/keeper.go index 7136962a3..532dd58f4 100644 --- a/x/dispute/keeper/keeper.go +++ b/x/dispute/keeper/keeper.go @@ -1,14 +1,16 @@ package keeper import ( + "encoding/binary" "fmt" + "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/tellor-io/layer/x/dispute/types" ) @@ -19,6 +21,8 @@ type ( memKey storetypes.StoreKey paramstore paramtypes.Subspace + bankkeeper types.BankKeeper + oracleKeeper types.OracleKeeper stakingKeeper types.StakingKeeper } ) @@ -29,6 +33,8 @@ func NewKeeper( memKey storetypes.StoreKey, ps paramtypes.Subspace, + bankkeeper types.BankKeeper, + oracleKeeper types.OracleKeeper, stakingKeeper types.StakingKeeper, ) *Keeper { // set KeyTable if it has not already been set @@ -42,6 +48,8 @@ func NewKeeper( memKey: memKey, paramstore: ps, + bankkeeper: bankkeeper, + oracleKeeper: oracleKeeper, stakingKeeper: stakingKeeper, } } @@ -49,3 +57,70 @@ func NewKeeper( func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +func (k Keeper) moduleStore(ctx sdk.Context) prefix.Store { + return prefix.NewStore(ctx.KVStore(k.storeKey), disputeKeyBytes()) +} + +func (k Keeper) accAddress(addy string) sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(addy) + if err != nil { + panic(err) + } + return addr +} + +func (k Keeper) disputeFee(ctx sdk.Context, stake math.LegacyDec, category types.DisputeCategory) (fee math.LegacyDec, err error) { + switch category { + case types.DisputeCategory_WARNING: + // calculate 1 percent of bond + multiplier, _ := sdk.NewDecFromStr("0.01") + fee = stake.Mul(multiplier) + case types.DisputeCategory_MINOR: + // calculate 5 percent of bond + multiplier, _ := sdk.NewDecFromStr("0.05") + fee = stake.Mul(multiplier) + case types.DisputeCategory_MAJOR: + // calculate 100 percent of bond + fee = stake + default: + err = fmt.Errorf("invalid dispute category") + fee = math.LegacyZeroDec() + } + return fee, err +} + +func (k Keeper) SetDisputeCount(ctx sdk.Context, count uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.KeyPrefix(types.DisputeKey) + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, count) + store.Set(byteKey, bz) +} + +func (k Keeper) GetDisputesCount(ctx sdk.Context) uint64 { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{}) + byteKey := types.KeyPrefix(types.DisputeKey) + bz := store.Get(byteKey) + if bz == nil { + return 1 // start disputes from id 1 + } + return binary.BigEndian.Uint64(bz) +} + +func disputeKeyBytes() []byte { + return types.KeyPrefix(types.DisputeKey) +} + +func disputeIdBytes(id uint64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, id) + return bz +} + +func openDisputesKeyBytes() []byte { + return types.KeyPrefix(types.OpenDisputesKey) +} +func reporterKeyBytes(key string) []byte { + return types.KeyPrefix(key) +} diff --git a/x/dispute/keeper/msg_server_propose_dispute.go b/x/dispute/keeper/msg_server_propose_dispute.go new file mode 100644 index 000000000..a64f1552a --- /dev/null +++ b/x/dispute/keeper/msg_server_propose_dispute.go @@ -0,0 +1,196 @@ +package keeper + +import ( + "context" + "crypto/sha256" + "fmt" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/tellor-io/layer/x/dispute/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k msgServer) ProposeDispute(goCtx context.Context, msg *types.MsgProposeDispute) (*types.MsgProposeDisputeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + cat := msg.Category + reporter := msg.Report.Reporter + params := types.DisputeParams{ + Report: *msg.Report, + Category: cat, + } + hashId := sha256.Sum256(k.cdc.MustMarshal(¶ms)) + reporterKey := fmt.Sprintf("%s:%x", reporter, hashId) + disputeId := k.GetDisputesCount(ctx) + msgSender := k.accAddress(msg.Creator) + + feeList := make([]types.PaymentInfo, 0) + feePaid := types.PaymentInfo{ + Disputer: msgSender, + Amount: msg.Fee, + } + // get dispute by reporter + var dispute types.Dispute + disputeBytes := k.disputeBytes(ctx, reporterKey) + if disputeBytes == nil { + reporterAccount := k.accAddress(reporter) + // get reporter stake + reporterStake := k.oracleKeeper.GetTotalReporterBond(ctx, reporterAccount) + disputeFee, err := k.disputeFee(ctx, reporterStake, cat) + if err != nil { + return nil, err + } + // create new dispute + status := func() types.DisputeStatus { + if disputeFee.GTE(math.LegacyDec(msg.Fee.Amount)) { + return types.DisputeStatus_PREVOTE + } else { + // slashReporter + return types.DisputeStatus_VOTING + } + } + percent := sdk.NewDecWithPrec(5, 2) + dispute = types.Dispute{ + HashId: hashId[:], + DisputeId: disputeId, + Category: cat, + DisputeFee: disputeFee.BigInt().Uint64(), + StartTime: ctx.BlockTime().Unix(), + Block: ctx.BlockHeight(), + Status: status(), + Report: msg.Report, + FeePayers: append(feeList, feePaid), + FeeTotal: sdk.NewCoin(sdk.DefaultBondDenom, msg.Fee.Amount), + Round: 1, + // burnamount is 5 percent of the dispute fee, change to 2.5 + BurnAmount: sdk.NewCoin(sdk.DefaultBondDenom, disputeFee.Mul(percent).TruncateInt()), + } + } else { + // TODO: remove this else case to its own msg function since fee isn't paid in second round + k.cdc.Unmarshal(disputeBytes, &dispute) + burnAmount := dispute.BurnAmount.Amount.Mul(sdk.NewInt(2)) + // if burn amount is greater than fee then we can't start a new round + if burnAmount.GTE(math.NewIntFromUint64(dispute.DisputeFee)) { + return nil, status.Error(codes.InvalidArgument, "burn amount is greater than dispute fee") + } + switch dispute.Status { + case types.DisputeStatus_UNRESOLVED: + // dispute failed to reach quorum so lets start a new round + if ctx.BlockTime().Unix() > dispute.EndTime+86400 { + return nil, status.Error(codes.InvalidArgument, "sorry missed the deadline to start another round") + } + dispute.Round += 1 + dispute.PrevDisputeIds = append(dispute.PrevDisputeIds, dispute.DisputeId) + dispute.DisputeId = disputeId // new dispute id + dispute.Status = types.DisputeStatus_PREVOTE + dispute.StartTime = ctx.BlockTime().Unix() + dispute.EndTime = 0 // reset end time to 0 + dispute.Block = ctx.BlockHeight() + // burn amount doubles every round + dispute.BurnAmount = sdk.NewCoin(sdk.DefaultBondDenom, burnAmount) + default: + // when dispute is in prevote, voting, resolved, or failed status + // we can't start a new round + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("dispute in %s can not start new round", dispute.Status)) + } + } + + if !msg.PayFromBond { + if err := k.lockTokensFromAccount(ctx, msgSender, msg.Fee); err != nil { + panic(err) + } + } else { + if err := k.lockTokensFromBond(ctx, msgSender, msg.Fee); err != nil { + panic(err) + } + } + if err := k.setDispute(ctx, &dispute); err != nil { + panic(err) + } + return &types.MsgProposeDisputeResponse{}, nil +} + +func (k Keeper) disputeBytes(ctx sdk.Context, reporterKey string) []byte { + store := k.moduleStore(ctx) + return store.Get(reporterKeyBytes(reporterKey)) +} + +func (k Keeper) setDispute(ctx sdk.Context, dispute *types.Dispute) error { + store := k.moduleStore(ctx) + + reporterKey := fmt.Sprintf("%s:%x", dispute.Report.Reporter, dispute.HashId) + + openDisputes, _ := k.GetOpenDisputes(ctx, &types.QueryGetOpenDisputesRequest{}) + openDisputes.OpenDisputes.Disputes = append(openDisputes.OpenDisputes.Disputes, dispute.DisputeId) + + k.SetDisputeCount(ctx, dispute.DisputeId+1) + store.Set(openDisputesKeyBytes(), k.cdc.MustMarshal(openDisputes.OpenDisputes)) + store.Set(disputeIdBytes(dispute.DisputeId), k.cdc.MustMarshal(dispute)) + store.Set(reporterKeyBytes(reporterKey), k.cdc.MustMarshal(dispute)) + return nil +} + +func (k Keeper) lockTokensFromAccount(ctx sdk.Context, payer sdk.AccAddress, fee sdk.Coin) error { + // check if sender has enough balance + if !k.bankkeeper.HasBalance(ctx, payer, fee) { + return status.Error(codes.InvalidArgument, "sender does not have enough balance") + } + if err := k.bankkeeper.SendCoinsFromAccountToModule(ctx, payer, types.ModuleName, sdk.NewCoins(fee)); err != nil { + return status.Error(codes.Internal, fmt.Sprintf("failed to send coins: %v", err)) + } + return nil +} + +type UndelegatedInfo struct { + ValidatorAddress sdk.ValAddress + Amount math.LegacyDec +} + +func (k Keeper) lockTokensFromBond(ctx sdk.Context, payer sdk.AccAddress, fee sdk.Coin) error { + var undelegatedInfos []UndelegatedInfo + amount := math.LegacyDec(fee.Amount) + remainingAmount := amount + k.stakingKeeper.IterateDelegatorDelegations(ctx, payer, func(delegation stakingtypes.Delegation) (stop bool) { + + validator, found := k.stakingKeeper.GetValidator(ctx, sdk.ValAddress(delegation.ValidatorAddress)) + + if !found { + return false + } + if remainingAmount.IsZero() { + return true // Break + } + if delegation.Shares.GTE(amount) { + k.stakingKeeper.RemoveValidatorTokensAndShares(ctx, validator, amount) + delegation.Shares = delegation.Shares.Sub(amount) + k.stakingKeeper.SetDelegation(ctx, delegation) + undelegatedInfos = append(undelegatedInfos, UndelegatedInfo{ + ValidatorAddress: validator.GetOperator(), + Amount: remainingAmount, + }) + remainingAmount.Sub(amount) + return true // Break + } else { + k.stakingKeeper.RemoveValidatorTokensAndShares(ctx, validator, delegation.Shares) + remainingAmount.Sub(delegation.Shares) + delegation.Shares = math.LegacyDec(sdk.ZeroInt()) + k.stakingKeeper.SetDelegation(ctx, delegation) + undelegatedInfos = append(undelegatedInfos, UndelegatedInfo{ + ValidatorAddress: validator.GetOperator(), + Amount: remainingAmount, + }) + } + return false // Continue iterating through all delegations + }) + // store.Set(types.KeyPrefix(types.DelegationsKey), k.cdc.MustMarshal(delegations)) + if remainingAmount.IsPositive() { + return status.Error(codes.InvalidArgument, "not enough delegated tokens to pay dispute fee") + } + k.bankkeeper.SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, types.ModuleName, sdk.NewCoins(fee)) + return nil + +} diff --git a/x/dispute/keeper/query_get_dispute_by_id.go b/x/dispute/keeper/query_get_dispute_by_id.go new file mode 100644 index 000000000..b352ece38 --- /dev/null +++ b/x/dispute/keeper/query_get_dispute_by_id.go @@ -0,0 +1,31 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tellor-io/layer/x/dispute/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetDisputeById(goCtx context.Context, req *types.QueryGetDisputeByIdRequest) (*types.QueryGetDisputeByIdResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + key := disputeIdBytes(req.Id) + store := k.moduleStore(ctx) + var dispute types.Dispute + disputeBytes := store.Get(key) + if disputeBytes == nil { + return nil, status.Error(codes.NotFound, fmt.Sprintf("dispute %d not found", req.Id)) + } + if err := k.cdc.Unmarshal(disputeBytes, &dispute); err != nil { + return nil, status.Error(codes.InvalidArgument, "failed to unmarshal dispute") + } + + return &types.QueryGetDisputeByIdResponse{Dispute: &dispute}, nil +} diff --git a/x/dispute/keeper/query_get_open_disputes.go b/x/dispute/keeper/query_get_open_disputes.go new file mode 100644 index 000000000..bdd89b3d7 --- /dev/null +++ b/x/dispute/keeper/query_get_open_disputes.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tellor-io/layer/x/dispute/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetOpenDisputes(goCtx context.Context, req *types.QueryGetOpenDisputesRequest) (*types.QueryGetOpenDisputesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + store := k.moduleStore(ctx) + var openDisputes types.OpenDisputes + if err := k.cdc.Unmarshal(store.Get(openDisputesKeyBytes()), &openDisputes); err != nil { + return nil, status.Error(codes.InvalidArgument, "failed to unmarshal open disputes") + } + + return &types.QueryGetOpenDisputesResponse{OpenDisputes: &openDisputes}, nil +} diff --git a/x/dispute/module.go b/x/dispute/module.go index 1b66631b8..73e25004e 100644 --- a/x/dispute/module.go +++ b/x/dispute/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + // this line is used by starport scaffolding # 1 "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -94,6 +95,7 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper + stakingKeeper types.StakingKeeper } func NewAppModule( @@ -101,12 +103,14 @@ func NewAppModule( keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + stakingKeeper types.StakingKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, accountKeeper: accountKeeper, bankKeeper: bankKeeper, + stakingKeeper: stakingKeeper, } } diff --git a/x/dispute/module_simulation.go b/x/dispute/module_simulation.go index 716994d00..4cc8fa9fa 100644 --- a/x/dispute/module_simulation.go +++ b/x/dispute/module_simulation.go @@ -23,7 +23,11 @@ var ( ) const ( -// this line is used by starport scaffolding # simapp/module/const + opWeightMsgProposeDispute = "op_weight_msg_propose_dispute" + // TODO: Determine the simulation weight value + defaultWeightMsgProposeDispute int = 100 + + // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module. @@ -51,6 +55,17 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + var weightMsgProposeDispute int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgProposeDispute, &weightMsgProposeDispute, nil, + func(_ *rand.Rand) { + weightMsgProposeDispute = defaultWeightMsgProposeDispute + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgProposeDispute, + disputesimulation.SimulateMsgProposeDispute(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations @@ -59,6 +74,14 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // ProposalMsgs returns msgs used for governance proposals for simulations. func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + opWeightMsgProposeDispute, + defaultWeightMsgProposeDispute, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + disputesimulation.SimulateMsgProposeDispute(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/dispute/simulation/propose_dispute.go b/x/dispute/simulation/propose_dispute.go new file mode 100644 index 000000000..0ae15e596 --- /dev/null +++ b/x/dispute/simulation/propose_dispute.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/tellor-io/layer/x/dispute/keeper" + "github.com/tellor-io/layer/x/dispute/types" +) + +func SimulateMsgProposeDispute( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgProposeDispute{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the ProposeDispute simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "ProposeDispute simulation not implemented"), nil, nil + } +} diff --git a/x/dispute/types/codec.go b/x/dispute/types/codec.go index 844157a87..6746f3254 100644 --- a/x/dispute/types/codec.go +++ b/x/dispute/types/codec.go @@ -3,15 +3,19 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - // this line is used by starport scaffolding # 1 + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgProposeDispute{}, "dispute/ProposeDispute", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgProposeDispute{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/dispute/types/dispute.pb.go b/x/dispute/types/dispute.pb.go index a8e9a1116..c2c8cff9d 100644 --- a/x/dispute/types/dispute.pb.go +++ b/x/dispute/types/dispute.pb.go @@ -94,15 +94,16 @@ type Dispute struct { DisputeId uint64 `protobuf:"varint,2,opt,name=disputeId,proto3" json:"disputeId,omitempty"` Category DisputeCategory `protobuf:"varint,3,opt,name=category,proto3,enum=layer.dispute.DisputeCategory" json:"category,omitempty"` DisputeFee uint64 `protobuf:"varint,4,opt,name=disputeFee,proto3" json:"disputeFee,omitempty"` - StartTime uint64 `protobuf:"varint,5,opt,name=startTime,proto3" json:"startTime,omitempty"` - EndTime uint64 `protobuf:"varint,6,opt,name=endTime,proto3" json:"endTime,omitempty"` - Block uint64 `protobuf:"varint,7,opt,name=block,proto3" json:"block,omitempty"` - Status DisputeStatus `protobuf:"varint,8,opt,name=status,proto3,enum=layer.dispute.DisputeStatus" json:"status,omitempty"` - Report *MicroReport `protobuf:"bytes,9,opt,name=report,proto3" json:"report,omitempty"` - FeePayers []PaymentInfo `protobuf:"bytes,10,rep,name=feePayers,proto3" json:"feePayers"` - FeeTotal types.Coin `protobuf:"bytes,11,opt,name=feeTotal,proto3" json:"feeTotal"` - Round uint64 `protobuf:"varint,12,opt,name=round,proto3" json:"round,omitempty"` - PrevDisputeIds []uint64 `protobuf:"varint,13,rep,packed,name=prevDisputeIds,proto3" json:"prevDisputeIds,omitempty"` + BurnAmount types.Coin `protobuf:"bytes,5,opt,name=burnAmount,proto3" json:"burnAmount"` + StartTime int64 `protobuf:"varint,6,opt,name=startTime,proto3" json:"startTime,omitempty"` + EndTime int64 `protobuf:"varint,7,opt,name=endTime,proto3" json:"endTime,omitempty"` + Block int64 `protobuf:"varint,8,opt,name=block,proto3" json:"block,omitempty"` + Status DisputeStatus `protobuf:"varint,9,opt,name=status,proto3,enum=layer.dispute.DisputeStatus" json:"status,omitempty"` + Report *MicroReport `protobuf:"bytes,10,opt,name=report,proto3" json:"report,omitempty"` + FeePayers []PaymentInfo `protobuf:"bytes,11,rep,name=feePayers,proto3" json:"feePayers"` + FeeTotal types.Coin `protobuf:"bytes,12,opt,name=feeTotal,proto3" json:"feeTotal"` + Round uint64 `protobuf:"varint,13,opt,name=round,proto3" json:"round,omitempty"` + PrevDisputeIds []uint64 `protobuf:"varint,14,rep,packed,name=prevDisputeIds,proto3" json:"prevDisputeIds,omitempty"` } func (m *Dispute) Reset() { *m = Dispute{} } @@ -166,21 +167,28 @@ func (m *Dispute) GetDisputeFee() uint64 { return 0 } -func (m *Dispute) GetStartTime() uint64 { +func (m *Dispute) GetBurnAmount() types.Coin { + if m != nil { + return m.BurnAmount + } + return types.Coin{} +} + +func (m *Dispute) GetStartTime() int64 { if m != nil { return m.StartTime } return 0 } -func (m *Dispute) GetEndTime() uint64 { +func (m *Dispute) GetEndTime() int64 { if m != nil { return m.EndTime } return 0 } -func (m *Dispute) GetBlock() uint64 { +func (m *Dispute) GetBlock() int64 { if m != nil { return m.Block } @@ -307,45 +315,46 @@ func init() { func init() { proto.RegisterFile("layer/dispute/dispute.proto", fileDescriptor_2a5d4b70d69c78b5) } var fileDescriptor_2a5d4b70d69c78b5 = []byte{ - // 595 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x51, 0x4f, 0xdb, 0x3c, - 0x14, 0x6d, 0x68, 0x69, 0x9b, 0x5b, 0xe0, 0x8b, 0x2c, 0xf4, 0xc9, 0xeb, 0x50, 0x16, 0xf1, 0x30, - 0x55, 0x48, 0x4b, 0x04, 0xdb, 0xd3, 0x26, 0x4d, 0x2a, 0xb4, 0x4c, 0x99, 0xa0, 0x45, 0xa6, 0xeb, - 0xa4, 0xbd, 0x4c, 0x69, 0xea, 0x96, 0x68, 0x49, 0x9c, 0xc5, 0x2e, 0x5a, 0xff, 0xc4, 0xb4, 0x9f, - 0xc5, 0x23, 0x8f, 0x7b, 0x9a, 0x26, 0xf8, 0x23, 0x53, 0x6c, 0x13, 0xa0, 0xe2, 0xc9, 0x3e, 0xf7, - 0x9e, 0x73, 0xaf, 0xaf, 0xce, 0x35, 0x3c, 0x8f, 0x83, 0x25, 0xcd, 0xbd, 0x69, 0xc4, 0xb3, 0x85, - 0xa0, 0x77, 0xa7, 0x9b, 0xe5, 0x4c, 0x30, 0xb4, 0x29, 0x93, 0xae, 0x0e, 0xb6, 0xb7, 0xe7, 0x6c, - 0xce, 0x64, 0xc6, 0x2b, 0x6e, 0x8a, 0xd4, 0xb6, 0x43, 0xc6, 0x13, 0xc6, 0xbd, 0x49, 0xc0, 0xa9, - 0x77, 0xb9, 0x3f, 0xa1, 0x22, 0xd8, 0xf7, 0x42, 0x16, 0xa5, 0x3a, 0xef, 0x3c, 0xee, 0x90, 0x05, - 0xcb, 0x84, 0xa6, 0xe2, 0x6b, 0x94, 0xce, 0x74, 0x85, 0xdd, 0x9f, 0x35, 0x68, 0xf4, 0x54, 0x1a, - 0xfd, 0x0f, 0xf5, 0x8b, 0x80, 0x5f, 0xf8, 0x53, 0x6c, 0x38, 0x46, 0x67, 0x83, 0x68, 0x84, 0x76, - 0xc0, 0xd4, 0x15, 0xfc, 0x29, 0x5e, 0x73, 0x8c, 0x4e, 0x8d, 0xdc, 0x07, 0xd0, 0x5b, 0x68, 0x86, - 0x81, 0xa0, 0x73, 0x96, 0x2f, 0x71, 0xd5, 0x31, 0x3a, 0x5b, 0x07, 0xb6, 0xfb, 0xe8, 0xed, 0xae, - 0xae, 0x7f, 0xa4, 0x59, 0xa4, 0xe4, 0x23, 0x1b, 0x40, 0x93, 0x8e, 0x29, 0xc5, 0x35, 0x59, 0xfa, - 0x41, 0xa4, 0xe8, 0xcc, 0x45, 0x90, 0x8b, 0x51, 0x94, 0x50, 0xbc, 0xae, 0x3a, 0x97, 0x01, 0x84, - 0xa1, 0x41, 0xd3, 0xa9, 0xcc, 0xd5, 0x65, 0xee, 0x0e, 0xa2, 0x6d, 0x58, 0x9f, 0xc4, 0x2c, 0xfc, - 0x86, 0x1b, 0x32, 0xae, 0x00, 0x7a, 0x03, 0x75, 0x2e, 0x02, 0xb1, 0xe0, 0xb8, 0x29, 0xdf, 0xb9, - 0xf3, 0xf4, 0x3b, 0xcf, 0x25, 0x87, 0x68, 0x2e, 0x3a, 0x80, 0x7a, 0x4e, 0x33, 0x96, 0x0b, 0x6c, - 0x3a, 0x46, 0xa7, 0x75, 0xd0, 0x5e, 0x51, 0x9d, 0x46, 0x61, 0xce, 0x88, 0x64, 0x10, 0xcd, 0x44, - 0xef, 0xc1, 0x9c, 0x51, 0x7a, 0x56, 0xf0, 0x38, 0x06, 0xa7, 0xfa, 0x84, 0xec, 0x4c, 0x79, 0xe1, - 0xa7, 0x33, 0x76, 0x58, 0xbb, 0xfa, 0xf3, 0xa2, 0x42, 0xee, 0x25, 0xe8, 0x1d, 0x34, 0x67, 0x94, - 0x8e, 0x98, 0x08, 0x62, 0xdc, 0x92, 0x5d, 0x9f, 0xb9, 0xca, 0x6a, 0xb7, 0xb0, 0xda, 0xd5, 0x56, - 0xbb, 0x47, 0x2c, 0x4a, 0xb5, 0xba, 0x14, 0x14, 0xc3, 0xe7, 0x6c, 0x91, 0x4e, 0xf1, 0x86, 0x1a, - 0x5e, 0x02, 0xf4, 0x12, 0xb6, 0xb2, 0x9c, 0x5e, 0xf6, 0xee, 0x7c, 0xe3, 0x78, 0xd3, 0xa9, 0x76, - 0x6a, 0x64, 0x25, 0xba, 0xcb, 0xa0, 0xf5, 0x60, 0x22, 0xd4, 0x86, 0xa6, 0x9a, 0x89, 0xe6, 0x72, - 0x2b, 0x4c, 0x52, 0x62, 0x64, 0x41, 0xf5, 0x7b, 0xa4, 0x36, 0xc2, 0x24, 0xc5, 0xb5, 0x68, 0x7d, - 0x19, 0xc4, 0x0b, 0x2a, 0x17, 0xc1, 0x24, 0x0a, 0x14, 0x2e, 0x8a, 0x28, 0xa1, 0x5c, 0x04, 0x49, - 0xa6, 0x4d, 0xbe, 0x0f, 0xec, 0x75, 0xe1, 0xbf, 0x95, 0x05, 0x41, 0x2d, 0x68, 0xf8, 0x83, 0x71, - 0xf7, 0xc4, 0xef, 0x59, 0x95, 0x02, 0x7c, 0xee, 0x92, 0x81, 0x3f, 0xf8, 0x60, 0x19, 0xc8, 0x84, - 0xf5, 0x53, 0x7f, 0x30, 0x24, 0xd6, 0x9a, 0xbc, 0x76, 0x3f, 0x0e, 0x89, 0x55, 0xdd, 0x23, 0xb0, - 0xf9, 0xc8, 0xbb, 0x42, 0x73, 0x46, 0xfa, 0xe3, 0xe1, 0xa8, 0x6f, 0x55, 0x10, 0x40, 0x7d, 0x3c, - 0x1c, 0x29, 0xfd, 0x06, 0x34, 0x49, 0xff, 0x7c, 0x78, 0x32, 0xee, 0xf7, 0xac, 0x35, 0xb4, 0x05, - 0xf0, 0x69, 0x50, 0xe2, 0x6a, 0xc1, 0x3c, 0xee, 0xfa, 0x27, 0xfd, 0x9e, 0x55, 0x3b, 0xec, 0x5d, - 0xdd, 0xd8, 0xc6, 0xf5, 0x8d, 0x6d, 0xfc, 0xbd, 0xb1, 0x8d, 0x5f, 0xb7, 0x76, 0xe5, 0xfa, 0xd6, - 0xae, 0xfc, 0xbe, 0xb5, 0x2b, 0x5f, 0xf6, 0xe6, 0x91, 0xb8, 0x58, 0x4c, 0xdc, 0x90, 0x25, 0x9e, - 0xa0, 0x71, 0xcc, 0xf2, 0x57, 0x11, 0xf3, 0xd4, 0x4f, 0xfb, 0x51, 0xfe, 0x35, 0xb1, 0xcc, 0x28, - 0x9f, 0xd4, 0xe5, 0x2f, 0x7b, 0xfd, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x51, 0xac, 0x47, 0xaa, 0xeb, - 0x03, 0x00, 0x00, + // 616 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x51, 0x4f, 0xdb, 0x3c, + 0x14, 0x6d, 0x48, 0x69, 0x9b, 0x5b, 0xe8, 0x17, 0x59, 0xe8, 0x93, 0xd7, 0xa1, 0x2c, 0xe2, 0x61, + 0xaa, 0x90, 0x96, 0x08, 0xb6, 0xa7, 0x4d, 0xda, 0x54, 0x68, 0x99, 0x32, 0x41, 0x8b, 0x4c, 0xd7, + 0x49, 0x7b, 0x99, 0xd2, 0xd6, 0x2d, 0xd1, 0x9a, 0x38, 0xb3, 0x1d, 0xb4, 0xfe, 0x8b, 0xfd, 0x2c, + 0xde, 0xc6, 0xe3, 0x9e, 0xa6, 0x09, 0xfe, 0xc8, 0x14, 0xc7, 0xb4, 0x80, 0x78, 0xd8, 0x53, 0x7d, + 0xce, 0x3d, 0xe7, 0xc6, 0xa7, 0xf7, 0x1a, 0x9e, 0xce, 0xc3, 0x05, 0xe5, 0xfe, 0x24, 0x12, 0x69, + 0x26, 0xe9, 0xed, 0xaf, 0x97, 0x72, 0x26, 0x19, 0xda, 0x54, 0x45, 0x4f, 0x93, 0xcd, 0xad, 0x19, + 0x9b, 0x31, 0x55, 0xf1, 0xf3, 0x53, 0x21, 0x6a, 0x3a, 0x63, 0x26, 0x62, 0x26, 0xfc, 0x51, 0x28, + 0xa8, 0x7f, 0xb1, 0x37, 0xa2, 0x32, 0xdc, 0xf3, 0xc7, 0x2c, 0x4a, 0x74, 0xdd, 0xbd, 0xff, 0x85, + 0x34, 0x5c, 0xc4, 0x34, 0x91, 0x5f, 0xa2, 0x64, 0xaa, 0x3b, 0xec, 0xfc, 0x2c, 0x43, 0xb5, 0x53, + 0x94, 0xd1, 0xff, 0x50, 0x39, 0x0f, 0xc5, 0x79, 0x30, 0xc1, 0x86, 0x6b, 0xb4, 0x36, 0x88, 0x46, + 0x68, 0x1b, 0x2c, 0xdd, 0x21, 0x98, 0xe0, 0x35, 0xd7, 0x68, 0x95, 0xc9, 0x8a, 0x40, 0xaf, 0xa1, + 0x36, 0x0e, 0x25, 0x9d, 0x31, 0xbe, 0xc0, 0xa6, 0x6b, 0xb4, 0x1a, 0xfb, 0x8e, 0x77, 0xef, 0xee, + 0x9e, 0xee, 0x7f, 0xa8, 0x55, 0x64, 0xa9, 0x47, 0x0e, 0x80, 0x16, 0x1d, 0x51, 0x8a, 0xcb, 0xaa, + 0xf5, 0x1d, 0x06, 0xbd, 0x03, 0x18, 0x65, 0x3c, 0x69, 0xc7, 0x2c, 0x4b, 0x24, 0x5e, 0x77, 0x8d, + 0x56, 0x7d, 0xff, 0x89, 0x57, 0x84, 0xf6, 0xf2, 0xd0, 0x9e, 0x0e, 0xed, 0x1d, 0xb2, 0x28, 0x39, + 0x28, 0x5f, 0xfe, 0x7e, 0x56, 0x22, 0x77, 0x2c, 0xf9, 0xd5, 0x85, 0x0c, 0xb9, 0x1c, 0x44, 0x31, + 0xc5, 0x15, 0xd7, 0x68, 0x99, 0x64, 0x45, 0x20, 0x0c, 0x55, 0x9a, 0x4c, 0x54, 0xad, 0xaa, 0x6a, + 0xb7, 0x10, 0x6d, 0xc1, 0xfa, 0x68, 0xce, 0xc6, 0x5f, 0x71, 0x4d, 0xf1, 0x05, 0x40, 0xaf, 0xa0, + 0x22, 0x64, 0x28, 0x33, 0x81, 0x2d, 0x15, 0x74, 0xfb, 0xf1, 0xa0, 0x67, 0x4a, 0x43, 0xb4, 0x16, + 0xed, 0x43, 0x85, 0xd3, 0x94, 0x71, 0x89, 0x41, 0x05, 0x68, 0x3e, 0x70, 0x9d, 0x44, 0x63, 0xce, + 0x88, 0x52, 0x10, 0xad, 0x44, 0x6f, 0xc1, 0x9a, 0x52, 0x7a, 0x9a, 0xeb, 0x04, 0xae, 0xbb, 0xe6, + 0x23, 0xb6, 0xd3, 0x62, 0x98, 0x41, 0x32, 0x65, 0x3a, 0xf8, 0xca, 0x82, 0xde, 0x40, 0x6d, 0x4a, + 0xe9, 0x80, 0xc9, 0x70, 0x8e, 0x37, 0xfe, 0xed, 0x6f, 0x5b, 0x1a, 0xf2, 0xf0, 0x9c, 0x65, 0xc9, + 0x04, 0x6f, 0xaa, 0x81, 0x14, 0x00, 0x3d, 0x87, 0x46, 0xca, 0xe9, 0x45, 0xe7, 0x76, 0xf0, 0x02, + 0x37, 0x5c, 0xb3, 0x55, 0x26, 0x0f, 0xd8, 0x1d, 0x06, 0xf5, 0x3b, 0x89, 0x50, 0x13, 0x6a, 0x45, + 0x26, 0xca, 0xd5, 0x5a, 0x59, 0x64, 0x89, 0x91, 0x0d, 0xe6, 0xb7, 0xa8, 0x58, 0x29, 0x8b, 0xe4, + 0xc7, 0xfc, 0xd3, 0x17, 0xe1, 0x3c, 0xa3, 0x6a, 0x93, 0x2c, 0x52, 0x80, 0x7c, 0x8a, 0x32, 0x8a, + 0xa9, 0x90, 0x61, 0x9c, 0xea, 0x2d, 0x59, 0x11, 0xbb, 0x6d, 0xf8, 0xef, 0xc1, 0x86, 0xa1, 0x3a, + 0x54, 0x83, 0xde, 0xb0, 0x7d, 0x1c, 0x74, 0xec, 0x52, 0x0e, 0x3e, 0xb5, 0x49, 0x2f, 0xe8, 0xbd, + 0xb7, 0x0d, 0x64, 0xc1, 0xfa, 0x49, 0xd0, 0xeb, 0x13, 0x7b, 0x4d, 0x1d, 0xdb, 0x1f, 0xfa, 0xc4, + 0x36, 0x77, 0x09, 0x6c, 0xde, 0x9b, 0x5d, 0xee, 0x39, 0x25, 0xdd, 0x61, 0x7f, 0xd0, 0xb5, 0x4b, + 0x08, 0xa0, 0x32, 0xec, 0x0f, 0x0a, 0xff, 0x06, 0xd4, 0x48, 0xf7, 0xac, 0x7f, 0x3c, 0xec, 0x76, + 0xec, 0x35, 0xd4, 0x00, 0xf8, 0xd8, 0x5b, 0x62, 0x33, 0x57, 0x1e, 0xb5, 0x83, 0xe3, 0x6e, 0xc7, + 0x2e, 0x1f, 0x74, 0x2e, 0xaf, 0x1d, 0xe3, 0xea, 0xda, 0x31, 0xfe, 0x5c, 0x3b, 0xc6, 0x8f, 0x1b, + 0xa7, 0x74, 0x75, 0xe3, 0x94, 0x7e, 0xdd, 0x38, 0xa5, 0xcf, 0xbb, 0xb3, 0x48, 0x9e, 0x67, 0x23, + 0x6f, 0xcc, 0x62, 0x5f, 0xd2, 0xf9, 0x9c, 0xf1, 0x17, 0x11, 0xf3, 0x8b, 0xa7, 0xfa, 0x7d, 0xf9, + 0x58, 0xe5, 0x22, 0xa5, 0x62, 0x54, 0x51, 0xcf, 0xf4, 0xe5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xf9, 0x43, 0x17, 0x9c, 0x2c, 0x04, 0x00, 0x00, } func (m *Dispute) Marshal() (dAtA []byte, err error) { @@ -384,12 +393,12 @@ func (m *Dispute) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], dAtA2[:j1]) i = encodeVarintDispute(dAtA, i, uint64(j1)) i-- - dAtA[i] = 0x6a + dAtA[i] = 0x72 } if m.Round != 0 { i = encodeVarintDispute(dAtA, i, uint64(m.Round)) i-- - dAtA[i] = 0x60 + dAtA[i] = 0x68 } { size, err := m.FeeTotal.MarshalToSizedBuffer(dAtA[:i]) @@ -400,7 +409,7 @@ func (m *Dispute) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintDispute(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x5a + dAtA[i] = 0x62 if len(m.FeePayers) > 0 { for iNdEx := len(m.FeePayers) - 1; iNdEx >= 0; iNdEx-- { { @@ -412,7 +421,7 @@ func (m *Dispute) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintDispute(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a } } if m.Report != nil { @@ -425,28 +434,38 @@ func (m *Dispute) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintDispute(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } if m.Status != 0 { i = encodeVarintDispute(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x40 + dAtA[i] = 0x48 } if m.Block != 0 { i = encodeVarintDispute(dAtA, i, uint64(m.Block)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if m.EndTime != 0 { i = encodeVarintDispute(dAtA, i, uint64(m.EndTime)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } if m.StartTime != 0 { i = encodeVarintDispute(dAtA, i, uint64(m.StartTime)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } + { + size, err := m.BurnAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDispute(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a if m.DisputeFee != 0 { i = encodeVarintDispute(dAtA, i, uint64(m.DisputeFee)) i-- @@ -551,6 +570,8 @@ func (m *Dispute) Size() (n int) { if m.DisputeFee != 0 { n += 1 + sovDispute(uint64(m.DisputeFee)) } + l = m.BurnAmount.Size() + n += 1 + l + sovDispute(uint64(l)) if m.StartTime != 0 { n += 1 + sovDispute(uint64(m.StartTime)) } @@ -739,6 +760,39 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { } } case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BurnAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDispute + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDispute + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDispute + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BurnAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) } @@ -752,12 +806,12 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartTime |= uint64(b&0x7F) << shift + m.StartTime |= int64(b&0x7F) << shift if b < 0x80 { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) } @@ -771,12 +825,12 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EndTime |= uint64(b&0x7F) << shift + m.EndTime |= int64(b&0x7F) << shift if b < 0x80 { break } } - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) } @@ -790,12 +844,12 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Block |= uint64(b&0x7F) << shift + m.Block |= int64(b&0x7F) << shift if b < 0x80 { break } } - case 8: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } @@ -814,7 +868,7 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { break } } - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Report", wireType) } @@ -850,7 +904,7 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FeePayers", wireType) } @@ -884,7 +938,7 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FeeTotal", wireType) } @@ -917,7 +971,7 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 12: + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) } @@ -936,7 +990,7 @@ func (m *Dispute) Unmarshal(dAtA []byte) error { break } } - case 13: + case 14: if wireType == 0 { var v uint64 for shift := uint(0); ; shift += 7 { diff --git a/x/dispute/types/expected_keepers.go b/x/dispute/types/expected_keepers.go index 25b7f564f..efa186906 100644 --- a/x/dispute/types/expected_keepers.go +++ b/x/dispute/types/expected_keepers.go @@ -1,12 +1,21 @@ package types import ( + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) type StakingKeeper interface { // Methods imported from staking should be defined here + RemoveValidatorTokensAndShares(ctx sdk.Context, validator stakingtypes.Validator, + sharesToRemove sdk.Dec, + ) (valOut stakingtypes.Validator, removedTokens math.Int) + + IterateDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, cb func(delegation stakingtypes.Delegation) (stop bool)) + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) + SetDelegation(ctx sdk.Context, delegation stakingtypes.Delegation) } // AccountKeeper defines the expected account keeper used for simulations (noalias) @@ -19,4 +28,12 @@ type AccountKeeper interface { type BankKeeper interface { SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins // Methods imported from bank should be defined here + HasBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin) bool + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error +} + +type OracleKeeper interface { + // Methods imported from oracle should be defined here + GetTotalReporterBond(ctx sdk.Context, reporter sdk.AccAddress) math.LegacyDec } diff --git a/x/dispute/types/keys.go b/x/dispute/types/keys.go index 112235bf2..b3be5fd90 100644 --- a/x/dispute/types/keys.go +++ b/x/dispute/types/keys.go @@ -12,6 +12,10 @@ const ( // MemStoreKey defines the in-memory store key MemStoreKey = "mem_dispute" + + DisputeKey = "Dispute" + + OpenDisputesKey = "OpenDisputes" ) func KeyPrefix(p string) []byte { diff --git a/x/dispute/types/message_propose_dispute.go b/x/dispute/types/message_propose_dispute.go new file mode 100644 index 000000000..b1fdfe1b0 --- /dev/null +++ b/x/dispute/types/message_propose_dispute.go @@ -0,0 +1,49 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgProposeDispute = "propose_dispute" + +var _ sdk.Msg = &MsgProposeDispute{} + +func NewMsgProposeDispute(creator string, report *MicroReport, category DisputeCategory, fee sdk.Coin, payFromBond bool) *MsgProposeDispute { + return &MsgProposeDispute{ + Creator: creator, + Report: report, + Category: category, + Fee: fee, + PayFromBond: payFromBond, + } +} + +func (msg *MsgProposeDispute) Route() string { + return RouterKey +} + +func (msg *MsgProposeDispute) Type() string { + return TypeMsgProposeDispute +} + +func (msg *MsgProposeDispute) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgProposeDispute) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgProposeDispute) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/dispute/types/message_propose_dispute_test.go b/x/dispute/types/message_propose_dispute_test.go new file mode 100644 index 000000000..f179a4ccf --- /dev/null +++ b/x/dispute/types/message_propose_dispute_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/tellor-io/layer/testutil/sample" +) + +func TestMsgProposeDispute_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgProposeDispute + err error + }{ + { + name: "invalid address", + msg: MsgProposeDispute{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgProposeDispute{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/dispute/types/open_disputes.pb.go b/x/dispute/types/open_disputes.pb.go new file mode 100644 index 000000000..4c7d2539a --- /dev/null +++ b/x/dispute/types/open_disputes.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: layer/dispute/open_disputes.proto + +package types + +import ( + 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 + +type OpenDisputes struct { + Disputes []uint64 `protobuf:"varint,1,rep,packed,name=disputes,proto3" json:"disputes,omitempty"` +} + +func (m *OpenDisputes) Reset() { *m = OpenDisputes{} } +func (m *OpenDisputes) String() string { return proto.CompactTextString(m) } +func (*OpenDisputes) ProtoMessage() {} +func (*OpenDisputes) Descriptor() ([]byte, []int) { + return fileDescriptor_12e5399bae368977, []int{0} +} +func (m *OpenDisputes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OpenDisputes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OpenDisputes.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 *OpenDisputes) XXX_Merge(src proto.Message) { + xxx_messageInfo_OpenDisputes.Merge(m, src) +} +func (m *OpenDisputes) XXX_Size() int { + return m.Size() +} +func (m *OpenDisputes) XXX_DiscardUnknown() { + xxx_messageInfo_OpenDisputes.DiscardUnknown(m) +} + +var xxx_messageInfo_OpenDisputes proto.InternalMessageInfo + +func (m *OpenDisputes) GetDisputes() []uint64 { + if m != nil { + return m.Disputes + } + return nil +} + +func init() { + proto.RegisterType((*OpenDisputes)(nil), "layer.dispute.OpenDisputes") +} + +func init() { proto.RegisterFile("layer/dispute/open_disputes.proto", fileDescriptor_12e5399bae368977) } + +var fileDescriptor_12e5399bae368977 = []byte{ + // 153 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x49, 0xac, 0x4c, + 0x2d, 0xd2, 0x4f, 0xc9, 0x2c, 0x2e, 0x28, 0x2d, 0x49, 0xd5, 0xcf, 0x2f, 0x48, 0xcd, 0x8b, 0x87, + 0x72, 0x8a, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x78, 0xc1, 0x4a, 0xf4, 0xa0, 0xa2, 0x4a, + 0x5a, 0x5c, 0x3c, 0xfe, 0x05, 0xa9, 0x79, 0x2e, 0x50, 0x45, 0x42, 0x52, 0x5c, 0x1c, 0x30, 0x0d, + 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0x2c, 0x41, 0x70, 0xbe, 0x93, 0xcb, 0x89, 0x47, 0x72, 0x8c, 0x17, + 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, + 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, + 0xea, 0x97, 0xa4, 0xe6, 0xe4, 0xe4, 0x17, 0xe9, 0x66, 0xe6, 0xeb, 0x43, 0x1c, 0x53, 0x01, 0x77, + 0x4e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x1d, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xd6, 0x25, 0x72, 0xa1, 0xac, 0x00, 0x00, 0x00, +} + +func (m *OpenDisputes) 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 *OpenDisputes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OpenDisputes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Disputes) > 0 { + dAtA2 := make([]byte, len(m.Disputes)*10) + var j1 int + for _, num := range m.Disputes { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintOpenDisputes(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOpenDisputes(dAtA []byte, offset int, v uint64) int { + offset -= sovOpenDisputes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OpenDisputes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Disputes) > 0 { + l = 0 + for _, e := range m.Disputes { + l += sovOpenDisputes(uint64(e)) + } + n += 1 + sovOpenDisputes(uint64(l)) + l + } + return n +} + +func sovOpenDisputes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOpenDisputes(x uint64) (n int) { + return sovOpenDisputes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *OpenDisputes) 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 ErrIntOverflowOpenDisputes + } + 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: OpenDisputes: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OpenDisputes: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpenDisputes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Disputes = append(m.Disputes, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpenDisputes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthOpenDisputes + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthOpenDisputes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Disputes) == 0 { + m.Disputes = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpenDisputes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Disputes = append(m.Disputes, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Disputes", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipOpenDisputes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOpenDisputes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOpenDisputes(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, ErrIntOverflowOpenDisputes + } + 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, ErrIntOverflowOpenDisputes + } + 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, ErrIntOverflowOpenDisputes + } + 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, ErrInvalidLengthOpenDisputes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOpenDisputes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOpenDisputes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOpenDisputes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOpenDisputes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOpenDisputes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dispute/types/query.pb.go b/x/dispute/types/query.pb.go index 29c233aa7..9e9e4bf7e 100644 --- a/x/dispute/types/query.pb.go +++ b/x/dispute/types/query.pb.go @@ -113,34 +113,217 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +type QueryGetOpenDisputesRequest struct { +} + +func (m *QueryGetOpenDisputesRequest) Reset() { *m = QueryGetOpenDisputesRequest{} } +func (m *QueryGetOpenDisputesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetOpenDisputesRequest) ProtoMessage() {} +func (*QueryGetOpenDisputesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_972b8e1a74396a43, []int{2} +} +func (m *QueryGetOpenDisputesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetOpenDisputesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetOpenDisputesRequest.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 *QueryGetOpenDisputesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetOpenDisputesRequest.Merge(m, src) +} +func (m *QueryGetOpenDisputesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetOpenDisputesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetOpenDisputesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetOpenDisputesRequest proto.InternalMessageInfo + +type QueryGetOpenDisputesResponse struct { + OpenDisputes *OpenDisputes `protobuf:"bytes,1,opt,name=openDisputes,proto3" json:"openDisputes,omitempty"` +} + +func (m *QueryGetOpenDisputesResponse) Reset() { *m = QueryGetOpenDisputesResponse{} } +func (m *QueryGetOpenDisputesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetOpenDisputesResponse) ProtoMessage() {} +func (*QueryGetOpenDisputesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_972b8e1a74396a43, []int{3} +} +func (m *QueryGetOpenDisputesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetOpenDisputesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetOpenDisputesResponse.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 *QueryGetOpenDisputesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetOpenDisputesResponse.Merge(m, src) +} +func (m *QueryGetOpenDisputesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetOpenDisputesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetOpenDisputesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetOpenDisputesResponse proto.InternalMessageInfo + +func (m *QueryGetOpenDisputesResponse) GetOpenDisputes() *OpenDisputes { + if m != nil { + return m.OpenDisputes + } + return nil +} + +type QueryGetDisputeByIdRequest struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *QueryGetDisputeByIdRequest) Reset() { *m = QueryGetDisputeByIdRequest{} } +func (m *QueryGetDisputeByIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetDisputeByIdRequest) ProtoMessage() {} +func (*QueryGetDisputeByIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_972b8e1a74396a43, []int{4} +} +func (m *QueryGetDisputeByIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetDisputeByIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetDisputeByIdRequest.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 *QueryGetDisputeByIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetDisputeByIdRequest.Merge(m, src) +} +func (m *QueryGetDisputeByIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetDisputeByIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetDisputeByIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetDisputeByIdRequest proto.InternalMessageInfo + +func (m *QueryGetDisputeByIdRequest) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type QueryGetDisputeByIdResponse struct { + Dispute *Dispute `protobuf:"bytes,1,opt,name=dispute,proto3" json:"dispute,omitempty"` +} + +func (m *QueryGetDisputeByIdResponse) Reset() { *m = QueryGetDisputeByIdResponse{} } +func (m *QueryGetDisputeByIdResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetDisputeByIdResponse) ProtoMessage() {} +func (*QueryGetDisputeByIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_972b8e1a74396a43, []int{5} +} +func (m *QueryGetDisputeByIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetDisputeByIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetDisputeByIdResponse.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 *QueryGetDisputeByIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetDisputeByIdResponse.Merge(m, src) +} +func (m *QueryGetDisputeByIdResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetDisputeByIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetDisputeByIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetDisputeByIdResponse proto.InternalMessageInfo + +func (m *QueryGetDisputeByIdResponse) GetDispute() *Dispute { + if m != nil { + return m.Dispute + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "layer.dispute.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "layer.dispute.QueryParamsResponse") + proto.RegisterType((*QueryGetOpenDisputesRequest)(nil), "layer.dispute.QueryGetOpenDisputesRequest") + proto.RegisterType((*QueryGetOpenDisputesResponse)(nil), "layer.dispute.QueryGetOpenDisputesResponse") + proto.RegisterType((*QueryGetDisputeByIdRequest)(nil), "layer.dispute.QueryGetDisputeByIdRequest") + proto.RegisterType((*QueryGetDisputeByIdResponse)(nil), "layer.dispute.QueryGetDisputeByIdResponse") } func init() { proto.RegisterFile("layer/dispute/query.proto", fileDescriptor_972b8e1a74396a43) } var fileDescriptor_972b8e1a74396a43 = []byte{ - // 297 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xc1, 0x4a, 0xc3, 0x30, - 0x18, 0xc7, 0x1b, 0xd1, 0x1d, 0x22, 0x5e, 0xe2, 0x04, 0x2d, 0x92, 0xb9, 0x5e, 0x94, 0x81, 0x0d, - 0xdb, 0xde, 0x60, 0x78, 0xf2, 0xa4, 0x3b, 0x7a, 0x4b, 0x67, 0x88, 0x81, 0xae, 0x5f, 0xd6, 0xa4, - 0xb2, 0x1e, 0xf5, 0x09, 0x04, 0x5f, 0x6a, 0xc7, 0x81, 0x17, 0x4f, 0x22, 0xad, 0x0f, 0x22, 0x4b, - 0x83, 0x50, 0x27, 0xde, 0xc2, 0xf7, 0xff, 0x7d, 0x3f, 0xfe, 0x5f, 0xf0, 0x49, 0xca, 0x4b, 0x91, - 0xb3, 0x7b, 0x65, 0x74, 0x61, 0x05, 0x5b, 0x14, 0x22, 0x2f, 0x63, 0x9d, 0x83, 0x05, 0x72, 0xe0, - 0xa2, 0xd8, 0x47, 0x61, 0x57, 0x82, 0x04, 0x97, 0xb0, 0xcd, 0xab, 0x81, 0xc2, 0x53, 0x09, 0x20, - 0x53, 0xc1, 0xb8, 0x56, 0x8c, 0x67, 0x19, 0x58, 0x6e, 0x15, 0x64, 0xc6, 0xa7, 0x83, 0x19, 0x98, - 0x39, 0x18, 0x96, 0x70, 0xe3, 0xdd, 0xec, 0x71, 0x98, 0x08, 0xcb, 0x87, 0x4c, 0x73, 0xa9, 0x32, - 0x07, 0x7b, 0x36, 0x6c, 0x37, 0xd1, 0x3c, 0xe7, 0x73, 0xef, 0x89, 0xba, 0x98, 0xdc, 0x6e, 0xb6, - 0x6f, 0xdc, 0x70, 0x2a, 0x16, 0x85, 0x30, 0x36, 0xba, 0xc6, 0x87, 0xad, 0xa9, 0xd1, 0x90, 0x19, - 0x41, 0xc6, 0xb8, 0xd3, 0x2c, 0x1f, 0xa3, 0x33, 0x74, 0xb1, 0x3f, 0x3a, 0x8a, 0x5b, 0x87, 0xc4, - 0x0d, 0x3e, 0xd9, 0x5d, 0x7d, 0xf4, 0x82, 0xa9, 0x47, 0x47, 0x4f, 0x08, 0xef, 0x39, 0x19, 0x59, - 0xe2, 0x4e, 0x43, 0x90, 0xfe, 0xaf, 0xc5, 0xed, 0x0a, 0x61, 0xf4, 0x1f, 0xd2, 0xf4, 0x89, 0xce, - 0x9f, 0xdf, 0xbe, 0x5e, 0x77, 0xfa, 0xa4, 0xc7, 0xac, 0x48, 0x53, 0xc8, 0x2f, 0x15, 0xb0, 0xbf, - 0x6e, 0x9d, 0x5c, 0xad, 0x2a, 0x8a, 0xd6, 0x15, 0x45, 0x9f, 0x15, 0x45, 0x2f, 0x35, 0x0d, 0xd6, - 0x35, 0x0d, 0xde, 0x6b, 0x1a, 0xdc, 0x0d, 0xa4, 0xb2, 0x0f, 0x45, 0x12, 0xcf, 0x60, 0xbe, 0x25, - 0x59, 0xfe, 0x68, 0x6c, 0xa9, 0x85, 0x49, 0x3a, 0xee, 0xcb, 0xc6, 0xdf, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xe9, 0xad, 0xf4, 0x8c, 0xda, 0x01, 0x00, 0x00, + // 479 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xc1, 0x6f, 0xd3, 0x30, + 0x14, 0xc6, 0x9b, 0x32, 0x8a, 0x64, 0x60, 0x48, 0x66, 0x20, 0x48, 0x47, 0x46, 0x73, 0x01, 0xc2, + 0x88, 0x69, 0x77, 0xe0, 0x88, 0x54, 0x4d, 0x42, 0x70, 0x19, 0xf4, 0xc8, 0x25, 0x72, 0x16, 0x2b, + 0x58, 0x6a, 0xf3, 0xbc, 0xd8, 0x45, 0x8b, 0x10, 0x17, 0xfe, 0x02, 0x24, 0xee, 0x88, 0x7f, 0x06, + 0x69, 0xc7, 0x49, 0x5c, 0x38, 0x21, 0xd4, 0xf2, 0x87, 0xa0, 0x39, 0x2f, 0x30, 0xb7, 0xdd, 0xb4, + 0x53, 0x53, 0x7f, 0xdf, 0xfb, 0xbe, 0x9f, 0x9e, 0x13, 0x72, 0x77, 0xcc, 0x2b, 0x51, 0xb2, 0x4c, + 0x6a, 0x35, 0x35, 0x82, 0x1d, 0x4c, 0x45, 0x59, 0xc5, 0xaa, 0x04, 0x03, 0xf4, 0xba, 0x95, 0x62, + 0x94, 0xfc, 0x8d, 0x1c, 0x72, 0xb0, 0x0a, 0x3b, 0x79, 0xaa, 0x4d, 0xfe, 0x66, 0x0e, 0x90, 0x8f, + 0x05, 0xe3, 0x4a, 0x32, 0x5e, 0x14, 0x60, 0xb8, 0x91, 0x50, 0x68, 0x54, 0xa3, 0x7d, 0xd0, 0x13, + 0xd0, 0x2c, 0xe5, 0x1a, 0xb3, 0xd9, 0xfb, 0x7e, 0x2a, 0x0c, 0xef, 0x33, 0xc5, 0x73, 0x59, 0x58, + 0x33, 0x7a, 0x7d, 0x97, 0x44, 0xf1, 0x92, 0x4f, 0x9a, 0x9c, 0x9e, 0xab, 0x81, 0x12, 0x45, 0x82, + 0x7f, 0x1a, 0x4b, 0xd7, 0xb5, 0xe0, 0x6f, 0x2d, 0x86, 0x1b, 0x84, 0xbe, 0x39, 0x69, 0x7f, 0x6d, + 0x43, 0x47, 0xe2, 0x60, 0x2a, 0xb4, 0x09, 0x5f, 0x91, 0x9b, 0xce, 0xa9, 0x56, 0x50, 0x68, 0x41, + 0x77, 0x48, 0xa7, 0x2e, 0xbf, 0xe3, 0xdd, 0xf7, 0x1e, 0x5e, 0x1d, 0xdc, 0x8a, 0x9d, 0x45, 0xc4, + 0xb5, 0x7d, 0xb8, 0x76, 0xf4, 0x6b, 0xab, 0x35, 0x42, 0x6b, 0x78, 0x8f, 0x74, 0x6d, 0xd6, 0x0b, + 0x61, 0xf6, 0x94, 0x28, 0x76, 0x11, 0xae, 0xa9, 0x4a, 0xc8, 0xe6, 0x6a, 0x19, 0x3b, 0x9f, 0x93, + 0x6b, 0x70, 0xea, 0x1c, 0x9b, 0xbb, 0x0b, 0xcd, 0xce, 0xa8, 0x33, 0x10, 0x6e, 0x13, 0xbf, 0x29, + 0xc0, 0xb3, 0x61, 0xf5, 0x32, 0xc3, 0x7a, 0xba, 0x4e, 0xda, 0x32, 0xb3, 0xa1, 0x6b, 0xa3, 0xb6, + 0xcc, 0xc2, 0xbd, 0xff, 0xb4, 0x8e, 0x1b, 0x69, 0x9e, 0x92, 0x2b, 0x58, 0x89, 0x20, 0xb7, 0x17, + 0x40, 0x70, 0x68, 0xd4, 0xd8, 0x06, 0xdf, 0x2f, 0x91, 0xcb, 0x36, 0x91, 0x1e, 0x92, 0x4e, 0xbd, + 0x20, 0xda, 0x5b, 0x18, 0x5a, 0xbe, 0x01, 0x3f, 0x3c, 0xcf, 0x52, 0xc3, 0x84, 0x0f, 0x3e, 0xfd, + 0xf8, 0xf3, 0xa5, 0xdd, 0xa3, 0x5b, 0xcc, 0x88, 0xf1, 0x18, 0xca, 0x27, 0x12, 0xd8, 0xaa, 0x57, + 0x85, 0x7e, 0xf5, 0xc8, 0x8d, 0x85, 0xfd, 0xd2, 0x68, 0x55, 0xc1, 0xea, 0x3b, 0xf2, 0x1f, 0x5f, + 0xc8, 0x8b, 0x54, 0x03, 0x4b, 0xb5, 0x4d, 0xa3, 0x33, 0xa9, 0x72, 0x61, 0x12, 0xe7, 0x45, 0xa5, + 0xdf, 0x3c, 0xb2, 0xee, 0x6e, 0x9c, 0x3e, 0x3a, 0xa3, 0x73, 0xf9, 0x0e, 0xfd, 0xe8, 0x22, 0x56, + 0xa4, 0x7b, 0x66, 0xe9, 0xfa, 0x94, 0x9d, 0x4b, 0x87, 0xcf, 0x49, 0x5a, 0x25, 0x32, 0x63, 0x1f, + 0x64, 0xf6, 0x71, 0xb8, 0x7b, 0x34, 0x0b, 0xbc, 0xe3, 0x59, 0xe0, 0xfd, 0x9e, 0x05, 0xde, 0xe7, + 0x79, 0xd0, 0x3a, 0x9e, 0x07, 0xad, 0x9f, 0xf3, 0xa0, 0xf5, 0x36, 0xca, 0xa5, 0x79, 0x37, 0x4d, + 0xe3, 0x7d, 0x98, 0x2c, 0x85, 0x1e, 0xfe, 0x8b, 0x35, 0x95, 0x12, 0x3a, 0xed, 0xd8, 0xaf, 0x6e, + 0xe7, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x6d, 0xe4, 0x69, 0x5d, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -157,6 +340,10 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a list of GetOpenDisputes items. + GetOpenDisputes(ctx context.Context, in *QueryGetOpenDisputesRequest, opts ...grpc.CallOption) (*QueryGetOpenDisputesResponse, error) + // Queries a list of GetDisputeById items. + GetDisputeById(ctx context.Context, in *QueryGetDisputeByIdRequest, opts ...grpc.CallOption) (*QueryGetDisputeByIdResponse, error) } type queryClient struct { @@ -176,10 +363,32 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) GetOpenDisputes(ctx context.Context, in *QueryGetOpenDisputesRequest, opts ...grpc.CallOption) (*QueryGetOpenDisputesResponse, error) { + out := new(QueryGetOpenDisputesResponse) + err := c.cc.Invoke(ctx, "/layer.dispute.Query/GetOpenDisputes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetDisputeById(ctx context.Context, in *QueryGetDisputeByIdRequest, opts ...grpc.CallOption) (*QueryGetDisputeByIdResponse, error) { + out := new(QueryGetDisputeByIdResponse) + err := c.cc.Invoke(ctx, "/layer.dispute.Query/GetDisputeById", 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) + // Queries a list of GetOpenDisputes items. + GetOpenDisputes(context.Context, *QueryGetOpenDisputesRequest) (*QueryGetOpenDisputesResponse, error) + // Queries a list of GetDisputeById items. + GetDisputeById(context.Context, *QueryGetDisputeByIdRequest) (*QueryGetDisputeByIdResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -189,6 +398,12 @@ 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) GetOpenDisputes(ctx context.Context, req *QueryGetOpenDisputesRequest) (*QueryGetOpenDisputesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOpenDisputes not implemented") +} +func (*UnimplementedQueryServer) GetDisputeById(ctx context.Context, req *QueryGetDisputeByIdRequest) (*QueryGetDisputeByIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDisputeById not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -212,6 +427,42 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_GetOpenDisputes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetOpenDisputesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetOpenDisputes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/layer.dispute.Query/GetOpenDisputes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetOpenDisputes(ctx, req.(*QueryGetOpenDisputesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetDisputeById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetDisputeByIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetDisputeById(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/layer.dispute.Query/GetDisputeById", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetDisputeById(ctx, req.(*QueryGetDisputeByIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "layer.dispute.Query", HandlerType: (*QueryServer)(nil), @@ -220,6 +471,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "GetOpenDisputes", + Handler: _Query_GetOpenDisputes_Handler, + }, + { + MethodName: "GetDisputeById", + Handler: _Query_GetDisputeById_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "layer/dispute/query.proto", @@ -281,6 +540,127 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryGetOpenDisputesRequest) 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 *QueryGetOpenDisputesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetOpenDisputesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetOpenDisputesResponse) 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 *QueryGetOpenDisputesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetOpenDisputesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.OpenDisputes != nil { + { + size, err := m.OpenDisputes.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 *QueryGetDisputeByIdRequest) 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 *QueryGetDisputeByIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetDisputeByIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGetDisputeByIdResponse) 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 *QueryGetDisputeByIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetDisputeByIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Dispute != nil { + { + size, err := m.Dispute.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 @@ -312,17 +692,64 @@ func (m *QueryParamsResponse) Size() (n int) { return n } -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *QueryGetOpenDisputesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n } -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + +func (m *QueryGetOpenDisputesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.OpenDisputes != nil { + l = m.OpenDisputes.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx + +func (m *QueryGetDisputeByIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + return n +} + +func (m *QueryGetDisputeByIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Dispute != nil { + l = m.Dispute.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 { @@ -451,6 +878,297 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetOpenDisputesRequest) 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: QueryGetOpenDisputesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetOpenDisputesRequest: 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 *QueryGetOpenDisputesResponse) 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: QueryGetOpenDisputesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetOpenDisputesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OpenDisputes", 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.OpenDisputes == nil { + m.OpenDisputes = &OpenDisputes{} + } + if err := m.OpenDisputes.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 *QueryGetDisputeByIdRequest) 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: QueryGetDisputeByIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetDisputeByIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= 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 *QueryGetDisputeByIdResponse) 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: QueryGetDisputeByIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetDisputeByIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dispute", 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.Dispute == nil { + m.Dispute = &Dispute{} + } + if err := m.Dispute.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/dispute/types/query.pb.gw.go b/x/dispute/types/query.pb.gw.go index acd312bff..db711edfa 100644 --- a/x/dispute/types/query.pb.gw.go +++ b/x/dispute/types/query.pb.gw.go @@ -51,6 +51,78 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_GetOpenDisputes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetOpenDisputesRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetOpenDisputes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetOpenDisputes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetOpenDisputesRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetOpenDisputes(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetDisputeById_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetDisputeByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.GetDisputeById(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetDisputeById_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetDisputeByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.GetDisputeById(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 +152,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetOpenDisputes_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_GetOpenDisputes_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_GetOpenDisputes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetDisputeById_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_GetDisputeById_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_GetDisputeById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +259,61 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetOpenDisputes_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_GetOpenDisputes_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_GetOpenDisputes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetDisputeById_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_GetDisputeById_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_GetDisputeById_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}, []string{"tellor-io", "layer", "dispute", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetOpenDisputes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"tellor-io", "layer", "dispute", "get_open_disputes"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetDisputeById_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"tellor-io", "layer", "dispute", "get_dispute_by_id", "id"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_GetOpenDisputes_0 = runtime.ForwardResponseMessage + + forward_Query_GetDisputeById_0 = runtime.ForwardResponseMessage ) diff --git a/x/dispute/types/tx.pb.go b/x/dispute/types/tx.pb.go index 01e56ab03..33af38531 100644 --- a/x/dispute/types/tx.pb.go +++ b/x/dispute/types/tx.pb.go @@ -6,10 +6,16 @@ package types import ( context "context" fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "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. @@ -23,18 +29,150 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgProposeDispute struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Report *MicroReport `protobuf:"bytes,2,opt,name=report,proto3" json:"report,omitempty"` + Category DisputeCategory `protobuf:"varint,3,opt,name=category,proto3,enum=layer.dispute.DisputeCategory" json:"category,omitempty"` + Fee types.Coin `protobuf:"bytes,4,opt,name=fee,proto3" json:"fee"` + PayFromBond bool `protobuf:"varint,5,opt,name=payFromBond,proto3" json:"payFromBond,omitempty"` +} + +func (m *MsgProposeDispute) Reset() { *m = MsgProposeDispute{} } +func (m *MsgProposeDispute) String() string { return proto.CompactTextString(m) } +func (*MsgProposeDispute) ProtoMessage() {} +func (*MsgProposeDispute) Descriptor() ([]byte, []int) { + return fileDescriptor_3a591d7bef5d6e8a, []int{0} +} +func (m *MsgProposeDispute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProposeDispute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProposeDispute.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 *MsgProposeDispute) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProposeDispute.Merge(m, src) +} +func (m *MsgProposeDispute) XXX_Size() int { + return m.Size() +} +func (m *MsgProposeDispute) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProposeDispute.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProposeDispute proto.InternalMessageInfo + +func (m *MsgProposeDispute) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgProposeDispute) GetReport() *MicroReport { + if m != nil { + return m.Report + } + return nil +} + +func (m *MsgProposeDispute) GetCategory() DisputeCategory { + if m != nil { + return m.Category + } + return DisputeCategory_INVALID +} + +func (m *MsgProposeDispute) GetFee() types.Coin { + if m != nil { + return m.Fee + } + return types.Coin{} +} + +func (m *MsgProposeDispute) GetPayFromBond() bool { + if m != nil { + return m.PayFromBond + } + return false +} + +type MsgProposeDisputeResponse struct { +} + +func (m *MsgProposeDisputeResponse) Reset() { *m = MsgProposeDisputeResponse{} } +func (m *MsgProposeDisputeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgProposeDisputeResponse) ProtoMessage() {} +func (*MsgProposeDisputeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3a591d7bef5d6e8a, []int{1} +} +func (m *MsgProposeDisputeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgProposeDisputeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgProposeDisputeResponse.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 *MsgProposeDisputeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgProposeDisputeResponse.Merge(m, src) +} +func (m *MsgProposeDisputeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgProposeDisputeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgProposeDisputeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgProposeDisputeResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgProposeDispute)(nil), "layer.dispute.MsgProposeDispute") + proto.RegisterType((*MsgProposeDisputeResponse)(nil), "layer.dispute.MsgProposeDisputeResponse") +} + func init() { proto.RegisterFile("layer/dispute/tx.proto", fileDescriptor_3a591d7bef5d6e8a) } var fileDescriptor_3a591d7bef5d6e8a = []byte{ - // 127 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0x49, 0xac, 0x4c, - 0x2d, 0xd2, 0x4f, 0xc9, 0x2c, 0x2e, 0x28, 0x2d, 0x49, 0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x8b, 0xeb, 0x41, 0xc5, 0x8d, 0x58, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, - 0x9d, 0x5c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, - 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2b, 0x3d, 0xb3, - 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xbf, 0x24, 0x35, 0x27, 0x27, 0xbf, 0x48, 0x37, - 0x33, 0x5f, 0x1f, 0x62, 0x78, 0x05, 0xc2, 0xf8, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x15, - 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x46, 0x61, 0x42, 0x6c, 0x7c, 0x00, 0x00, 0x00, + // 357 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x4e, 0xea, 0x40, + 0x14, 0x86, 0x3b, 0x17, 0x2e, 0x97, 0x3b, 0xe4, 0x92, 0xdc, 0xc6, 0x98, 0x52, 0x92, 0xb1, 0x61, + 0xd5, 0x98, 0x38, 0x13, 0xea, 0xce, 0x25, 0x10, 0x77, 0x24, 0xa6, 0x4b, 0xe3, 0xa6, 0x2d, 0xc7, + 0xda, 0x04, 0x7a, 0x9a, 0x99, 0xc1, 0xd0, 0xb7, 0xf0, 0xb1, 0x58, 0xb2, 0x74, 0x65, 0x0c, 0xbc, + 0x81, 0x4f, 0x60, 0x68, 0x8b, 0x4a, 0x5d, 0xb8, 0x6a, 0xe7, 0x9c, 0xef, 0x9f, 0x7f, 0xfe, 0x39, + 0x43, 0x4f, 0xe7, 0x41, 0x0e, 0x52, 0xcc, 0x12, 0x95, 0x2d, 0x35, 0x08, 0xbd, 0xe2, 0x99, 0x44, + 0x8d, 0xe6, 0xbf, 0xa2, 0xce, 0xab, 0xba, 0x7d, 0x12, 0x63, 0x8c, 0x45, 0x47, 0xec, 0xff, 0x4a, + 0xc8, 0xee, 0x1f, 0x8b, 0xab, 0x6f, 0xd5, 0x64, 0x11, 0xaa, 0x05, 0x2a, 0x11, 0x06, 0x0a, 0xc4, + 0xe3, 0x30, 0x04, 0x1d, 0x0c, 0x45, 0x84, 0x49, 0x5a, 0xf6, 0x07, 0x6f, 0x84, 0xfe, 0x9f, 0xaa, + 0xf8, 0x46, 0x62, 0x86, 0x0a, 0x26, 0xa5, 0xd6, 0xb4, 0xe8, 0x9f, 0x48, 0x42, 0xa0, 0x51, 0x5a, + 0xc4, 0x21, 0xee, 0x5f, 0xff, 0xb0, 0x34, 0x3d, 0xda, 0x92, 0x90, 0xa1, 0xd4, 0xd6, 0x2f, 0x87, + 0xb8, 0x1d, 0xcf, 0xe6, 0x47, 0x47, 0xe4, 0xd3, 0x24, 0x92, 0xe8, 0x17, 0x84, 0x5f, 0x91, 0xe6, + 0x15, 0x6d, 0x47, 0x81, 0x86, 0x18, 0x65, 0x6e, 0x35, 0x1c, 0xe2, 0x76, 0x3d, 0x56, 0x53, 0x55, + 0xbe, 0xe3, 0x8a, 0xf2, 0x3f, 0x78, 0x73, 0x48, 0x1b, 0xf7, 0x00, 0x56, 0xb3, 0x30, 0xeb, 0xf1, + 0x32, 0x0d, 0xdf, 0xa7, 0xe1, 0x55, 0x1a, 0x3e, 0xc6, 0x24, 0x1d, 0x35, 0xd7, 0x2f, 0x67, 0x86, + 0xbf, 0x67, 0x4d, 0x87, 0x76, 0xb2, 0x20, 0xbf, 0x96, 0xb8, 0x18, 0x61, 0x3a, 0xb3, 0x7e, 0x3b, + 0xc4, 0x6d, 0xfb, 0x5f, 0x4b, 0x83, 0x3e, 0xed, 0x7d, 0xcb, 0xec, 0x83, 0xca, 0x30, 0x55, 0xe0, + 0x45, 0xb4, 0x31, 0x55, 0xb1, 0x79, 0x47, 0xbb, 0xb5, 0x4b, 0x71, 0xea, 0x51, 0xeb, 0x5b, 0xd8, + 0xee, 0x4f, 0xc4, 0xc1, 0x64, 0x34, 0x59, 0x6f, 0x19, 0xd9, 0x6c, 0x19, 0x79, 0xdd, 0x32, 0xf2, + 0xb4, 0x63, 0xc6, 0x66, 0xc7, 0x8c, 0xe7, 0x1d, 0x33, 0x6e, 0xcf, 0xe3, 0x44, 0x3f, 0x2c, 0x43, + 0x1e, 0xe1, 0x42, 0x68, 0x98, 0xcf, 0x51, 0x5e, 0x24, 0x28, 0xca, 0x11, 0xaf, 0x3e, 0x5f, 0x48, + 0x9e, 0x81, 0x0a, 0x5b, 0xc5, 0x0c, 0x2f, 0xdf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x10, 0xf2, 0x81, + 0x48, 0x3f, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -49,6 +187,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + ProposeDispute(ctx context.Context, in *MsgProposeDispute, opts ...grpc.CallOption) (*MsgProposeDisputeResponse, error) } type msgClient struct { @@ -59,22 +198,525 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) ProposeDispute(ctx context.Context, in *MsgProposeDispute, opts ...grpc.CallOption) (*MsgProposeDisputeResponse, error) { + out := new(MsgProposeDisputeResponse) + err := c.cc.Invoke(ctx, "/layer.dispute.Msg/ProposeDispute", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + ProposeDispute(context.Context, *MsgProposeDispute) (*MsgProposeDisputeResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) ProposeDispute(ctx context.Context, req *MsgProposeDispute) (*MsgProposeDisputeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProposeDispute not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_ProposeDispute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgProposeDispute) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ProposeDispute(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/layer.dispute.Msg/ProposeDispute", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ProposeDispute(ctx, req.(*MsgProposeDispute)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "layer.dispute.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "layer/dispute/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "ProposeDispute", + Handler: _Msg_ProposeDispute_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "layer/dispute/tx.proto", +} + +func (m *MsgProposeDispute) 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 *MsgProposeDispute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProposeDispute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PayFromBond { + i-- + if m.PayFromBond { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Category != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Category)) + i-- + dAtA[i] = 0x18 + } + if m.Report != nil { + { + size, err := m.Report.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + 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 *MsgProposeDisputeResponse) 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 *MsgProposeDisputeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgProposeDisputeResponse) 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 *MsgProposeDispute) 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)) + } + if m.Report != nil { + l = m.Report.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.Category != 0 { + n += 1 + sovTx(uint64(m.Category)) + } + l = m.Fee.Size() + n += 1 + l + sovTx(uint64(l)) + if m.PayFromBond { + n += 2 + } + return n +} + +func (m *MsgProposeDisputeResponse) 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 *MsgProposeDispute) 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: MsgProposeDispute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProposeDispute: 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 Report", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Report == nil { + m.Report = &MicroReport{} + } + if err := m.Report.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Category", wireType) + } + m.Category = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Category |= DisputeCategory(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", 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.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PayFromBond", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PayFromBond = bool(v != 0) + 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 *MsgProposeDisputeResponse) 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: MsgProposeDisputeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgProposeDisputeResponse: 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/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 60dce6f5a..27f4ce97a 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -63,3 +64,18 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func HashQueryData(queryData []byte) []byte { return crypto.Keccak256(queryData) } + +func (k Keeper) GetTotalReporterBond(ctx sdk.Context, reporter sdk.AccAddress) math.LegacyDec { + delegations := k.stakingKeeper.GetAllDelegatorDelegations(ctx, reporter) + + var totalStakedTokens sdk.Dec = sdk.ZeroDec() + for _, delegation := range delegations { + totalStakedTokens = totalStakedTokens.Add(delegation.Shares) + } + return totalStakedTokens +} + +func (k Keeper) IsReporterStaked(ctx sdk.Context, reporter sdk.AccAddress) bool { + totalStakedTokens := k.GetTotalReporterBond(ctx, reporter) + return totalStakedTokens.GT(sdk.ZeroDec()) +} diff --git a/x/oracle/keeper/msg_server_submit_value.go b/x/oracle/keeper/msg_server_submit_value.go index 6c1fce29b..95330ce1d 100644 --- a/x/oracle/keeper/msg_server_submit_value.go +++ b/x/oracle/keeper/msg_server_submit_value.go @@ -144,16 +144,6 @@ func getValueType(registry types.RegistryKeeper, cdc codec.BinaryCodec, ctx sdk. return dataSpec.ValueType, nil } -func (k Keeper) IsReporterStaked(ctx sdk.Context, reporter sdk.AccAddress) bool { - delegations := k.stakingKeeper.GetAllDelegatorDelegations(ctx, reporter) - - var totalStakedTokens sdk.Dec = sdk.ZeroDec() - for _, delegation := range delegations { - totalStakedTokens = totalStakedTokens.Add(delegation.Shares) - } - return totalStakedTokens.GT(sdk.ZeroDec()) -} - func (k Keeper) verifySignature(ctx sdk.Context, reporter sdk.AccAddress, value, signature string) bool { reporterAccount := k.accountKeeper.GetAccount(ctx, reporter) pubKey := reporterAccount.GetPubKey() @@ -214,28 +204,3 @@ func decodeValue(value, dataType string) ([]interface{}, error) { } return result, nil } - -// cleanup reports list -// func (k Keeper) CleanupReports(ctx sdk.Context, qid string) { -// qIdBytes, err := hex.DecodeString(qid) -// if err != nil { -// return -// } -// store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReportsKey)) -// var reportsList types.Reports -// if err := k.cdc.Unmarshal(store.Get(qIdBytes), &reportsList); err != nil { -// return -// } -// var newReportsList types.Reports -// // current time variable -// var currentTime = ctx.BlockTime().Unix() -// // if report.timestamp + 7days is less than current time, then delete the report -// for _, report := range reportsList.Reports { -// if report.Timestamp+604800 < uint64(currentTime) { -// continue -// } -// newReportsList.Reports = append(newReportsList.Reports, report) -// } - -// store.Set(qIdBytes, k.cdc.MustMarshal(&newReportsList)) -// } diff --git a/x/oracle/keeper/query_get_reports.go b/x/oracle/keeper/query_get_reports.go index 738b8d199..6f3ba2369 100644 --- a/x/oracle/keeper/query_get_reports.go +++ b/x/oracle/keeper/query_get_reports.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -18,6 +19,11 @@ func (k Keeper) GetReportsbyQid(goCtx context.Context, req *types.QueryGetReport return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(goCtx) + fmt.Println(k.bankKeeper.GetAccountsBalances(ctx), "!!!!!!!!!!!!!!!!!!!") + fmt.Println(k.accountKeeper.GetModuleAddress(stakingtypes.BondedPoolName)) + fmt.Println(k.accountKeeper.GetModuleAccount(ctx, stakingtypes.BondedPoolName)) + k.bankKeeper.SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, types.ModuleName, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(90000000)))) + fmt.Println(k.bankKeeper.GetAccountsBalances(ctx), "______________________") qIdBytes, err := hex.DecodeString(req.QId) if err != nil { return nil, fmt.Errorf("failed to decode query ID string: %v", err) diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go index 27da470e1..07ae3df7b 100644 --- a/x/oracle/types/expected_keepers.go +++ b/x/oracle/types/expected_keepers.go @@ -3,6 +3,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -21,11 +23,15 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI // Methods imported from account should be defined here } // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetAccountsBalances(ctx sdk.Context) []banktypes.Balance + SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error // Methods imported from bank should be defined here }