-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tian000/noah
Noah
- Loading branch information
Showing
10 changed files
with
153 additions
and
14 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,7 @@ | ||
--- | ||
'example': patch | ||
'@rainbow-me/rainbowkit': patch | ||
'site': patch | ||
--- | ||
|
||
Add Phantom wallet support |
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
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
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
30 changes: 30 additions & 0 deletions
30
packages/rainbowkit/src/wallets/walletConnectors/phantomWallet/phantomWallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions
69
packages/rainbowkit/src/wallets/walletConnectors/phantomWallet/phantomWallet.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,69 @@ | ||
import { InjectedConnector } from 'wagmi/connectors/injected'; | ||
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext'; | ||
import { Wallet } from '../../Wallet'; | ||
|
||
export interface PhantomWalletOptions { | ||
chains: Chain[]; | ||
shimDisconnect?: boolean; | ||
} | ||
|
||
export const phantomWallet = ({ | ||
chains, | ||
shimDisconnect, | ||
}: PhantomWalletOptions): Wallet => { | ||
return { | ||
createConnector: () => { | ||
const getProvider = () => | ||
typeof window !== 'undefined' | ||
? ((window as any).phantom as any)?.ethereum | ||
: undefined; | ||
|
||
const connector = new InjectedConnector({ | ||
chains, | ||
options: { getProvider, shimDisconnect }, | ||
}); | ||
|
||
return { | ||
connector, | ||
extension: { | ||
instructions: { | ||
steps: [ | ||
{ | ||
description: | ||
'We recommend pinning Phantom to your taskbar for easier access to your wallet.', | ||
step: 'install', | ||
title: 'Install the Phantom extension', | ||
}, | ||
{ | ||
description: | ||
'Be sure to back up your wallet using a secure method. Never share your secret recovery 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', | ||
}, | ||
], | ||
}, | ||
learnMoreUrl: 'https://help.phantom.app', | ||
}, | ||
}; | ||
}, | ||
downloadUrls: { | ||
android: 'https://play.google.com/store/apps/details?id=app.phantom', | ||
browserExtension: 'https://phantom.app/download', | ||
ios: 'https://apps.apple.com/app/phantom-solana-wallet/1598432977', | ||
}, | ||
iconBackground: '#551BF9', | ||
iconUrl: async () => (await import('./phantomWallet.svg')).default, | ||
id: 'phantom', | ||
installed: | ||
(typeof window !== 'undefined' && | ||
!!((window as any).phantom as any)?.ethereum) || | ||
undefined, | ||
name: 'Phantom', | ||
}; | ||
}; |
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