-
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.
* feat: zerionWallet * fix: removed shimDisconnect option in favor of options passthrough * fix: added window.zerionWallet check for zerionWallet * fix: resolved zerion walletconnect uri typo
- Loading branch information
1 parent
7f669bd
commit 2b4ede4
Showing
6 changed files
with
167 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 | ||
--- | ||
|
||
Zerion Support | ||
|
||
**Example usage** | ||
|
||
```ts | ||
import { | ||
getDefaultWallets, | ||
connectorsForWallets, | ||
} from '@rainbow-me/rainbowkit'; | ||
import { zerionWallet } from '@rainbow-me/rainbowkit/wallets'; | ||
const { wallets } = getDefaultWallets({ appName, chains }); | ||
const connectors = connectorsForWallets([ | ||
...wallets, | ||
{ | ||
groupName: 'Other', | ||
wallets: [zerionWallet({ 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
5 changes: 5 additions & 0 deletions
5
packages/rainbowkit/src/wallets/walletConnectors/zerionWallet/zerionWallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions
125
packages/rainbowkit/src/wallets/walletConnectors/zerionWallet/zerionWallet.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,125 @@ | ||
/* 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 ZerionWalletOptions { | ||
chains: Chain[]; | ||
} | ||
|
||
export const zerionWallet = ({ | ||
chains, | ||
...options | ||
}: ZerionWalletOptions & InjectedConnectorOptions): Wallet => { | ||
const isZerionInjected = | ||
typeof window !== 'undefined' && | ||
((typeof window.ethereum !== 'undefined' && window.ethereum.isZerion) || | ||
// @ts-expect-error | ||
typeof window.zerionWallet !== 'undefined'); | ||
|
||
const shouldUseWalletConnect = !isZerionInjected; | ||
|
||
return { | ||
id: 'zerion', | ||
name: 'Zerion', | ||
iconUrl: async () => (await import('./zerionWallet.svg')).default, | ||
iconAccent: '#2962ef', | ||
iconBackground: '#fff', | ||
installed: !shouldUseWalletConnect ? isZerionInjected : undefined, | ||
downloadUrls: { | ||
browserExtension: | ||
'https://chrome.google.com/webstore/detail/klghhnkeealcohjjanjjdaeeggmfmlpl', | ||
android: | ||
'https://play.google.com/store/apps/details?id=io.zerion.android', | ||
ios: 'https://apps.apple.com/app/apple-store/id1456732565', | ||
qrCode: 'https://link.zerion.io/pt3gdRP0njb', | ||
}, | ||
createConnector: () => { | ||
const connector = shouldUseWalletConnect | ||
? getWalletConnectConnector({ chains }) | ||
: new InjectedConnector({ | ||
chains, | ||
options: { | ||
getProvider: () => | ||
typeof window !== 'undefined' | ||
? // @ts-expect-error | ||
window.zerionWallet || window.ethereum | ||
: undefined, | ||
...options, | ||
}, | ||
}); | ||
|
||
const getUri = async () => { | ||
const { uri } = (await connector.getProvider()).connector; | ||
|
||
return isAndroid() | ||
? uri | ||
: `https://wallet.zerion.io/wc?uri=${encodeURIComponent(uri)}`; | ||
}; | ||
|
||
return { | ||
connector, | ||
mobile: { | ||
getUri: shouldUseWalletConnect ? getUri : undefined, | ||
}, | ||
qrCode: shouldUseWalletConnect | ||
? { | ||
getUri, | ||
instructions: { | ||
learnMoreUrl: | ||
'https://zerion.io/blog/announcing-the-zerion-smart-wallet/', | ||
steps: [ | ||
{ | ||
description: | ||
'We recommend putting Zerion on your home screen for quicker access.', | ||
step: 'install', | ||
title: 'Open the Zerion 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: { | ||
instructions: { | ||
learnMoreUrl: 'https://help.zerion.io/en/', | ||
steps: [ | ||
{ | ||
description: | ||
'We recommend pinning Zerion to your taskbar for quicker access to your wallet.', | ||
step: 'install', | ||
title: 'Install the Zerion 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
2b4ede4
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-rainbowdotme.vercel.app
rainbowkit-site-git-main-rainbowdotme.vercel.app
rainbowkit.com
rainbowkit.vercel.app
www.rainbowkit.com
2b4ede4
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-rainbowdotme.vercel.app
rainbowkit-example.vercel.app
rainbowkit-example-git-main-rainbowdotme.vercel.app