Skip to content

Commit

Permalink
feat(proto): add cosmos proto sources
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Mar 29, 2022
1 parent ad3efbc commit a8ef3a8
Show file tree
Hide file tree
Showing 108 changed files with 8,932 additions and 0 deletions.
13 changes: 13 additions & 0 deletions proto/cosmos-sdk/cosmos/app/module/v1alpha1/module.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";

package cosmos.app.module.v1alpha1;

import "cosmos/app/v1alpha1/module.proto";

// Module is the module config object for the cosmos.app v1 app module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/cosmos/cosmos-sdk/app"
use_package: {name: "cosmos.app.v1alpha1"}
};
}
36 changes: 36 additions & 0 deletions proto/cosmos-sdk/cosmos/app/v1alpha1/config.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
syntax = "proto3";

package cosmos.app.v1alpha1;

import "google/protobuf/any.proto";

// Config represents the configuration for a Cosmos SDK ABCI app.
// It is intended that all state machine logic including the version of
// baseapp and tx handlers (and possibly even Tendermint) that an app needs
// can be described in a config object. For compatibility, the framework should
// allow a mixture of declarative and imperative app wiring, however, apps
// that strive for the maximum ease of maintainability should be able to describe
// their state machine with a config object alone.
message Config {
// modules are the module configurations for the app.
repeated ModuleConfig modules = 1;
}

// ModuleConfig is a module configuration for an app.
message ModuleConfig {
// name is the unique name of the module within the app. It should be a name
// that persists between different versions of a module so that modules
// can be smoothly upgraded to new versions.
//
// For example, for the module cosmos.bank.module.v1.Module, we may chose
// to simply name the module "bank" in the app. When we upgrade to
// cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same
// and the framework knows that the v2 module should receive all the same state
// that the v1 module had. Note: modules should provide info on which versions
// they can migrate from in the ModuleDescriptor.can_migration_from field.
string name = 1;

// config is the config object for the module. Module config messages should
// define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension.
google.protobuf.Any config = 2;
}
93 changes: 93 additions & 0 deletions proto/cosmos-sdk/cosmos/app/v1alpha1/module.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
syntax = "proto3";

package cosmos.app.v1alpha1;

import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
// module indicates that this proto type is a config object for an app module
// and optionally provides other descriptive information about the module.
// It is recommended that a new module config object and go module is versioned
// for every state machine breaking version of a module. The recommended
// pattern for doing this is to put module config objects in a separate proto
// package from the API they expose. Ex: the cosmos.group.v1 API would be
// exposed by module configs cosmos.group.module.v1, cosmos.group.module.v2, etc.
ModuleDescriptor module = 57193479;
}

// ModuleDescriptor describes an app module.
message ModuleDescriptor {
// go_import names the package that should be imported by an app to load the
// module in the runtime module registry. Either go_import must be defined here
// or the go_package option must be defined at the file level to indicate
// to users where to location the module implementation. go_import takes
// precedence over go_package when both are defined.
string go_import = 1;

// use_package refers to a protobuf package that this module
// uses and exposes to the world. In an app, only one module should "use"
// or own a single protobuf package. It is assumed that the module uses
// all of the .proto files in a single package.
repeated PackageReference use_package = 2;

// can_migrate_from defines which module versions this module can migrate
// state from. The framework will check that one module version is able to
// migrate from a previous module version before attempting to update its
// config. It is assumed that modules can transitively migrate from earlier
// versions. For instance if v3 declares it can migrate from v2, and v2
// declares it can migrate from v1, the framework knows how to migrate
// from v1 to v3, assuming all 3 module versions are registered at runtime.
repeated MigrateFromInfo can_migrate_from = 3;
}

