Skip to content

getCosmWasmClient throws error on custom chain #501

@GiovaniGuizzoBA

Description

@GiovaniGuizzoBA

Hello. I am facing an issue with the method getCosmWasmClient from the useChain hook.
For starters, I am using my own chain with a custom config.
Here's the ChainProvider code (obfuscated):

    <ChainProvider
          chains={[MY_CHAIN]}
          assetLists={[MY_ASSETS]}
          wallets={wallets}
          sessionOptions={{ duration: 10800000 }}
          signerOptions={{
            signingStargate: () => {
              return {
                aminoTypes: myAminoTypes,
                registry: registry,
                gasPrice: GasPrice.fromString(`${DEFAULT_GAS_PRICE}${MY_DENOM}`),
              };
            },
            signingCosmwasm: () => {
              return {
                gasPrice: GasPrice.fromString(`${DEFAULT_GAS_PRICE}${MY_DENOM}`),
              };
            },
            preferredSignType: () => "amino",
          }}
          endpointOptions={{
            endpoints: {
              [MY_CHAIN.chain_name]: {
                rpc: [MY_CHAIN.apis!.rpc![0].address],
                rest: [MY_CHAIN.apis!.rest![0].address],
              },
            },
          }}
        >
        {children}
    </ChainProvider>

Calling const { getCosmWasmClient } = useChain(MY_CHAIN.chain_name); from the component and then trying to use getCosmWasmClient does not work. I get the following error:

Uncaught (in promise) Something wrong! Probably no valid RPC endpoint for chain my-chain

The interesting part is that getStargateClient works perfectly fine. It connects to my endpoints and I can even sign transactions normally. The problem is only with the getCosmWasmClient. It also throws a lot (hundreds) of errors like this:

Access to XMLHttpRequest at 'https://rpc.cosmos.directory/my-chain' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

It appears it is not using the endpoints I configured for cosmwasm, only for the regular stargate.

I am using v2.18.0.
Any help is much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions