cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
635 stars 328 forks source link

Error: Query failed with (6): rpc error: code = Unknown desc = unable to resolve type URL /cosmos.gov.v1.MsgVote: tx parse error #1545

Closed shangbingHu closed 6 months ago

shangbingHu commented 6 months ago
import { defaultRegistryTypes } from "@cosmjs/stargate";

const wallet = await DirectSecp256k1HdWallet.fromMnemonic(some_mnemonic, some_options)
const [firstAccount] = await wallet.getAccounts();
const rpcEndpoint = "https://rpc-cosmoshub.blockapsis.com";
const client = await SigningStargateClient.connectWithSigner(
    rpcEndpoint,
    wallet,
    {
        gasPrice: GasPrice.fromString("0.025uatom")
    }
);

const foundMsgType = defaultRegistryTypes.find(
    (element) => element[0] === "/cosmos.gov.v1.MsgVote"
)

const finalMsg = {
    typeUrl: foundMsgType[0],
    value: foundMsgType[1].fromPartial({    
        "proposal_id": "868",
        "voter": firstAccount.address,
        "option": 1
    }),
}

const result = await client.signAndBroadcast(firstAccount.address, [finalMsg], "auto", "")

For such codes above, there'll be ERROR: Query failed with (6): rpc error: code = Unknown desc = unable to resolve type URL /cosmos.gov.v1.MsgVote: tx parse error

but the error will be reproduced on cosmos chain but not on osmo chain

shangbingHu commented 6 months ago

"/cosmos.gov.v1.MsgVote" ==> "/cosmos.gov.v1beta1.MsgVote" Resolved !

shangbingHu commented 6 months ago

"/cosmos.gov.v1.MsgVote" ==> "/cosmos.gov.v1beta1.MsgVote" Resolved !