Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCosmWasmClient throws error on custom chain #501

Open
GiovaniGuizzoYUB opened this issue Sep 19, 2024 · 0 comments
Open

getCosmWasmClient throws error on custom chain #501

GiovaniGuizzoYUB opened this issue Sep 19, 2024 · 0 comments

Comments

@GiovaniGuizzoYUB
Copy link

GiovaniGuizzoYUB commented Sep 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant