Skip to content

Commit

Permalink
feat: add TokenPocket wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
chendatony31 authored and DanielSinclair committed Jul 12, 2023
1 parent e7e19ed commit 0fe2211
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/rainbowkit/src/wallets/walletConnectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { rabbyWallet } from './rabbyWallet/rabbyWallet';
import { rainbowWallet } from './rainbowWallet/rainbowWallet';
import { safeWallet } from './safeWallet/safeWallet';
import { tahoWallet } from './tahoWallet/tahoWallet';
import { tokenPocketWallet } from './tokenPocketWallet/tokenPocketWallet';
import { trustWallet } from './trustWallet/trustWallet';
import { walletConnectWallet } from './walletConnectWallet/walletConnectWallet';
import { xdefiWallet } from './xdefiWallet/xdefiWallet';
Expand All @@ -37,6 +38,7 @@ export {
rainbowWallet,
safeWallet,
tahoWallet,
tokenPocketWallet,
trustWallet,
okxWallet,
walletConnectWallet,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { isMobile } from '../../../utils/isMobile';
import { Wallet } from '../../Wallet';
import { getWalletConnectConnector } from '../../getWalletConnectConnector';

export interface TokenPocketWalletOptions {
projectId: string;
chains: Chain[];
}

export const tokenPocketWallet = ({
chains,
projectId,
}: TokenPocketWalletOptions): Wallet => {
const isTokenPocketInjected =
typeof window !== 'undefined' && window.ethereum?.isTokenPocket === true;

const shouldUseWalletConnect = !isTokenPocketInjected;

return {
id: 'tokenPocket',
name: 'TokenPocket',
iconUrl: async () => (await import('./tokenPocketWallet.svg')).default,
iconBackground: '#2980FE',
installed: !shouldUseWalletConnect ? isTokenPocketInjected : undefined,
downloadUrls: {
chrome:
'https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii',
browserExtension: 'https://extension.tokenpocket.pro/',
android:
'https://play.google.com/store/apps/details?id=vip.mytokenpocket',
ios: 'https://apps.apple.com/us/app/tp-global-wallet/id6444625622',
qrCode: 'https://tokenpocket.pro/en/download/app',
mobile: 'https://tokenpocket.pro/en/download/app',
},
createConnector: () => {
const connector = shouldUseWalletConnect
? getWalletConnectConnector({ projectId, chains })
: new InjectedConnector({ chains });

const getUri = async () => {
const { uri } = (await connector.getProvider()).connector;
return isMobile()
? `tpoutside://wc?uri=${encodeURIComponent(uri)}`
: uri;
};

return {
connector,
mobile: {
getUri: shouldUseWalletConnect ? getUri : undefined,
},
qrCode: shouldUseWalletConnect
? {
getUri,
instructions: {
learnMoreUrl: 'https://help.tokenpocket.pro/en/',
steps: [
{
description:
'We recommend putting TokenPocket on your home screen for quicker access.',
step: 'install',
title: 'Open the TokenPocket 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,
extension: {
instructions: {
learnMoreUrl:
'https://help.tokenpocket.pro/en/extension-wallet/faq/installation-tutorial',
steps: [
{
description:
'We recommend pinning TokenPocket to your taskbar for quicker access to your wallet.',
step: 'install',
title: 'Install the TokenPocket 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',
},
],
},
},
};
},
};
};
11 changes: 11 additions & 0 deletions site/data/docs/custom-wallet-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,17 @@ tahoWallet(options: {
});
```

#### TokenPocket Wallet

```tsx
import { tokenPocketWallet } from '@rainbow-me/rainbowkit/wallets';

tokenPocketWallet(options: {
projectId: string;
chains: Chain[];
});
```

#### Trust Wallet

```tsx
Expand Down

0 comments on commit 0fe2211

Please sign in to comment.