-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: onekey wallet support * fix: onekey icon svg
- Loading branch information
1 parent
c434ca7
commit 60968a5
Showing
6 changed files
with
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
'@rainbow-me/rainbowkit': patch | ||
--- | ||
|
||
OneKey Wallet Support | ||
|
||
**Example usage** | ||
|
||
```ts | ||
import { | ||
getDefaultWallets, | ||
connectorsForWallets, | ||
} from '@rainbow-me/rainbowkit'; | ||
import { oneKeyWallet } from '@rainbow-me/rainbowkit/wallets'; | ||
const { wallets } = getDefaultWallets({ appName, projectId, chains }); | ||
const connectors = connectorsForWallets([ | ||
...wallets, | ||
{ | ||
groupName: 'Other', | ||
wallets: [oneKeyWallet({ 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
1 change: 1 addition & 0 deletions
1
packages/rainbowkit/src/wallets/walletConnectors/oneKeyWallet/oneKeyWallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions
76
packages/rainbowkit/src/wallets/walletConnectors/oneKeyWallet/oneKeyWallet.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,76 @@ | ||
import { InjectedConnector } from 'wagmi/connectors/injected'; | ||
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext'; | ||
import { Wallet } from '../../Wallet'; | ||
|
||
export interface OnekeyWalletOptions { | ||
chains: Chain[]; | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
$onekey: any; | ||
} | ||
} | ||
|
||
export const oneKeyWallet = ({ chains }: OnekeyWalletOptions): Wallet => { | ||
const provider = typeof window !== 'undefined' && window['$onekey']?.ethereum; | ||
const isOnekeyInjected = Boolean(provider); | ||
|
||
return { | ||
createConnector: () => { | ||
const connector = new InjectedConnector({ | ||
chains, | ||
options: { | ||
getProvider: () => provider, | ||
}, | ||
}); | ||
|
||
return { | ||
connector, | ||
extension: { | ||
instructions: { | ||
learnMoreUrl: | ||
'https://help.onekey.so/hc/en-us/categories/360000170236', | ||
steps: [ | ||
{ | ||
description: | ||
'We recommend pinning OneKey Wallet to your taskbar for quicker access to your wallet.', | ||
step: 'install', | ||
title: 'Install the OneKey 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', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
}, | ||
downloadUrls: { | ||
android: | ||
'https://play.google.com/store/apps/details?id=so.onekey.app.wallet', | ||
browserExtension: 'https://www.onekey.so/download/', | ||
chrome: | ||
'https://chrome.google.com/webstore/detail/onekey/jnmbobjmhlngoefaiojfljckilhhlhcj', | ||
edge: 'https://microsoftedge.microsoft.com/addons/detail/onekey/obffkkagpmohennipjokmpllocnlndac', | ||
ios: 'https://apps.apple.com/us/app/onekey-open-source-wallet/id1609559473', | ||
mobile: 'https://www.onekey.so/download/', | ||
qrCode: 'https://www.onekey.so/download/', | ||
}, | ||
iconAccent: '#00B812', | ||
iconBackground: '#fff', | ||
iconUrl: async () => (await import('./oneKeyWallet.svg')).default, | ||
id: 'onekey', | ||
installed: isOnekeyInjected, | ||
name: 'OneKey', | ||
}; | ||
}; |
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
60968a5
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.vercel.app
rainbowkit-site-rainbowdotme.vercel.app
rainbowkit-site-git-main-rainbowdotme.vercel.app
www.rainbowkit.com
rainbowkit.com
60968a5
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-git-main-rainbowdotme.vercel.app
rainbowkit-example-rainbowdotme.vercel.app
rainbowkit-example.vercel.app