Skip to content

Commit

Permalink
feat: crypto.com defi wallet injected provider support (#1499)
Browse files Browse the repository at this point in the history
* feat: add injected defi wallet

* build: bump injected package

* docs: add defi wallet

* build: bump demo injected package

* Update packages/demo/package.json

* Update packages/injected/package.json

---------

Co-authored-by: Adam Carpenter <[email protected]>
  • Loading branch information
kabaluyot and Adamj1232 authored Jan 30, 2023
1 parent 9c693b6 commit 76d89a5
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/src/routes/docs/[...4]wallets/injected.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ const injected = injectedModule({
- Exodus - _Desktop & Mobile_
- Frontier - _Desktop & Mobile_
- Rainbow - _Desktop & Mobile_
- DeFiWallet - _Desktop & Mobile_

## Build Environments

Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@web3-onboard/keepkey": "^2.3.3",
"@web3-onboard/keystone": "^2.3.3",
"@web3-onboard/ledger": "^2.4.2",
"@web3-onboard/injected-wallets": "^2.6.2-alpha.3",
"@web3-onboard/injected-wallets": "^2.6.2-alpha.4",
"@web3-onboard/magic": "^2.1.3",
"@web3-onboard/phantom": "^2.0.0-alpha.1",
"@web3-onboard/portis": "^2.1.3",
Expand Down
1 change: 1 addition & 0 deletions packages/injected/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ console.log(connectedWallets)
- Exodus - _Desktop & Mobile_
- Frontier - _Desktop & Mobile_
- Rainbow - _Desktop & Mobile_
- DeFiWallet - _Desktop & Mobile_

## Filtering Wallets

Expand Down
5 changes: 3 additions & 2 deletions packages/injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/injected-wallets",
"version": "2.6.2-alpha.3",
"version": "2.6.2-alpha.4",
"description": "Injected wallet module for connecting browser extension and mobile wallets to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -31,7 +31,8 @@
"confirmed",
"Injected Wallet",
"GameStop",
"Phantom"
"Phantom",
"DeFi Wallet"
],
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion packages/injected/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export const WALLET_NAMES: { [key: string]: string } = {
trust: 'Trust Wallet',
frontier: 'Frontier',
zerion: 'Zerion',
rainbow: 'Rainbow'
rainbow: 'Rainbow',
defiwallet: 'DeFi Wallet'
}
7 changes: 7 additions & 0 deletions packages/injected/src/icons/defiwallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default `<svg width="100%" height="100%" viewBox="0 0 222 256" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M111 0L0 64V192L111 256L222 192V64L111 0ZM111 0L0 64V192L111 256L222 192V64L111 0Z"
fill="white" />
<path
d="M154.822 206H139.028L120.12 188.667V179.778L139.695 161.111V131.556L165.277 114.889L194.417 136.889L154.822 206ZM89.4228 159.333L92.3146 131.556L82.7495 106.667H139.251L129.908 131.556L132.577 159.333H110.778H89.4228ZM102.325 188.667L83.4168 206.222H67.4008L27.5832 136.889L56.9459 115.111L82.7495 131.556V161.111L102.325 179.778V188.667ZM67.1784 55.3334H154.599L165.054 99.7778H56.9459L67.1784 55.3334ZM111 0L0 64V192L111 256L222 192V64L111 0Z"
fill="#03316C" />
</svg>`
10 changes: 7 additions & 3 deletions packages/injected/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export enum ProviderIdentityFlag {
Zeal = 'isZeal',
Zerion = 'isZerion',
Rainbow = 'isRainbow',
SafePal = 'isSafePal'
SafePal = 'isSafePal',
DeFiWallet = 'isDeficonnectProvider'
}

export enum ProviderLabel {
Expand Down Expand Up @@ -103,7 +104,8 @@ export enum ProviderLabel {
OKXWallet = 'OKX Wallet',
Zerion = 'Zerion',
Rainbow = 'Rainbow',
SafePal = 'SafePal'
SafePal = 'SafePal',
DeFiWallet = 'DeFi Wallet'
}

export interface MeetOneProvider extends ExternalProvider {
Expand Down Expand Up @@ -132,7 +134,8 @@ export enum InjectedNameSpace {
Phantom = 'phantom',
OKXWallet = 'okxwallet',
Trust = 'trustwallet',
Frontier = 'frontier'
Frontier = 'frontier',
DeFiConnectProvider = 'deficonnectProvider'
}

export interface CustomWindow extends Window {
Expand Down Expand Up @@ -166,6 +169,7 @@ export interface CustomWindow extends Window {
}
okxwallet: InjectedProvider
trustwallet: InjectedProvider
deficonnectProvider: InjectedProvider
}

export type InjectedProvider = ExternalProvider &
Expand Down
15 changes: 14 additions & 1 deletion packages/injected/src/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,18 @@ const okxwallet: InjectedWalletModule = {
platforms: ['desktop']
}

const defiwallet: InjectedWalletModule = {
label: ProviderLabel.DeFiWallet,
injectedNamespace: InjectedNameSpace.DeFiConnectProvider,
checkProviderIdentity: ({ provider }) =>
!!provider && !!provider[ProviderIdentityFlag.DeFiWallet],
getIcon: async () => (await import('./icons/defiwallet.js')).default,
getInterface: async () => ({
provider: createEIP1193Provider(window.deficonnectProvider)
}),
platforms: ['all'],
}

const wallets = [
zeal,
exodus,
Expand Down Expand Up @@ -745,7 +757,8 @@ const wallets = [
okxwallet,
zerion,
rainbow,
safepal
safepal,
defiwallet
]

export default wallets

0 comments on commit 76d89a5

Please sign in to comment.