Skip to content
Merged
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
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The following blockchain libraries (generated by Telescope) are available via np
- [Amino Encoding](#amino-encoding)
- [Prototypes Options](#prototypes-options)
- [Prototypes Methods](#prototypes-methods)
- [Enums Methods](#enums-options)
- [LCD Client Options](#lcd-client-options)
- [RPC Client Options](#rpc-client-options)
- [Stargate Client Options](#stargate-client-options)
Expand Down Expand Up @@ -79,6 +80,7 @@ The following blockchain libraries (generated by Telescope) are available via np
- [RPC Client Classes](#rpc-client-classes)
- [Instant RPC Methods](#instant-rpc-methods)
- [Manually registering types](#manually-registering-types)
- [JSON Patch Protos](#json-patch-protos)
- [CosmWasm](#cosmwasm)
- [Dependencies](#dependencies)
- [Troubleshooting](#troubleshooting)
Expand Down Expand Up @@ -314,6 +316,7 @@ telescope({
| `prototypes.addTypeUrlToObjects` | add typeUrl field to generated Decoders | `true` |
| `prototypes.enableRegistryLoader` | generate Registry loader to *.registry.ts files | `true` |
| `prototypes.enableMessageComposer` | generate MessageComposer to *.registry.ts files | `true` |
| `prototypes.patch` | An object mapping filenames to an array of `Operation` to be applied as patches to proto files during generation. See [JSON Patch Protos](#json-patch-protos) | `undefined`|

### Prototypes Methods

Expand All @@ -327,6 +330,13 @@ telescope({
| `prototypes.methods.fromSDK` | boolean to enable `fromSDK` method on proto objects | `false` |
| `prototypes.methods.toSDK` | boolean to enable `toSDK` method on proto objects | `false` |

### Enums Options

| option | description | defaults |
| ------------------------------------- | --------------------------------------------------------------- | ---------- |
| `enums.useCustomNames` | Enables the usage of custom names for enums if specified through proto options or annotations, allowing for more descriptive or project-specific naming conventions. | `false` |


### LCD Client Options

| option | description | defaults |
Expand Down Expand Up @@ -986,6 +996,51 @@ export const getCustomSigningClient = async ({ rpcEndpoint, signer }: { rpcEndpo
};
```

## JSON Patch Protos

The `prototypes.patch` configuration within the options object allows for dynamic modifications to protobuf definitions during code generation. This feature is designed to apply specific changes to proto files without altering the original source. By using JSON Patch operations such as `replace` and `add`, developers can customize the generated output to better fit project requirements when upstream SDK PRs are lagging or not in production.

Patches are specified as arrays of `Operation`s, where each operation is defined by:
- `op`: The operation type (`add` or `replace`).
- `path`: The JSON path to the target field, optionally prefixed with `@` to denote paths derived automatically from the package name, simplifying navigation within the proto file's structure.
- `value`: The new value to be set at the target location specified by the path.

Here is how these patches can be defined within the prototypes configuration:

```json
{
"prototypes": {
"patch": {
"cosmwasm/wasm/v1/types.proto": [
{
"op": "replace",
"path": "@/AccessType/valuesOptions/ACCESS_TYPE_UNSPECIFIED/(gogoproto.enumvalue_customname)",
"value": "UnspecifiedAccess"
},
{
"op": "replace",
"path": "@/AccessType/valuesOptions/ACCESS_TYPE_NOBODY/(gogoproto.enumvalue_customname)",
"value": "NobodyAccess"
},
{
"op": "add",
"path": "@/AccessType/values/ACCESS_TYPE_SUPER_FUN",
"value": 4
},
{
"op": "add",
"path": "@/AccessType/valuesOptions/ACCESS_TYPE_SUPER_FUN",
"value": {
"(gogoproto.enumvalue_customname)": "SuperFunAccessType"
}
}
]
}
}
}
```


## CosmWasm

Generate TypeScript SDKs for your CosmWasm smart contracts by using the `cosmwasm` option on `TelescopeOptions`. The `cosmwasm` option is actually a direct reference to the `TSBuilderInput` object, for the most up-to-date documentation, visit [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen).
Expand Down
Loading