-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
5,372 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
package comdex.common.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/comdex-official/comdex/x/common/types"; | ||
|
||
message WhitelistedContract { | ||
uint64 game_id = 1; | ||
string security_address = 2; | ||
string contract_admin = 3; | ||
string game_name = 4; | ||
string contract_address = 5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
package comdex.common.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "comdex/common/v1beta1/params.proto"; | ||
import "comdex/common/v1beta1/common.proto"; | ||
|
||
option go_package = "github.com/comdex-official/comdex/x/common/types"; | ||
|
||
// GenesisState defines the common module's genesis state. | ||
message GenesisState { | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
repeated WhitelistedContract whitelisted_contracts = 2 [ (gogoproto.moretags) = "yaml:\"whitelisted_contracts\"" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
package comdex.common.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/comdex-official/comdex/x/common/types"; | ||
|
||
// Params defines the set of module parameters. | ||
message Params { | ||
// Security address that can whitelist/delist contract | ||
repeated string security_address = 1 [ | ||
(gogoproto.jsontag) = "security_address,omitempty", | ||
(gogoproto.moretags) = "yaml:\"security_address\"" | ||
]; | ||
|
||
uint64 contract_gas_limit = 2 [ | ||
(gogoproto.jsontag) = "contract_gas_limit,omitempty", | ||
(gogoproto.moretags) = "yaml:\"contract_gas_limit\"" | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
syntax = "proto3"; | ||
package comdex.common.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "comdex/common/v1beta1/params.proto"; | ||
import "comdex/common/v1beta1/common.proto"; | ||
|
||
option go_package = "github.com/comdex-official/comdex/x/common/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Parameters queries the parameters of the module. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
option (google.api.http).get = "/comdex/common/v1beta1/params"; | ||
} | ||
rpc QueryWhitelistedContracts(QueryWhitelistedContractsRequest) returns (QueryWhitelistedContractsResponse) { | ||
option (google.api.http).get = "/comdex/common/v1beta1/whitelisted_contracts"; | ||
} | ||
} | ||
|
||
// 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]; | ||
} | ||
|
||
message QueryWhitelistedContractsRequest{ | ||
cosmos.base.query.v1beta1.PageRequest pagination = 1 | ||
[(gogoproto.moretags) = "yaml:\"pagination\""]; | ||
} | ||
|
||
message QueryWhitelistedContractsResponse { | ||
repeated WhitelistedContract whilisted_contracts = 1 [(gogoproto.nullable) = false]; | ||
cosmos.base.query.v1beta1.PageResponse pagination = 2 | ||
[(gogoproto.moretags) = "yaml:\"pagination\""]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
syntax = "proto3"; | ||
package comdex.common.v1beta1; | ||
import "gogoproto/gogo.proto"; | ||
|
||
import "cosmos/msg/v1/msg.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "comdex/common/v1beta1/params.proto"; | ||
|
||
|
||
option go_package = "github.com/comdex-official/comdex/x/common/types"; | ||
|
||
// Msg defines the Msg service. | ||
service Msg { | ||
rpc RegisterContract(MsgRegisterContract) returns(MsgRegisterContractResponse); | ||
rpc DeRegisterContract(MsgDeRegisterContract) returns(MsgDeRegisterContractResponse); | ||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); | ||
} | ||
|
||
message MsgRegisterContract { | ||
string security_address = 1; | ||
string game_name = 2; | ||
string contract_address = 3; | ||
} | ||
|
||
message MsgRegisterContractResponse {} | ||
|
||
message MsgDeRegisterContract { | ||
string security_address = 1; | ||
uint64 game_id = 2; | ||
} | ||
|
||
message MsgDeRegisterContractResponse {} | ||
|
||
|
||
// MsgUpdateParams is the MsgUpdateParams request type. | ||
// | ||
// Since: 0.47 | ||
message MsgUpdateParams { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// authority is the address that controls the module (defaults to x/gov unless overwritten). | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
|
||
// params defines the x/auth parameters to update. | ||
// | ||
// NOTE: All parameters must be supplied. | ||
Params params = 2 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// MsgUpdateParamsResponse defines the response structure for executing a | ||
// MsgUpdateParams message. | ||
// | ||
// Since: 0.47 | ||
message MsgUpdateParamsResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
syntax = "proto3"; | ||
|
||
package cosmos.msg.v1; | ||
|
||
import "google/protobuf/descriptor.proto"; | ||
|
||
// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated. | ||
// We need this right now because gogoproto codegen needs to import the extension. | ||
option go_package = "github.com/cosmos/cosmos-sdk/types/msgservice"; | ||
|
||
extend google.protobuf.ServiceOptions { | ||
// service indicates that the service is a Msg service and that requests | ||
// must be transported via blockchain transactions rather than gRPC. | ||
// Tooling can use this annotation to distinguish between Msg services and | ||
// other types of services via reflection. | ||
bool service = 11110000; | ||
} | ||
|
||
extend google.protobuf.MessageOptions { | ||
// signer must be used in cosmos messages in order | ||
// to signal to external clients which fields in a | ||
// given cosmos message must be filled with signer | ||
// information (address). | ||
// The field must be the protobuf name of the message | ||
// field extended with this MessageOption. | ||
// The field must either be of string kind, or of message | ||
// kind in case the signer information is contained within | ||
// a message inside the cosmos message. | ||
repeated string signer = 11110000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
"github.com/comdex-official/comdex/x/common/keeper" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { | ||
|
||
Msg := []byte(`{"resolve_bet":{}}`) | ||
|
||
allContracts := k.GetAllContract(ctx) | ||
logger := k.Logger(ctx) | ||
|
||
for _, data := range allContracts { | ||
err := k.SudoContractCall(ctx, data.ContractAddress, Msg) | ||
if err != nil { | ||
logger.Error(fmt.Sprintf("Game Id %d contract call error", data.GameId)) | ||
} | ||
logger.Info(fmt.Sprintf("Game Id %d contract call", data.GameId)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
// "strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
|
||
// sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/comdex-official/comdex/x/common/types" | ||
) | ||
|
||
// GetQueryCmd returns the cli query commands for this module | ||
func GetQueryCmd(queryRoute string) *cobra.Command { | ||
// Group common queries under a subcommand | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
cmd.AddCommand(CmdQueryParams(), | ||
QueryWhitelistedContracts()) | ||
// this line is used by starport scaffolding # 1 | ||
|
||
return cmd | ||
} | ||
|
||
func QueryWhitelistedContracts() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "whitelisted-contracts", | ||
Short: "Query all whitelisted contracts", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
ctx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
pagination, err := client.ReadPageRequest(cmd.Flags()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
queryClient := types.NewQueryClient(ctx) | ||
|
||
res, err := queryClient.QueryWhitelistedContracts(cmd.Context(), &types.QueryWhitelistedContractsRequest{ | ||
Pagination: pagination, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return ctx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
flags.AddPaginationFlagsToCmd(cmd, "whitelisted-contracts") | ||
|
||
return cmd | ||
} |
Oops, something went wrong.