-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: iopayWallet * fix: global navigator * chore: tweak * revert: rename iopayWallet to ioPayWallet --------- Co-authored-by: MK <[email protected]>
- Loading branch information
Showing
6 changed files
with
93 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
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
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
packages/rainbowkit/src/wallets/walletConnectors/iopayWallet/iopayWallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions
65
packages/rainbowkit/src/wallets/walletConnectors/iopayWallet/iopayWallet.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,65 @@ | ||
import { isAndroid } from '../../../utils/isMobile'; | ||
import { DefaultWalletOptions, Wallet } from '../../Wallet'; | ||
import { getInjectedConnector } from '../../getInjectedConnector'; | ||
import { getWalletConnectConnector } from '../../getWalletConnectConnector'; | ||
|
||
export type IoPayWalletOptions = DefaultWalletOptions; | ||
|
||
function isIoPayMobile(): boolean { | ||
return ( | ||
typeof navigator !== 'undefined' && | ||
typeof navigator.userAgent !== 'undefined' && | ||
(navigator?.userAgent.includes('IoPayAndroid') || | ||
navigator?.userAgent.includes('IoPayiOs')) | ||
); | ||
} | ||
|
||
export const iopayWallet = ({ | ||
projectId, | ||
walletConnectParameters, | ||
}: IoPayWalletOptions): Wallet => ({ | ||
id: 'iopay', | ||
name: 'ioPay Wallet', | ||
iconUrl: async () => (await import('./iopayWallet.svg')).default, | ||
iconBackground: '#fff', | ||
downloadUrls: { | ||
android: | ||
'https://play.google.com/store/apps/details?id=io.iotex.iopay.gp&pli=1', | ||
ios: 'https://apps.apple.com/us/app/iopay-multichain-crypto-wallet/id1478086371', | ||
qrCode: 'https://iopay.me/', | ||
}, | ||
mobile: { | ||
getUri: (uri: string) => { | ||
return isAndroid() ? uri : `iopay://wc?uri=${encodeURIComponent(uri)}`; | ||
}, | ||
}, | ||
qrCode: { | ||
getUri: (uri: string) => uri, | ||
instructions: { | ||
learnMoreUrl: 'https://iopay.me/', | ||
steps: [ | ||
{ | ||
description: 'wallet_connectors.iopay.qr_code.step1.description', | ||
step: 'install', | ||
title: 'wallet_connectors.iopay.qr_code.step1.title', | ||
}, | ||
{ | ||
description: 'wallet_connectors.iopay.qr_code.step2.description', | ||
step: 'create', | ||
title: 'wallet_connectors.iopay.qr_code.step2.title', | ||
}, | ||
{ | ||
description: 'wallet_connectors.iopay.qr_code.step3.description', | ||
step: 'scan', | ||
title: 'wallet_connectors.iopay.qr_code.step3.title', | ||
}, | ||
], | ||
}, | ||
}, | ||
createConnector: isIoPayMobile() | ||
? getInjectedConnector({}) | ||
: getWalletConnectConnector({ | ||
projectId, | ||
walletConnectParameters, | ||
}), | ||
}); |
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