Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

bug: Incompatible read only type cannot be assigned to the mutable type string[] - Configuring chains #85

Closed
1 task done
mutedcase opened this issue Jan 30, 2023 · 2 comments

Comments

@mutedcase
Copy link

mutedcase commented Jan 30, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I got started with the create-wagmi next.js project and am running into an issue configuring a new chain.

Returning an error configuring new chains 'canto' and 'goerli' which is preventing from connecting to the desired chains.

Here's the code:

import { getDefaultClient } from 'connectkit'
import { createClient, configureChains } from 'wagmi'
import { canto, goerli } from '@wagmi/chains'
import { publicProvider } from 'wagmi/providers/public'


const { chains, provider } = configureChains(
  [canto, goerli],
  [publicProvider()]
)

Here's the error (also same for goerli

Type '{ readonly id: 7700; readonly name: "Canto"; readonly network: "canto"; readonly nativeCurrency: { readonly decimals: 18; readonly name: "Canto"; readonly symbol: "CANTO"; }; readonly rpcUrls: { readonly default: { ...; }; readonly public: { ...; }; }; readonly blockExplorers: { ...; }; }' is not assignable to type 'Chain'.
The types of 'rpcUrls.default.http' are incompatible between these types.
The type 'readonly ["https://canto.slingshot.finance"]' is 'readonly' and cannot be assigned to the mutable type 'string[]'.

When I try to change the import to import { canto, goerli } from 'wagmi/chains' then 'canto' doesn't exist and I receive the following error:

Module '"wagmi/chains"' has no exported member 'canto'.

So in the docs it says the below:
image
But if that were the case I wouldn't need to do

Entirely possible this is a configuration error on my side but couldn't be more confused.

I tried creating a new variable canto and making it type Chain but I circle back to the read only error when I do that.

My current workaround is just doing the work in here but this should just be handled out of the box or I'm possibly ridiculous

Expected Behavior

The chains that I configure should connect out of the box based on the documentation. On connecting wallet, all chains in my configureChains() hook should function properly and connect/switch networks automatically.

Steps To Reproduce

*assumes you have metamask set up

  • open a new directory
  • run npm init wagmi -- --template next-connectkit
  • copy-paste the code in the description into the 'wagmi.ts' file
  • run npm run dev
  • try and connect the wallet to the canto chain -- can be imported by going to chainlist and finding canto and importing it to your wallet

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

No response

@mutedcase mutedcase changed the title bug: Incompatible types bug: Incompatible read only type cannot be assigned to the mutable type string[] - Configuring chains Jan 30, 2023
@tmm
Copy link
Member

tmm commented Jan 30, 2023

What version of @wagmi/chains are you using?

@jxom
Copy link
Member

jxom commented Jan 30, 2023

Can you update wagmi to 0.11 and try again?

Closing as I resolved the issue by upgrading wagmi.

@jxom jxom closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants