Skip to content

Commit 8df0450

Browse files
authored
Merge pull request #772 from hyperweb-io/add-docs-and-learn
Added new docs and learn based on Readme
2 parents e3b65a7 + c8e1f14 commit 8df0450

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+18408
-679
lines changed

README.md

Lines changed: 134 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -109,179 +109,171 @@ The following blockchain libraries (generated by Telescope) are available via np
109109

110110
## Quickstart
111111

112-
Follow the instructions below to generate a new Typescript package that you can publish to npm.
113-
114-
First, install `telescope` and `create-cosmos-app`
112+
Follow the instructions below to generate a new Typescript package that you can publish to npm. You can also follow the video: https://youtu.be/iQf6p65fbdY
115113

114+
`create-interchain-app`
116115
```sh
117-
npm install -g @cosmology/telescope create-cosmos-app
116+
npm install -g create-interchain-app
118117
```
119118

119+
120120
### Generate
121121

122-
Use the [`create-cosmos-app`](https://github.com/hyperweb-io/create-cosmos-app/) command to create a new package from the `telescope` boilerplate.
122+
Use the [`create-interchain-app`](https://github.com/hyperweb-io/create-interchain-app/) command to create a new package from the `telescope` boilerplate.
123123

124124
```sh
125-
cca --boilerplate telescope
126-
```
125+
cia --boilerplate telescope
127126

128-
Then, you'll navigate into `./your-project/packages/telescope` package for the next steps.
129127

130-
You can also use `telescope generate` command to generate package according to the prompt or terminal command params such as:
131-
`telescope generate --access public --userfullname testname --useremail [email protected] --module-desc test --username salkfl --license MIT --module-name test --chain-name cosmos --use-npm-scoped`
132-
133-
The available options are:
134-
`--userfullname` `--useremail` `--module-desc` `--username` `--module-name` `--chain-name` `--access` `--use-npm-scoped` `--license`
128+
Then, you'll navigate into `./your-project/packages/telescope` package for the next steps.
135129
136130
If some required options are missing, it will prompt to ask for the info.
137131
138-
To be noted, `--use-npm-scoped` only works when `--access` is `public`
132+
For detailed cli `generate` commands, please check our docs and learn directories.
139133
140-
### Download protos with CLI
134+
### Download protos
141135
142136
The old ` telescope install ` command has been deprecated
143137
144-
You can use our CLI to download protos by using `download` command.
138+
You can use our script to download protos by using `download-protos`command in the boilerplate.
145139
146140
```sh
147-
telescope download
141+
yarn download-protos
148142
```
149143
150144
You should now see some repos cloned in `./git-modules` and proto files generated in `./protos`. These are the proto files downloaded according to your config.
151145
152-
Examples:
146+
For detailed cli `download` commands, please check our docs and learn directories.
153147
154-
```sh
155-
# Telescope will do the download according to .json file of --config
156-
# Telescope will put proto into location specified by --out
157-
telescope download --config ./protod.config.json --out ./git-modules
158-
```
148+
### Transpile
149+
150+
To create the Typescript files for your chain, run the `yarn codegen` command inside of the package.
159151
160-
```sh
161-
# Telescope download from target repo according to --git-repo
162-
# in format of (i.e. <owner>/<repository> or <owner>/<repository>/<branch>)
163-
# <branch> can be empty, it will use main as default
164-
# Also --targets is required to specify the targets to download
165-
# in format like cosmos/auth/v1beta1/auth.proto
166-
telescope download --git-repo target-repo --targets target-proto
167152
```
153+
yarn codegen
154+
```
155+
156+
### Build
157+
158+
Finally, run `install` and `build` to generate the JS and types for publishing your module to npm.
168159
169160
```sh
170-
# ssh arg is optional, default is false
171-
telescope download --config ./protod.config.json --out ./git-modules --ssh true
161+
yarn build
172162
```
173163
164+
### Publishing
174165
175-
```js
176-
// .protod.config.json example
177-
//
178-
// `repos` are the repository it's going to clone
179-
// in format of (i.e. { "owner": <owner>, "repo": <repo> } or { "owner": <owner>, "repo": <repo>, "branch": <branch> })
180-
// <branch> can be empty, it will use main as default
181-
//
182-
// `protoDirMapping` is the directory of repo specified if the proto is not under repo's root directory ./protos
183-
// in format of (i.e. <owner>/<repository> or <owner>/<repository>/<branch>)
184-
// <branch> can be empty, it will use main as default
185-
//
186-
// `outDir` is where the output proto will be put
187-
//
188-
// `targets` are the target proto to download
189-
// `targets` can be patterns like:
190-
// "cosmos/bank/v1beta1/tx.proto",
191-
// "cosmos/gov/**/*.proto",
192-
// "cosmos/authz/**/*.proto",
193-
{
194-
"repos": [
195-
{ "owner": "cosmos", "repo": "cosmos-sdk" },
196-
...
197-
],
198-
"protoDirMapping": {
199-
"gogo/protobuf/master": ".",
200-
...
201-
},
202-
"outDir": "protos",
203-
"ssh": true,
204-
"tempRepoDir": "git-modules",
205-
"targets": [
206-
"cosmos/auth/v1beta1/auth.proto",
207-
...
208-
]
209-
}
210-
```
166+
Now you should have code inside of your `./src` folder, ready for publshing. If you used the `create-interchain-app` boilerplate, use `lerna` to publish (and/or read the README in the boilerplate for instructions), or run `npm publish` from your repository.
211167
212-
### Transpile
168+
# Usage
213169
214-
To create the Typescript files for your chain, run the `yarn codegen` command inside of the package.
170+
## Advanced Install
171+
The methods below are all the options you can use to install and use Telescope
215172
173+
### Telescope CLI
174+
Install telescope
175+
```sh
176+
npm install -g @cosmology/telescope
216177
```
217-
yarn codegen
218-
```
178+
The steps by order are: generate, download and transpile.
219179
220-
### Transpile with CLI
180+
1.Generate a package with the telescope CLI:
221181
222-
Less recommended, but you can also use our CLI for transpilation. To create the Typescript files with the `cli`, run the `transpile` command.
182+
Use and follow the default prompt:
183+
```sh
184+
telescope generate
185+
```
223186
187+
Or advanced cli option by your choice:
224188
```sh
225-
telescope transpile
189+
telescope generate --access public --userfullname "Your Name" --useremail "[email protected]" --module-desc "Your module description" --username "your-username" --license MIT --module-name "your-module" --chain-name cosmos --use-npm-scoped
226190
```
227191
228-
You should now see some `.ts` files generated in `./src`. These are the real source files used in your application.
192+
Available options:
193+
- `--userfullname`: Your full name
194+
- `--useremail`: Your email
195+
- `--module-desc`: Module description
196+
- `--username`: GitHub username
197+
- `--module-name`: Module name
198+
- `--chain-name`: Chain name
199+
- `--access`: Package access (`public` or `private`)
200+
- `--use-npm-scoped`: Use npm scoped package (only works with `--access public`)
201+
- `--license`: License type
202+
203+
2.Download protocol buffer files:
204+
```sh
205+
telescope download
206+
```
229207
230-
Examples:
208+
This will clone repositories into `./git-modules` and generate proto files in `./protos`.
231209
210+
Download with a config file:
232211
```sh
233-
# Telescope takes chain1 folder as input,
234-
# and generate files in 'gen/src' folder.
235-
telescope transpile --protoDirs ../../__fixtures__/chain1 --outPath gen/src
212+
telescope download --config ./protod.config.json --out ./git-modules
236213
```
237214
215+
Download from a specific repo:
238216
```sh
239-
# Telescope takes chain1 folder as input,
240-
# and generate files in 'gen/src' folder using default telescope options.
241-
telescope transpile --protoDirs ../../__fixtures__/chain1 --outPath gen/src --useDefaults
217+
telescope download --git-repo owner/repository --targets cosmos/auth/v1beta1/auth.proto
242218
```
243219
220+
3. Transpile (Generate TypeScript code from proto files):
221+
Use default telescope option:
244222
```sh
245-
# Telescope takes chain1 folder(from args) and chain2 folder(from config) as input,
246-
# and generate files in 'gen/src'(defined in the config file, will override outPath in args) folder using a config file.
247-
# Note: --config will override --useDefaults.
248-
telescope transpile --protoDirs ../../__fixtures__/chain1 --config .telescope.json
223+
telescope transpile
249224
```
250225
226+
Use customized telescope option:
251227
```sh
252-
# Telescope takes more than one config. The config afterward will override those in front. In this case values in .telescope-ext.json will override those in .telescope.json.
253-
telescope transpile --config .telescope.json --config .telescope-ext.json
228+
telescope transpile --config your-config.json
254229
```
255230
256-
```js
257-
//.telescope.json
258-
{
259-
"protoDirs": [
260-
"../../fixtures/chain2"
261-
],
262-
"outPath": "gen/src",
263-
"options": {
264-
// telescope options
265-
...
266-
}
267-
}
231+
### CIA
232+
Please follow the video: https://youtu.be/iQf6p65fbdY
233+
Or [Go to Quickstart](#quickstart)
234+
235+
### CCA
236+
First, install `create-cosmos-app`
237+
238+
```sh
239+
npm install -g create-cosmos-app
268240
```
269241
270-
### Build
242+
Use the [`create-cosmos-app`](https://github.com/hyperweb-io/create-cosmos-app/) command to create a new package from the `telescope` boilerplate.
271243
272-
Finally, run `install` and `build` to generate the JS and types for publishing your module to npm.
244+
```sh
245+
cca --boilerplate telescope
246+
```
273247
248+
Then, you'll navigate into `./your-project/packages/telescope` package for the next steps.
249+
250+
Install dependency and use cli to download the protos you want.
274251
```sh
275-
yarn build
252+
yarn install
253+
telescope download --config ./your.config.json
276254
```
277255

278-
### Publishing
256+
To create the Typescript files for your chain, run the `yarn codegen` command inside of the package.
279257

280-
Now you should have code inside of your `./src` folder, ready for publshing. If you used the `create-cosmos-app` boilerplate, use `lerna` to publish (and/or read the README in the boilerplate for instructions), or run `npm publish` from your repository.
258+
```sh
259+
yarn codegen
260+
```
281261

282-
# Usage
262+
### Manual install
263+
If you want to use telescope in your own project.
283264

284-
## Programatic Usage
265+
Run the command in ./your-project
266+
```sh
267+
yarn add --dev @cosmology/telescope
268+
```
269+
Install helpers and cosmjs [dependencies listed here](#dependencies)
270+
271+
We recommand to use [Go to Programatic Usage](#programatic-usage)
272+
273+
You can also use [Go to Telescope Cli](#telescope-cli)
274+
To be noted for cli command, add 'npx' or 'yarn' prefix when you use it within your project. For instance: 'yarn telescope generate', 'npx telescope download', etc.
275+
276+
### Programatic Usage
285277

286278
First add telescope to your `devDependencies`:
287279

@@ -291,6 +283,39 @@ yarn add --dev @cosmology/telescope
291283

292284
Install helpers and cosmjs [dependencies listed here](#dependencies)
293285

286+
Download command example:
287+
```js
288+
import downloadProtos from '@cosmology/telescope/main/commands/download'
289+
290+
const config = {
291+
repos: [
292+
{ owner: "cosmos", repo: "cosmos-sdk", branch: "release/v0.50.x" },
293+
{ owner: "cosmos", repo: "ibc-go" },
294+
],
295+
protoDirMapping: {
296+
"gogo/protobuf/master": ".",
297+
"googleapis/googleapis/master": ".",
298+
"protocolbuffers/protobuf/main": "src"
299+
},
300+
outDir: "protos",
301+
ssh: false,
302+
tempRepoDir: "git-modules",
303+
targets: [
304+
"cosmos/**/*.proto",
305+
"ibc/**/*.proto",
306+
]
307+
};
308+
309+
downloadProtos(config)
310+
.then(() => console.log('✅ Proto download completed'))
311+
// @ts-ignore
312+
.catch((error) => {
313+
console.error('❌ Proto download failed:', error);
314+
process.exit(1);
315+
});
316+
```
317+
318+
Transpile command example:
294319
```js
295320
import { join } from 'path';
296321
import telescope from '@cosmology/telescope';
@@ -1365,7 +1390,7 @@ A unified toolkit for building applications and smart contracts in the Interchai
13651390
| **Wallet Connectors**| [**Interchain Kit**](https://github.com/hyperweb-io/interchain-kit)<sup>beta</sup>, [**Cosmos Kit**](https://github.com/hyperweb-io/cosmos-kit) | Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface. |
13661391
| **Signing Clients** | [**InterchainJS**](https://github.com/hyperweb-io/interchainjs)<sup>beta</sup>, [**CosmJS**](https://github.com/cosmos/cosmjs) | A single, universal signing interface for any network |
13671392
| **SDK Clients** | [**Telescope**](https://github.com/hyperweb-io/telescope) | Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules. |
1368-
| **Starter Kits** | [**Create Interchain App**](https://github.com/hyperweb-io/create-interchain-app)<sup>beta</sup>, [**Create Cosmos App**](https://github.com/hyperweb-io/create-cosmos-app) | Set up a modern Interchain app by running one command. |
1393+
| **Starter Kits** | [**Create Interchain App**](https://github.com/hyperweb-io/create-interchain-app)<sup>beta</sup> | Set up a modern Interchain app by running one command. |
13691394
| **UI Kits** | [**Interchain UI**](https://github.com/hyperweb-io/interchain-ui) | The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit. |
13701395
| **Testing Frameworks** | [**Starship**](https://github.com/hyperweb-io/starship) | Unified Testing and Development for the Interchain. |
13711396
| **TypeScript Smart Contracts** | [**Create Hyperweb App**](https://github.com/hyperweb-io/create-hyperweb-app) | Build and deploy full-stack blockchain applications with TypeScript |

0 commit comments

Comments
 (0)