Skip to content

Commit

Permalink
feat: mew wallet support (#1073)
Browse files Browse the repository at this point in the history
* feat: add mew wallet

* fix: id, qr code

* fix: name

* chore: remove unnecessary code

* chore: cleanup, add installed property

* devop: run lint

* chore: updated changeset example usage

---------

Co-authored-by: Jesus Morales Jr <jmjles@gmail.com>
Co-authored-by: Gamaliel Padillo <gamalielgad1234@gmail.com>
  • Loading branch information
3 people committed Mar 10, 2023
1 parent a27618a commit 3399df5
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .changeset/cuddly-jars-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@rainbow-me/rainbowkit': patch
---

MEW Wallet Support

**Example usage**

```ts
import {
getDefaultWallets,
connectorsForWallets,
} from '@rainbow-me/rainbowkit';
import { mewWallet } from '@rainbow-me/rainbowkit/wallets';
const connectors = connectorsForWallets([
...wallets,
{
groupName: 'Other',
wallets: [
argentWallet({ chains }),
trustWallet({ chains }),
mewWallet({ chains }),
ledgerWallet({ chains }),
],
},
]);
```
2 changes: 2 additions & 0 deletions packages/example/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
argentWallet,
imTokenWallet,
ledgerWallet,
mewWallet,
omniWallet,
trustWallet,
} from '@rainbow-me/rainbowkit/wallets';
Expand Down Expand Up @@ -111,6 +112,7 @@ const connectors = connectorsForWallets([
argentWallet({ chains }),
imTokenWallet({ chains }),
ledgerWallet({ chains }),
mewWallet({ chains }),
omniWallet({ chains }),
trustWallet({ 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 @@ -5,6 +5,7 @@ import { imTokenWallet } from './imTokenWallet/imTokenWallet';
import { injectedWallet } from './injectedWallet/injectedWallet';
import { ledgerWallet } from './ledgerWallet/ledgerWallet';
import { metaMaskWallet } from './metaMaskWallet/metaMaskWallet';
import { mewWallet } from './mewWallet/mewWallet';
import { omniWallet } from './omniWallet/omniWallet';
import { rainbowWallet } from './rainbowWallet/rainbowWallet';
import { trustWallet } from './trustWallet/trustWallet';
Expand All @@ -18,6 +19,7 @@ export {
injectedWallet,
ledgerWallet,
metaMaskWallet,
mewWallet,
omniWallet,
rainbowWallet,
trustWallet,
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,43 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import { InjectedConnector } from 'wagmi/connectors/injected';
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext';
import { Wallet } from '../../Wallet';
export interface MewWalletOptions {
chains: Chain[];
shimDisconnect?: boolean;
}

export const mewWallet = ({
chains,
shimDisconnect,
}: MewWalletOptions): Wallet => {
const isMewWalletInjected =
typeof window !== 'undefined' &&
Boolean(
(
window.ethereum as typeof window.ethereum &
(undefined | { isMEWwallet?: boolean })
)?.isMEWwallet
);
return {
id: 'mew',
name: 'MEW wallet',
iconUrl: async () => (await import('./mewWallet.svg')).default,
iconBackground: '#fff',
installed: isMewWalletInjected,
downloadUrls: {
android:
'https://play.google.com/store/apps/details?id=com.myetherwallet.mewwallet&referrer=utm_source%3Drainbow',
ios: 'https://apps.apple.com/app/apple-store/id1464614025?pt=118781877&mt=8&ct=rainbow',
qrCode: 'https://www.mewwallet.com/',
},
createConnector: () => {
return {
connector: new InjectedConnector({
chains,
options: { shimDisconnect },
}),
};
},
};
};
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 @@ -159,6 +159,16 @@ metaMaskWallet(options: {
});
```

#### MEW Wallet

```tsx
import { mewWallet } from '@rainbow-me/rainbowkit/wallets';
mewWallet(options: {
chains: Chain[];
shimDisconnect?: boolean;
});
```

#### Omni

```tsx
Expand Down

2 comments on commit 3399df5

@vercel
Copy link

@vercel vercel bot commented on 3399df5 Mar 10, 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 3399df5 Mar 10, 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.