Advanced Installation and Usage
This document outlines all available methods to install and use Telescope.
Telescope CLI
Install Telescope globally:
npm install -g @cosmology/telescopeGenerate a Package
Use the interactive prompt:
telescope generateOr specify options directly:
telescope generate --access public --userfullname "Your Name" --useremail "your@email.com" --module-desc "Your module description" --username "your-username" --license MIT --module-name "your-module" --chain-name cosmos --use-npm-scopedAvailable Options:
- --userfullname: Your full name
- --useremail: Your email
- --module-desc: Module description
- --username: GitHub username
- --module-name: Module name
- --chain-name: Chain name
- --access: Package access (- publicor- private)
- --use-npm-scoped: Use npm scoped package (only works with- --access public)
- --license: License type
Download Protocol Buffers
Basic usage:
telescope downloadWith a config file:
telescope download --config ./protod.config.json --out ./git-modulesFrom a specific repository:
telescope download --git-repo owner/repository --targets cosmos/auth/v1beta1/auth.protoTranspile Proto Files
With default options:
telescope transpileWith custom configuration:
telescope transpile --config your-config.jsonCreate Interchain App (CIA)
Install CIA globally:
npm install -g create-interchain-appCreate a new project with the Telescope boilerplate:
cia --boilerplate telescopeNavigate to your project directory:
cd ./your-project/packages/your-module
yarn installDownload protos and generate code:
yarn download-protos
yarn codegenCreate Cosmos App (CCA)
Install CCA globally:
npm install -g create-cosmos-appCreate a new package with the Telescope boilerplate:
cca --boilerplate telescopeNavigate to your package directory:
cd ./your-project/packages/telescope
yarn installDownload protos and generate code:
telescope download --config ./your.config.json
yarn codegenManual Installation
Add Telescope to your project:
yarn add --dev @cosmology/telescopeInstall required dependencies:
yarn add @cosmjs/amino @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpcUse either the programmatic API or the CLI with npm/yarn prefixes:
yarn telescope generate
npx telescope downloadProgrammatic Usage
First, add Telescope and dependencies:
yarn add --dev @cosmology/telescope
yarn add @cosmjs/amino @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpcDownloading Protos Programmatically
import downloadProtos from '@cosmology/telescope/main/commands/download'
 
const config = {
  repos: [
    { owner: "cosmos", repo: "cosmos-sdk", branch: "release/v0.50.x" },
    { owner: "cosmos", repo: "ibc-go" },
  ],
  protoDirMapping: {
    "gogo/protobuf/master": ".",
    "googleapis/googleapis/master": ".",
    "protocolbuffers/protobuf/main": "src"
  },
  outDir: "protos",
  ssh: false,
  tempRepoDir: "git-modules",
  targets: [
    "cosmos/**/*.proto",
    "ibc/**/*.proto",
  ]
};
 
downloadProtos(config)
  .then(() => console.log('✅ Proto download completed'))
  // @ts-ignore
  .catch((error) => {
    console.error('❌ Proto download failed:', error);
    process.exit(1);
  });Generating Code Programmatically
import { join } from 'path';
import telescope from '@cosmology/telescope';
import { sync as rimraf } from 'rimraf';
 
// Define input and output paths
const protoDirs = [join(__dirname, '/../proto')];
const outPath = join(__dirname, '../src');
rimraf(outPath);
 
// Run Telescope with options
telescope({
  protoDirs,
  outPath,
  
  // all options are totally optional
  options: {
    aminoEncoding: {
      enabled: true
    },
    lcdClients: {
      enabled: false
    },
    rpcClients: {
      enabled: false,
      camelCase: true
    },
    
    // Package-specific options
    packages: {
      nebula: {
        prototypes: {
          typingsFormat: {
            useExact: false
          }
        }
      },
      akash: {
        stargateClients: {
          enabled: true,
          includeCosmosDefaultTypes: false
        },
        prototypes: {
          typingsFormat: {
            useExact: false
          }
        }
      }
    }
  }
}).then(() => {
  console.log('✨ all done!');
}).catch(e => {
  console.error(e);
  process.exit(1);
});Example: Build Script Integration
// scripts/codegen.js
import { join } from 'path';
import telescope from '@cosmology/telescope';
import { sync as rimraf } from 'rimraf';
 
const protoDirs = [join(__dirname, '/../proto')];
const outPath = join(__dirname, '../src/generated');
rimraf(outPath);
 
telescope({
  protoDirs,
  outPath,
  options: {
    tsDisable: {
      disableAll: false,
      patterns: ['**/amino/**']
    },
    eslintDisable: {
      patterns: ['**/tx.amino.ts']
    },
    prototypes: {
      includePackageVar: true,
      typingsFormat: {
        useDeepPartial: true,
        timestamp: 'date',
        duration: 'duration'
      }
    }
  }
}).then(() => {
  console.log('✨ Code generation complete');
});