Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update docs #686

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ The following blockchain libraries (generated by Telescope) are available via np
- [Manually registering types](#manually-registering-types)
- [JSON Patch Protos](#json-patch-protos)
- [CosmWasm](#cosmwasm)
- [Helper Functions Configuration](#helper-functions-configuration)
- [Pattern Matching Priority:](#pattern-matching-priority)
- [Generated Output Examples:](#generated-output-examples)
- [Notes:](#notes)
- [Dependencies](#dependencies)
- [Troubleshooting](#troubleshooting)
- [Create React App](#create-react-app)
Expand Down Expand Up @@ -396,6 +400,8 @@ See [RPC Clients](#rpc-clients) for more info.
| `helperFuncCreators.nameMappers.Msg.creatorPrefix`| Prefix for the function creator for `Msg` services. | `"create"` |
| `helperFuncCreators.nameMappers.Msg.hookPrefix` | Prefix for the hooks for `Msg` services. | `"use"` |

See [Helper Functions Configuration](#helper-functions-configuration) for more info.

### Stargate Client Options

| option | description | defaults |
Expand Down Expand Up @@ -1098,6 +1104,67 @@ const options: TelescopeOptions = {
};
```


## Helper Functions Configuration
The nameMappers object supports three service types: All, Query, and Msg. Each pattern within these categories can specify:
```js
{
"pattern": {
funcBody: (name: string) => string, // Function to transform the method name
creatorPrefix?: string, // Prefix for the creator function (default: "create")
hookPrefix?: string // Prefix for the hook function (default: "use")
}
}
```

```js
const options: TelescopeOptions = {
helperFuncCreators: {
enabled: true,
genCustomHooks: true,
include: {
patterns: ["cosmos.gov.v1beta1.**", "cosmos.bank.v1beta1.*Send*"],
},
nameMappers: {
All: {
"cosmos.gov.v1beta1.*Vote*": {
funcBody: (name) => `helper${name}`,
creatorPrefix: "build",
hookPrefix: "use",
},
},
Query: {
"cosmos.gov.v1beta1.*Deposits*": {
funcBody: (name) => `goOver${name}`,
},
},
Msg: {
"cosmos.gov.v1beta1.*VoteWeighted*": {
funcBody: (name) => `lets${name}`,
creatorPrefix: "construct",
hookPrefix: "useTx",
},
},
},
},
};

```
### Pattern Matching Priority:
1. Service-specific patterns (`Query`, `Msg`) take precedence over `All` patterns
2. More specific patterns take precedence over general patterns
3. Patterns are case-sensitive
### Generated Output Examples:
- For a method named `VoteWeighted`:
- Default: `createVoteWeighted` and `useVoteWeighted`
- With custom mapping: `constructLetsVoteWeighted` and `useTxLetsVoteWeighted`
### Notes:
- Patterns support glob-style matching (e.g., `**`, `*`)
- Each service type can have its own naming conventions
- Custom prefixes are optional; defaults will be used if not specified
- Function body transformations can be customized using the funcBody property


## Dependencies

If you don't use the boilerplate, you will need to manually install
Expand Down
68 changes: 68 additions & 0 deletions packages/telescope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ The following blockchain libraries (generated by Telescope) are available via np
- [Manually registering types](#manually-registering-types)
- [JSON Patch Protos](#json-patch-protos)
- [CosmWasm](#cosmwasm)
- [Helper Functions Configuration](#helper-functions-configuration)
- [Pattern Matching Priority:](#pattern-matching-priority)
- [Generated Output Examples:](#generated-output-examples)
- [Notes:](#notes)
- [Dependencies](#dependencies)
- [Troubleshooting](#troubleshooting)
- [Create React App](#create-react-app)
Expand Down Expand Up @@ -396,6 +400,8 @@ See [RPC Clients](#rpc-clients) for more info.
| `helperFuncCreators.nameMappers.Msg.creatorPrefix`| Prefix for the function creator for `Msg` services. | `"create"` |
| `helperFuncCreators.nameMappers.Msg.hookPrefix` | Prefix for the hooks for `Msg` services. | `"use"` |

See [Helper Functions Configuration](#helper-functions-configuration) for more info.

### Stargate Client Options

| option | description | defaults |
Expand Down Expand Up @@ -1098,6 +1104,67 @@ const options: TelescopeOptions = {
};
```


## Helper Functions Configuration
The nameMappers object supports three service types: All, Query, and Msg. Each pattern within these categories can specify:
```js
{
"pattern": {
funcBody: (name: string) => string, // Function to transform the method name
creatorPrefix?: string, // Prefix for the creator function (default: "create")
hookPrefix?: string // Prefix for the hook function (default: "use")
}
}
```

```js
const options: TelescopeOptions = {
helperFuncCreators: {
enabled: true,
genCustomHooks: true,
include: {
patterns: ["cosmos.gov.v1beta1.**", "cosmos.bank.v1beta1.*Send*"],
},
nameMappers: {
All: {
"cosmos.gov.v1beta1.*Vote*": {
funcBody: (name) => `helper${name}`,
creatorPrefix: "build",
hookPrefix: "use",
},
},
Query: {
"cosmos.gov.v1beta1.*Deposits*": {
funcBody: (name) => `goOver${name}`,
},
},
Msg: {
"cosmos.gov.v1beta1.*VoteWeighted*": {
funcBody: (name) => `lets${name}`,
creatorPrefix: "construct",
hookPrefix: "useTx",
},
},
},
},
};

```
### Pattern Matching Priority:
1. Service-specific patterns (`Query`, `Msg`) take precedence over `All` patterns
2. More specific patterns take precedence over general patterns
3. Patterns are case-sensitive
### Generated Output Examples:
- For a method named `VoteWeighted`:
- Default: `createVoteWeighted` and `useVoteWeighted`
- With custom mapping: `constructLetsVoteWeighted` and `useTxLetsVoteWeighted`
### Notes:
- Patterns support glob-style matching (e.g., `**`, `*`)
- Each service type can have its own naming conventions
- Custom prefixes are optional; defaults will be used if not specified
- Function body transformations can be customized using the funcBody property


## Dependencies

If you don't use the boilerplate, you will need to manually install
Expand Down Expand Up @@ -1179,3 +1246,4 @@ Thanks to these engineers, teams and projects for inspiring Telescope:
AS DESCRIBED IN THE TELESCOPE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating Telescope will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Telescope code or Telescope CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

Loading