feat: init API go module (#10600)
* feat: init api module * add script * update cosmos-proto
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
version: v1
|
||||
managed:
|
||||
enabled: true
|
||||
go_package_prefix:
|
||||
default: github.com/cosmos/cosmos-sdk/api
|
||||
plugins:
|
||||
- name: go-pulsar
|
||||
out: .
|
||||
opt: paths=source_relative
|
||||
@@ -0,0 +1,13 @@
|
||||
version: v1
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
lint:
|
||||
use:
|
||||
- DEFAULT
|
||||
- COMMENTS
|
||||
- FILE_LOWER_SNAKE_CASE
|
||||
except:
|
||||
- SERVICE_SUFFIX
|
||||
- PACKAGE_VERSION_SUFFIX
|
||||
- RPC_REQUEST_STANDARD_NAME
|
||||
@@ -0,0 +1,114 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cosmos.orm.v1alpha1;
|
||||
|
||||
import "google/protobuf/descriptor.proto";
|
||||
|
||||
extend google.protobuf.MessageOptions {
|
||||
|
||||
// table specifies that this message will be used as an ORM table. It cannot
|
||||
// be used together with the singleton option.
|
||||
TableDescriptor table = 104503790;
|
||||
|
||||
// singleton specifies that this message will be used as an ORM singleton. It cannot
|
||||
// be used together with the table option.
|
||||
SingletonDescriptor singleton = 104503791;
|
||||
}
|
||||
|
||||
// TableDescriptor describes an ORM table.
|
||||
message TableDescriptor {
|
||||
|
||||
// primary_key defines the primary key for the table.
|
||||
PrimaryKeyDescriptor primary_key = 1;
|
||||
|
||||
// index defines one or more secondary indexes.
|
||||
repeated SecondaryIndexDescriptor index = 2;
|
||||
|
||||
// id is a non-zero integer ID that must be unique within the
|
||||
// tables and singletons in this file. It may be deprecated in the future when this
|
||||
// can be auto-generated.
|
||||
uint32 id = 3;
|
||||
}
|
||||
|
||||
// PrimaryKeyDescriptor describes a table primary key.
|
||||
message PrimaryKeyDescriptor {
|
||||
|
||||
// fields is a comma-separated list of fields in the primary key. Spaces are
|
||||
// not allowed. Supported field types, their encodings, and any applicable constraints
|
||||
// are described below.
|
||||
// - uint32, uint64 are encoded as big-endian fixed width bytes and support
|
||||
// sorted iteration.
|
||||
// - string's are encoded as raw bytes in terminal key segments and null-terminated
|
||||
// in non-terminal segments. Null characters are thus forbidden in strings.
|
||||
// string fields support sorted iteration.
|
||||
// - bytes are encoded as raw bytes in terminal segments and length-prefixed
|
||||
// with a single byte in non-terminal segments. Because of this byte arrays
|
||||
// longer than 255 bytes cannot be used in keys and bytes fields should not
|
||||
// be assumed to be lexically sorted.
|
||||
// - int32, sint32, int64, sint64 are encoding as fixed width bytes with
|
||||
// an encoding that enables sorted iteration.
|
||||
// - google.protobuf.Timestamp and google.protobuf.Duration are encoded
|
||||
// as 12 bytes using an encoding that enables sorted iteration.
|
||||
// - enum fields are encoded using varint encoding and do not support sorted
|
||||
// iteration.
|
||||
// - bool fields are encoded as a single byte 0 or 1.
|
||||
//
|
||||
// All other fields types are unsupported in keys including repeated and
|
||||
// oneof fields.
|
||||
//
|
||||
// Primary keys are prefixed by the varint encoded table id and the byte 0x0
|
||||
// plus any additional prefix specified by the schema.
|
||||
string fields = 1;
|
||||
|
||||
// auto_increment specifies that the primary key is generated by an
|
||||
// auto-incrementing integer. If this is set to true fields must only
|
||||
// contain one field of that is of type uint64.
|
||||
bool auto_increment = 2;
|
||||
|
||||
// references specifies that this primary key references the primary key
|
||||
// of another table. See the documentation for the SecondaryIndexDescriptor.references
|
||||
// field for more details. An additional constraint placed on primary keys
|
||||
// which reference another table is that those references cannot be circular.
|
||||
string references = 3;
|
||||
}
|
||||
|
||||
// PrimaryKeyDescriptor describes a table secondary index.
|
||||
message SecondaryIndexDescriptor {
|
||||
|
||||
// fields is a comma-separated list of fields in the index. The supported
|
||||
// field types are the same as those for PrimaryKeyDescriptor.fields.
|
||||
// Index keys are prefixed by the varint encoded table id and the varint
|
||||
// encoded index id plus any additional prefix specified by the schema.
|
||||
//
|
||||
// In addition the the field segments, non-unique index keys are suffixed with
|
||||
// any additional primary key fields not present in the index fields so that the
|
||||
// primary key can be reconstructed. Unique indexes instead of being suffixed
|
||||
// store the remaining primary key fields in the value..
|
||||
string fields = 1;
|
||||
|
||||
// id is a non-zero integer ID that must be unique within the indexes for this
|
||||
// table. It may be deprecated in the future when this can be auto-generated.
|
||||
uint32 id = 2;
|
||||
|
||||
// unique specifies that this an unique index.
|
||||
bool unique = 3;
|
||||
|
||||
// references specifies that this index references another table defined in the same
|
||||
// proto file. Currently references are not support to tables with composite
|
||||
// primary keys, therefore fields must reference one field and its type must
|
||||
// be the same type as the primary key field of the referenced table.
|
||||
// References to tables in defined by different proto files are not supported
|
||||
// to avoid tight coupling of dependencies. Beyond validating that the reference
|
||||
// is valid key constraints are currently not enforced, but references should
|
||||
// be used by clients to perform automatic joins.
|
||||
string references = 4;
|
||||
}
|
||||
|
||||
// TableDescriptor describes an ORM singleton table which has at most one instance.
|
||||
message SingletonDescriptor {
|
||||
|
||||
// id is a non-zero integer ID that must be unique within the
|
||||
// tables and singletons in this file. It may be deprecated in the future when this
|
||||
// can be auto-generated.
|
||||
uint32 id = 1;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cosmos.orm.v1alpha1;
|
||||
|
||||
import "google/protobuf/descriptor.proto";
|
||||
|
||||
// SchemaDescriptor describes an ORM schema that contains all the information
|
||||
// needed for a dynamic client to decode the stored data.
|
||||
message SchemaDescriptor {
|
||||
|
||||
// files is the set of all FileDescriptorProto's needed to decode the stored data.
|
||||
// A schema imposes the constraint that every file and every table within that
|
||||
// schema have at most one instance in the store.
|
||||
google.protobuf.FileDescriptorSet files = 1;
|
||||
|
||||
// modules is the set of modules in the schema.
|
||||
repeated ModuleEntry modules = 2;
|
||||
|
||||
// ModuleEntry describes a single module's schema.
|
||||
message ModuleEntry {
|
||||
// name is the name of the module. In the multi-store model this name is
|
||||
// used to locate the module's store.
|
||||
string name = 1;
|
||||
|
||||
// prefix is an optional prefix that precedes all keys in this module's
|
||||
// store.
|
||||
bytes prefix = 2;
|
||||
|
||||
// files describes the schema files used in this module.
|
||||
repeated FileEntry files = 3;
|
||||
}
|
||||
|
||||
// FileEntry describes an ORM file used in a module.
|
||||
message FileEntry {
|
||||
// id is a prefix that will be varint encoded and prepended to all the
|
||||
// table keys specified in the file's tables.
|
||||
uint32 id = 1;
|
||||
|
||||
// file_name is the name of a file in the FileDescriptor set that contains
|
||||
// table definitions.
|
||||
string file_name = 2;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
module github.com/cosmos/cosmos-sdk/api
|
||||
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/cosmos/cosmos-proto v1.0.0-alpha1
|
||||
google.golang.org/protobuf v1.27.1
|
||||
)
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
github.com/cosmos/cosmos-proto v0.0.0-20211123144845-528f5002c9f8 h1:JOVLjm4qgBMnjZIciFqfFMzeIIuJTOXdlpzJdvXQbVA=
|
||||
github.com/cosmos/cosmos-proto v0.0.0-20211123144845-528f5002c9f8/go.mod h1:msdDWOvfStHLG+Z2y2SJ0dcqimZ2vc8M1MPnZ4jOF7U=
|
||||
github.com/cosmos/cosmos-proto v1.0.0-alpha1 h1:1taNmovbd2WlO6zfaJTRhQ21DjWROiepfWbiDDLKMWQ=
|
||||
github.com/cosmos/cosmos-proto v1.0.0-alpha1/go.mod h1:msdDWOvfStHLG+Z2y2SJ0dcqimZ2vc8M1MPnZ4jOF7U=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.27.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
|
||||
Reference in New Issue
Block a user