leapwallet / cosmos-extension

The Super Wallet for the Interchain
https://leapwallet.io
Other
29 stars 13 forks source link

Signing Stargate Client crashing while message signing #78

Open francisblakewood opened 2 weeks ago

francisblakewood commented 2 weeks ago

Signing Stargate Client crashing while message signing

Summary:

Following docs for setting up leap to be able to sign message crashes Leap wallet extension (version: "0.15.6").

** Aditionally - same code works with window.keplr

Screenshot 2024-10-26 at 12 40 03

Reference imports:

import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import {
  Registry,
} from "@cosmjs/proto-signing";
import {
  AminoTypes,
  createDefaultAminoConverters,
  defaultRegistryTypes,
  SigningStargateClient,
} from "@cosmjs/stargate";
import {
  createWasmAminoConverters,
  wasmTypes,
} from "@cosmjs/cosmwasm-stargate";

versions:

"@cosmjs/amino": "^0.32.4",
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "0.32.4",

Reference code:

const leap = window.leap;

if (!leap) {
  console.log("leap wallet not installed");
} else {

  await leap.enable(chainId);

  const signOptions = {
    preferNoSetFee: true,
    preferNoSetMemo: true,
    disableBalanceCheck: true,
  };

  const offlineSigner = leap.getOfflineSigner(
    destinationChain.chainExternalId,
    signOptions
  );
  const stargateClient =
    await SigningStargateClient.connectWithSigner(
      "rpc-url",
      offlineSigner,
      {
        registry: new Registry([
          ...defaultRegistryTypes,
          ...wasmTypes,
        ]),
        aminoTypes: new AminoTypes(aminoConverters),
      }
    );
  const account = await stargateClient.getAccount(account_address);
  const signerData = {
    accountNumber: account.accountNumber,
    chainId: destinationChain.chainExternalId,
    sequence: account.sequence,
  };
  const messages = {
      typeUrl: messageData.typeUrl,
      value: {
        sender: messageData.value.sender,
        contract: messageData.value.contract,
        msg: encoding.encode(messageData.value.msg),
        funds: messageData.value.funds,
      },
    };

  const respoonse: TxRaw = await stargateClient.sign(
   account_address,
    messages,
    {
      amount: [],
      gas: "1000000",
    },
    "",
    signerData
  );
}