telescope
telescope copied to clipboard
Tutorial not working
Hi Cosmology!
I followed the video tutorial from Turn your Cosmos SDK chain into a TypeScript npm module
and got a bunch of errors when running yarn
at the end.
➜ ~ cd /tmp
➜ /tmp nvm use v20.9.0
Now using node v20.9.0 (npm v10.2.4)
➜ /tmp telescope
Telescope 1.0.17
? [cmd] what do you want to do? generate
? [name] Enter your new module name testapp
Cloning into 'testapp'...
? [__CHAINNAME__] Enter chain name in all lowercase, e.g. osmosis testapp
? [__USERFULLNAME__] Enter author full name TLI
? [__USEREMAIL__] Enter author email [email protected]
? [__MODULENAME__] Enter the module name testapp
? [__MODULEDESC__] Enter the module description testapp
? [__USERNAME__] Enter your github username foobar
? [__ACCESS__] Module access? public
? [__LICENSE__] Which license? MIT
? [scoped] use npm scopes? No
|||
(o o)
ooO--(_)--Ooo-
✨ Great work!
➜ /tmp cd testapp
➜ testapp telescope
Telescope 1.0.17
? [cmd] what do you want to do? install
? [pkg] which packages do you want to support? cosmos, cosmos_proto
npm WARN config production Use `--omit=dev` instead.
added 6 packages in 2s
installing @protobufs/amino...
installing @protobufs/cosmos_proto...
installing @protobufs/cosmos...
installing @protobufs/gogoproto...
installing @protobufs/google...
installing @protobufs/tendermint...
➜ testapp telescope
Telescope 1.0.17
? [cmd] what do you want to do? transpile
? [protoDirs] where is the proto directory? ./proto
? [outPath] where is the output directory? ./src/codegen
✨ files transpiled in '/tmp/testapp/src/codegen'
✨ transpilation successful!
➜ testapp yarn
[BUNCH OF ERRORS HERE, E.G.]
$ /tmp/testapp/node_modules/.bin/tsc -p tsconfig.json --outDir dist --module commonjs
src/codegen/cosmos/auth/v1beta1/query.lcd.ts:2:27 - error TS2307: Cannot find module '@cosmology/lcd' or its corresponding type declarations.
2 import { LCDClient } from "@cosmology/lcd";
~~~~~~~~~~~~~~~~
src/codegen/cosmos/authz/v1beta1/query.lcd.ts:2:27 - error TS2307: Cannot find module '@cosmology/lcd' or its corresponding type declarations.
2 import { LCDClient } from "@cosmology/lcd";
~~~~~~~~~~~~~~~~
src/codegen/cosmos/authz/v1beta1/tx.registry.ts:3:101 - error TS2322: Type '{ typeUrl: string; encode(message: MsgGrant, writer?: BinaryWriter): BinaryWriter; decode(input: Uint8Array | BinaryReader, length?: number): MsgGrant; ... 7 more ...; toProtoMsg(message: MsgGrant): MsgGrantProtoMsg; }' is not assignable to type 'GeneratedType'.
Type '{ typeUrl: string; encode(message: MsgGrant, writer?: BinaryWriter): BinaryWriter; decode(input: Uint8Array | BinaryReader, length?: number): MsgGrant; ... 7 more ...; toProtoMsg(message: MsgGrant): MsgGrantProtoMsg; }' is missing the following properties from type 'TsProtoGeneratedType': fromJSON, toJSON
3 export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.authz.v1beta1.MsgGrant", MsgGrant], ["/cosmos.authz.v1beta1.MsgExec", MsgExec], ["/cosmos.authz.v1beta1.MsgRevoke", MsgRevoke]];
~~~~~~~~
src/codegen/cosmos/authz/v1beta1/tx.registry.ts:3:146 - error TS2322: Type '{ typeUrl: string; encode(message: MsgExec, writer?: BinaryWriter): BinaryWriter; decode(input: Uint8Array | BinaryReader, length?: number): MsgExec; ... 7 more ...; toProtoMsg(message: MsgExec): MsgExecProtoMsg; }' is not assignable to type 'GeneratedType'.
Type '{ typeUrl: string; encode(message: MsgExec, writer?: BinaryWriter): BinaryWriter; decode(input: Uint8Array | BinaryReader, length?: number): MsgExec; ... 7 more ...; toProtoMsg(message: MsgExec): MsgExecProtoMsg; }' is missing the following properties from type 'TsProtoGeneratedType': fromJSON, toJSON
3 export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.authz.v1beta1.MsgGrant", MsgGrant], ["/cosmos.authz.v1beta1.MsgExec", MsgExec], ["/cosmos.authz.v1beta1.MsgRevoke", MsgRevoke]];
~~~~~~~
src/codegen/cosmos/authz/v1beta1/tx.registry.ts:3:192 - error TS2322: Type '{ typeUrl: string; encode(message: MsgRevoke, writer?: BinaryWriter): BinaryWriter; decode(input: Uint8Array | BinaryReader, length?: number): MsgRevoke; ... 7 more ...; toProtoMsg(message: MsgRevoke): MsgRevokeProtoMsg; }' is not assignable to type 'GeneratedType'.
Type '{ typeUrl: string; encode(message: MsgRevoke, writer?: BinaryWriter): BinaryWriter; decode(input: Uint8Array | BinaryReader, length?: number): MsgRevoke; ... 7 more ...; toProtoMsg(message: MsgRevoke): MsgRevokeProtoMsg; }' is missing the following properties from type 'TsProtoGeneratedType': fromJSON, toJSON
...
Things I had to do in order to make it work.
Run yarn add @cosmology/lcd
After running the transpile command a first time, edit .telescope.json
and set the following
{
"protoDirs": [
"./proto"
],
"outPath": "./src/codegen",
"options": {
"interfaces": {
"enabled": false,
"useByDefault": false,
"useUnionTypes": false
},
"prototypes": {
"enabled": true,
"parser": {
"keepCase": false
},
"methods": {
"fromJSON": true, ----> Change this to `true`
"toJSON": true, ----> Change this to `true`
"encode": true,
"decode": true,
"fromPartial": true,
"toAmino": true,
"fromAmino": true,
"fromProto": true,
"toProto": true
},
"addTypeUrlToObjects": true,
"addTypeUrlToDecoders": true,
"enableRegistryLoader": false, ----> Add this line
"typingsFormat": {
"duration": "duration",
"timestamp": "timestamp", ----> Change `date` to `timestamp`
"useExact": false,
"useDeepPartial": false,
"num64": "bigint",
"useTelescopeGeneratedType": true, ----> Add this line
"customTypes": {
"useCosmosSDKDec": true
}
}
},
"bundle": {
"enabled": true
},
"stargateClients": {
"enabled": true,
"includeCosmosDefaultTypes": true
},
"aminoEncoding": {
"enabled": true
},
"lcdClients": {
"enabled": true
},
"rpcClients": {
"enabled": true,
"camelCase": true
},
"tsDisable": { ----> Add this whole block
"patterns": [
"**/client.ts"
]
}
}
}
I have no idea if this is the right way of working around the build issue.
thanks! We're working to update the video :)
@Zetazzz https://github.com/cosmology-tech/telescope-module-boilerplate