// PackageReference is a reference to a protobuf package used by a module.
message PackageReference {
// name is the fully-qualified name of the package.
string name = 1;

// revision is the optional revision of the package that is being used.
// Protobuf packages used in Cosmos should generally have a major version
// as the last part of the package name, ex. foo.bar.baz.v1.
// The revision of a package can be thought of as the minor version of a
// package which has additional backwards compatible definitions that weren't
// present in a previous version.
//
// A package should indicate its revision with a source code comment
// above the package declaration in one of its fields containing the
// test "Revision N" where N is an integer revision. All packages start
// at revision 0 the first time they are released in a module.
//
// When a new version of a module is released and items are added to existing
// .proto files, these definitions should contain comments of the form
// "Since Revision N" where N is an integer revision.
//
// When the module runtime starts up, it will check the pinned proto
// image and panic if there are runtime protobuf definitions that are not
// in the pinned descriptor which do not have
// a "Since Revision N" comment or have a "Since Revision N" comment where
// N is <= to the revision specified here. This indicates that the protobuf
// files have been updated, but the pinned file descriptor hasn't.
//
// If there are items in the pinned file descriptor with a revision
// greater than the value indicated here, this will also cause a panic
// as it may mean that the pinned descriptor for a legacy module has been
// improperly updated or that there is some other versioning discrepancy.
// Runtime protobuf definitions will also be checked for compatibility
// with pinned file descriptors to make sure there are no incompatible changes.
//
// This behavior ensures that:
// * pinned proto images are up-to-date
// * protobuf files are carefully annotated with revision comments which
// are important good client UX
// * protobuf files are changed in backwards and forwards compatible ways
uint32 revision = 2;
}

// MigrateFromInfo is information on a module version that a newer module
// can migrate from.
message MigrateFromInfo {

// module is the fully-qualified protobuf name of the module config object
// for the previous module version, ex: "cosmos.group.module.v1.Module".
string module = 1;
}
22 changes: 22 additions & 0 deletions proto/cosmos-sdk/cosmos/app/v1alpha1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";

package cosmos.app.v1alpha1;

import "cosmos/app/v1alpha1/config.proto";

// Query is the app module query service.
service Query {

// Config returns the current app config.
rpc Config(QueryConfigRequest) returns (QueryConfigResponse) {}
}

// QueryConfigRequest is the Query/Config request type.
message QueryConfigRequest {}

// QueryConfigRequest is the Query/Config response type.
message QueryConfigResponse {

// config is the current app config.
Config config = 1;
}
47 changes: 47 additions & 0 deletions proto/cosmos-sdk/cosmos/auth/v1beta1/auth.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";
package cosmos.auth.v1beta1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";

// BaseAccount defines a base account type. It contains all the necessary fields
// for basic account functionality. Any custom account type should extend this
// type for additional functionality (e.g. vesting).
message BaseAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = false;

option (cosmos_proto.implements_interface) = "AccountI";

string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty"];
uint64 account_number = 3;
uint64 sequence = 4;
}

// ModuleAccount defines an account for modules that holds coins on a pool.
message ModuleAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos_proto.implements_interface) = "ModuleAccountI";

BaseAccount base_account = 1 [(gogoproto.embed) = true];
string name = 2;
repeated string permissions = 3;
}

// Params defines the parameters for the auth module.
message Params {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;

uint64 max_memo_characters = 1;
uint64 tx_sig_limit = 2;
uint64 tx_size_cost_per_byte = 3;
uint64 sig_verify_cost_ed25519 = 4 [(gogoproto.customname) = "SigVerifyCostED25519"];
uint64 sig_verify_cost_secp256k1 = 5 [(gogoproto.customname) = "SigVerifyCostSecp256k1"];
}
17 changes: 17 additions & 0 deletions proto/cosmos-sdk/cosmos/auth/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";
package cosmos.auth.v1beta1;

import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "cosmos/auth/v1beta1/auth.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";

// GenesisState defines the auth module's genesis state.
message GenesisState {
// params defines all the paramaters of the module.
Params params = 1 [(gogoproto.nullable) = false];

// accounts are the accounts present at genesis.
repeated google.protobuf.Any accounts = 2;
}
130 changes: 130 additions & 0 deletions proto/cosmos-sdk/cosmos/auth/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
syntax = "proto3";
package cosmos.auth.v1beta1;

