Skip to content

Compilation failure when enabling fromAmino/toAmino #385

@webmaster128

Description

@webmaster128

I tried using fromAmino/toAmino in cosmjs-types by adding the following settings:

diff --git a/scripts/codegen.js b/scripts/codegen.js
index 77f108d..9b64cfa 100755
--- a/scripts/codegen.js
+++ b/scripts/codegen.js
@@ -15,6 +15,10 @@ telescope({
   ],
   outPath: outPath,
   options: {
+    aminoEncoding: {
+      enabled: true,
+      useRecursiveV2encoding: true,
+    },
     logLevel: 0,
     useSDKTypes: false,
     tsDisable: {
@@ -59,6 +63,8 @@ telescope({
         // See https://github.com/cosmos/cosmjs/pull/1329
         fromJSON: true,
         toJSON: true,
+        fromAmino: true,
+        toAmino: true,
       },
       typingsFormat: {
         useDeepPartial: true,

Unfortunately this leads to the folloing compilation errors:

src/ibc/lightclients/tendermint/v1/tendermint.ts:523:28 - error TS2551: Property 'header_1' does not exist on type 'Misbehaviour'. Did you mean 'header1'?

523     obj.header_1 = message.header_1 ? Header.toAmino(message.header_1) : undefined;
                               ~~~~~~~~

  src/ibc/lightclients/tendermint/v1/tendermint.ts:79:3
    79   header1?: Header;
         ~~~~~~~
    'header1' is declared here.

src/ibc/lightclients/tendermint/v1/tendermint.ts:523:62 - error TS2551: Property 'header_1' does not exist on type 'Misbehaviour'. Did you mean 'header1'?

523     obj.header_1 = message.header_1 ? Header.toAmino(message.header_1) : undefined;
                                                                 ~~~~~~~~

  src/ibc/lightclients/tendermint/v1/tendermint.ts:79:3
    79   header1?: Header;
         ~~~~~~~
    'header1' is declared here.

src/ibc/lightclients/tendermint/v1/tendermint.ts:524:28 - error TS2551: Property 'header_2' does not exist on type 'Misbehaviour'. Did you mean 'header2'?

524     obj.header_2 = message.header_2 ? Header.toAmino(message.header_2) : undefined;
                               ~~~~~~~~

  src/ibc/lightclients/tendermint/v1/tendermint.ts:80:3
    80   header2?: Header;
         ~~~~~~~
    'header2' is declared here.

src/ibc/lightclients/tendermint/v1/tendermint.ts:524:62 - error TS2551: Property 'header_2' does not exist on type 'Misbehaviour'. Did you mean 'header2'?

524     obj.header_2 = message.header_2 ? Header.toAmino(message.header_2) : undefined;
                                                                 ~~~~~~~~

  src/ibc/lightclients/tendermint/v1/tendermint.ts:80:3
    80   header2?: Header;
         ~~~~~~~
    'header2' is declared here.

So this error is around accessing the non-Amino object, e.g.

/**
 * Misbehaviour is a wrapper over two conflicting Headers
 * that implements Misbehaviour interface expected by ICS-02
 */
export interface Misbehaviour {
  /** ClientID is deprecated */
  /** @deprecated */
  clientId: string;
  header1?: Header;
  header2?: Header;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions