Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failure when enabling fromAmino/toAmino #385

Closed
webmaster128 opened this issue Jun 13, 2023 · 3 comments
Closed

Compilation failure when enabling fromAmino/toAmino #385

webmaster128 opened this issue Jun 13, 2023 · 3 comments

Comments

@webmaster128
Copy link

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;
}
@Zetazzz
Copy link
Collaborator

Zetazzz commented Jun 19, 2023

Hi, sorry for the late response.

I've checked this, I guess this's related to handling property names.

I'll try to make sure and do a quick fix

Thank you very much!

@Zetazzz
Copy link
Collaborator

Zetazzz commented Jun 21, 2023

Hi, I've made a quick fix on this and published, please check

#398

@webmaster128
Copy link
Author

Thank you!

@Zetazzz Zetazzz closed this as completed Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants