-
Notifications
You must be signed in to change notification settings - Fork 619
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
63d1387
commit 936b523
Showing
6 changed files
with
171 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
'@rainbow-me/rainbowkit': patch | ||
--- | ||
|
||
OKX Wallet Support | ||
|
||
**Example usage** | ||
|
||
```ts | ||
import { | ||
getDefaultWallets, | ||
connectorsForWallets, | ||
} from '@rainbow-me/rainbowkit'; | ||
import { okxWallet } from '@rainbow-me/rainbowkit/wallets'; | ||
const { wallets } = getDefaultWallets({ appName, chains }); | ||
const connectors = connectorsForWallets([ | ||
...wallets, | ||
{ | ||
groupName: 'Other', | ||
wallets: [okxWallet({ chains })], | ||
}, | ||
]); | ||
``` |
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
4 changes: 4 additions & 0 deletions
4
packages/rainbowkit/src/wallets/walletConnectors/okxWallet/okxWallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions
119
packages/rainbowkit/src/wallets/walletConnectors/okxWallet/okxWallet.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,119 @@ | ||
/* 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 { isAndroid } from '../../../utils/isMobile'; | ||
import { Wallet } from '../../Wallet'; | ||
import { getWalletConnectConnector } from '../../getWalletConnectConnector'; | ||
|
||
export interface OKXWalletOptions { | ||
chains: Chain[]; | ||
} | ||
|
||
export const okxWallet = ({ | ||
chains, | ||
...options | ||
}: OKXWalletOptions & InjectedConnectorOptions): Wallet => { | ||
// `isOkxWallet` or `isOKExWallet` needs to be added to the wagmi `Ethereum` object | ||
const isOKXInjected = | ||
typeof window !== 'undefined' && | ||
// @ts-expect-error | ||
typeof window.okxwallet !== 'undefined'; | ||
|
||
const shouldUseWalletConnect = !isOKXInjected; | ||
|
||
return { | ||
id: 'okx', | ||
name: 'OKX Wallet', | ||
iconUrl: async () => (await import('./okxWallet.svg')).default, | ||
iconAccent: '#000', | ||
iconBackground: '#000', | ||
downloadUrls: { | ||
browserExtension: | ||
'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge', | ||
android: | ||
'https://play.google.com/store/apps/details?id=com.okinc.okex.gp', | ||
ios: 'https://itunes.apple.com/app/id1327268470?mt=8', | ||
qrCode: 'https://www.okx.com/web3', | ||
}, | ||
createConnector: () => { | ||
const connector = shouldUseWalletConnect | ||
? getWalletConnectConnector({ chains }) | ||
: new InjectedConnector({ | ||
chains, | ||
options: { | ||
// @ts-expect-error | ||
getProvider: () => window.okxwallet, | ||
...options, | ||
}, | ||
}); | ||
|
||
return { | ||
connector, | ||
mobile: { | ||
getUri: shouldUseWalletConnect | ||
? async () => { | ||
const { uri } = (await connector.getProvider()).connector; | ||
return isAndroid() | ||
? uri | ||
: `okex://main/wc?uri=${encodeURIComponent(uri)}`; | ||
} | ||
: undefined, | ||
}, | ||
qrCode: shouldUseWalletConnect | ||
? { | ||
getUri: async () => (await connector.getProvider()).connector.uri, | ||
instructions: { | ||
learnMoreUrl: 'https://www.okx.com/web3/', | ||
steps: [ | ||
{ | ||
description: | ||
'We recommend putting OKX Wallet on your home screen for quicker access.', | ||
step: 'install', | ||
title: 'Open the OKX Wallet 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: { | ||
learnMoreUrl: 'https://www.okx.com/web3/', | ||
instructions: { | ||
steps: [ | ||
{ | ||
description: | ||
'We recommend pinning OKX Wallet to your taskbar for quicker access to your wallet.', | ||
step: 'install', | ||
title: 'Install the OKX Wallet 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
936b523
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rainbowkit-site – ./
rainbowkit-site-git-main-rainbowdotme.vercel.app
rainbowkit.com
www.rainbowkit.com
rainbowkit.vercel.app
rainbowkit-site-rainbowdotme.vercel.app
936b523
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rainbowkit-example – ./
rainbowkit-example.vercel.app
rainbowkit-example-git-main-rainbowdotme.vercel.app
rainbowkit-example-rainbowdotme.vercel.app