Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-yw committed Nov 5, 2024
1 parent 298c5cc commit 6c544a4
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 134 deletions.
132 changes: 65 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ The following blockchain libraries (generated by Telescope) are available via np
- [LCD Client Options](#lcd-client-options)
- [RPC Client Options](#rpc-client-options)
- [Helper Functions](#helper-functions)
- [Name Mappers Configuration](#name-mappers-configuration)
- [Pattern Matching Priority:](#pattern-matching-priority)
- [Generated Output Examples:](#generated-output-examples)
- [Notes:](#notes)
- [Stargate Client Options](#stargate-client-options)
- [State Management](#state-management)
- [React Query](#react-query)
Expand Down Expand Up @@ -92,11 +96,6 @@ 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](#helper-functions-1)
- [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 @@ -401,6 +400,67 @@ 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"` |

### 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
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



### Stargate Client Options

| option | description | defaults |
Expand Down Expand Up @@ -1103,68 +1163,6 @@ const options: TelescopeOptions = {
};
```

## Helper Functions

### 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
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
132 changes: 65 additions & 67 deletions packages/telescope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ The following blockchain libraries (generated by Telescope) are available via np
- [LCD Client Options](#lcd-client-options)
- [RPC Client Options](#rpc-client-options)
- [Helper Functions](#helper-functions)
- [Name Mappers Configuration](#name-mappers-configuration)
- [Pattern Matching Priority:](#pattern-matching-priority)
- [Generated Output Examples:](#generated-output-examples)
- [Notes:](#notes)
- [Stargate Client Options](#stargate-client-options)
- [State Management](#state-management)
- [React Query](#react-query)
Expand Down Expand Up @@ -92,11 +96,6 @@ 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](#helper-functions-1)
- [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 @@ -401,6 +400,67 @@ 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"` |

### 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
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



### Stargate Client Options

| option | description | defaults |
Expand Down Expand Up @@ -1103,68 +1163,6 @@ const options: TelescopeOptions = {
};
```

## Helper Functions

### 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
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

0 comments on commit 6c544a4

Please sign in to comment.