question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How should custom AminoTypes be written?

See original GitHub issue

I’m using @cosmjs/ Stargate to plug into Osmosis dex

const aminoTypes = new AminoTypes({
        "What do I write here????": {
          aminoType: "osmosis/gamm/swap-exact-amount-in",
          toAmino: (data) => {
            debugger
            return data
          },
          fromAmino: (data) => {
            debugger
            return data
          },
        },
      });

The complete code:

async swap () {
      const aminoTypes = new AminoTypes({
        "/osmosis.gamm.swap-exact-amount-in": {
          aminoType: "osmosis/gamm/swap-exact-amount-in",
          toAmino: (data) => {
            debugger
            return data
          },
          fromAmino: (data) => {
            debugger
            return data
          },
        },
      });
      const offlineSigner = window.keplr.getOfflineSignerOnlyAmino(this.chainId);
      let sddf = this.accounts = await offlineSigner.getAccounts();
      const client = this.client = await SigningStargateClient.connectWithSigner(
        network,
        offlineSigner,
        {
          aminoTypes
        }
      );
      const address = this.accounts[0].address

      const msgAny = {
        "typeUrl": "/osmosis.gamm.swap-exact-amount-in",
        "value": {
          "sender": address,
          "routes": [
            {
              "poolId": "7",
              "tokenOutDenom": "uosmo"
            }
          ],
          "tokenIn": {
            "denom": "ibc/7C4D60AA95E5A7558B0A364860979CA34B7FF8AAF255B87AF9E879374470CEC0",
            "amount": "21429239"
          },
          "tokenOutMinAmount": "201687"
        }
      }

      const fee = {
        amount: [],
        gas: "100000", // 180k
      };
      const memo = "备忘录211";
      try {
        const result = await this.client.signAndBroadcast(
          address,
          [msgAny],
          fee,
          memo
        );
        assertIsDeliverTxSuccess(result);
        if (result.code !== undefined &&
          result.code !== 0) {
          alert("Failed to send tx: " + result.log || result.rawLog);
        } else {
          alert("Succeed to send tx:" + result.transactionHash);
        }
      } catch (error) {
        let sd = error
        debugger
        alert("Failed to send tx:" + error.message);
      }
    }

Error

Error: Unregistered type url: /osmosis.gamm.swap-exact-amount-in\n at Registry.lookupTypeWithError (webpack-internal:///./node_modules/@cosmjs/proto-signing/build/registry.js:74:19)\n at Registry.encode (webpack-internal:///./node_modules/@cosmjs/proto-signing/build/registry.js:90:27)\n at Registry.encodeAsAny (webpack-internal:///./node_modules/@cosmjs/proto-signing/build/registry.js:99:34)\n at eval (webpack-internal:///./node_modules/@cosmjs/proto-signing/build/registry.js:106:77)\n at Array.map (<anonymous>)\n at Registry.encodeTxBody (webpack-internal:///./node_modules/@cosmjs/proto-signing/build/registry.js:106:55)\n at Registry.encode (webpack-internal:///./node_modules/@cosmjs/proto-signing/build/registry.js:88:25)\n at SigningStargateClient.signAmino (webpack-internal:///./node_modules/@cosmjs/stargate/build/signingstargateclient.js:218:49)\n at async SigningStargateClient.signAndBroadcast (webpack-internal:///./node_modules/@cosmjs/stargate/build/signingstargateclient.js:167:23)"

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pyramationcommented, May 29, 2022
0reactions
nooomskicommented, May 31, 2022

Closing as there’s 3 solutions provided. Please open again if you’re still running into issues. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

AminoTypes | @cosmjs/stargate Documentation
Class AminoTypes. A map from Stargate message types as used in the messages's Any type to Amino types.
Read more >
Guidelines | Wiki | Mystic Messenger Amino
Custom titles are special titles that are completely of the user's choice awarded for reaching 100 days, 365 days, reaching Level 15, 16,...
Read more >
How To Create Custom Types in TypeScript - DigitalOcean
This tutorial will show you how to use custom types with TypeScript, how to ... that allows you to write TypeScript directly in...
Read more >
@osmonauts/telescope - npm
Latest version: 0.80.0-rc.1, last published: 9 minutes ago. ... There are 8 other projects in the npm registry using @osmonauts/telescope.
Read more >
Good-To-Know Dev Terms - Cosmos Developer Portal
Any chain built with the Cosmos SDK can typically be referred to as "a Cosmos ... Marshaling is vital to pass output parameters...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found