diff --git a/packages/rainbowkit/src/wallets/walletConnectors/bitKeepWallet/bitKeepWallet.svg b/packages/rainbowkit/src/wallets/walletConnectors/bitKeepWallet/bitKeepWallet.svg new file mode 100644 index 0000000000..c7be2f3a77 --- /dev/null +++ b/packages/rainbowkit/src/wallets/walletConnectors/bitKeepWallet/bitKeepWallet.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/rainbowkit/src/wallets/walletConnectors/bitKeepWallet/bitKeepWallet.ts b/packages/rainbowkit/src/wallets/walletConnectors/bitKeepWallet/bitKeepWallet.ts new file mode 100644 index 0000000000..89e742198f --- /dev/null +++ b/packages/rainbowkit/src/wallets/walletConnectors/bitKeepWallet/bitKeepWallet.ts @@ -0,0 +1,154 @@ +/* eslint-disable sort-keys-fix/sort-keys-fix */ +import type { InjectedConnectorOptions } from '@wagmi/core/connectors/injected'; +import { InjectedConnector } from 'wagmi/connectors/injected'; +import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext'; +import { getWalletConnectUri } from '../../../utils/getWalletConnectUri'; +import { isAndroid } from '../../../utils/isMobile'; +import { Wallet } from '../../Wallet'; +import { getWalletConnectConnector } from '../../getWalletConnectConnector'; +import type { + WalletConnectConnectorOptions, + WalletConnectLegacyConnectorOptions, +} from '../../getWalletConnectConnector'; + +export interface BitKeepWalletLegacyOptions { + projectId?: string; + chains: Chain[]; + walletConnectVersion: '2'; + walletConnectOptions?: WalletConnectLegacyConnectorOptions; +} + +export interface BitKeepWalletOptions { + projectId: string; + chains: Chain[]; + walletConnectVersion?: '2'; + walletConnectOptions?: WalletConnectConnectorOptions; +} + +export const bitKeepWallet = ({ + chains, + projectId, + walletConnectOptions, + walletConnectVersion = '2', + ...options +}: (BitKeepWalletLegacyOptions | BitKeepWalletOptions) & + InjectedConnectorOptions): Wallet => { + // Not using the explicit isBitKeep fn to check for bitKeep + // so that users can continue to use the bitKeep button + // to interact with wallets compatible with window.ethereum. + // The connector's getProvider will instead favor the real bitKeep + + const isBitKeepInjected = + typeof window !== 'undefined' && + (window as any).bitkeep !== undefined && + ((window as any).bitkeep as any)?.ethereum !== undefined && + ((window as any).bitkeep as any).isBitKeep === true; + + const shouldUseWalletConnect = !isBitKeepInjected; + + return { + id: 'bitKeep', + name: 'BitKeep', + iconUrl: 'https://bitkeep.com/favicon.ico', + iconAccent: '#f6851a', + iconBackground: '#fff', + installed: !shouldUseWalletConnect ? isBitKeepInjected : undefined, + downloadUrls: { + android: 'https://bitkeep.com/en/download?type=2', + browserExtension: + 'https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak', + chrome: + 'https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak', + ios: 'https://apps.apple.com/app/bitkeep/id1395301115', + mobile: 'https://bitkeep.com/en/download?type=2', + qrCode: 'https://bitkeep.com/en/download', + }, + + createConnector: () => { + const connector = shouldUseWalletConnect + ? getWalletConnectConnector({ + chains, + options: walletConnectOptions, + projectId, + version: walletConnectVersion, + }) + : new InjectedConnector({ + chains, + options: { + // @ts-expect-error + getProvider: () => window.bitkeep.ethereum, + ...options, + }, + }); + + const getUri = async () => { + const uri = await getWalletConnectUri(connector, walletConnectVersion); + + return isAndroid() + ? uri + : `bitkeep://wc?uri=${encodeURIComponent(uri)}`; + }; + + return { + connector, + extension: { + instructions: { + learnMoreUrl: 'https://study.bitkeep.com', + steps: [ + { + description: + 'We recommend pinning BitKeep to your taskbar for quicker access to your wallet.', + step: 'install', + title: 'Install the BitKeep extension', + }, + { + description: + 'Be sure to back up your wallet using a secure method. Never share your secret phrase with anyone.', + step: 'create', + title: 'Create or Import a Wallet', + }, + { + description: + 'Once you set up your wallet, click below to refresh the browser and load up the extension.', + step: 'refresh', + title: 'Refresh your browser', + }, + ], + }, + }, + mobile: { + getUri: shouldUseWalletConnect ? getUri : undefined, + }, + qrCode: shouldUseWalletConnect + ? { + getUri: async () => + getWalletConnectUri(connector, walletConnectVersion), + instructions: { + learnMoreUrl: 'https://study.bitkeep.com', + steps: [ + { + description: + 'We recommend putting BitKeep on your home screen for quicker access.', + step: 'install', + title: 'Open the BitKeep app', + }, + { + description: + 'Be sure to back up your wallet using a secure method. Never share your secret phrase with anyone.', + step: 'create', + title: 'Create or Import a Wallet', + }, + { + description: + 'After you scan, a connection prompt will appear for you to connect your wallet.', + step: 'scan', + title: 'Tap the scan button', + }, + ], + }, + } + : undefined, + }; + }, + }; +}; diff --git a/packages/rainbowkit/src/wallets/walletConnectors/index.ts b/packages/rainbowkit/src/wallets/walletConnectors/index.ts index cbc7c2a97a..43dcc48059 100644 --- a/packages/rainbowkit/src/wallets/walletConnectors/index.ts +++ b/packages/rainbowkit/src/wallets/walletConnectors/index.ts @@ -1,4 +1,5 @@ import { argentWallet } from './argentWallet/argentWallet'; +import { bitKeepWallet } from './bitKeepWallet/bitKeepWallet'; import { bitskiWallet } from './bitskiWallet/bitskiWallet'; import { braveWallet } from './braveWallet/braveWallet'; import { coinbaseWallet } from './coinbaseWallet/coinbaseWallet'; @@ -22,6 +23,7 @@ import { zerionWallet } from './zerionWallet/zerionWallet'; export { argentWallet, + bitKeepWallet, bitskiWallet, braveWallet, coinbaseWallet, diff --git a/site/data/docs/custom-wallet-list.mdx b/site/data/docs/custom-wallet-list.mdx index b9819bb478..0c61ae83ae 100644 --- a/site/data/docs/custom-wallet-list.mdx +++ b/site/data/docs/custom-wallet-list.mdx @@ -126,6 +126,17 @@ argentWallet(options: { }); ``` +#### bitKeep + +```tsx +import { bitKeepWallet } from '@rainbow-me/rainbowkit/wallets'; + +bitKeepWallet(options: { + projectId: string; + chains: Chain[]; +}); +``` + #### Bitski ```tsx