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: add coinbase wallet support #3264

Merged
merged 1 commit into from
Jul 18, 2023
Merged
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
8 changes: 7 additions & 1 deletion apps/web/src/components/Common/Providers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { IS_MAINNET, WALLETCONNECT_PROJECT_ID } from '@lenster/data/constants';
import {
APP_NAME,
IS_MAINNET,
WALLETCONNECT_PROJECT_ID
} from '@lenster/data/constants';
import { ApolloProvider, webClient } from '@lenster/lens/apollo';
import getRpc from '@lenster/lib/getRpc';
import getLivepeerTheme from '@lib/getLivepeerTheme';
Expand All @@ -12,6 +16,7 @@ import { ThemeProvider } from 'next-themes';
import type { ReactNode } from 'react';
import { configureChains, createConfig, WagmiConfig } from 'wagmi';
import { mainnet, polygon, polygonMumbai } from 'wagmi/chains';
import { CoinbaseWalletConnector } from 'wagmi/connectors/coinbaseWallet';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
Expand All @@ -29,6 +34,7 @@ const { chains, publicClient } = configureChains(

const connectors: any = [
new InjectedConnector({ chains, options: { shimDisconnect: true } }),
new CoinbaseWalletConnector({ options: { appName: APP_NAME } }),
new WalletConnectConnector({
options: { projectId: WALLETCONNECT_PROJECT_ID },
chains
Expand Down
8 changes: 8 additions & 0 deletions packages/lib/getWalletDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ describe('getWalletDetails', () => {
);
});

test('should return correct details for Coinbase Waller', () => {
const walletDetails = getWalletDetails('Coinbase Wallet');
expect(walletDetails.name).toBe('Coinbase Wallet');
expect(walletDetails.logo).toBe(
`${STATIC_IMAGES_URL}/wallets/coinbase.svg`
);
});

test('should return correct details for name other than WalletConnect', () => {
const walletDetails = getWalletDetails('SomeOtherWallet');
expect(walletDetails.name).toBe('SomeOtherWallet');
Expand Down
5 changes: 5 additions & 0 deletions packages/lib/getWalletDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ const getWalletDetails = (name: string): WalletDetails => {
WalletConnect: {
name: 'WalletConnect',
logo: `${STATIC_IMAGES_URL}/wallets/walletconnect.svg`
},
'Coinbase Wallet': {
name: 'Coinbase Wallet',
logo: `${STATIC_IMAGES_URL}/wallets/coinbase.svg`
}
};
const defaultDetails: WalletDetails = {
name,
logo: `${STATIC_IMAGES_URL}/wallets/browser-wallet.svg`
};

return walletDetails[name] || defaultDetails;
};

Expand Down
Loading