Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bitget wallet connector #914

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import type { Web3ReactHooks } from '@web3-react/core'
import type { GnosisSafe } from '@web3-react/gnosis-safe'
import type { MetaMask } from '@web3-react/metamask'
import { BitKeep } from '@akkafinance/web3-react-bitkeep'
import type { Network } from '@web3-react/network'
import type { WalletConnect } from '@web3-react/walletconnect'
import type { WalletConnect as WalletConnectV2 } from '@web3-react/walletconnect-v2'
Expand Down
4 changes: 3 additions & 1 deletion example/components/ProviderExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import type { WalletConnect as WalletConnectV2 } from '@web3-react/walletconnect

import { coinbaseWallet, hooks as coinbaseWalletHooks } from '../connectors/coinbaseWallet'
import { hooks as metaMaskHooks, metaMask } from '../connectors/metaMask'
import { hooks as bitKeepHooks, bitKeep } from '../connectors/bitgetWallet'
import { hooks as networkHooks, network } from '../connectors/network'
import { hooks as walletConnectHooks, walletConnect } from '../connectors/walletConnect'
import { hooks as walletConnectV2Hooks, walletConnectV2 } from '../connectors/walletConnectV2'
import { getName } from '../utils'

const connectors: [MetaMask | WalletConnect | WalletConnectV2 | CoinbaseWallet | Network, Web3ReactHooks][] = [
const connectors: [MetaMask | BitKeep | WalletConnect | WalletConnectV2 | CoinbaseWallet | Network, Web3ReactHooks][] = [
[metaMask, metaMaskHooks],
[bitKeep, bitKeepHooks],
[walletConnect, walletConnectHooks],
[walletConnectV2, walletConnectV2Hooks],
[coinbaseWallet, coinbaseWalletHooks],
Expand Down
40 changes: 40 additions & 0 deletions example/components/connectorCards/BitgetWalletCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useEffect, useState } from 'react'

import { hooks, bitKeep } from '../../connectors/bitgetWallet'
import { Card } from '../Card'

const { useChainId, useAccounts, useIsActivating, useIsActive, useProvider, useENSNames } = hooks

export default function BitgetWalletCard() {
const chainId = useChainId()
const accounts = useAccounts()
const isActivating = useIsActivating()

const isActive = useIsActive()

const provider = useProvider()
const ENSNames = useENSNames(provider)

const [error, setError] = useState(undefined)

// attempt to connect eagerly on mount
useEffect(() => {
void bitKeep.connectEagerly().catch(() => {
console.debug('Failed to connect eagerly to metamask')
})
}, [])

return (
<Card
connector={bitKeep}
activeChainId={chainId}
isActivating={isActivating}
isActive={isActive}
error={error}
setError={setError}
accounts={accounts}
provider={provider}
ENSNames={ENSNames}
/>
)
}
4 changes: 4 additions & 0 deletions example/connectors/bitgetWallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { initializeConnector } from '@web3-react/core'
import { BitKeep } from '@akkafinance/web3-react-bitkeep'

export const [bitKeep, hooks] = initializeConnector<BitKeep>((actions) => new BitKeep({ actions }))
2 changes: 2 additions & 0 deletions example/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CoinbaseWalletCard from '../components/connectorCards/CoinbaseWalletCard'
import GnosisSafeCard from '../components/connectorCards/GnosisSafeCard'
import MetaMaskCard from '../components/connectorCards/MetaMaskCard'
import BitgetWalletCard from '../components/connectorCards/BitgetWalletCard'
import NetworkCard from '../components/connectorCards/NetworkCard'
import WalletConnectV2Card from '../components/connectorCards/WalletConnectV2Card'
import ProviderExample from '../components/ProviderExample'
Expand All @@ -10,6 +11,7 @@ export default function Home() {
<>
<ProviderExample />
<div style={{ display: 'flex', flexFlow: 'wrap', fontFamily: 'sans-serif' }}>
<BitgetWalletCard />
<MetaMaskCard />
<WalletConnectV2Card />
<CoinbaseWalletCard />
Expand Down
2 changes: 2 additions & 0 deletions example/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import { GnosisSafe } from '@web3-react/gnosis-safe'
import { MetaMask } from '@web3-react/metamask'
import { BitKeep } from '@akkafinance/web3-react-bitkeep'
import { Network } from '@web3-react/network'
import type { Connector } from '@web3-react/types'
import { WalletConnect as WalletConnect } from '@web3-react/walletconnect'
import { WalletConnect as WalletConnectV2 } from '@web3-react/walletconnect-v2'

export function getName(connector: Connector) {
if (connector instanceof MetaMask) return 'MetaMask'
if (connector instanceof BitKeep) return 'Bitget Wallet'
if (connector instanceof WalletConnectV2) return 'WalletConnect V2'
if (connector instanceof WalletConnect) return 'WalletConnect'
if (connector instanceof CoinbaseWallet) return 'Coinbase Wallet'
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"example"
],
"devDependencies": {
"@akkafinance/bitkeep-detect-provider": "^1.0.0",
"@akkafinance/web3-react-bitkeep": "^1.0.0",
"@coinbase/wallet-sdk": "^3.3.0",
"@testing-library/react-hooks": "^8.0.0",
"@tsconfig/recommended": "^1.0.1",
Expand Down
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.0.tgz#223572538f6bea336750039bb43a4016dcc8182d"
integrity sha512-iowxq3U30sghZotgl4s/oJRci6WPBfNO5YYgk2cIOMCHr3LeGPcsZjCEr+33Q4N+oV3OABDAtA+pyvWjbvBifQ==

"@akkafinance/bitkeep-detect-provider@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@akkafinance/bitkeep-detect-provider/-/bitkeep-detect-provider-1.0.0.tgz#7de16aca785b2f47e3f8b80e4fecb2d186772208"
integrity sha512-LAHjZD51NwJZ/Ck1/JsA/NMcmwcM7m6obNMD09BN8LMeuoKcVn9Roj1azrP9ETXqoYGLuwQwb9Y2kKzARY5gdw==

"@akkafinance/web3-react-bitkeep@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@akkafinance/web3-react-bitkeep/-/web3-react-bitkeep-1.0.0.tgz#f794290aabb1eaa82e4b36e02b646676764b8414"
integrity sha512-qG3wBu+WDh1YZzEhD6orhaKl9id22fZBnhtHl2zVZ+gx3i9OeaS4A2KACKiutZtxt5VnhBAybWIl3swi4Dj5Jg==
dependencies:
"@akkafinance/bitkeep-detect-provider" "^1.0.0"
"@web3-react/types" "^8.2.0"

"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789"
Expand Down