-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ty
committed
Apr 19, 2023
1 parent
4bbaac1
commit e4d48c3
Showing
6 changed files
with
81 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 | ||
--- | ||
|
||
Safeheron Wallet Support | ||
|
||
**Example usage** | ||
|
||
```ts | ||
import { | ||
getDefaultWallets, | ||
connectorsForWallets, | ||
} from '@rainbow-me/rainbowkit'; | ||
import { safeheronWallet } from '@rainbow-me/rainbowkit/wallets'; | ||
const { wallets } = getDefaultWallets({ appName, chains }); | ||
const connectors = connectorsForWallets([ | ||
...wallets, | ||
{ | ||
groupName: 'Other', | ||
wallets: [safeheronWallet({ 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
...ges/rainbowkit/src/wallets/walletConnectors/safeheronWallet/safeheronWallet.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions
43
packages/rainbowkit/src/wallets/walletConnectors/safeheronWallet/safeheronWallet.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,43 @@ | ||
/* eslint-disable sort-keys-fix/sort-keys-fix */ | ||
import type { InjectedConnectorOptions } from '@wagmi/core/dist/connectors/injected'; | ||
import { InjectedConnector } from 'wagmi/connectors/injected'; | ||
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext'; | ||
import { Wallet } from '../../Wallet'; | ||
|
||
export interface SafeheronWalletOptions { | ||
chains: Chain[]; | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
safeheron: any; | ||
} | ||
} | ||
|
||
export const safeheronWallet = ({ | ||
chains, | ||
...options | ||
}: SafeheronWalletOptions & InjectedConnectorOptions): Wallet => ({ | ||
id: 'safeheron', | ||
name: 'Safeheron', | ||
installed: | ||
typeof window !== 'undefined' && | ||
typeof window.safeheron !== 'undefined' && | ||
(window.safeheron as any).isSafeheron === true, | ||
iconUrl: async () => (await import('./safeheronWallet.svg')).default, | ||
iconBackground: '#fff', | ||
downloadUrls: { | ||
browserExtension: | ||
'https://chrome.google.com/webstore/detail/safeheron/aiaghdjafpiofpainifbgfgjfpclngoh', | ||
}, | ||
createConnector: () => ({ | ||
connector: new InjectedConnector({ | ||
chains, | ||
options: { | ||
getProvider: () => | ||
typeof window !== 'undefined' ? window.safeheron : undefined, | ||
...options, | ||
}, | ||
}), | ||
}), | ||
}); |
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