Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed May 17, 2023
2 parents 5bbdf7b + 86dac39 commit 2041cb6
Show file tree
Hide file tree
Showing 3,572 changed files with 309,764 additions and 269,929 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ npm install -g @osmonauts/telescope

### Generate

Use the `generate` command to create a new package.
Use the `generate` command to create a new package.

```sh
telescope generate
cd ./your-new-project
yarn
yarn
```
### Add Protobufs

Expand All @@ -98,7 +98,7 @@ telescope install @protobufs/osmosis

### Transpile

To create the Typescript files, run the `transpile` command.
To create the Typescript files, run the `transpile` command.

```sh
telescope transpile
Expand Down Expand Up @@ -224,7 +224,7 @@ telescope({
### LCD Client Options

| option | description | defaults |
| ------------------------------ | -------------------------------------------------------------- | ---------- |
| ------------------------------ | -------------------------------------------------------------- | ---------- |
| `lcdClients.enabled` | generate LCD clients that can query proto `Query` messages | `true` |
| `lcdClients.bundle` | will generate factory bundle aggregate of all LCD Clients | `true` |
| `lcdClients.scoped` | will generate factory of scoped LCD Clients | `undefined`|
Expand All @@ -235,7 +235,7 @@ See [LCD Clients](#lcd-clients) for more info.
### RPC Client Options

| option | description | defaults |
| ------------------------------ | -------------------------------------------------------------- | ----------------------------- |
| ------------------------------ | -------------------------------------------------------------- | ----------------------------- |
| `rpcClients.enabled` | generate RPC clients that can interact with proto messages | `true` |
| `rpcClients.bundle` | will generate factory bundle aggregate of all RPC Clients | `true` |
| `rpcClients.camelCase` | use camel-case for RPC methods when generating RPC clients | `true` |
Expand All @@ -257,31 +257,44 @@ See [RPC Clients](#rpc-clients) for more info.
| option | description | defaults |
| -------------------------------- | ---------------------------------------------------------------------- | ---------|
| `reactQuery.enabled` | if true, will create react hooks that use `@tanstack/react-query` hooks | `false` |
| `reactQuery.include.protos` | if set, will create the hooks on matched proto filenames or patterns using minimatch | `[]` |
| `reactQuery.include.packages` | if set, will create the hooks on matched packages files using minimatch | `[]` |
| `reactQuery.include.patterns` | if set, will create the hooks on matched patterns of files using minimatch(deprecated in favor of packages and protos have been supported minimatch) | `[]` |

#### Mobx

| option | description | defaults |
| -------------------------------- | ---------------------------------------------------------------------- | ---------|
| `mobx.enabled` | if true, will create mobx stores that use `mobx` | `false` |
| `mobx.include.protos` | if set, will create the mobx stores on matched proto filenames or patterns using minimatch | `[]` |
| `mobx.include.packages` | if set, will create the mobx stores on matched packages files using minimatch | `[]` |
| `mobx.include.patterns` | if set, will create the mobx stores on matched patterns of proto files using minimatch(deprecated in favor of packages and protos have been supported minimatch) | `[]` |


#### Pinia

| option | description | defaults |
| -------------------------------- | ---------------------------------------------------------------------- | ---------|
| `pinia.enabled` | if true, will create pinia stores that use `pinia` | `false` |
| `mobx.include.protos` | if set, will create the pinia stores on matched proto filenames or patterns using minimatch | `[]` |
| `mobx.include.packages` | if set, will create the pinia stores on matched packages files using minimatch | `[]` |
| `mobx.include.patterns` | if set, will create the pinia stores on matched patterns of proto files using minimatch(deprecated in favor of packages and protos have been supported minimatch) | `[]` |


### Typings and Formating

| option | description | defaults |
| option | description | defaults |
| ----------------------------------------- | -------------------------------------------------------------- | --------- |
| `prototypes.typingsFormat.customTypes.useCosmosSDKDec` | enable handling "prototypes.typingsFormat.customTypes.useCosmosSDKDec" proto custom type. Used to show decimal fields with the custom type correctly. Highly recommend set to true. | `false` |
| `prototypes.typingsFormat.longLibrary` | 'long' or 'bigint', the way of generating int64 proto types, set to 'bigint' to enable using more stable built-in type | `long` |
| `prototypes.typingsFormat.useDeepPartial` | defaults to true, but if disabled uses the `Partial` TS type | `true` |
| `prototypes.typingsFormat.useExact` | defaults to false, but if enabled uses the `Exact` TS type | `false` |
| `prototypes.typingsFormat.timestamp` | use either `date` or `timestamp` for `Timestamp` proto type | "date" |
| `prototypes.typingsFormat.duration` | use either `duration` or `string` for `Duration` proto type | "duration"|

### Protobuf parser

| option | description | defaults |
| option | description | defaults |
| ----------------------------------------- | -------------------------------------------------------------- | --------- |
| `prototypes.parser.keepCase` | passes `keepCase` to protobuf `parse()` to keep original casing | `true` |
| `prototypes.parser.alternateCommentMode` | passes `alternateCommentMode` to protobuf `parse()` method | `true` |
Expand Down Expand Up @@ -313,6 +326,7 @@ See [RPC Clients](#rpc-clients) for more info.

| option | description | defaults |
| ------------------------------ | ----------------------------------------------------------------- | ---------- |
| `env` | 'default' or 'v-next', set to 'v-next' to enable yet to release features | `default` |
| `removeUnusedImports` | removes unused imports | `true` |
| `classesUseArrowFunctions` | classes use arrow functions instead of `bind()`ing in constructors | `false` |
| `includeExternalHelpers` | exports a few helpers functions in `extern.ts` | `false` |
Expand Down Expand Up @@ -462,7 +476,7 @@ const res = await signAndBroadcast({

## LCD Clients

For querying data via REST endpoints, you can use LCD Clients. For a better developer experience, you can generate a factory of scoped bundles of all LCD Clients with the `lcdClients` option.
For querying data via REST endpoints, you can use LCD Clients. For a better developer experience, you can generate a factory of scoped bundles of all LCD Clients with the `lcdClients` option.

```ts
const options: TelescopeOptions = {
Expand Down Expand Up @@ -540,7 +554,7 @@ main().then(() => {
```
## RPC Clients

For querying data via RPC endpoints, you can use RPC Clients. For a better developer experience, you can generate a factory of scoped bundles of all RPC Clients with the `rpcClients` option.
For querying data via RPC endpoints, you can use RPC Clients. For a better developer experience, you can generate a factory of scoped bundles of all RPC Clients with the `rpcClients` option.

```ts
const options: TelescopeOptions = {
Expand Down Expand Up @@ -593,7 +607,7 @@ const main = async () => {

If you want to instantiate a single client, you can generate RPC classes with the `rpcClients` option;

For any module that has a `Msg`, `Query` or `Service` type, a
For any module that has a `Msg`, `Query` or `Service` type, a

```js
import { osmosis, cosmos } from 'osmojs';
Expand Down Expand Up @@ -651,7 +665,7 @@ export const getCustomSigningClient = async ({ rpcEndpoint, signer }: { rpcEndpo
...osmosis.superfluid.AminoConverter
});

// load the
// load the
osmosis.gamm.v1beta1.load(registry);
osmosis.lockup.load(registry);
osmosis.superfluid.load(registry);
Expand All @@ -673,7 +687,7 @@ Generate TypeScript SDKs for your CosmWasm smart contracts by using the `cosmwas
```ts
import { TSBuilderInput } from '@cosmwasm/ts-codegen';
const options: TelescopeOptions = {
cosmwasm: {
cosmwasm: {
contracts: [
{
name: 'SG721',
Expand Down Expand Up @@ -722,7 +736,7 @@ Here is an example of a `config-overrides.js`:

https://github.com/pyramation/osmosis-ui/blob/main/config-overrides.js

### Babel
### Babel

This should not be an issue, but if you experience problems with syntax or are not using `preset-env`, you may need these babel plugins:

Expand Down
79 changes: 79 additions & 0 deletions __fixtures__/osmojs/cosmos-sdk/proto/amino/amino.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
syntax = "proto3";

package amino;

import "google/protobuf/descriptor.proto";

// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated.
// We need this right now because gogoproto codegen needs to import the extension.
option go_package = "github.com/cosmos/cosmos-sdk/types/tx/amino";

extend google.protobuf.MessageOptions {
// name is the string used when registering a concrete
// type into the Amino type registry, via the Amino codec's
// `RegisterConcrete()` method. This string MUST be at most 39
// characters long, or else the message will be rejected by the
// Ledger hardware device.
string name = 11110001;

// encoding describes the encoding format used by Amino for the given
// message. The field type is chosen to be a string for
// flexibility, but it should ideally be short and expected to be
// machine-readable, for example "base64" or "utf8_json". We
// highly recommend to use underscores for word separation instead of spaces.
//
// If left empty, then the Amino encoding is expected to be the same as the
// Protobuf one.
//
// This annotation should not be confused with the `encoding`
// one which operates on the field level.
string message_encoding = 11110002;
}

extend google.protobuf.FieldOptions {
// encoding describes the encoding format used by Amino for
// the given field. The field type is chosen to be a string for
// flexibility, but it should ideally be short and expected to be
// machine-readable, for example "base64" or "utf8_json". We
// highly recommend to use underscores for word separation instead of spaces.
//
// If left empty, then the Amino encoding is expected to be the same as the
// Protobuf one.
//
// This annotation should not be confused with the
// `message_encoding` one which operates on the message level.
string encoding = 11110003;

// field_name sets a different field name (i.e. key name) in
// the amino JSON object for the given field.
//
// Example:
//
// message Foo {
// string bar = 1 [(amino.field_name) = "baz"];
// }
//
// Then the Amino encoding of Foo will be:
// `{"baz":"some value"}`
string field_name = 11110004;

// dont_omitempty sets the field in the JSON object even if
// its value is empty, i.e. equal to the Golang zero value. To learn what
// the zero values are, see https://go.dev/ref/spec#The_zero_value.
//
// Fields default to `omitempty`, which is the default behavior when this
// annotation is unset. When set to true, then the field value in the
// JSON object will be set, i.e. not `undefined`.
//
// Example:
//
// message Foo {
// string bar = 1;
// string baz = 2 [(amino.dont_omitempty) = true];
// }
//
// f := Foo{};
// out := AminoJSONEncoder(&f);
// out == {"baz":""}
bool dont_omitempty = 11110005;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
syntax = "proto3";
package cosmos.auth.v1beta1;

import "amino/amino.proto";
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 (amino.name) = "cosmos-sdk/BaseAccount";
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = false;

option (cosmos_proto.implements_interface) = "AccountI";

string address = 1;
google.protobuf.Any pub_key = 2 [
(gogoproto.jsontag) = "public_key,omitempty",
(gogoproto.moretags) = "yaml:\"public_key\"",
(amino.field_name) = "public_key"
];
uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""];
uint64 sequence = 4;
}

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

BaseAccount base_account = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""];
string name = 2;
repeated string permissions = 3;
}

// Params defines the parameters for the auth module.
message Params {
option (amino.name) = "cosmos-sdk/x/auth/Params";
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;

uint64 max_memo_characters = 1 [(gogoproto.moretags) = "yaml:\"max_memo_characters\""];
uint64 tx_sig_limit = 2 [(gogoproto.moretags) = "yaml:\"tx_sig_limit\""];
uint64 tx_size_cost_per_byte = 3 [(gogoproto.moretags) = "yaml:\"tx_size_cost_per_byte\""];
uint64 sig_verify_cost_ed25519 = 4
[(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""];
uint64 sig_verify_cost_secp256k1 = 5
[(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
package cosmos.auth.v1beta1;

import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "cosmos/auth/v1beta1/auth.proto";
import "amino/amino.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, (amino.dont_omitempty) = true];

// accounts are the accounts present at genesis.
repeated google.protobuf.Any accounts = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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";
}
}

// 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;
}

// 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 {}

// 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];
}

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

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

0 comments on commit 2041cb6

Please sign in to comment.