ts-sdk icon indicating copy to clipboard operation
ts-sdk copied to clipboard

Getting error `Unsupported type: '/eth.types.v1.EthAccount'` with brand new keplr wallet

Open Vishwas1 opened this issue 1 year ago • 7 comments

We are getting this error when trying to execute a contract function deployed on testnet-1

Error: Unsupported type: '/eth.types.v1.EthAccount'
at accountFromAny (accounts.js:76:13)
    at SigningCosmWasmClient.getAccount (cosmwasmclient.js:82:54)
    at async SigningCosmWasmClient.getSequence (cosmwasmclient.js:91:21)
    at async SigningCosmWasmClient.sign (signingcosmwasmclient.js:406:11)
    at async SigningCosmWasmClient.signAndBroadcast (signingcosmwasmclient.js:365:19)
    at async SigningCosmWasmClient.executeMultiple (signingcosmwasmclient.js:290:20)
    at async smartContractExecuteRPC (execute.js:25:1)
    at async VueComponent.mint (index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/e-kyc/OnChainId.vue?vue&type=script&lang=js:161:24)

Code snippet we are trying:

import {
    NibiruTxClient,
    NibiruQuerier
} from "@nibiruchain/nibijs"

export async function createClient(rpcUrl, offlineSigner) {
   

    const txClient = await NibiruTxClient.connectWithSigner(
        rpcUrl,
        offlineSigner
    )
    console.log({
        txClient: txClient.wasmClient
    })
    return txClient.wasmClient
}

export async function createNonSigningClient(rpcUrl) {
    const client = await NibiruQuerier.connect(rpcUrl)
    return client
}

version: "@nibiruchain/nibijs": "^4.5.1"

How to recreate?

try calling this particular contract nibi1ag6a26rvt9duue8wh8rsp94z9lx7c5pdjf8mlkals6f2uqr0aj0s4ltp6q function mint() with the following param:

{"hypersign_proof": {"credential_id": "", "data": "","description": "Proves that user has finished his/her KYC", "proof_type_image": "something", "sbt_code": "T1" , "proof_type" : "proof_of_personhood" }}

Make sure to generate a brand new wallet in Keplr and try.

Note; we have notice that when we use validator's account then it works. but when creating a brand new account in keplr wallet or even in cli, it does not work through JS sdk.

Vishwas1 avatar Sep 24 '24 15:09 Vishwas1

Please see here: https://github.com/cosmos/relayer/issues/1493

cgilbe27 avatar Sep 24 '24 15:09 cgilbe27

Context From Telegram [2024-09-24]

"Yeah, I am almost positive it's related to protobuf registration on the signing client. We will need to extend the wasm client and publish a version of nibijs that plays nicely with Nibiru accounts" - Nibiru

"yes or else need to give PR to cosmjs .. best is to update nibijs sdk" - Hypersign

Would note that I don't think this one is blocked. We do need to extend the default Wasm signing client to register the other account type.

Unique-Divine avatar Sep 24 '24 18:09 Unique-Divine

https://github.com/NibiruChain/ts-sdk/blob/develop/src/sdk/tx/txClient.ts#L23

cgilbe27 avatar Sep 24 '24 19:09 cgilbe27

https://github.com/cosmos/cosmjs/blob/33271bc51cdc865cadb647a1b7ab55d873637f39/packages/stargate/src/signingstargateclient.ts#L55

CalicoNino avatar Sep 25 '24 21:09 CalicoNino

Outline of a similar issue with ethermint https://github.com/cosmos/cosmjs/issues/1351

Since the fix requires a change to the Account parser in cosmjs, and seems that isn't going to be worked on. We could potentially append their existing account parser to accept our eth account, outlined here https://github.com/cosmos/cosmjs/blob/main/packages/stargate/src/accounts.ts#L44-L89. But this can be a second solution since, we don't want to be dependant on their PR approval.

A possible solution is that we can either extend or create a wrapper for the NibiruTxClient to accept ethaccounts. Found this script that allows signing and simulating Cosmos-EVM transactions using Keplr:

  • signEvmWithKeplr: It fetches account details, constructs a transaction, and signs it using Keplr for Cosmos-EVM chains like Evmos. The signed transaction is returned ready for broadcast.
  • simulateEvmWithKeplr: It simulates a transaction to estimate gas usage by creating and sending a mock transaction without broadcasting it.

CalicoNino avatar Oct 02 '24 14:10 CalicoNino

Reproducing on Testnet, created a new keplr wallet and deployed a counter contract. Was able to reproduce. NOTE: Must ensure that Wallet is newly generated with Keplr only.

Regardless knowing that the error is sided from https://github.com/cosmos/cosmjs/blob/main/packages/stargate/src/accounts.ts#L44-L89, we would need to make a Account parser for our Eth accounts.

CalicoNino avatar Oct 02 '24 18:10 CalicoNino

Reproducing on Testnet, created a new keplr wallet and deployed a counter contract. Was able to reproduce. NOTE: Must ensure that Wallet is newly generated with Keplr only...

Great find on reproducing the issue

Unique-Divine avatar Oct 05 '24 18:10 Unique-Divine

:tada: This issue has been resolved in version 5.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

nibibot avatar Oct 18 '24 14:10 nibibot