Skip to content

Commit

Permalink
chore: add docs under packages/telescope
Browse files Browse the repository at this point in the history
  • Loading branch information
j-yw committed Nov 4, 2024
1 parent b8f1f79 commit 4626b3f
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 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)
- [Name Mappers Configuration](#name-mappers-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 @@ -1098,6 +1102,66 @@ const options: TelescopeOptions = {
};
```

## Name Mappers 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
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 +1243,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.

0 comments on commit 4626b3f

Please sign in to comment.