Skip to content

Commit a207b31

Browse files
committed
docs: update telescope docs and add new rpc docs
1 parent 944e123 commit a207b31

File tree

4 files changed

+12506
-13241
lines changed

4 files changed

+12506
-13241
lines changed

.DS_Store

0 Bytes
Binary file not shown.

docs/apis/rpc/interact-rpc.mdx

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Interacting with RPC endpoints
2+
3+
As shown on the RPC specifications, there are different endpoints to communicate with the Osmosis chain. Unlike the LCD rest api, the RPC endpoints provide genereic endpoints to communicate with the various modules available. For example the [ABCI Query](/api?v=RPC#/operations/abci_query) allows you the query different data from Osmosis.
4+
5+
For more information please read generating, [signing and boradcasting transactions.] https://docs.cosmos.network/v0.46/run-node/txs.html on the cosmos-sdk docs.
6+
7+
## Querying the ABCI Query with Javascript via Telescope
8+
9+
If you are looking to query, sign and broadcast transactions using Javascript. Telescope and OsmoJS make this very easy. The following is a very simple example of you could acomplish this using Telescope.
10+
11+
## Setting up Telescope
12+
```bash
13+
# Install dependencies
14+
yarn install
15+
# Install Telescope
16+
npm install -g @osmonauts/telescope
17+
# Select the chains you would like to interact with
18+
telescope install
19+
# Generate types
20+
yarn codegen
21+
```
22+
## Ssimple query example
23+
Edit src/index.ts
24+
```javascript
25+
26+
import { osmosis } from "./codegen";
27+
const { createRPCQueryClient } = osmosis.ClientFactory;
28+
29+
30+
async function getBalance() {
31+
32+
const client = await createRPCQueryClient({ rpcEndpoint: "https://rpc.osmosis.zone" });
33+
// // now you can query the cosmos modules
34+
const balance = await client.cosmos.bank.v1beta1
35+
.allBalances({ address: 'osmo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3aq6l09' });
36+
}
37+
38+
async function getPools() {
39+
40+
const client = await createRPCQueryClient({ rpcEndpoint: "https://rpc.osmosis.zone" });
41+
const pools = await client.osmosis.gamm.v1beta1.pools();
42+
console.log(pools);
43+
}
44+
45+
getPools().catch(console.error);
46+
getBalance().catch(console.error);
47+
48+
```
49+
50+
Run the code and see the responses from the rpc endpoint.
51+
```bash
52+
yarn dev
53+
````
54+
55+
For extended details and documentations, see the documentation for Telescope.
56+
57+
58+

docs/telescope/README.md

+119-61
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,69 @@ A "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protob
2121

2222
The following blockchain libraries (generated by Telescope) are available via npm
2323

24-
* [akashjs](https://www.npmjs.com/package/akashjs)
25-
* [comdex](https://www.npmjs.com/package/comdex)
2624
* [osmojs](https://www.npmjs.com/package/osmojs)
27-
* [pylonsjs](https://www.npmjs.com/package/pylonsjs)
2825
* [stargazejs](https://www.npmjs.com/package/stargazejs)
2926
* [juno-network](https://www.npmjs.com/package/juno-network)
27+
* [stridejs](https://www.npmjs.com/package/stridejs)
28+
* [akashjs](https://www.npmjs.com/package/akashjs)
29+
* [comdex](https://www.npmjs.com/package/comdex)
30+
* [pylonsjs](https://www.npmjs.com/package/pylonsjs)
31+
32+
🎥 [Checkout our video playlist](https://www.youtube.com/watch?v=n82MsLe82mk&list=PL-lMkVv7GZwyQaK6bp6kMdOS5mzosxytC) to learn how to use `telescope`!
3033

3134
## Table of contents
3235

33-
- [Telescope](#telescope)
36+
- [Telescope 🔭](#telescope-)
3437
- [Table of contents](#table-of-contents)
35-
- [QuickStart](#quickstart)
38+
- [Quickstart](#quickstart)
39+
- [Generate](#generate)
40+
- [Add Protobufs](#add-protobufs)
41+
- [Transpile](#transpile)
42+
- [Build](#build)
3643
- [Usage](#usage)
37-
- [Programmatic Usage](#programatic-usage)
38-
- [Options](#options)
39-
- [Types](#types)
40-
- [Composing Messages](#composing-messages)
41-
- [Calculating Fees](#calculating-fees)
42-
- [Stargate Clients](#stargate-clients)
43-
- [Creating Signers](#creating-signers)
44-
- [Broadcasting Messages](#broadcasting-messages)
45-
- [LCD Clients](#lcd-clients)
46-
- [RPC Clients](#rpc-clients)
47-
- [CosmWasm](#cosmwasm)
48-
- [Dependencies](#dependencies)
49-
- [Manually Registering Types](#manually-registering-types)
50-
- [Troubleshooting](#troubleshooting)
51-
- [Development](#developing)
52-
- [Sponsors](#sponsors)
53-
- [Related](#related)
54-
- [Credits](#credits)
44+
- [Programatic Usage](#programatic-usage)
45+
- [Options](#options)
46+
- [Amino Encoding](#amino-encoding)
47+
- [Prototypes Options](#prototypes-options)
48+
- [Prototypes Methods](#prototypes-methods)
49+
- [LCD Client Options](#lcd-client-options)
50+
- [RPC Client Options](#rpc-client-options)
51+
- [Stargate Client Options](#stargate-client-options)
52+
- [Typings and Formating](#typings-and-formating)
53+
- [Protobuf parser](#protobuf-parser)
54+
- [Typescript Disabling](#typescript-disabling)
55+
- [ESLint Disabling](#eslint-disabling)
56+
- [Bundle](#bundle)
57+
- [Output](#output)
58+
- [Types](#types)
59+
- [Timestamp](#timestamp)
60+
- [Duration](#duration)
61+
- [Composing Messages](#composing-messages)
62+
- [Calculating Fees](#calculating-fees)
63+
- [Stargate Clients](#stargate-clients)
64+
- [Creating Signers](#creating-signers)
65+
- [Amino Signer](#amino-signer)
66+
- [Proto Signer](#proto-signer)
67+
- [Broadcasting messages](#broadcasting-messages)
68+
- [LCD Clients](#lcd-clients)
69+
- [LCD Clients Classes](#lcd-clients-classes)
70+
- [RPC Clients](#rpc-clients)
71+
- [RPC Client Classes](#rpc-client-classes)
72+
- [Manually registering types](#manually-registering-types)
73+
- [CosmWasm](#cosmwasm)
74+
- [Dependencies](#dependencies)
75+
- [Troubleshooting](#troubleshooting)
76+
- [Create React App](#create-react-app)
77+
- [Babel](#babel)
78+
- [Developing](#developing)
79+
- [Initial setup](#initial-setup)
80+
- [Building](#building)
81+
- [Tests](#tests)
82+
- [Generators](#generators)
83+
- [Sponsors](#sponsors)
84+
- [Related](#related)
85+
- [Credits](#credits)
86+
- [Disclaimer](#disclaimer)
5587

5688
## Quickstart
5789

@@ -135,14 +167,6 @@ telescope({
135167

136168
// all options are totally optional ;)
137169
options: {
138-
prototypes: {
139-
includePackageVar: false,
140-
typingsFormat: {
141-
useExact: false,
142-
timestamp: 'date',
143-
duration: 'duration'
144-
},
145-
}
146170
aminoEncoding: {
147171
enabled: true
148172
},
@@ -186,12 +210,6 @@ telescope({
186210

187211
## Options
188212

189-
### Bundle
190-
191-
| option | description | defaults |
192-
| ------------------------------ | -------------------------------------------------------------- | ---------- |
193-
| `bundle.enabled` | bundle all files into a scoped index file | `true` |
194-
195213
### Amino Encoding
196214

197215
| option | description | defaults |
@@ -205,12 +223,27 @@ telescope({
205223

206224
| option | description | defaults |
207225
| ----------------------------------------- | -------------------------------------------------------------- | ---------- |
226+
| `prototypes.enabled` | enables the generation of proto encoding methods | `true` |
208227
| `prototypes.includePackageVar` | export a `protoPackage` variable to indicate package name | `false` |
209228
| `prototypes.excluded.packages` | exclude a set of packages from transpilation | `undefined`|
210229
| `prototypes.excluded.protos` | exclude a set of proto files from transpilation | `undefined`|
211-
| `prototypes.fieldDefaultIsOptional` | boolean value representing default optionality of field | `false`|
212-
| `prototypes.useOptionalNullable` | use `(gogoproto.nullable)` values in determining optionality | `true`|
213-
| `prototypes.allowUndefinedTypes` | boolean value allowing `Type`s to be `undefined` | `false`|
230+
| `prototypes.fieldDefaultIsOptional` | boolean value representing default optionality of field | `false` |
231+
| `prototypes.useOptionalNullable` | use `(gogoproto.nullable)` values in determining optionality | `true` |
232+
| `prototypes.allowUndefinedTypes` | boolean value allowing `Type`s to be `undefined` | `false` |
233+
| `prototypes.optionalQueryParams` | boolean value setting queryParams to be optional | `false` |
234+
| `prototypes.optionalPageRequests` | boolean value setting `PageRequest` fields to optional | `false` |
235+
236+
### Prototypes Methods
237+
238+
| option | description | defaults|
239+
| ---------------------------------- | ----------------------------------------------------------------- | ------- |
240+
| `prototypes.methods.encode` | boolean to enable `encode` method on proto objects | `true` |
241+
| `prototypes.methods.decode` | boolean to enable `decode` method on proto objects | `true` |
242+
| `prototypes.methods.fromJSON` | boolean to enable `fromJSON` method on proto objects | `true` |
243+
| `prototypes.methods.toJSON` | boolean to enable `toJSON` method on proto objects | `true` |
244+
| `prototypes.methods.fromPartial` | boolean to enable `fromPartial` method on proto objects | `true` |
245+
| `prototypes.methods.fromSDK` | boolean to enable `fromSDK` method on proto objects | `false` |
246+
| `prototypes.methods.toSDK` | boolean to enable `toSDK` method on proto objects | `false` |
214247

215248
### LCD Client Options
216249

@@ -222,15 +255,17 @@ telescope({
222255
| `lcdClients.scopedIsExclusive` | will allow both scoped bundles and all RPC Clients | `true` |
223256

224257
See [LCD Clients](#lcd-clients) for more info.
258+
225259
### RPC Client Options
226260

227-
| option | description | defaults |
228-
| ------------------------------ | -------------------------------------------------------------- | ---------- |
229-
| `rpcClients.enabled` | generate RPC clients that can interact with proto messages | `true` |
230-
| `rpcClients.bundle` | will generate factory bundle aggregate of all RPC Clients | `true` |
231-
| `rpcClients.camelCase` | use camel-case for RPC methods when generating RPC clients | `true` |
232-
| `rpcClients.scoped` | will generate factory of scoped RPC Clients | `undefined`|
233-
| `rpcClients.scopedIsExclusive` | will allow both scoped bundles and all RPC Clients | `true` |
261+
| option | description | defaults |
262+
| ------------------------------ | -------------------------------------------------------------- | ----------------------------- |
263+
| `rpcClients.enabled` | generate RPC clients that can interact with proto messages | `true` |
264+
| `rpcClients.bundle` | will generate factory bundle aggregate of all RPC Clients | `true` |
265+
| `rpcClients.camelCase` | use camel-case for RPC methods when generating RPC clients | `true` |
266+
| `rpcClients.scoped` | will generate factory of scoped RPC Clients | `undefined` |
267+
| `rpcClients.scopedIsExclusive` | will allow both scoped bundles and all RPC Clients | `true` |
268+
| `rpcClients.enabledServices` | which services to enable | [`Msg`,`Query`,`Service`] |
234269

235270
See [RPC Clients](#rpc-clients) for more info.
236271

@@ -253,7 +288,7 @@ See [RPC Clients](#rpc-clients) for more info.
253288

254289
| option | description | defaults |
255290
| ----------------------------------------- | -------------------------------------------------------------- | --------- |
256-
| `prototypes.parser.keepCase` | passes `keepCase` to protobuf `parse()` to keep original casing | `false` |
291+
| `prototypes.parser.keepCase` | passes `keepCase` to protobuf `parse()` to keep original casing | `true` |
257292
| `prototypes.parser.alternateCommentMode` | passes `alternateCommentMode` to protobuf `parse()` method | `true` |
258293
| `prototypes.parser.preferTrailingComment` | passes `preferTrailingComment` to protobuf `parse()` method | `false` |
259294

@@ -265,6 +300,27 @@ See [RPC Clients](#rpc-clients) for more info.
265300
| `tsDisable.patterns` | if set, will include `//@ts-nocheck` on matched patterns | `[]` |
266301
| `tsDisable.files` | if set, will include `//@ts-nocheck` on matched files | `[]` |
267302

303+
### ESLint Disabling
304+
305+
| option | description | defaults |
306+
| -------------------------------------------- | ---------------------------------------------------------------- | ---------|
307+
| `eslintDisable.disableAll` | if true, will include `/* eslint-disable */` on every output file | `false` |
308+
| `eslintDisable.patterns` | if set, will include `/* eslint-disable */` on matched patterns | `[]` |
309+
| `eslintDisable.files` | if set, will include `/* eslint-disable */` on matched files | `[]` |
310+
311+
### Bundle
312+
313+
| option | description | defaults |
314+
| ------------------------------ | -------------------------------------------------------------- | ---------- |
315+
| `bundle.enabled` | bundle all files into a scoped index file | `true` |
316+
317+
### Output
318+
319+
| option | description | defaults |
320+
| ------------------------------ | ----------------------------------------------------------------- | ---------- |
321+
| `removeUnusedImports` | removes unused imports | `true` |
322+
| `classesUseArrowFunctions` | classes use arrow functions instead of `bind()`ing in constructors | `false` |
323+
268324
## Types
269325

270326
### Timestamp
@@ -369,12 +425,12 @@ To broadcast messages, you'll want to use either [keplr](https://docs.keplr.app/
369425
Likely you'll want to use the Amino, so unless you need proto, you should use this one:
370426

371427
```js
372-
import { getOfflineSigner as getOfflineSignerAmino } from '@osmonauts/helpers';
428+
import { getOfflineSigner as getOfflineSignerAmino } from 'cosmjs-utils';
373429
```
374430
### Proto Signer
375431

376432
```js
377-
import { getOfflineSigner as getOfflineSignerProto } from '@osmonauts/helpers';
433+
import { getOfflineSigner as getOfflineSignerProto } from 'cosmjs-utils';
378434
```
379435

380436
WARNING: NOT RECOMMENDED TO USE PLAIN-TEXT MNEMONICS. Please take care of your security and use best practices such as AES encryption and/or methods from 12factor applications.
@@ -457,13 +513,13 @@ const options: TelescopeOptions = {
457513
This will generate a nice helper in the `ClientFactory`, which you can then use to query multiple modules from a single object:
458514

459515
```js
460-
import { osmosis } from './proto';
516+
import { osmosis } from './codegen';
461517

462518
const main = async () => {
463519
const client = await osmosis.ClientFactory.createLCDClient({ restEndpoint: REST_ENDPOINT });
464520

465521
// now you can query the modules
466-
const poolInfo = await client.osmosis.gamm.v1beta1.pool({ poolId: "1" });
522+
const pool = await client.osmosis.gamm.v1beta1.pool({ poolId: "1" });
467523
const balance = await client.cosmos.bank.v1beta1.allBalances({ address: 'osmo1addresshere' });
468524
};
469525
```
@@ -476,8 +532,8 @@ If you want to instantiate a single client, for any module that has a `Query` ty
476532
import { osmosis } from "osmojs";
477533

478534
export const main = async () => {
479-
const LCDClient = osmosis.gamm.v1beta1.LCDQueryClient;
480-
const client = new LCDClient({ restEndpoint: REST_ENDPOINT });
535+
const requestClient = new LCDClient({ restEndpoint: REST_ENDPOINT });
536+
const client = new osmosis.gamm.v1beta1.LCDQueryClient({ requestClient });
481537
const pools = await client.pools();
482538
console.log(pools);
483539
};
@@ -529,8 +585,11 @@ This will generate helpers `createRPCQueryClient` and `createRPCTxClient` in the
529585
import { osmosis } from './proto';
530586

531587
const main = async () => {
532-
const query = await osmosis.ClientFactory.createRPCQueryClient({ rpc });
533-
const tx = await osmosis.ClientFactory.createRPCMsgClient({ rpc });
588+
const client = await osmosis.ClientFactory.createRPCQueryClient({ rpcEndpoint });
589+
590+
// now you can query the modules
591+
const pool = await client.osmosis.gamm.v1beta1.pool({ poolId: "1" });
592+
const balance = await client.cosmos.bank.v1beta1.allBalances({ address: 'osmo1addresshere' });
534593
};
535594
```
536595

@@ -548,7 +607,7 @@ const QueryClient = osmosis.gamm.v1beta1.QueryClientImpl;
548607
const ServiceClient = cosmos.base.tendermint.v1beta1.ServiceClientImpl;
549608
```
550609

551-
Here is an example of making a query
610+
Here is an example of making a query if you want to use the RPC client classes manually:
552611

553612
```js
554613
import { osmosis } from "osmojs";
@@ -638,14 +697,13 @@ const options: TelescopeOptions = {
638697

639698
If you don't use the boilerplate, you will need to manually install
640699

641-
- `@osmonauts/helpers`
642700
- `@cosmjs/amino`
643701
- `@cosmjs/proto-signing`
644702
- `@cosmjs/stargate`
645703
- `@cosmjs/tendermint-rpc`
646704

647705
```sh
648-
yarn add @osmonauts/helpers @cosmjs/amino @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpc
706+
yarn add @cosmjs/amino @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpc
649707
```
650708

651709
If you use the LCD Client generation, you'll need to add
@@ -717,7 +775,7 @@ Checkout these related projects:
717775

718776
## Credits
719777

720-
🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator)
778+
🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator)
721779

722780
Thanks to these engineers, teams and projects for inspiring Telescope:
723781

@@ -732,4 +790,4 @@ Thanks to these engineers, teams and projects for inspiring Telescope:
732790

733791
AS DESCRIBED IN THE TELESCOPE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
734792

735-
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.
793+
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 commit comments

Comments
 (0)