diff --git a/simapp/Dockerfile.proto b/simapp/Dockerfile.proto new file mode 100644 index 0000000..7d83441 --- /dev/null +++ b/simapp/Dockerfile.proto @@ -0,0 +1,6 @@ +FROM ghcr.io/cosmos/proto-builder:0.14.0 + + + +WORKDIR /workspace + diff --git a/simapp/Makefile b/simapp/Makefile new file mode 100644 index 0000000..51e749e --- /dev/null +++ b/simapp/Makefile @@ -0,0 +1,56 @@ +# Proto build helpers for the astro module + +SHELL := /bin/bash + +PWD := $(shell pwd) +DOCKER ?= docker +WORKDIR ?= /workspace + +# Use the published Cosmos SDK proto-builder image (has protoc, buf, plugins) +PROTO_IMAGE ?= ghcr.io/cosmos/proto-builder:0.14.0 + +# Local image tag if you want to build the wrapper Dockerfile in this repo +PROTO_IMAGE_LOCAL ?= astro-proto-builder:local + +# Convenience for running inside the container with current UID/GID so files are writable +UID_GID := $(shell id -u):$(shell id -g) + +.PHONY: proto-image proto-image-local proto-lint proto-format proto-gen proto-clean + +proto-image: + $(DOCKER) pull $(PROTO_IMAGE) + +# Build a local image from Dockerfile.proto (optional) +proto-image-local: + $(DOCKER) build -f Dockerfile.proto -t $(PROTO_IMAGE_LOCAL) . + +proto-format: + mkdir -p .cache + $(DOCKER) run --rm \ + -v $(PWD):$(WORKDIR) -w $(WORKDIR) \ + -e HOME=$(WORKDIR) \ + -e XDG_CACHE_HOME=$(WORKDIR)/.cache \ + -e BUF_CACHE_DIR=$(WORKDIR)/.cache \ + $(PROTO_IMAGE) buf format -w + +proto-lint: + mkdir -p .cache + $(DOCKER) run --rm \ + -v $(PWD):$(WORKDIR) -w $(WORKDIR) \ + -e HOME=$(WORKDIR) \ + -e XDG_CACHE_HOME=$(WORKDIR)/.cache \ + -e BUF_CACHE_DIR=$(WORKDIR)/.cache \ + $(PROTO_IMAGE) buf lint + +proto-gen: + mkdir -p .cache + $(DOCKER) run --rm -u $(UID_GID) \ + -v $(PWD):$(WORKDIR) -w $(WORKDIR) \ + -e HOME=$(WORKDIR) \ + -e XDG_CACHE_HOME=$(WORKDIR)/.cache \ + -e BUF_CACHE_DIR=$(WORKDIR)/.cache \ + $(PROTO_IMAGE) buf generate --template buf.gen.yaml + +# Remove any previously generated code under gen/ or other temp dirs if you use them +proto-clean: + rm -rf gen 2>/dev/null || true diff --git a/simapp/app/abci.go b/simapp/app/abci.go new file mode 100644 index 0000000..7848d25 --- /dev/null +++ b/simapp/app/abci.go @@ -0,0 +1,84 @@ +package simapp + +import ( + "bytes" + "crypto/rand" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + // VoteExtensionHandler defines a dummy vote extension handler for SimApp. + // + // NOTE: This implementation is solely used for testing purposes. DO NOT use + // in a production application! + VoteExtensionHandler struct{} + + // VoteExtension defines the structure used to create a dummy vote extension. + VoteExtension struct { + Hash []byte + Height int64 + Data []byte + } +) + +func NewVoteExtensionHandler() *VoteExtensionHandler { + return &VoteExtensionHandler{} +} + +func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { + bApp.SetExtendVoteHandler(h.ExtendVote()) + bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension()) +} + +func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { + return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + buf := make([]byte, 1024) + + _, err := rand.Read(buf) + if err != nil { + return nil, fmt.Errorf("failed to generate random vote extension data: %w", err) + } + + ve := VoteExtension{ + Hash: req.Hash, + Height: req.Height, + Data: buf, + } + + bz, err := json.Marshal(ve) + if err != nil { + return nil, fmt.Errorf("failed to encode vote extension: %w", err) + } + + return &abci.ResponseExtendVote{VoteExtension: bz}, nil + } +} + +func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + var ve VoteExtension + + if err := json.Unmarshal(req.VoteExtension, &ve); err != nil { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + switch { + case req.Height != ve.Height: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case !bytes.Equal(req.Hash, ve.Hash): + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case len(ve.Data) != 1024: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/simapp/app/ante.go b/simapp/app/ante.go new file mode 100644 index 0000000..eab46c4 --- /dev/null +++ b/simapp/app/ante.go @@ -0,0 +1,51 @@ +package simapp + +import ( + "errors" + + circuitante "cosmossdk.io/x/circuit/ante" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/ante" +) + +// HandlerOptions are the options required for constructing a default SDK AnteHandler. +type HandlerOptions struct { + ante.HandlerOptions + CircuitKeeper circuitante.CircuitBreaker +} + +// NewAnteHandler returns an AnteHandler that checks and increments sequence +// numbers, checks signatures & account numbers, and deducts fees from the first +// signer. +func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { + if options.AccountKeeper == nil { + return nil, errors.New("account keeper is required for ante builder") + } + + if options.BankKeeper == nil { + return nil, errors.New("bank keeper is required for ante builder") + } + + if options.SignModeHandler == nil { + return nil, errors.New("sign mode handler is required for ante builder") + } + + anteDecorators := []sdk.AnteDecorator{ + ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), + ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), + ante.NewValidateBasicDecorator(), + ante.NewTxTimeoutHeightDecorator(), + ante.NewValidateMemoDecorator(options.AccountKeeper), + ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), + ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), + ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators + ante.NewValidateSigCountDecorator(options.AccountKeeper), + ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), + ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler, options.SigVerifyOptions...), + ante.NewIncrementSequenceDecorator(options.AccountKeeper), + } + + return sdk.ChainAnteDecorators(anteDecorators...), nil +} diff --git a/simapp/app/app.go b/simapp/app/app.go new file mode 100644 index 0000000..0910c86 --- /dev/null +++ b/simapp/app/app.go @@ -0,0 +1,904 @@ +package simapp + +import ( + "encoding/json" + "fmt" + "io" + "maps" + + "github.com/binary-builders/astro/simapp/x/astro" + abci "github.com/cometbft/cometbft/abci/types" + dbm "github.com/cosmos/cosmos-db" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/gogoproto/proto" + "github.com/spf13/cast" + + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + "cosmossdk.io/client/v2/autocli" + clienthelpers "cosmossdk.io/client/v2/helpers" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/circuit" + circuitkeeper "cosmossdk.io/x/circuit/keeper" + circuittypes "cosmossdk.io/x/circuit/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" + "cosmossdk.io/x/nft" + nftkeeper "cosmossdk.io/x/nft/keeper" + nftmodule "cosmossdk.io/x/nft/module" + "cosmossdk.io/x/tx/signing" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" + runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/server/api" + "github.com/cosmos/cosmos-sdk/server/config" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/std" + testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + "github.com/cosmos/cosmos-sdk/x/auth/posthandler" + authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" + "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensus "github.com/cosmos/cosmos-sdk/x/consensus" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/epochs" + epochskeeper "github.com/cosmos/cosmos-sdk/x/epochs/keeper" + epochstypes "github.com/cosmos/cosmos-sdk/x/epochs/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/gov" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/cosmos-sdk/x/group" + groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper" + groupmodule "github.com/cosmos/cosmos-sdk/x/group/module" + "github.com/cosmos/cosmos-sdk/x/mint" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/cosmos/cosmos-sdk/x/protocolpool" + protocolpoolkeeper "github.com/cosmos/cosmos-sdk/x/protocolpool/keeper" + protocolpooltypes "github.com/cosmos/cosmos-sdk/x/protocolpool/types" + "github.com/cosmos/cosmos-sdk/x/slashing" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" +) + +const appName = "SimApp" + +var ( + // DefaultNodeHome default home directories for the application daemon + DefaultNodeHome string + + // module account permissions + maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + nft.ModuleName: nil, + protocolpooltypes.ModuleName: nil, + protocolpooltypes.ProtocolPoolEscrowAccount: nil} +) + +var ( + _ runtime.AppI = (*SimApp)(nil) + _ servertypes.Application = (*SimApp)(nil) +) + +// SimApp extends an ABCI application, but with most of its parameters exported. +// They are exported for convenience in creating helper functions, as object +// capabilities aren't needed for testing. +type SimApp struct { + *baseapp.BaseApp + legacyAmino *codec.LegacyAmino + appCodec codec.Codec + txConfig client.TxConfig + interfaceRegistry types.InterfaceRegistry + + // keys to access the substores + keys map[string]*storetypes.KVStoreKey + + // essential keepers + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.BaseKeeper + AstroKeeper astro.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + UpgradeKeeper *upgradekeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + ConsensusParamsKeeper consensusparamkeeper.Keeper + CircuitKeeper circuitkeeper.Keeper + + // supplementary keepers + FeeGrantKeeper feegrantkeeper.Keeper + GroupKeeper groupkeeper.Keeper + AuthzKeeper authzkeeper.Keeper + NFTKeeper nftkeeper.Keeper + EpochsKeeper epochskeeper.Keeper + ProtocolPoolKeeper protocolpoolkeeper.Keeper + + // the module manager + ModuleManager *module.Manager + BasicModuleManager module.BasicManager + + // simulation manager + sm *module.SimulationManager + + // module configurator + configurator module.Configurator +} + +func init() { + var err error + DefaultNodeHome, err = clienthelpers.GetNodeHomeDirectory(".simapp") + if err != nil { + panic(err) + } +} + +// NewSimApp returns a reference to an initialized SimApp. +func NewSimApp( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + loadLatest bool, + appOpts servertypes.AppOptions, + baseAppOptions ...func(*baseapp.BaseApp), +) *SimApp { + interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, + }) + appCodec := codec.NewProtoCodec(interfaceRegistry) + legacyAmino := codec.NewLegacyAmino() + txConfig := tx.NewTxConfig(appCodec, tx.DefaultSignModes) + + if err := interfaceRegistry.SigningContext().Validate(); err != nil { + panic(err) + } + + std.RegisterLegacyAminoCodec(legacyAmino) + std.RegisterInterfaces(interfaceRegistry) + + // Below we could construct and set an application specific mempool and + // ABCI 1.0 PrepareProposal and ProcessProposal handlers. These defaults are + // already set in the SDK's BaseApp, this shows an example of how to override + // them. + // + // Example: + // + // bApp := baseapp.NewBaseApp(...) + // nonceMempool := mempool.NewSenderNonceMempool() + // abciPropHandler := NewDefaultProposalHandler(nonceMempool, bApp) + // + // bApp.SetMempool(nonceMempool) + // bApp.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) + // bApp.SetProcessProposal(abciPropHandler.ProcessProposalHandler()) + // + // Alternatively, you can construct BaseApp options, append those to + // baseAppOptions and pass them to NewBaseApp. + // + // Example: + // + // prepareOpt = func(app *baseapp.BaseApp) { + // abciPropHandler := baseapp.NewDefaultProposalHandler(nonceMempool, app) + // app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) + // } + // baseAppOptions = append(baseAppOptions, prepareOpt) + + // create and set dummy vote extension handler + voteExtOp := func(bApp *baseapp.BaseApp) { + voteExtHandler := NewVoteExtensionHandler() + voteExtHandler.SetHandlers(bApp) + } + baseAppOptions = append(baseAppOptions, voteExtOp, baseapp.SetOptimisticExecution()) + + bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...) + bApp.SetCommitMultiStoreTracer(traceStore) + bApp.SetVersion(version.Version) + bApp.SetInterfaceRegistry(interfaceRegistry) + bApp.SetTxEncoder(txConfig.TxEncoder()) + + keys := storetypes.NewKVStoreKeys( + authtypes.StoreKey, + banktypes.StoreKey, + stakingtypes.StoreKey, + minttypes.StoreKey, + distrtypes.StoreKey, + slashingtypes.StoreKey, + govtypes.StoreKey, + consensusparamtypes.StoreKey, + upgradetypes.StoreKey, + feegrant.StoreKey, + evidencetypes.StoreKey, + circuittypes.StoreKey, + authzkeeper.StoreKey, + nftkeeper.StoreKey, + group.StoreKey, + epochstypes.StoreKey, + protocolpooltypes.StoreKey, + ) + + // register streaming services + if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil { + panic(err) + } + + app := &SimApp{ + BaseApp: bApp, + legacyAmino: legacyAmino, + appCodec: appCodec, + txConfig: txConfig, + interfaceRegistry: interfaceRegistry, + keys: keys, + } + + // set the BaseApp's parameter store + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + runtime.EventService{}, + ) + bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) + + // add keepers + app.AccountKeeper = authkeeper.NewAccountKeeper( + appCodec, + runtime.NewKVStoreService(keys[authtypes.StoreKey]), + authtypes.ProtoBaseAccount, + maccPerms, + authcodec.NewBech32Codec(sdk.Bech32MainPrefix), + sdk.Bech32MainPrefix, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authkeeper.WithUnorderedTransactions(true), + ) + + app.BankKeeper = bankkeeper.NewBaseKeeper( + appCodec, + runtime.NewKVStoreService(keys[banktypes.StoreKey]), + app.AccountKeeper, + BlockedAddresses(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + logger, + ) + + // optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper) + enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), + } + txConfig, err := tx.NewTxConfigWithOptions( + appCodec, + txConfigOpts, + ) + if err != nil { + panic(err) + } + app.txConfig = txConfig + + /* + app.StakingKeeper = stakingkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), + app.AccountKeeper, + app.BankKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr), + authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), + ) + */ + app.MintKeeper = mintkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[minttypes.StoreKey]), + app.AstroKeeper, + app.AccountKeeper, + app.BankKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + // mintkeeper.WithMintFn(mintkeeper.DefaultMintFn(minttypes.DefaultInflationCalculationFn)), custom mintFn can be added here + ) + + app.ProtocolPoolKeeper = protocolpoolkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[protocolpooltypes.StoreKey]), + app.AccountKeeper, + app.BankKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + app.DistrKeeper = distrkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), + app.AccountKeeper, + app.BankKeeper, + app.AstroKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + distrkeeper.WithExternalCommunityPool(app.ProtocolPoolKeeper), + ) + + app.SlashingKeeper = slashingkeeper.NewKeeper( + appCodec, + legacyAmino, + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), + app.AstroKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[feegrant.StoreKey]), + app.AccountKeeper, + ) + // TODO: + // register the staking hooks + // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks + // app.StakingKeeper.SetHooks( + // stakingtypes.NewMultiStakingHooks( + // app.DistrKeeper.Hooks(), + // app.SlashingKeeper.Hooks(), + // ), + // ) + + app.CircuitKeeper = circuitkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[circuittypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.AccountKeeper.AddressCodec(), + ) + app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper) + + app.AuthzKeeper = authzkeeper.NewKeeper( + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), + appCodec, + app.MsgServiceRouter(), + app.AccountKeeper, + ) + + groupConfig := group.DefaultConfig() + /* + Example of setting group params: + groupConfig.MaxMetadataLen = 1000 + */ + app.GroupKeeper = groupkeeper.NewKeeper( + keys[group.StoreKey], + appCodec, + app.MsgServiceRouter(), + app.AccountKeeper, + groupConfig, + ) + + // get skipUpgradeHeights from the app options + skipUpgradeHeights := map[int64]bool{} + for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { + skipUpgradeHeights[int64(h)] = true + } + homePath := cast.ToString(appOpts.Get(flags.FlagHome)) + // set the governance module account as the authority for conducting upgrades + app.UpgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), + appCodec, + homePath, + app.BaseApp, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + // Register the proposal types + // Deprecated: Avoid adding new handlers, instead use the new proposal flow + // by granting the governance module the right to execute the message. + // See: https://docs.cosmos.network/main/modules/gov#proposal-messages + govRouter := govv1beta1.NewRouter() + govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler) + govConfig := govtypes.DefaultConfig() + /* + Example of setting gov params: + govConfig.MaxMetadataLen = 10000 + */ + govKeeper := govkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[govtypes.StoreKey]), + app.AccountKeeper, + app.BankKeeper, + app.AstroKeeper, + app.DistrKeeper, + app.MsgServiceRouter(), + govConfig, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + // govkeeper.WithCustomCalculateVoteResultsAndVotingPowerFn(...), // Add if you want to use a custom vote calculation function. + ) + + // Set legacy router for backwards compatibility with gov v1beta1 + govKeeper.SetLegacyRouter(govRouter) + + app.GovKeeper = *govKeeper.SetHooks( + govtypes.NewMultiGovHooks( + // register the governance hooks + ), + ) + + app.NFTKeeper = nftkeeper.NewKeeper( + runtime.NewKVStoreService(keys[nftkeeper.StoreKey]), + appCodec, + app.AccountKeeper, + app.BankKeeper, + ) + + // create evidence keeper with router + evidenceKeeper := evidencekeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), + app.AstroKeeper, + app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), + ) + // If evidence needs to be handled for the app, set routes in router here and seal + app.EvidenceKeeper = *evidenceKeeper + + app.EpochsKeeper = epochskeeper.NewKeeper( + runtime.NewKVStoreService(keys[epochstypes.StoreKey]), + appCodec, + ) + + app.EpochsKeeper.SetHooks( + epochstypes.NewMultiEpochHooks( + // insert epoch hooks receivers here + ), + ) + + /**** Module Options ****/ + + // NOTE: Any module instantiated in the module manager that is later modified + // must be passed by reference here. + app.ModuleManager = module.NewManager( + genutil.NewAppModule( + app.AccountKeeper, app.AstroKeeper, app, + txConfig, + ), + auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, nil), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, nil), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, nil), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, nil), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.AstroKeeper, nil, app.interfaceRegistry), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.AstroKeeper, nil), + upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), + evidence.NewAppModule(app.EvidenceKeeper), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), + circuit.NewAppModule(appCodec, app.CircuitKeeper), + epochs.NewAppModule(app.EpochsKeeper), + protocolpool.NewAppModule(app.ProtocolPoolKeeper, app.AccountKeeper, app.BankKeeper), + ) + + // BasicModuleManager defines the module BasicManager is in charge of setting up basic, + // non-dependant module elements, such as codec registration and genesis verification. + // By default it is composed of all the module from the module manager. + // Additionally, app module basics can be overwritten by passing them as argument. + app.BasicModuleManager = module.NewBasicManagerFromManager( + app.ModuleManager, + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + govtypes.ModuleName: gov.NewAppModuleBasic( + []govclient.ProposalHandler{}, + ), + }) + app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) + app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) + + // NOTE: upgrade module is required to be prioritized + app.ModuleManager.SetOrderPreBlockers( + upgradetypes.ModuleName, + authtypes.ModuleName, + ) + // During begin block slashing happens after distr.BeginBlocker so that + // there is nothing left over in the validator fee pool, to keep the + // CanWithdrawInvariant invariant. + // NOTE: staking module is required if HistoricalEntries param > 0 + app.ModuleManager.SetOrderBeginBlockers( + minttypes.ModuleName, + distrtypes.ModuleName, + protocolpooltypes.ModuleName, + slashingtypes.ModuleName, + evidencetypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + authz.ModuleName, + epochstypes.ModuleName, + ) + app.ModuleManager.SetOrderEndBlockers( + govtypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + group.ModuleName, + protocolpooltypes.ModuleName, + ) + + // NOTE: The genutils module must occur after staking so that pools are + // properly initialized with tokens from genesis accounts. + // NOTE: The genutils module must also occur after auth so that it can access the params from auth. + genesisModuleOrder := []string{ + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + authz.ModuleName, + feegrant.ModuleName, + nft.ModuleName, + group.ModuleName, + upgradetypes.ModuleName, + vestingtypes.ModuleName, + consensusparamtypes.ModuleName, + circuittypes.ModuleName, + epochstypes.ModuleName, + protocolpooltypes.ModuleName, + } + + exportModuleOrder := []string{ + consensusparamtypes.ModuleName, + authtypes.ModuleName, + protocolpooltypes.ModuleName, // Must be exported before bank + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + authz.ModuleName, + feegrant.ModuleName, + nft.ModuleName, + group.ModuleName, + upgradetypes.ModuleName, + vestingtypes.ModuleName, + circuittypes.ModuleName, + epochstypes.ModuleName, + } + + app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) + app.ModuleManager.SetOrderExportGenesis(exportModuleOrder...) + + // Uncomment if you want to set a custom migration order here. + // app.ModuleManager.SetOrderMigrations(custom order) + + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + err = app.ModuleManager.RegisterServices(app.configurator) + if err != nil { + panic(err) + } + + // RegisterUpgradeHandlers is used for registering any on-chain upgrades. + // Make sure it's called after `app.ModuleManager` and `app.configurator` are set. + app.RegisterUpgradeHandlers() + + autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules)) + + reflectionSvc, err := runtimeservices.NewReflectionService() + if err != nil { + panic(err) + } + reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) + + // add test gRPC service for testing gRPC queries in isolation + testdata_pulsar.RegisterQueryServer(app.GRPCQueryRouter(), testdata_pulsar.QueryImpl{}) + + // create the simulation manager and define the order of the modules for deterministic simulations + // + // NOTE: this is not required apps that don't use the simulator for fuzz testing + // transactions + overrideModules := map[string]module.AppModuleSimulation{ + authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, nil), + } + app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules) + + app.sm.RegisterStoreDecoders() + + // initialize stores + app.MountKVStores(keys) + + // initialize BaseApp + app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(app.PreBlocker) + app.SetBeginBlocker(app.BeginBlocker) + app.SetEndBlocker(app.EndBlocker) + app.setAnteHandler(txConfig) + + // In v0.46, the SDK introduces _postHandlers_. PostHandlers are like + // antehandlers, but are run _after_ the `runMsgs` execution. They are also + // defined as a chain, and have the same signature as antehandlers. + // + // In baseapp, postHandlers are run in the same store branch as `runMsgs`, + // meaning that both `runMsgs` and `postHandler` state will be committed if + // both are successful, and both will be reverted if any of the two fails. + // + // The SDK exposes a default postHandlers chain + // + // Please note that changing any of the anteHandler or postHandler chain is + // likely to be a state-machine breaking change, which needs a coordinated + // upgrade. + app.setPostHandler() + + if loadLatest { + if err := app.LoadLatestVersion(); err != nil { + panic(fmt.Errorf("error loading last version: %w", err)) + } + } + + return app +} + +func (app *SimApp) setAnteHandler(txConfig client.TxConfig) { + anteHandler, err := NewAnteHandler( + HandlerOptions{ + ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + SignModeHandler: txConfig.SignModeHandler(), + FeegrantKeeper: app.FeeGrantKeeper, + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + SigVerifyOptions: []ante.SigVerificationDecoratorOption{ + // change below as needed. + ante.WithUnorderedTxGasCost(ante.DefaultUnorderedTxGasCost), + ante.WithMaxUnorderedTxTimeoutDuration(ante.DefaultMaxTimeoutDuration), + }, + }, + &app.CircuitKeeper, + }, + ) + if err != nil { + panic(err) + } + + // Set the AnteHandler for the app + app.SetAnteHandler(anteHandler) +} + +func (app *SimApp) setPostHandler() { + postHandler, err := posthandler.NewPostHandler( + posthandler.HandlerOptions{}, + ) + if err != nil { + panic(err) + } + + app.SetPostHandler(postHandler) +} + +// Name returns the name of the App +func (app *SimApp) Name() string { return app.BaseApp.Name() } + +// PreBlocker application updates every pre block +func (app *SimApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.ModuleManager.PreBlock(ctx) +} + +// BeginBlocker application updates every begin block +func (app *SimApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.ModuleManager.BeginBlock(ctx) +} + +// EndBlocker application updates every end block +func (app *SimApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.ModuleManager.EndBlock(ctx) +} + +func (a *SimApp) Configurator() module.Configurator { + return a.configurator +} + +// InitChainer application update at chain initialization +func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { + var genesisState GenesisState + if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { + panic(err) + } + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) + return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) +} + +// LoadHeight loads a particular height +func (app *SimApp) LoadHeight(height int64) error { + return app.LoadVersion(height) +} + +// LegacyAmino returns SimApp's amino codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *SimApp) LegacyAmino() *codec.LegacyAmino { + return app.legacyAmino +} + +// AppCodec returns SimApp's app codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *SimApp) AppCodec() codec.Codec { + return app.appCodec +} + +// InterfaceRegistry returns SimApp's InterfaceRegistry +func (app *SimApp) InterfaceRegistry() types.InterfaceRegistry { + return app.interfaceRegistry +} + +// TxConfig returns SimApp's TxConfig +func (app *SimApp) TxConfig() client.TxConfig { + return app.txConfig +} + +// AutoCliOpts returns the autocli options for the app. +func (app *SimApp) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.ModuleManager.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.ModuleManager.Modules), + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + +// DefaultGenesis returns a default genesis from the registered AppModuleBasic's. +func (a *SimApp) DefaultGenesis() map[string]json.RawMessage { + return a.BasicModuleManager.DefaultGenesis(a.appCodec) +} + +// GetKey returns the KVStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (app *SimApp) GetKey(storeKey string) *storetypes.KVStoreKey { + return app.keys[storeKey] +} + +// GetStoreKeys returns all the stored store keys. +func (app *SimApp) GetStoreKeys() []storetypes.StoreKey { + keys := make([]storetypes.StoreKey, 0, len(app.keys)) + for _, key := range app.keys { + keys = append(keys, key) + } + + return keys +} + +// SimulationManager implements the SimulationApp interface +func (app *SimApp) SimulationManager() *module.SimulationManager { + return app.sm +} + +// RegisterAPIRoutes registers all application module routes with the provided +// API server. +func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { + clientCtx := apiSvr.ClientCtx + // Register new tx routes from grpc-gateway. + authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // Register new CometBFT queries routes from grpc-gateway. + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // Register node gRPC service for grpc-gateway. + nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // Register grpc-gateway routes for all modules. + app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // register swagger API from root so that other applications can override easily + if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil { + panic(err) + } +} + +// RegisterTxService implements the Application.RegisterTxService method. +func (app *SimApp) RegisterTxService(clientCtx client.Context) { + authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) +} + +// RegisterTendermintService implements the Application.RegisterTendermintService method. +func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { + cmtApp := server.NewCometABCIWrapper(app) + cmtservice.RegisterTendermintService( + clientCtx, + app.BaseApp.GRPCQueryRouter(), + app.interfaceRegistry, + cmtApp.Query, + ) +} + +func (app *SimApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) +} + +// GetMaccPerms returns a copy of the module account permissions +// +// NOTE: This is solely to be used for testing purposes. +func GetMaccPerms() map[string][]string { + return maps.Clone(maccPerms) +} + +// BlockedAddresses returns all the app's blocked account addresses. +func BlockedAddresses() map[string]bool { + modAccAddrs := make(map[string]bool) + for acc := range GetMaccPerms() { + modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true + } + + // allow the following addresses to receive funds + delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + + return modAccAddrs +} diff --git a/simapp/app/export.go b/simapp/app/export.go new file mode 100644 index 0000000..e547270 --- /dev/null +++ b/simapp/app/export.go @@ -0,0 +1,11 @@ +package simapp + +import ( + servertypes "github.com/cosmos/cosmos-sdk/server/types" +) + +// ExportAppStateAndValidators exports the state of the application for a genesis +// file. +func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (servertypes.ExportedApp, error) { + panic("not used") +} diff --git a/simapp/app/genesis.go b/simapp/app/genesis.go new file mode 100644 index 0000000..69fa46b --- /dev/null +++ b/simapp/app/genesis.go @@ -0,0 +1,14 @@ +package simapp + +import ( + "encoding/json" +) + +// GenesisState of the blockchain is represented here as a map of raw json +// messages key'd by a identifier string. +// The identifier is used to determine which module genesis information belongs +// to so it may be appropriately routed during init chain. +// Within this application default genesis information is retrieved from +// the ModuleBasicManager which populates json from each BasicModule +// object provided to it during init. +type GenesisState map[string]json.RawMessage diff --git a/simapp/app/upgrades.go b/simapp/app/upgrades.go new file mode 100644 index 0000000..23fe666 --- /dev/null +++ b/simapp/app/upgrades.go @@ -0,0 +1,39 @@ +package simapp + +import ( + "context" + + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + + "github.com/cosmos/cosmos-sdk/types/module" +) + +// UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade +// from v050 to v053. +// +// NOTE: This upgrade defines a reference implementation of what an upgrade +// could look like when an application is migrating from Cosmos SDK version +// v0.50.x to v0.53.x. +const UpgradeName = "v050-to-v053" + +func (app SimApp) RegisterUpgradeHandlers() { + app.UpgradeKeeper.SetUpgradeHandler( + UpgradeName, + func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) + }, + ) + + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(err) + } + + if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{} + + // configure store loader that checks if version == upgradeHeight and applies store upgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } +} diff --git a/simapp/buf.gen.yaml b/simapp/buf.gen.yaml new file mode 100644 index 0000000..33a393a --- /dev/null +++ b/simapp/buf.gen.yaml @@ -0,0 +1,12 @@ +version: v1 + +plugins: + # protoc-gen-go via Buf remote plugin (handles module path mapping) + - plugin: buf.build/protocolbuffers/go + out: . + + # protoc-gen-go-grpc via Buf remote plugin + - plugin: buf.build/grpc/go + out: . + opt: + - require_unimplemented_servers=false diff --git a/simapp/buf.work.yaml b/simapp/buf.work.yaml new file mode 100644 index 0000000..520b852 --- /dev/null +++ b/simapp/buf.work.yaml @@ -0,0 +1,8 @@ +version: v1 + +# Treat the 'proto' folder as the module root. +# This ensures imports like "astro/..." resolve correctly +# for files located at "proto/astro/...". +directories: + - proto + diff --git a/simapp/go.mod b/simapp/go.mod index 61a89b0..6f457ea 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -9,7 +9,7 @@ require ( cosmossdk.io/core v0.11.3 cosmossdk.io/depinject v1.2.1 // indirect cosmossdk.io/log v1.6.0 - cosmossdk.io/math v1.5.3 // indirect + cosmossdk.io/math v1.5.3 cosmossdk.io/store v1.1.2 cosmossdk.io/x/circuit v0.2.0 cosmossdk.io/x/evidence v0.2.0 @@ -28,7 +28,13 @@ require ( github.com/spf13/viper v1.20.1 // indirect github.com/stretchr/testify v1.10.0 // indirect go.uber.org/mock v0.5.2 // indirect - google.golang.org/protobuf v1.36.6 // indirect + google.golang.org/protobuf v1.36.6 +) + +require ( + cosmossdk.io/errors v1.0.2 + github.com/grpc-ecosystem/grpc-gateway v1.16.0 + google.golang.org/grpc v1.72.2 ) require ( @@ -40,7 +46,6 @@ require ( cloud.google.com/go/iam v1.2.2 // indirect cloud.google.com/go/monitoring v1.21.2 // indirect cloud.google.com/go/storage v1.49.0 // indirect - cosmossdk.io/errors v1.0.2 // indirect cosmossdk.io/schema v1.1.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -118,7 +123,6 @@ require ( github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.8 // indirect @@ -208,7 +212,6 @@ require ( google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect - google.golang.org/grpc v1.72.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.2 // indirect nhooyr.io/websocket v1.8.6 // indirect diff --git a/simapp/proto/astro/astro/v1/genesis.proto b/simapp/proto/astro/astro/v1/genesis.proto new file mode 100644 index 0000000..2f9d7ef --- /dev/null +++ b/simapp/proto/astro/astro/v1/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package astro.astro.v1; + +option go_package = "github.com/binary-builders/astro/simapp/x/astro/types;types"; + +import "astro/astro/v1/params.proto"; + +// GenesisState defines the astro module's genesis state. +message GenesisState { + Params params = 1; +} diff --git a/simapp/proto/astro/astro/v1/params.proto b/simapp/proto/astro/astro/v1/params.proto new file mode 100644 index 0000000..769b85e --- /dev/null +++ b/simapp/proto/astro/astro/v1/params.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package astro.astro.v1; + +option go_package = "github.com/binary-builders/astro/simapp/x/astro/types;types"; + +// Params defines the parameters for the astro module. +message Params { + // example is a placeholder param to demonstrate wiring. + string example = 1; +} diff --git a/simapp/proto/astro/astro/v1/query.proto b/simapp/proto/astro/astro/v1/query.proto new file mode 100644 index 0000000..48164e2 --- /dev/null +++ b/simapp/proto/astro/astro/v1/query.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package astro.astro.v1; + +option go_package = "github.com/binary-builders/astro/simapp/x/astro/types;types"; + +import "astro/astro/v1/params.proto"; + +// Query defines the gRPC query service for the astro module. +service Query { + // Params returns the current module parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse); +} + +message QueryParamsRequest {} + +message QueryParamsResponse { + Params params = 1; +} diff --git a/simapp/proto/astro/astro/v1/tx.proto b/simapp/proto/astro/astro/v1/tx.proto new file mode 100644 index 0000000..e9b1ef8 --- /dev/null +++ b/simapp/proto/astro/astro/v1/tx.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package astro.astro.v1; + +option go_package = "github.com/binary-builders/astro/simapp/x/astro/types;types"; + +// Msg defines the Msg service for the astro module. +service Msg { + // Example demonstrates a simple message RPC. + rpc Example(MsgExample) returns (MsgExampleResponse); +} + +// MsgExample is a placeholder example message. +message MsgExample { + string creator = 1; + string payload = 2; +} + +// MsgExampleResponse is returned after handling MsgExample. +message MsgExampleResponse {} diff --git a/simapp/proto/buf.yaml b/simapp/proto/buf.yaml new file mode 100644 index 0000000..1349c5f --- /dev/null +++ b/simapp/proto/buf.yaml @@ -0,0 +1,11 @@ +version: v1 + +# Name is optional; included for clarity if using Buf Schema Registry. +name: buf.build/binarybuilders/astro-simapp + +deps: + - buf.build/googleapis/googleapis + - buf.build/cosmos/cosmos-proto + - buf.build/cosmos/gogo-proto + - buf.build/cosmos/ics23 + diff --git a/simapp/third_party/proto/README.md b/simapp/third_party/proto/README.md new file mode 100644 index 0000000..c7eb451 --- /dev/null +++ b/simapp/third_party/proto/README.md @@ -0,0 +1,9 @@ +Place third-party `.proto` dependencies here if vendoring. + +Common examples: +- cosmos/gogo-proto +- cosmos/cosmos-proto +- googleapis/google/api + +If you use the `ghcr.io/cosmos/proto-builder` image with `buf`, you typically don't need to vendor these; `buf` fetches them from the Buf Schema Registry per `buf.yaml` deps. + diff --git a/simapp/x/astro/astro.go b/simapp/x/astro/astro.go new file mode 100644 index 0000000..1d8f258 --- /dev/null +++ b/simapp/x/astro/astro.go @@ -0,0 +1,36 @@ +package astro + +import ( + "context" + + "cosmossdk.io/core/address" + "cosmossdk.io/math" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +type Keeper interface { + StakingTokenSupply(ctx context.Context) (math.Int, error) + BondedRatio(ctx context.Context) (math.LegacyDec, error) + ValidatorAddressCodec() address.Codec + ConsensusAddressCodec() address.Codec + IterateValidators(ctx context.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error + Validator(ctx context.Context, valAddress sdk.ValAddress) (stakingtypes.ValidatorI, error) + ValidatorByConsAddr(ctx context.Context, consAddress sdk.ConsAddress) (stakingtypes.ValidatorI, error) + Delegation(ctx context.Context, address sdk.AccAddress, address2 sdk.ValAddress) (stakingtypes.DelegationI, error) + IterateDelegations(ctx context.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) error + GetAllSDKDelegations(ctx context.Context) ([]stakingtypes.Delegation, error) + GetAllValidators(ctx context.Context) ([]stakingtypes.Validator, error) + GetAllDelegatorDelegations(ctx context.Context, delegator sdk.AccAddress) ([]stakingtypes.Delegation, error) + Slash(ctx context.Context, consAddress sdk.ConsAddress, i int64, i2 int64, dec math.LegacyDec) (math.Int, error) + SlashWithInfractionReason(ctx context.Context, consAddress sdk.ConsAddress, i int64, i2 int64, dec math.LegacyDec, infraction stakingtypes.Infraction) (math.Int, error) + Jail(ctx context.Context, consAddress sdk.ConsAddress) error + Unjail(ctx context.Context, consAddress sdk.ConsAddress) error + MaxValidators(ctx context.Context) (uint32, error) + IsValidatorJailed(ctx context.Context, addr sdk.ConsAddress) (bool, error) + ApplyAndReturnValidatorSetUpdates(ctx context.Context) (updates []abci.ValidatorUpdate, err error) + GetParams(ctx context.Context) (params stakingtypes.Params, err error) + IterateBondedValidatorsByPower(ctx context.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error + TotalBondedTokens(ctx context.Context) (math.Int, error) +} diff --git a/simapp/x/astro/keeper/genesis.go b/simapp/x/astro/keeper/genesis.go new file mode 100644 index 0000000..3195ec2 --- /dev/null +++ b/simapp/x/astro/keeper/genesis.go @@ -0,0 +1,21 @@ +package keeper + +import ( + "github.com/binary-builders/astro/simapp/x/astro/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the module state from genesis. +func (k Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) error { + // initialize module state here as needed + _ = ctx + _ = gs + return nil +} + +// ExportGenesis exports the current module state to genesis. +func (k Keeper) ExportGenesis(ctx sdk.Context) (*types.GenesisState, error) { + _ = ctx + // populate from state when implemented + return types.DefaultGenesis(), nil +} diff --git a/simapp/x/astro/keeper/keeper.go b/simapp/x/astro/keeper/keeper.go new file mode 100644 index 0000000..80973aa --- /dev/null +++ b/simapp/x/astro/keeper/keeper.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "cosmossdk.io/core/store" + "github.com/cosmos/cosmos-sdk/codec" +) + +// Keeper provides state management for the x/astro module. +type Keeper struct { + cdc codec.Codec + storeService store.KVStoreService + authority string +} + +// NewKeeper returns a new Keeper instance. +func NewKeeper(cdc codec.Codec, storeService store.KVStoreService, authority string) Keeper { + return Keeper{ + cdc: cdc, + storeService: storeService, + authority: authority, + } +} + +// Authority returns the module authority address (typically the gov module account). +func (k Keeper) Authority() string { return k.authority } diff --git a/simapp/x/astro/module/module.go b/simapp/x/astro/module/module.go new file mode 100644 index 0000000..92bd735 --- /dev/null +++ b/simapp/x/astro/module/module.go @@ -0,0 +1,87 @@ +package module + +import ( + "encoding/json" + + "cosmossdk.io/core/appmodule" + "github.com/binary-builders/astro/simapp/x/astro/keeper" + "github.com/binary-builders/astro/simapp/x/astro/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkmodule "github.com/cosmos/cosmos-sdk/types/module" +) + +// AppModuleBasic implements the sdk AppModuleBasic interface for x/astro. +type AppModuleBasic struct{} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(context client.Context, mux *runtime.ServeMux) { + // TODO implement me + panic("implement me") +} + +var _ sdkmodule.AppModuleBasic = AppModuleBasic{} + +func (AppModuleBasic) Name() string { return types.ModuleName } +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} +func (AppModuleBasic) RegisterInterfaces(reg codectypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var gs types.GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return err + } + return gs.Validate() +} + +// AppModule implements the sdk AppModule interface for x/astro. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func (am AppModule) IsOnePerModuleType() {} + +func (am AppModule) IsAppModule() {} + +var _ appmodule.AppModule = AppModule{} + +func NewAppModule(_ codec.Codec, k keeper.Keeper) AppModule { + return AppModule{keeper: k} +} + +func (am AppModule) Name() string { return types.ModuleName } + +func (am AppModule) RegisterServices(_ sdkmodule.Configurator) {} + +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var gs types.GenesisState + cdc.MustUnmarshalJSON(data, &gs) + + // The keeper InitGenesis uses context.Context; bridge from sdk.Context + if err := am.keeper.InitGenesis(ctx, gs); err != nil { + panic(err) + } + return []abci.ValidatorUpdate{} +} + +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs, err := am.keeper.ExportGenesis(ctx) + if err != nil { + panic(err) + } + return cdc.MustMarshalJSON(gs) +} + +func (am AppModule) ConsensusVersion() uint64 { return 1 } diff --git a/simapp/x/astro/types/codec.go b/simapp/x/astro/types/codec.go new file mode 100644 index 0000000..8a05acd --- /dev/null +++ b/simapp/x/astro/types/codec.go @@ -0,0 +1,14 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +// RegisterLegacyAminoCodec registers the necessary x/astro interfaces and concrete types +// on the provided LegacyAmino codec. This is a no-op for now. +func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} + +// RegisterInterfaces registers interfaces and implementations of the x/astro module. +// This is a no-op for now. +func RegisterInterfaces(_ codectypes.InterfaceRegistry) {} diff --git a/simapp/x/astro/types/errors.go b/simapp/x/astro/types/errors.go new file mode 100644 index 0000000..bd05572 --- /dev/null +++ b/simapp/x/astro/types/errors.go @@ -0,0 +1,10 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +// x/astro module sentinel errors +var ( + ErrSample = errorsmod.Register(ModuleName, 1, "sample error") +) diff --git a/simapp/x/astro/types/genesis.pb.go b/simapp/x/astro/types/genesis.pb.go new file mode 100644 index 0000000..1a6fbe5 --- /dev/null +++ b/simapp/x/astro/types/genesis.pb.go @@ -0,0 +1,154 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: astro/astro/v1/genesis.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// GenesisState defines the astro module's genesis state. +type GenesisState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *GenesisState) Reset() { + *x = GenesisState{} + if protoimpl.UnsafeEnabled { + mi := &file_astro_astro_v1_genesis_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenesisState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenesisState) ProtoMessage() {} + +func (x *GenesisState) ProtoReflect() protoreflect.Message { + mi := &file_astro_astro_v1_genesis_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenesisState.ProtoReflect.Descriptor instead. +func (*GenesisState) Descriptor() ([]byte, []int) { + return file_astro_astro_v1_genesis_proto_rawDescGZIP(), []int{0} +} + +func (x *GenesisState) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +var File_astro_astro_v1_genesis_proto protoreflect.FileDescriptor + +var file_astro_astro_v1_genesis_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x76, 0x31, + 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, + 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x1a, 0x1b, + 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x76, 0x31, 0x2f, 0x70, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e, 0x0a, 0x0c, 0x47, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x70, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x61, 0x73, + 0x74, 0x72, 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x3d, 0x5a, 0x3b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, + 0x2d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, + 0x73, 0x69, 0x6d, 0x61, 0x70, 0x70, 0x2f, 0x78, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x3b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_astro_astro_v1_genesis_proto_rawDescOnce sync.Once + file_astro_astro_v1_genesis_proto_rawDescData = file_astro_astro_v1_genesis_proto_rawDesc +) + +func file_astro_astro_v1_genesis_proto_rawDescGZIP() []byte { + file_astro_astro_v1_genesis_proto_rawDescOnce.Do(func() { + file_astro_astro_v1_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_astro_astro_v1_genesis_proto_rawDescData) + }) + return file_astro_astro_v1_genesis_proto_rawDescData +} + +var file_astro_astro_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_astro_astro_v1_genesis_proto_goTypes = []interface{}{ + (*GenesisState)(nil), // 0: astro.astro.v1.GenesisState + (*Params)(nil), // 1: astro.astro.v1.Params +} +var file_astro_astro_v1_genesis_proto_depIdxs = []int32{ + 1, // 0: astro.astro.v1.GenesisState.params:type_name -> astro.astro.v1.Params + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_astro_astro_v1_genesis_proto_init() } +func file_astro_astro_v1_genesis_proto_init() { + if File_astro_astro_v1_genesis_proto != nil { + return + } + file_astro_astro_v1_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_astro_astro_v1_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenesisState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_astro_astro_v1_genesis_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_astro_astro_v1_genesis_proto_goTypes, + DependencyIndexes: file_astro_astro_v1_genesis_proto_depIdxs, + MessageInfos: file_astro_astro_v1_genesis_proto_msgTypes, + }.Build() + File_astro_astro_v1_genesis_proto = out.File + file_astro_astro_v1_genesis_proto_rawDesc = nil + file_astro_astro_v1_genesis_proto_goTypes = nil + file_astro_astro_v1_genesis_proto_depIdxs = nil +} diff --git a/simapp/x/astro/types/genesis_ext.go b/simapp/x/astro/types/genesis_ext.go new file mode 100644 index 0000000..25a7979 --- /dev/null +++ b/simapp/x/astro/types/genesis_ext.go @@ -0,0 +1,13 @@ +package types + +// DefaultGenesis returns the default genesis state. +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + } +} + +// Validate validates the genesis state. +func (gs *GenesisState) Validate() error { + return gs.Params.Validate() +} diff --git a/simapp/x/astro/types/keys.go b/simapp/x/astro/types/keys.go new file mode 100644 index 0000000..81ffea9 --- /dev/null +++ b/simapp/x/astro/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "astro" + + // StoreKey is the string store representation + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName + + // MemStoreKey is the mem store key + MemStoreKey = "mem_" + ModuleName +) diff --git a/simapp/x/astro/types/params.pb.go b/simapp/x/astro/types/params.pb.go new file mode 100644 index 0000000..ca2fffe --- /dev/null +++ b/simapp/x/astro/types/params.pb.go @@ -0,0 +1,148 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: astro/astro/v1/params.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Params defines the parameters for the astro module. +type Params struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // example is a placeholder param to demonstrate wiring. + Example string `protobuf:"bytes,1,opt,name=example,proto3" json:"example,omitempty"` +} + +func (x *Params) Reset() { + *x = Params{} + if protoimpl.UnsafeEnabled { + mi := &file_astro_astro_v1_params_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Params) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Params) ProtoMessage() {} + +func (x *Params) ProtoReflect() protoreflect.Message { + mi := &file_astro_astro_v1_params_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Params.ProtoReflect.Descriptor instead. +func (*Params) Descriptor() ([]byte, []int) { + return file_astro_astro_v1_params_proto_rawDescGZIP(), []int{0} +} + +func (x *Params) GetExample() string { + if x != nil { + return x.Example + } + return "" +} + +var File_astro_astro_v1_params_proto protoreflect.FileDescriptor + +var file_astro_astro_v1_params_proto_rawDesc = []byte{ + 0x0a, 0x1b, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x76, 0x31, + 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x61, + 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x22, 0x22, 0x0a, + 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x2d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x2f, + 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x73, 0x69, 0x6d, 0x61, 0x70, 0x70, 0x2f, 0x78, 0x2f, 0x61, + 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_astro_astro_v1_params_proto_rawDescOnce sync.Once + file_astro_astro_v1_params_proto_rawDescData = file_astro_astro_v1_params_proto_rawDesc +) + +func file_astro_astro_v1_params_proto_rawDescGZIP() []byte { + file_astro_astro_v1_params_proto_rawDescOnce.Do(func() { + file_astro_astro_v1_params_proto_rawDescData = protoimpl.X.CompressGZIP(file_astro_astro_v1_params_proto_rawDescData) + }) + return file_astro_astro_v1_params_proto_rawDescData +} + +var file_astro_astro_v1_params_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_astro_astro_v1_params_proto_goTypes = []interface{}{ + (*Params)(nil), // 0: astro.astro.v1.Params +} +var file_astro_astro_v1_params_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_astro_astro_v1_params_proto_init() } +func file_astro_astro_v1_params_proto_init() { + if File_astro_astro_v1_params_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_astro_astro_v1_params_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Params); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_astro_astro_v1_params_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_astro_astro_v1_params_proto_goTypes, + DependencyIndexes: file_astro_astro_v1_params_proto_depIdxs, + MessageInfos: file_astro_astro_v1_params_proto_msgTypes, + }.Build() + File_astro_astro_v1_params_proto = out.File + file_astro_astro_v1_params_proto_rawDesc = nil + file_astro_astro_v1_params_proto_goTypes = nil + file_astro_astro_v1_params_proto_depIdxs = nil +} diff --git a/simapp/x/astro/types/params_ext.go b/simapp/x/astro/types/params_ext.go new file mode 100644 index 0000000..813a091 --- /dev/null +++ b/simapp/x/astro/types/params_ext.go @@ -0,0 +1,8 @@ +package types + +// DefaultParams returns the default parameters for the module. +// Relies on the generated Params type from protobufs. +func DefaultParams() *Params { return &Params{} } + +// Validate performs basic validation on Params. +func (p *Params) Validate() error { return nil } diff --git a/simapp/x/astro/types/query.pb.go b/simapp/x/astro/types/query.pb.go new file mode 100644 index 0000000..a606ef9 --- /dev/null +++ b/simapp/x/astro/types/query.pb.go @@ -0,0 +1,213 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: astro/astro/v1/query.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type QueryParamsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *QueryParamsRequest) Reset() { + *x = QueryParamsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_astro_astro_v1_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryParamsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryParamsRequest) ProtoMessage() {} + +func (x *QueryParamsRequest) ProtoReflect() protoreflect.Message { + mi := &file_astro_astro_v1_query_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryParamsRequest.ProtoReflect.Descriptor instead. +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return file_astro_astro_v1_query_proto_rawDescGZIP(), []int{0} +} + +type QueryParamsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *QueryParamsResponse) Reset() { + *x = QueryParamsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_astro_astro_v1_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryParamsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryParamsResponse) ProtoMessage() {} + +func (x *QueryParamsResponse) ProtoReflect() protoreflect.Message { + mi := &file_astro_astro_v1_query_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryParamsResponse.ProtoReflect.Descriptor instead. +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return file_astro_astro_v1_query_proto_rawDescGZIP(), []int{1} +} + +func (x *QueryParamsResponse) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +var File_astro_astro_v1_query_proto protoreflect.FileDescriptor + +var file_astro_astro_v1_query_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x76, 0x31, + 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x61, 0x73, + 0x74, 0x72, 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x1a, 0x1b, 0x61, 0x73, + 0x74, 0x72, 0x6f, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x45, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x61, + 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x5a, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, + 0x51, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x22, 0x2e, 0x61, 0x73, 0x74, 0x72, + 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, + 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x2d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x73, + 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x73, 0x69, 0x6d, 0x61, 0x70, 0x70, 0x2f, 0x78, 0x2f, + 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_astro_astro_v1_query_proto_rawDescOnce sync.Once + file_astro_astro_v1_query_proto_rawDescData = file_astro_astro_v1_query_proto_rawDesc +) + +func file_astro_astro_v1_query_proto_rawDescGZIP() []byte { + file_astro_astro_v1_query_proto_rawDescOnce.Do(func() { + file_astro_astro_v1_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_astro_astro_v1_query_proto_rawDescData) + }) + return file_astro_astro_v1_query_proto_rawDescData +} + +var file_astro_astro_v1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_astro_astro_v1_query_proto_goTypes = []interface{}{ + (*QueryParamsRequest)(nil), // 0: astro.astro.v1.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: astro.astro.v1.QueryParamsResponse + (*Params)(nil), // 2: astro.astro.v1.Params +} +var file_astro_astro_v1_query_proto_depIdxs = []int32{ + 2, // 0: astro.astro.v1.QueryParamsResponse.params:type_name -> astro.astro.v1.Params + 0, // 1: astro.astro.v1.Query.Params:input_type -> astro.astro.v1.QueryParamsRequest + 1, // 2: astro.astro.v1.Query.Params:output_type -> astro.astro.v1.QueryParamsResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_astro_astro_v1_query_proto_init() } +func file_astro_astro_v1_query_proto_init() { + if File_astro_astro_v1_query_proto != nil { + return + } + file_astro_astro_v1_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_astro_astro_v1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryParamsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_astro_astro_v1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryParamsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_astro_astro_v1_query_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_astro_astro_v1_query_proto_goTypes, + DependencyIndexes: file_astro_astro_v1_query_proto_depIdxs, + MessageInfos: file_astro_astro_v1_query_proto_msgTypes, + }.Build() + File_astro_astro_v1_query_proto = out.File + file_astro_astro_v1_query_proto_rawDesc = nil + file_astro_astro_v1_query_proto_goTypes = nil + file_astro_astro_v1_query_proto_depIdxs = nil +} diff --git a/simapp/x/astro/types/query_grpc.pb.go b/simapp/x/astro/types/query_grpc.pb.go new file mode 100644 index 0000000..b021dcb --- /dev/null +++ b/simapp/x/astro/types/query_grpc.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: astro/astro/v1/query.proto + +package types + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Query_Params_FullMethodName = "/astro.astro.v1.Query/Params" +) + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type QueryClient interface { + // Params returns the current module parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc.ClientConnInterface +} + +func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +// All implementations should embed UnimplementedQueryServer +// for forward compatibility +type QueryServer interface { + // Params returns the current module parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer should be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to QueryServer will +// result in compilation errors. +type UnsafeQueryServer interface { + mustEmbedUnimplementedQueryServer() +} + +func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + s.RegisterService(&Query_ServiceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_Params_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Query_ServiceDesc is the grpc.ServiceDesc for Query service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Query_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "astro.astro.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "astro/astro/v1/query.proto", +} diff --git a/simapp/x/astro/types/tx.pb.go b/simapp/x/astro/types/tx.pb.go new file mode 100644 index 0000000..e969a20 --- /dev/null +++ b/simapp/x/astro/types/tx.pb.go @@ -0,0 +1,217 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: astro/astro/v1/tx.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// MsgExample is a placeholder example message. +type MsgExample struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Payload string `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (x *MsgExample) Reset() { + *x = MsgExample{} + if protoimpl.UnsafeEnabled { + mi := &file_astro_astro_v1_tx_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgExample) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgExample) ProtoMessage() {} + +func (x *MsgExample) ProtoReflect() protoreflect.Message { + mi := &file_astro_astro_v1_tx_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MsgExample.ProtoReflect.Descriptor instead. +func (*MsgExample) Descriptor() ([]byte, []int) { + return file_astro_astro_v1_tx_proto_rawDescGZIP(), []int{0} +} + +func (x *MsgExample) GetCreator() string { + if x != nil { + return x.Creator + } + return "" +} + +func (x *MsgExample) GetPayload() string { + if x != nil { + return x.Payload + } + return "" +} + +// MsgExampleResponse is returned after handling MsgExample. +type MsgExampleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *MsgExampleResponse) Reset() { + *x = MsgExampleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_astro_astro_v1_tx_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgExampleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgExampleResponse) ProtoMessage() {} + +func (x *MsgExampleResponse) ProtoReflect() protoreflect.Message { + mi := &file_astro_astro_v1_tx_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MsgExampleResponse.ProtoReflect.Descriptor instead. +func (*MsgExampleResponse) Descriptor() ([]byte, []int) { + return file_astro_astro_v1_tx_proto_rawDescGZIP(), []int{1} +} + +var File_astro_astro_v1_tx_proto protoreflect.FileDescriptor + +var file_astro_astro_v1_tx_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x76, 0x31, + 0x2f, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x61, 0x73, 0x74, 0x72, 0x6f, + 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, 0x22, 0x40, 0x0a, 0x0a, 0x4d, 0x73, 0x67, + 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, + 0x72, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x4d, + 0x73, 0x67, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x32, 0x50, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x49, 0x0a, 0x07, 0x45, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, + 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x1a, + 0x22, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x2d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, + 0x73, 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x73, 0x69, 0x6d, 0x61, 0x70, 0x70, 0x2f, 0x78, + 0x2f, 0x61, 0x73, 0x74, 0x72, 0x6f, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_astro_astro_v1_tx_proto_rawDescOnce sync.Once + file_astro_astro_v1_tx_proto_rawDescData = file_astro_astro_v1_tx_proto_rawDesc +) + +func file_astro_astro_v1_tx_proto_rawDescGZIP() []byte { + file_astro_astro_v1_tx_proto_rawDescOnce.Do(func() { + file_astro_astro_v1_tx_proto_rawDescData = protoimpl.X.CompressGZIP(file_astro_astro_v1_tx_proto_rawDescData) + }) + return file_astro_astro_v1_tx_proto_rawDescData +} + +var file_astro_astro_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_astro_astro_v1_tx_proto_goTypes = []interface{}{ + (*MsgExample)(nil), // 0: astro.astro.v1.MsgExample + (*MsgExampleResponse)(nil), // 1: astro.astro.v1.MsgExampleResponse +} +var file_astro_astro_v1_tx_proto_depIdxs = []int32{ + 0, // 0: astro.astro.v1.Msg.Example:input_type -> astro.astro.v1.MsgExample + 1, // 1: astro.astro.v1.Msg.Example:output_type -> astro.astro.v1.MsgExampleResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_astro_astro_v1_tx_proto_init() } +func file_astro_astro_v1_tx_proto_init() { + if File_astro_astro_v1_tx_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_astro_astro_v1_tx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgExample); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_astro_astro_v1_tx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgExampleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_astro_astro_v1_tx_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_astro_astro_v1_tx_proto_goTypes, + DependencyIndexes: file_astro_astro_v1_tx_proto_depIdxs, + MessageInfos: file_astro_astro_v1_tx_proto_msgTypes, + }.Build() + File_astro_astro_v1_tx_proto = out.File + file_astro_astro_v1_tx_proto_rawDesc = nil + file_astro_astro_v1_tx_proto_goTypes = nil + file_astro_astro_v1_tx_proto_depIdxs = nil +} diff --git a/simapp/x/astro/types/tx_grpc.pb.go b/simapp/x/astro/types/tx_grpc.pb.go new file mode 100644 index 0000000..92dc7a4 --- /dev/null +++ b/simapp/x/astro/types/tx_grpc.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: astro/astro/v1/tx.proto + +package types + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Msg_Example_FullMethodName = "/astro.astro.v1.Msg/Example" +) + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type MsgClient interface { + // Example demonstrates a simple message RPC. + Example(ctx context.Context, in *MsgExample, opts ...grpc.CallOption) (*MsgExampleResponse, error) +} + +type msgClient struct { + cc grpc.ClientConnInterface +} + +func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) Example(ctx context.Context, in *MsgExample, opts ...grpc.CallOption) (*MsgExampleResponse, error) { + out := new(MsgExampleResponse) + err := c.cc.Invoke(ctx, Msg_Example_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +// All implementations should embed UnimplementedMsgServer +// for forward compatibility +type MsgServer interface { + // Example demonstrates a simple message RPC. + Example(context.Context, *MsgExample) (*MsgExampleResponse, error) +} + +// UnimplementedMsgServer should be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (UnimplementedMsgServer) Example(context.Context, *MsgExample) (*MsgExampleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Example not implemented") +} + +// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MsgServer will +// result in compilation errors. +type UnsafeMsgServer interface { + mustEmbedUnimplementedMsgServer() +} + +func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + s.RegisterService(&Msg_ServiceDesc, srv) +} + +func _Msg_Example_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExample) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Example(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_Example_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Example(ctx, req.(*MsgExample)) + } + return interceptor(ctx, in, info, handler) +} + +// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Msg_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "astro.astro.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Example", + Handler: _Msg_Example_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "astro/astro/v1/tx.proto", +}