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

feat(CoinbaseWalletOptions): add preference #2002

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-lies-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rainbow-me/rainbowkit": patch
---

Add `preference` to CoinbaseWalletOptions
4 changes: 4 additions & 0 deletions packages/rainbowkit/src/config/getDefaultConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Transport } from 'viem';
import { http, CreateConfigParameters } from 'wagmi';
import { createConfig } from 'wagmi';
import { CoinbaseWalletParameters } from 'wagmi/connectors';
import type { RainbowKitChain } from '../components/RainbowKitProvider/RainbowKitChainContext';
import type { WalletList } from '../wallets/Wallet';
import { computeWalletConnectMetaData } from '../wallets/computeWalletConnectMetaData';
Expand Down Expand Up @@ -34,6 +35,7 @@ interface GetDefaultConfigParameters<
appIcon?: string;
wallets?: WalletList;
projectId: string;
coinbaseWalletPreference?: CoinbaseWalletParameters<'4'>['preference'];
}

const createDefaultTransports = <
Expand Down Expand Up @@ -61,6 +63,7 @@ export const getDefaultConfig = <
appIcon,
wallets,
projectId,
coinbaseWalletPreference,
...wagmiParameters
}: GetDefaultConfigParameters<chains, transports>) => {
const { transports, chains, ...restWagmiParameters } = wagmiParameters;
Expand Down Expand Up @@ -90,6 +93,7 @@ export const getDefaultConfig = <
appDescription,
appUrl,
appIcon,
coinbaseWalletPreference,
walletConnectParameters: { metadata },
},
);
Expand Down
7 changes: 6 additions & 1 deletion packages/rainbowkit/src/wallets/connectorsForWallets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { CreateConnectorFn } from 'wagmi';
import { CoinbaseWalletParameters } from 'wagmi/connectors';
import { isHexString } from '../utils/colors';
import { omitUndefinedValues } from '../utils/omitUndefinedValues';
import { uniqueBy } from '../utils/uniqueBy';
Expand All @@ -22,18 +23,20 @@ export interface ConnectorsForWalletsParameters {
appDescription?: string;
appUrl?: string;
appIcon?: string;
coinbaseWalletPreference?: CoinbaseWalletParameters<'4'>['preference'];
walletConnectParameters?: RainbowKitWalletConnectParameters;
}

export const connectorsForWallets = (
walletList: WalletList,
{
projectId,
walletConnectParameters,
walletConnectParameters = {},
appName,
appDescription,
appUrl,
appIcon,
coinbaseWalletPreference,
}: ConnectorsForWalletsParameters,
): CreateConnectorFn[] => {
if (!walletList.length) {
Expand Down Expand Up @@ -69,6 +72,8 @@ export const connectorsForWallets = (
projectId,
appName,
appIcon,
// `preference` is being used only for `coinbaseWallet` wallet
preference: coinbaseWalletPreference,
// `option` is being used only for `walletConnectWallet` wallet
options: {
metadata: walletConnectMetaData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { CreateConnectorFn, createConnector } from 'wagmi';
import { coinbaseWallet as coinbaseConnector } from 'wagmi/connectors';
import {
CoinbaseWalletParameters,
coinbaseWallet as coinbaseConnector,
} from 'wagmi/connectors';
import { isIOS } from '../../../utils/isMobile';
import { Wallet, WalletDetailsParams } from '../../Wallet';

export interface CoinbaseWalletOptions {
appName: string;
appIcon?: string;
preference?: CoinbaseWalletParameters<'4'>['preference'];
}

export const coinbaseWallet = ({
appName,
appIcon,
preference,
}: CoinbaseWalletOptions): Wallet => {
const getUri = (uri: string) => uri;
const ios = isIOS();
Expand Down Expand Up @@ -97,6 +102,7 @@ export const coinbaseWallet = ({
const connector: CreateConnectorFn = coinbaseConnector({
appName,
appLogoUrl: appIcon,
preference,
});

return createConnector((config) => ({
Expand Down