onchainkit: Bug: [OnchainKitProvider] chain type incompatible

Describe the bug and the steps to reproduce it

  1. Checkout https://github.com/sergical/ossummer/pull/17
  2. Check web/src/OnchainProviders.tsx
  3. See type error

Full TS error

Type '{ blockExplorers: { readonly default: { readonly name: "Basescan"; readonly url: "https://sepolia.basescan.org"; readonly apiUrl: "https://api-sepolia.basescan.org/api"; }; }; contracts: { ...; }; ... 10 more ...; readonly network: "base-sepolia"; } | { ...; }' is not assignable to type 'Chain'.
  Type '{ blockExplorers: { readonly default: { readonly name: "Basescan"; readonly url: "https://sepolia.basescan.org"; readonly apiUrl: "https://api-sepolia.basescan.org/api"; }; }; contracts: { ...; }; ... 10 more ...; readonly network: "base-sepolia"; }' is not assignable to type 'Chain'.
    Types of property 'fees' are incompatible.
      Type 'ChainFees<undefined> | undefined' is not assignable to type 'ChainFees<ChainFormatters | undefined> | undefined'.
        Type 'ChainFees<undefined>' is not assignable to type 'ChainFees<ChainFormatters | undefined>'.
          Types of property 'baseFeeMultiplier' are incompatible.
            Type 'number | ((args: ChainFeesFnParameters<undefined>) => number | Promise<number>) | undefined' is not assignable to type 'number | ((args: ChainFeesFnParameters<ChainFormatters | undefined>) => number | Promise<number>) | undefined'.
              Type '(args: ChainFeesFnParameters<undefined>) => number | Promise<number>' is not assignable to type 'number | ((args: ChainFeesFnParameters<ChainFormatters | undefined>) => number | Promise<number>) | undefined'.
                Type '(args: ChainFeesFnParameters<undefined>) => number | Promise<number>' is not assignable to type '(args: ChainFeesFnParameters<ChainFormatters | undefined>) => number | Promise<number>'.
                  Types of parameters 'args' and 'args' are incompatible.
                    Type 'ChainFeesFnParameters<ChainFormatters | undefined>' is not assignable to type 'ChainFeesFnParameters<undefined>'.
                      The types of 'block.transactions' are incompatible between these types.
                        Type '`0x${string}`[] | ({ type: "legacy"; chainId?: number | undefined; yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; ... 11 more ...; transactionIndex: number | null; } | { ...; } | { ...; } |...' is not assignable to type '`0x${string}`[] | ({ type: "legacy"; chainId?: number | undefined; yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; ... 11 more ...; transactionIndex: number | null; } | { ...; } | { ...; } |...'. Two different types with this name exist, but they are unrelated.
                          Type '({ type: "legacy"; chainId?: number | undefined; yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; ... 10 more ...; transactionIndex: number | null; } | { ...; }...' is not assignable to type '`0x${string}`[] | ({ type: "legacy"; chainId?: number | undefined; yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; ... 11 more ...; transactionIndex: number | null; } | { ...; } | { ...; } |...'.
                            Type '({ type: "legacy"; chainId?: number | undefined; yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; ... 10 more ...; transactionIndex: number | null; } | { ...; }...' is not assignable to type '`0x${string}`[]'.
                              Type '{ type: "legacy"; chainId?: number | undefined; yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; ... 10 more ...; transactionIndex: number | null; } | { ...; } ...' is not assignable to type '`0x${string}`'.
                                Type '{ type: "legacy"; chainId?: number | undefined; yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; ... 10 more ...; transactionIndex: number | null; }' is not assignable to type '`0x${string}`'.ts(2322)
types.d.ts(31, 5): The expected type comes from property 'chain' which is declared here on type 'IntrinsicAttributes & OnchainKitProviderReact'

Also issue with QueryClientProvider Screenshot 2024-06-24 at 10 50 25 PM

This is when signed in and Avatar component is rendered (I think) - client stack trace below

Warning: Cannot update a component (`HotReload`) while rendering a different component (`Avatar`). To locate the bad setState() call inside `Avatar`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render at Avatar
QueryClientProvider.js:21 Uncaught Error: No QueryClient set, use QueryClientProvider to set one
    at useQueryClient (QueryClientProvider.js:21:15)
    at useBaseQuery (useBaseQuery.js:28:91)
    at useQuery (useQuery.js:13:74)
    at useName (useName.js:26:73)
    at Avatar (Avatar.js:48:78)

What’s the expected behavior?

Render without errors

What version of the libraries are you using?

“@coinbase/onchainkit”: “0.22.3”, “viem”: “2.x”, “wagmi”: “^2.9.2”, “@privy-io/react-auth”: “^1.71.0”, “@privy-io/server-auth”: “^1.7.3”, “@privy-io/wagmi”: “^0.2.10”,

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 28 (14 by maintainers)

Most upvoted comments

I think this problem is happening again with last versions of viem (2.21.55) and wagmi (2.14.1). Type 'import("/Users/xxx/xxx/xxx/node_modules/@coinbase/onchainkit/node_modules/viem/_types/types/chain").Chain' is not assignable to type 'import("/Users/xxx/xxx/xxx/node_modules/viem/_types/types/chain").Chain'.

Also I am using the <FundButton /> which throws the following error: WagmiProviderNotFoundError: useConfig must be used within WagmiProvider. The above error occurred in the <FundButton> component. It was handled by the <ReactDevOverlay> error boundary. Error Component Stack Screenshot 2024-12-13 at 18 50 41

everything works as expected now

@Zizzamia this man is 🐐 just fyi gn fren!

Aight let me move that to peer dependencies as well

Verified this by removing @tanstack/react-query in the package.json and recompiling after using no cache.

I think this is the same problem as we bundle up @tanstack/react-query as well

For you, I’ll pull an all nighter

neovim + biome

Wouldn’t expect any less from you