forked from rainbow-me/rainbowkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7e19ed
commit 0fe2211
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...rainbowkit/src/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions
112
packages/rainbowkit/src/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters