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
Changes from 1 commit
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
64 changes: 64 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)
- [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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the top level of this should be sth like: Helper Functions. And include this part inside.

And under the Options of Helper Functions, We can have a reference like others did:

See Helper Functions for more info.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, can you please take another look, thank you.

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
Loading