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

SmartRouter onChainProvider client Type mismatch #9704

Open
S1nPur1ty opened this issue Apr 29, 2024 · 6 comments
Open

SmartRouter onChainProvider client Type mismatch #9704

S1nPur1ty opened this issue Apr 29, 2024 · 6 comments
Labels
Bug Something isn't working

Comments

@S1nPur1ty
Copy link

S1nPur1ty commented Apr 29, 2024

I am trying to solve the following:

Imports:

import {
  SmartRouter
} from "@pancakeswap/smart-router";

import { createPublicClient, http } from "viem";

import { bsc } from "viem/chains";

In here, I have my client var with the bsc info.

const client = createPublicClient({
  chain: bsc,
  transport: http("https://bsc-dataseed.binance.org/"),
  batch: {
    multicall: {
      batchSize: 1024 * 200,
    },
  },
});

And I call it like this:

const quoteProvider = SmartRouter.createQuoteProvider({
  onChainProvider: () => client,
});

However, I get to see this weird warning:

Type '{ account: undefined; batch?: { multicall?: boolean | { batchSize?: number | undefined; wait?: number | undefined; } | undefined; } | undefined; cacheTime: number; chain: Assign<{ readonly id: 56; ... 5 more ...; readonly contracts: { ...; }; }, ChainConfig<...>>; ... 53 more ...; extend: <const client extends { ......' is not assignable to type '{ account: undefined; batch?: { multicall?: boolean | { batchSize?: number | undefined; wait?: number | undefined; } | undefined; } | undefined; cacheTime: number; chain: Chain | undefined; ... 53 more ...; extend: <const client extends { ...; } & Partial<...>>(fn: (client: Client<...>) => client) => Client<...>; }'.
  Types of property 'chain' are incompatible.
    Type 'Assign<{ readonly id: 56; readonly name: "BNB Smart Chain"; readonly network: "bsc"; readonly nativeCurrency: { readonly decimals: 18; readonly name: "BNB"; readonly symbol: "BNB"; }; readonly rpcUrls: { ...; }; readonly blockExplorers: { ...; }; readonly contracts: { ...; }; }, ChainConfig<...>>' is not assignable to type 'Chain | undefined'.
      Type 'Assign<{ readonly id: 56; readonly name: "BNB Smart Chain"; readonly network: "bsc"; readonly nativeCurrency: { readonly decimals: 18; readonly name: "BNB"; readonly symbol: "BNB"; }; readonly rpcUrls: { ...; }; readonly blockExplorers: { ...; }; readonly contracts: { ...; }; }, ChainConfig<...>>' is not assignable to type 'Chain'.
        Type 'Assign<{ readonly id: 56; readonly name: "BNB Smart Chain"; readonly network: "bsc"; readonly nativeCurrency: { readonly decimals: 18; readonly name: "BNB"; readonly symbol: "BNB"; }; readonly rpcUrls: { ...; }; readonly blockExplorers: { ...; }; readonly contracts: { ...; }; }, ChainConfig<...>>' is not assignable to type 'ChainConfig<ChainFormatters | undefined>'.
          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>'.
                            Types of property 'client' are incompatible.
                              Type 'import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/@pancakeswap/smart-router/node_modules/viem/_types/clients/createClient").Client<import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/@pancakeswap/smart-router/node_modules/viem/_types/clients/transports/createTransport"...' is not assignable to type 'import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/viem/_types/clients/createClient").Client<import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/viem/_types/clients/transports/createTransport").Transport, import("/Users/singular/Development/HappyGames/happy-game-web/nod...'.
                                Type 'Client<Transport, Chain<ChainFormatters | undefined>>' is not assignable to type 'Client_Base<Transport, Chain<ChainFormatters | undefined>, Account | undefined, undefined>'.
                                  Types of property 'account' are incompatible.
                                    Type 'import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/@pancakeswap/smart-router/node_modules/viem/_types/accounts/types").Account | undefined' is not assignable to type 'import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/viem/_types/accounts/types").Account | undefined'.
                                      Type 'LocalAccount<string, `0x${string}`>' is not assignable to type 'Account | undefined'.
                                        Type 'import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/@pancakeswap/smart-router/node_modules/viem/_types/accounts/types").LocalAccount<string, `0x${string}`>' is not assignable to type 'import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/viem/_types/accounts/types").LocalAccount<string, `0x${string}`>'.
                                          Type 'LocalAccount<string, `0x${string}`>' is not assignable to type 'CustomSource'.
                                            Types of property 'signTypedData' are incompatible.
                                              Type '<const TTypedData extends { [x: string]: readonly import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/viem/node_modules/abitype/dist/types/abi").TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `bool[${s...' is not assignable to type '<const TTypedData extends { [x: string]: readonly import("/Users/singular/Development/HappyGames/happy-game-web/node_modules/viem/node_modules/abitype/dist/types/abi").TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `bool[${s...'. Two different types with this name exist, but they are unrelated.
                                                Types of parameters 'typedData' and 'typedData' are incompatible.
                                                  Type 'TypedDataDefinition<TTypedData, TPrimaryType>' is not assignable to type 'TypedDataDefinition<TTypedData, string>'.
                                                    Type 'TypedDataDefinition<TTypedData, TPrimaryType>' is not assignable to type '{ [key_3: string]: any; } extends (TTypedData extends { [x: string]: readonly TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `bool[${string}]`]: undefined; [x: `bytes[${string}]`]: undefined; [x: `bytes9[${string}]`]: undefi...'.ts(2322)
providers.d.ts(37, 31): The expected type comes from the return type of this signature.
Codeium: Explain Problem

const client: {
    account: undefined;
    batch?: {
        multicall?: boolean | {
            batchSize?: number | undefined;
            wait?: number | undefined;
        } | undefined;
    } | undefined;
    cacheTime: number;
    chain: Assign<{
        readonly id: 56;
        ... 5 more ...;
        readonly contracts: {
            ...;
        };
    }, ChainConfig<...>>;
    ... 53 more ...;
    extend: <const client extends {
        ...;
    } & Partial<...>>(fn: (client: Client<...>) => client) => Client<...>;
}

@chefjackson can you please take a look

@chefjackson
Copy link
Collaborator

Should be type mismatch after upgrading to viem v2

@chefjackson chefjackson added the Bug Something isn't working label May 6, 2024
@PancakeSwap-bot
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 2 days.

4 similar comments
@PancakeSwap-bot
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 2 days.

@PancakeSwap-bot
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 2 days.

@PancakeSwap-bot
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 2 days.

@PancakeSwap-bot
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 2 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants