-
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: CLV Wallet connector * fix: icon * fix: imports * fix: reorder connector keys * fix: i18n * fix: qr code instructions --------- Co-authored-by: Sophie <sophie4140@outlook.com>
- Loading branch information
1 parent
efb8566
commit e41103f
Showing
7 changed files
with
199 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 | ||
--- | ||
|
||
CLV Wallet Support | ||
|
||
**Example usage** | ||
|
||
```ts | ||
import { | ||
getDefaultWallets, | ||
connectorsForWallets, | ||
} from '@rainbow-me/rainbowkit'; | ||
import { clvWallet } from '@rainbow-me/rainbowkit/wallets'; | ||
const { wallets } = getDefaultWallets({ appName, chains }); | ||
const connectors = connectorsForWallets([ | ||
...wallets, | ||
{ | ||
groupName: 'Other', | ||
wallets: [clvWallet({ chains, projectId })], | ||
}, | ||
]); | ||
``` |
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
packages/rainbowkit/src/wallets/walletConnectors/clvWallet/clvWallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions
130
packages/rainbowkit/src/wallets/walletConnectors/clvWallet/clvWallet.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,130 @@ | ||
import { InjectedConnector } from 'wagmi/connectors/injected'; | ||
import { Chain } from '../../../components/RainbowKitProvider/RainbowKitChainContext'; | ||
import { getWalletConnectUri } from '../../../utils/getWalletConnectUri'; | ||
import { Wallet } from '../../Wallet'; | ||
import { | ||
WalletConnectConnectorOptions, | ||
getWalletConnectConnector, | ||
} from '../../getWalletConnectConnector'; | ||
|
||
export interface CLVWalletOptions { | ||
projectId: string; | ||
chains: Chain[]; | ||
walletConnectVersion?: '2'; | ||
walletConnectOptions?: WalletConnectConnectorOptions; | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
clover: any; | ||
} | ||
} | ||
|
||
export const clvWallet = ({ | ||
chains, | ||
projectId, | ||
walletConnectOptions, | ||
walletConnectVersion = '2', | ||
}: CLVWalletOptions): Wallet => { | ||
const provider = typeof window !== 'undefined' && window['clover']; | ||
const isCLVInjected = Boolean(provider); | ||
|
||
const shouldUseWalletConnect = !isCLVInjected; | ||
|
||
return { | ||
id: 'clv', | ||
name: 'CLV', | ||
iconUrl: async () => (await import('./clvWallet.svg')).default, | ||
iconBackground: '#fff', | ||
iconAccent: '#BDFDE2', | ||
installed: !shouldUseWalletConnect ? isCLVInjected : undefined, | ||
downloadUrls: { | ||
chrome: | ||
'https://chrome.google.com/webstore/detail/clv-wallet/nhnkbkgjikgcigadomkphalanndcapjk', | ||
ios: 'https://apps.apple.com/app/clover-wallet/id1570072858', | ||
mobile: 'https://apps.apple.com/app/clover-wallet/id1570072858', | ||
qrCode: 'https://clv.org/', | ||
}, | ||
createConnector: () => { | ||
const connector = shouldUseWalletConnect | ||
? getWalletConnectConnector({ | ||
chains, | ||
options: walletConnectOptions, | ||
projectId, | ||
version: walletConnectVersion, | ||
}) | ||
: new InjectedConnector({ | ||
chains, | ||
options: { | ||
getProvider: () => provider, | ||
}, | ||
}); | ||
|
||
const getUri = async () => { | ||
const uri = await getWalletConnectUri(connector, '2'); | ||
return uri; | ||
}; | ||
|
||
return { | ||
connector, | ||
extension: { | ||
instructions: { | ||
learnMoreUrl: 'https://clv.org/', | ||
steps: [ | ||
{ | ||
description: | ||
'wallet_connectors.clv.extension.step1.description', | ||
step: 'install', | ||
title: 'wallet_connectors.clv.extension.step1.title', | ||
}, | ||
{ | ||
description: | ||
'wallet_connectors.clv.extension.step2.description', | ||
step: 'create', | ||
title: 'wallet_connectors.clv.extension.step2.title', | ||
}, | ||
{ | ||
description: | ||
'wallet_connectors.clv.extension.step3.description', | ||
step: 'refresh', | ||
title: 'wallet_connectors.clv.extension.step3.title', | ||
}, | ||
], | ||
}, | ||
}, | ||
mobile: { | ||
getUri: shouldUseWalletConnect ? getUri : undefined, | ||
}, | ||
qrCode: shouldUseWalletConnect | ||
? { | ||
getUri: async () => | ||
getWalletConnectUri(connector, walletConnectVersion), | ||
instructions: { | ||
learnMoreUrl: 'https://clv.org/', | ||
steps: [ | ||
{ | ||
description: | ||
'wallet_connectors.clv.qr_code.step1.description', | ||
step: 'install', | ||
title: 'wallet_connectors.clv.qr_code.step1.title', | ||
}, | ||
{ | ||
description: | ||
'wallet_connectors.clv.qr_code.step2.description', | ||
step: 'create', | ||
title: 'wallet_connectors.clv.qr_code.step2.title', | ||
}, | ||
{ | ||
description: | ||
'wallet_connectors.clv.qr_code.step3.description', | ||
step: 'scan', | ||
title: 'wallet_connectors.clv.qr_code.step3.title', | ||
}, | ||
], | ||
}, | ||
} | ||
: undefined, | ||
}; | ||
}, | ||
}; | ||
}; |
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
e41103f
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
e41103f
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.vercel.app
v1-rainbowkit.vercel.app
rainbowkit-site-rainbowdotme.vercel.app
v2-rainbowkit.vercel.app
rainbowkit-site-git-main-rainbowdotme.vercel.app
rainbowkit.com
www.rainbowkit.com