Skip to content

Commit

Permalink
feat: onekeyWallet support (#1455)
Browse files Browse the repository at this point in the history
* feat: onekey wallet support

* fix: onekey icon svg
  • Loading branch information
salil-naik authored Aug 22, 2023
1 parent c434ca7 commit 60968a5
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .changeset/ninety-meals-drum.md
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 })],
},
]);
```
2 changes: 2 additions & 0 deletions packages/example/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
mewWallet,
okxWallet,
omniWallet,
oneKeyWallet,
phantomWallet,
rabbyWallet,
safeheronWallet,
Expand Down Expand Up @@ -117,6 +118,7 @@ const connectors = connectorsForWallets([
mewWallet({ chains }),
okxWallet({ chains, projectId }),
omniWallet({ chains, projectId }),
oneKeyWallet({ chains }),
phantomWallet({ chains }),
rabbyWallet({ chains }),
safeheronWallet({ chains }),
Expand Down
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 @@ -18,6 +18,7 @@ import { metaMaskWallet } from './metaMaskWallet/metaMaskWallet';
import { mewWallet } from './mewWallet/mewWallet';
import { okxWallet } from './okxWallet/okxWallet';
import { omniWallet } from './omniWallet/omniWallet';
import { oneKeyWallet } from './oneKeyWallet/oneKeyWallet';
import { phantomWallet } from './phantomWallet/phantomWallet';
import { rabbyWallet } from './rabbyWallet/rabbyWallet';
import { rainbowWallet } from './rainbowWallet/rainbowWallet';
Expand Down Expand Up @@ -53,6 +54,7 @@ export {
mewWallet,
okxWallet,
omniWallet,
oneKeyWallet,
phantomWallet,
rabbyWallet,
rainbowWallet,
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,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',
};
};
10 changes: 10 additions & 0 deletions site/data/docs/custom-wallet-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,16 @@ omniWallet(options: {
});
```

#### OneKey

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

oneKeyWallet(options: {
chains: Chain[];
});
```

#### Phantom

```tsx
Expand Down

2 comments on commit 60968a5

@vercel
Copy link

@vercel vercel bot commented on 60968a5 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 60968a5 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.