NibiruChain / ts-sdk

TypeScript-based client for interacting with the Nibiru blockchain
MIT License
34 stars 8 forks source link

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

Open Vishwas1 opened 1 week ago

Vishwas1 commented 1 week ago

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.

cgilbe27 commented 1 week ago

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

Unique-Divine commented 1 week ago

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.

cgilbe27 commented 1 week ago

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

CalicoNino commented 1 week ago

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

CalicoNino commented 14 hours ago

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:

CalicoNino commented 9 hours ago

Tried reproducing the bug locally and on devnet3, created a new keplr wallet and deployed a cw-nft and attempted to mint. No errors where thrown.

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.