Skip to content

Commit

Permalink
feat:add bybit btc
Browse files Browse the repository at this point in the history
  • Loading branch information
lance10030 committed Jun 24, 2024
1 parent c00d2b5 commit e60bdcd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const B2ModalProvider: FC<{ children: ReactNode, isAutoConnect?: boolean,
await connect("okx")
setCurrentWallet(w)
return
} if (w === WalletTypes.WALLET_BYBIT_BTC && !isBtcConnected) {
await connect("bybit")
setCurrentWallet(w)
return
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/utils/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import iconBybit from '../../imgs/bybit.png'
export type InstalledObj = Record<WalletTypes, boolean>
export type EvmConnectorName = 'gate' | 'metamask' | 'bybit' | 'okx'

export const BtcWalletArr = [WalletTypes.WALLET_OKX_BTC, WalletTypes.WALLET_TOMO_BTC, WalletTypes.WALLET_UNISAT]
export const BtcWalletArr = [WalletTypes.WALLET_OKX_BTC, WalletTypes.WALLET_TOMO_BTC, WalletTypes.WALLET_UNISAT, WalletTypes.WALLET_BYBIT_BTC]
export const EvmWalletArr = [WalletTypes.WALLET_GATE, WalletTypes.WALLET_METAMASK, WalletTypes.WALLET_BYBIT_EVM, WalletTypes.WALLET_OKX_EVM, WalletTypes.WALLET_TOMO_EVM]
export const defaultInstalledMap: InstalledObj = {
metamask: false,
Expand All @@ -18,7 +18,8 @@ export const defaultInstalledMap: InstalledObj = {
gate: false,
tomo_evm: false,
tomo_btc: false,
bybit_evm: false
bybit_evm: false,
bybit_btc: false
}


Expand Down Expand Up @@ -60,6 +61,9 @@ export const btcWalletNameTransformer = (wallet: string): WalletTypes | undefine
if (wallet?.toLocaleLowerCase().includes('tomo')) {
name = WalletTypes.WALLET_TOMO_BTC
}
if (wallet?.toLocaleLowerCase().includes('bybit')) {
name = WalletTypes.WALLET_BYBIT_BTC
}
return name
}

Expand All @@ -76,6 +80,7 @@ export const checkWalletInstall = (i: InstalledObj): InstalledObj => {
}
if (window.bybitWallet) {
installed.bybit_evm = true
installed.bybit_btc = true
}
if (window.tomo_evm) {
installed.tomo_btc = true;
Expand All @@ -87,6 +92,7 @@ export const getBtcWalletName = (wallet: string) => {
if (wallet.toLowerCase().includes('unisat')) return 'UniSat Wallet'
if (wallet.toLowerCase().includes('okx')) return 'OKX Wallet'
if (wallet.toLocaleLowerCase().includes('tomo')) return 'Tomo Wallet'
if (wallet.toLocaleLowerCase().includes('bybit')) return 'Bybit Wallet'
return ''
}
export const WalletIconConf = [
Expand Down
6 changes: 4 additions & 2 deletions src/utils/wallet/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export enum BtcConnectorName {
Unisat = 'Unisat',
OKX = 'OKX',
Tomo = 'Tomo'
Tomo = 'Tomo',
Bybit = 'Bybit'
}
export type Network = 'livenet' | 'testnet'

Expand All @@ -20,7 +21,8 @@ export enum WalletTypes {
WALLET_GATE = 'gate',
WALLET_TOMO_EVM = 'tomo_evm',
WALLET_TOMO_BTC = 'tomo_btc',
WALLET_BYBIT_EVM = 'bybit_evm'
WALLET_BYBIT_EVM = 'bybit_evm',
WALLET_BYBIT_BTC = 'bybit_btc'
}

export enum ChainType {
Expand Down

0 comments on commit e60bdcd

Please sign in to comment.