import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "cosmos/auth/v1beta1/auth.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";

// Query defines the gRPC querier service.
service Query {
// Accounts returns all the existing accounts
//
// Since: cosmos-sdk 0.43
rpc Accounts(QueryAccountsRequest) returns (QueryAccountsResponse) {
option (google.api.http).get = "/cosmos/auth/v1beta1/accounts";
}

// Account returns account details based on address.
rpc Account(QueryAccountRequest) returns (QueryAccountResponse) {
option (google.api.http).get = "/cosmos/auth/v1beta1/accounts/{address}";
}

// Params queries all parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cosmos/auth/v1beta1/params";
}

// ModuleAccounts returns all the existing module accounts.
rpc ModuleAccounts(QueryModuleAccountsRequest) returns (QueryModuleAccountsResponse) {
option (google.api.http).get = "/cosmos/auth/v1beta1/module_accounts";
}

// Bech32 queries bech32Prefix
rpc Bech32Prefix(Bech32PrefixRequest) returns (Bech32PrefixResponse) {
option (google.api.http).get = "/cosmos/auth/v1beta1/bech32";
}

// AddressBytesToString converts Account Address bytes to string
rpc AddressBytesToString(AddressBytesToStringRequest) returns (AddressBytesToStringResponse) {
option (google.api.http).get = "/cosmos/auth/v1beta1/bech32/{address_bytes}";
}

// AddressStringToBytes converts Address string to bytes
rpc AddressStringToBytes(AddressStringToBytesRequest) returns (AddressStringToBytesResponse) {
option (google.api.http).get = "/cosmos/auth/v1beta1/bech32/{address_string}";
}
}

// QueryAccountsRequest is the request type for the Query/Accounts RPC method.
//
// Since: cosmos-sdk 0.43
message QueryAccountsRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryAccountsResponse is the response type for the Query/Accounts RPC method.
//
// Since: cosmos-sdk 0.43
message QueryAccountsResponse {
// accounts are the existing accounts
repeated google.protobuf.Any accounts = 1 [(cosmos_proto.accepts_interface) = "AccountI"];

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryAccountRequest is the request type for the Query/Account RPC method.
message QueryAccountRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address defines the address to query for.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryModuleAccountsRequest is the request type for the Query/ModuleAccounts RPC method.
message QueryModuleAccountsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
}

// QueryAccountResponse is the response type for the Query/Account RPC method.
message QueryAccountResponse {
// account defines the account of the corresponding address.
google.protobuf.Any account = 1 [(cosmos_proto.accepts_interface) = "AccountI"];
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryModuleAccountsResponse is the response type for the Query/ModuleAccounts RPC method.
message QueryModuleAccountsResponse {
repeated google.protobuf.Any accounts = 1 [(cosmos_proto.accepts_interface) = "ModuleAccountI"];
}

// Bech32PrefixRequest is the request type for Bech32Prefix rpc method
message Bech32PrefixRequest {}

// Bech32PrefixResponse is the response type for Bech32Prefix rpc method
message Bech32PrefixResponse {
string bech32_prefix = 1;
}

// AddressBytesToStringRequest is the request type for AddressString rpc method
message AddressBytesToStringRequest {
bytes address_bytes = 1;
}

// AddressBytesToStringResponse is the response type for AddressString rpc method
message AddressBytesToStringResponse {
string address_string = 1;
}

// AddressStringToBytesRequest is the request type for AccountBytes rpc method
message AddressStringToBytesRequest {
string address_string = 1;
}

// AddressStringToBytesResponse is the response type for AddressBytes rpc method
message AddressStringToBytesResponse {
bytes address_bytes = 1;
}
Loading

0 comments on commit a8ef3a8

Please sign in to comment.