-
Notifications
You must be signed in to change notification settings - Fork 915
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
Handling wagmi & viem vesions #492
Comments
Let's see if I understood the issue. There are 4 elements at play here:
The problem comes when the versions we use from I don't fully understand why the type mismatch ("Type error: Type 'string' is not assignable to type '`0x${string}`'") only happens when there's a version mismatch between Regarding the two proposed solutions, I think 2 makes more sense as it doesn't force us to rely on other projects. Two additional options that come to mind:
|
Yeah as I explained wevm/wagmi#1712 (comment) here, but here is the problem with current context : Checkout Here as you can see there is not Now run this command : You will see that it created a new Also now please do: Along with
This might be the solution indeed(Lol hopefully it dosen't mess up Still don't know why its checking
We actually had Also But really thanks Dani really appreciate it 🙌 Will keep digging on |
Yes, using yarn resolutions may fix this error. I had a similar problem with ethers some time ago and I was able to fix it using resolutions at package.json If this doesn't work, I think that 2 is a good option at least for now (and in the meantime trying to have a final fix from Wagmi). Thanks!! |
@technophile-04 Thanks for the explanation! Now I understand it better.
I'm guessing (not sure at all), it might check those files because they're imported by some of our source files? Maybe there's a way to tell TypeScript to resolve our types, and not the types from each package's node_modules. I found something worth trying here. It talks about using the {
"compilerOptions": {
...
"paths": {
"*": [
"src/*",
"types/*"
]
}
},
...
}
I agree it's not the best DX if the utility has to be used all over the place. But maybe having some // wagmiWrappers.ts
import { foo as wagmiFoo } from 'wagmi'
export const foo = address => wagmiFoo(`0x${address}`) // with the 0x
// in the code
import { foo } from './wagmiWrappers' // this could be `from 'wagmi-wrappers'` if we wanted to do remappings
const address = 'd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // without the 0x
const result = foo(address) Just thinking out loud. Again, I don't know if something like this would be feasible or if it makes sense to implement. |
Looking into it, my first feeling is it might be best to just get rid of the So to resolve this issue, it might be better to either use the I'll try and look into what this approach would look like, maybe there's additional drawbacks that I haven't considered yet. |
As I understand, we need What about dividing AddressInput component to What do you think? I can try to implement it next days
And could you please explain how is it decrease dx? |
Context :
We have configured
AddressType
tostring
instead of0x{string}
for better developer experience here in this file.We are using
viem
andwagmi
as our dependencieswagmi
andviem
both internally are usingabitype
as their dependencyIdeally, we shouldn't care about
patch
version releases but sincewagmi
andviem
are under constant development they are pretty actively fixing bugs and publishing new versions.Since
wagmi
andviem
are kind of the backbone of SE-2 and since we are a development template/starter kit and not a product , I think it makes sense to keep them updated obviously not every release but at least keep them checked after 1month or so because they add new chains, fix bugs, etc. <-- Would love to know what others thoughts on this-> The problem happens when there is a new
patch
version ofwagmi
andviem
and we need to update them.Ideally, it should have been as easy as
yarn workspace @se-2/nextjs up wagmi viem
since we are just updating them to**patch**
version. Checkout #419 "Steps to reproduce" section what chaos it causes when you doyarn workspace @se-2/nextjs up wagmi viem
:(Since we have
AddressType
as mentioned in begging this causes problems with types :(, We have faced this multiple times when trying to updatewagmi
This occurs whenever
wagmi's
internal version ofabitype
differs fromviem's
internal version ofabitype
.Checkout this issue wevm/wagmi#1712 (comment) comments, We created this issue even before
viem
was launched but there was a version mismatch ofabitype
betweenwagmi's
repo internal packagesAnd now since
viem
also usesabitype
anytime there is a version mismatch (which there is currently). Checkout wevm/wagmi#2736 because of which we have to lock version's of wagmi and viem at #420Solutions :
Make PR's / create issues to Wagmi repo to let them know and fix on their side (which we have been doing from the start). Not best solution because it might take time to resolve (like in current situtaion)
Keep updating
wagmi
normally as it is and updateviem
only if its internalabitype
version matches withwagmi
. In recent PR update wagmi & rainbow #491 I just updatedwagmi
keepingviem
same because they both haveabittype
version0.8.7
Obviously removing
AddressType
configuration is not an option since it will decrease the developer experience for beginners a lot :(I don't know if this is something we could handle on our own like forcing typescript to use our configuration of
AddressType
irrespective whatabitype
versionswagmi
andviem
are using, I tried playing and didn't find any good option, Would you love to hear from others 🙌We can go with point 2. of the solution but there might be a point when we will break because in case in future if
wagmi
might break withviem
version we are using and we also won't be able to updateviem
since itsabitype
version will be different from wagmiThe text was updated successfully, but these errors were encountered: