Skip to content

Commit

Permalink
chore: let user specify all wagmi options
Browse files Browse the repository at this point in the history
  • Loading branch information
magiziz committed Feb 3, 2024
1 parent 0f62e35 commit 4697cea
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/rainbowkit/src/config/getDefaultConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Transport } from 'viem';
import { http } from 'wagmi';
import { http, CreateConfigParameters } from 'wagmi';
import { WagmiProviderProps, createConfig } from 'wagmi';
import { type Chain } from 'wagmi/chains';
import type { WalletList } from '../wallets/Wallet';
Expand All @@ -18,16 +18,21 @@ export type _chains = readonly [Chain, ...Chain[]];
// It maps each 'Chain' id to a 'Transport'
export type _transports = Record<_chains[number]['id'], Transport>;

interface GetDefaultConfigParameters {
type WagmiConfigParameters = Omit<
CreateConfigParameters<_chains, _transports>,
// If you use 'client' you can't use 'transports' (we force to use 'transports')
// More info here https://wagmi.sh/core/api/createConfig#client
// We will also use our own 'connectors' instead of letting user specifying it
'client' | 'connectors'
>;

interface GetDefaultConfigParameters extends WagmiConfigParameters {
appName: string;
appDescription?: string;
appUrl?: string;
appIcon?: string;
wallets?: WalletList;
projectId: string;
chains: _chains;
transports?: _transports;
multiInjectedProviderDiscovery?: boolean;
}

const createDefaultTransports = (chains: _chains): _transports => {
Expand All @@ -47,10 +52,10 @@ export const getDefaultConfig = ({
appIcon,
wallets,
projectId,
chains,
multiInjectedProviderDiscovery = true,
transports,
...wagmiParameters
}: GetDefaultConfigParameters): WagmiProviderProps['config'] => {
let { transports, chains, ...restWagmiParameters } = wagmiParameters;

const metadata = computeWalletConnectMetaData({
appName,
appDescription,
Expand Down Expand Up @@ -88,6 +93,6 @@ export const getDefaultConfig = ({
connectors,
chains,
transports,
multiInjectedProviderDiscovery,
...restWagmiParameters,
});
};

0 comments on commit 4697cea

Please sign in to comment.