Skip to content

Commit

Permalink
fix: shimDisconnect option passthrough (#1080)
Browse files Browse the repository at this point in the history
* fix: shimDisconnect option passthrough

* fix: passthrough options for coinbaseWallet

* chore: changeset
  • Loading branch information
DanielSinclair committed Mar 16, 2023
1 parent 47b7bd9 commit 2a1d230
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-gifts-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rainbow-me/rainbowkit': patch
---

Fixed `shimDisconnect` wallet connector option to maintain default Wagmi disconnect behavior when `shimDisconnect` is unspecified. RainbowKit wallet connectors now also accept all `InjectedConnectorOptions` options.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import type { InjectedConnectorOptions } from '@wagmi/core/dist/connectors/injected';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { Wallet } from '../../Wallet';

export interface BitskiWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

export const bitskiWallet = ({
chains,
shimDisconnect,
}: BitskiWalletOptions): Wallet => ({
...options
}: BitskiWalletOptions & InjectedConnectorOptions): Wallet => ({
id: 'bitski',
name: 'Bitski',
installed:
Expand All @@ -28,7 +28,7 @@ export const bitskiWallet = ({
createConnector: () => ({
connector: new InjectedConnector({
chains,
options: { shimDisconnect },
options,
}),
}),
});
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import type { InjectedConnectorOptions } from '@wagmi/core/dist/connectors/injected';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { Wallet } from '../../Wallet';

export interface BraveWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

export const braveWallet = ({
chains,
shimDisconnect,
}: BraveWalletOptions): Wallet => ({
...options
}: BraveWalletOptions & InjectedConnectorOptions): Wallet => ({
id: 'brave',
name: 'Brave Wallet',
iconUrl: async () => (await import('./braveWallet.svg')).default,
Expand All @@ -27,7 +27,7 @@ export const braveWallet = ({
createConnector: () => ({
connector: new InjectedConnector({
chains,
options: { shimDisconnect },
options,
}),
}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface CoinbaseWalletOptions {
export const coinbaseWallet = ({
appName,
chains,
...options
}: CoinbaseWalletOptions): Wallet => {
const isCoinbaseWalletInjected =
typeof window !== 'undefined' && window.ethereum?.isCoinbaseWallet === true;
Expand Down Expand Up @@ -42,6 +43,7 @@ export const coinbaseWallet = ({
options: {
appName,
headlessMode: true,
...options,
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import type { InjectedConnectorOptions } from '@wagmi/core/dist/connectors/injected';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { Wallet } from '../../Wallet';

export interface InjectedWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

export const injectedWallet = ({
chains,
shimDisconnect,
}: InjectedWalletOptions): Wallet => ({
...options
}: InjectedWalletOptions & InjectedConnectorOptions): Wallet => ({
id: 'injected',
name: 'Injected Wallet',
iconUrl: async () => (await import('./injectedWallet.png')).default,
Expand All @@ -26,7 +26,7 @@ export const injectedWallet = ({
createConnector: () => ({
connector: new InjectedConnector({
chains,
options: { shimDisconnect },
options,
}),
}),
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import type { MetaMaskConnectorOptions } from '@wagmi/core/dist/connectors/metaMask';
import { MetaMaskConnector } from 'wagmi/connectors/metaMask';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { isAndroid } from '../../../utils/isMobile';
Expand All @@ -7,7 +8,6 @@ import { getWalletConnectConnector } from '../../getWalletConnectConnector';

export interface MetaMaskWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

function isMetaMask(ethereum: NonNullable<typeof window['ethereum']>) {
Expand Down Expand Up @@ -38,8 +38,8 @@ function isMetaMask(ethereum: NonNullable<typeof window['ethereum']>) {

export const metaMaskWallet = ({
chains,
shimDisconnect,
}: MetaMaskWalletOptions): Wallet => {
...options
}: MetaMaskWalletOptions & MetaMaskConnectorOptions): Wallet => {
const isMetaMaskInjected =
typeof window !== 'undefined' &&
typeof window.ethereum !== 'undefined' &&
Expand All @@ -66,7 +66,7 @@ export const metaMaskWallet = ({
? getWalletConnectConnector({ chains })
: new MetaMaskConnector({
chains,
options: { shimDisconnect },
options,
});

const getUri = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import type { InjectedConnectorOptions } from '@wagmi/core/dist/connectors/injected';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { Wallet } from '../../Wallet';
export interface MewWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

export const mewWallet = ({
chains,
shimDisconnect,
}: MewWalletOptions): Wallet => {
...options
}: MewWalletOptions & InjectedConnectorOptions): Wallet => {
const isMewWalletInjected =
typeof window !== 'undefined' &&
Boolean(
Expand All @@ -35,7 +35,7 @@ export const mewWallet = ({
return {
connector: new InjectedConnector({
chains,
options: { shimDisconnect },
options,
}),
};
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import type { InjectedConnectorOptions } from '@wagmi/core/dist/connectors/injected';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { isAndroid } from '../../../utils/isMobile';
Expand All @@ -7,7 +8,6 @@ import { getWalletConnectConnector } from '../../getWalletConnectConnector';

export interface RainbowWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

function isRainbow(ethereum: NonNullable<typeof window['ethereum']>) {
Expand All @@ -23,8 +23,8 @@ function isRainbow(ethereum: NonNullable<typeof window['ethereum']>) {

export const rainbowWallet = ({
chains,
shimDisconnect,
}: RainbowWalletOptions): Wallet => {
...options
}: RainbowWalletOptions & InjectedConnectorOptions): Wallet => {
const isRainbowInjected =
typeof window !== 'undefined' &&
typeof window.ethereum !== 'undefined' &&
Expand All @@ -46,7 +46,7 @@ export const rainbowWallet = ({
? getWalletConnectConnector({ chains })
: new InjectedConnector({
chains,
options: { shimDisconnect },
options,
});

const getUri = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import type { InjectedConnectorOptions } from '@wagmi/core/dist/connectors/injected';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { isAndroid } from '../../../utils/isMobile';
Expand All @@ -7,13 +8,12 @@ import { getWalletConnectConnector } from '../../getWalletConnectConnector';

export interface TrustWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

export const trustWallet = ({
chains,
shimDisconnect,
}: TrustWalletOptions): Wallet => ({
...options
}: TrustWalletOptions & InjectedConnectorOptions): Wallet => ({
id: 'trust',
name: 'Trust Wallet',
iconUrl: async () => (await import('./trustWallet.svg')).default,
Expand All @@ -33,7 +33,7 @@ export const trustWallet = ({
return {
connector: new InjectedConnector({
chains,
options: { shimDisconnect },
options,
}),
};
}
Expand Down
6 changes: 0 additions & 6 deletions site/data/docs/custom-wallet-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ import { injectedWallet } from '@rainbow-me/rainbowkit/wallets';

injectedWallet(options: {
chains: Chain[];
shimDisconnect?: boolean;
});
```

Expand All @@ -122,7 +121,6 @@ import { bitskiWallet } from '@rainbow-me/rainbowkit/wallets';

bitskiWallet(options: {
chains: Chain[];
shimDisconnect?: boolean;
});
```

Expand All @@ -133,7 +131,6 @@ import { braveWallet } from '@rainbow-me/rainbowkit/wallets';

braveWallet(options: {
chains: Chain[];
shimDisconnect?: boolean;
});
```

Expand Down Expand Up @@ -166,7 +163,6 @@ import { metaMaskWallet } from '@rainbow-me/rainbowkit/wallets';

metaMaskWallet(options: {
chains: Chain[];
shimDisconnect?: boolean;
});
```

Expand All @@ -176,7 +172,6 @@ metaMaskWallet(options: {
import { mewWallet } from '@rainbow-me/rainbowkit/wallets';
mewWallet(options: {
chains: Chain[];
shimDisconnect?: boolean;
});
```

Expand Down Expand Up @@ -207,7 +202,6 @@ import { trustWallet } from '@rainbow-me/rainbowkit/wallets';

trustWallet(options: {
chains: Chain[];
shimDisconnect?: boolean;
});
```

Expand Down

2 comments on commit 2a1d230

@vercel
Copy link

@vercel vercel bot commented on 2a1d230 Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 2a1d230 Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.