Skip to content

Commit

Permalink
Merge pull request #162 from lidofinance/fix/binance-wallet-follow-up-2
Browse files Browse the repository at this point in the history
Binance Wallet: reorder wallets, pass chainId, deeplink
  • Loading branch information
alx-khramov committed Aug 28, 2024
2 parents 17fff8b + 551aa9d commit 58aeb6b
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 26 deletions.
2 changes: 1 addition & 1 deletion apps/demo-react/components/WalletsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function WalletsModal(props: { isDarkTheme: boolean }) {
metrics={metrics}
shouldInvertWalletIcon={isDarkTheme}
linkDontHaveWallet={LINK_DONT_HAVE_WALLET_DEFAULT}
walletsPinned={['okx', 'browserExtension']}
walletsPinned={['binanceWallet', 'browserExtension']}
onClickWalletsMore={() => console.log('metrics: wallets modal show more')}
onClickWalletsLess={() => console.log('metrics: wallets modal show less')}
/>
Expand Down
8 changes: 8 additions & 0 deletions packages/connect-wallet-modal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @reef-knot/connect-wallet-modal

## 5.3.2

### Patch Changes

- Binance Wallet: actually use explicitly passed deeplink on mobiles
- Reorder wallets
- @reef-knot/wallets-list@2.2.2

## 5.3.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-wallet-modal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reef-knot/connect-wallet-modal",
"version": "5.3.1",
"version": "5.3.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -41,7 +41,7 @@
"@ledgerhq/hw-app-eth": "^6.37.1",
"@ledgerhq/hw-transport-webhid": "^6.29.0",
"@lidofinance/lido-ui": "^3.18.0",
"@reef-knot/wallets-list": "^2.2.1",
"@reef-knot/wallets-list": "^2.2.2",
"@types/react": "18.2.45",
"@types/react-dom": "18.2.17"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ const buttonComponentsByConnectorId: WalletsModalEthProps['buttonComponentsByCon
const WALLETS_DISPLAY_CONFIG_DEFAULT: WalletsModalEthProps['walletsShown'] = [
'browserExtension',
'metaMask',
'okx',
'ledgerHID',
'ledgerLive',
'walletConnect',
'binanceWallet',
'coinbase',
'trust',
'okx',
'exodus',
'brave',
'bitget',
Expand Down
41 changes: 26 additions & 15 deletions packages/connect-wallet-modal/src/connectButtons/ConnectBinance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useConnect } from 'wagmi';
import { useDisconnect } from '@reef-knot/core-react';
import { ConnectButton } from '../components/ConnectButton';
import { ConnectInjectedProps } from './types';
import { isMobileOrTablet } from '@reef-knot/wallets-helpers';
import { openWindow } from '../helpers/index';

export const ConnectBinance: FC<ConnectInjectedProps> = (
props: ConnectInjectedProps,
Expand All @@ -18,44 +20,53 @@ export const ConnectBinance: FC<ConnectInjectedProps> = (
downloadURLs,
detector,
connector,
deeplink,
...rest
} = props;

const metricsOnConnect = metrics?.events?.connect?.handlers[walletId];
const metricsOnClick = metrics?.events?.click?.handlers[walletId];

const { connect } = useConnect();
const { connectAsync } = useConnect();
const { disconnect } = useDisconnect();

const handleConnect = useCallback(() => {
const handleConnect = useCallback(async () => {
onBeforeConnect?.();
metricsOnClick?.();
disconnect?.();
connect(
{ connector },
{
onSuccess: () => {
onConnect?.();
metricsOnConnect?.();

if (isMobileOrTablet && deeplink && !detector?.()) {
openWindow(deeplink);
} else {
await connectAsync(
{ connector },
{
onSuccess: () => {
onConnect?.();
metricsOnConnect?.();
},
},
},
);
);
}
}, [

Check warning on line 51 in packages/connect-wallet-modal/src/connectButtons/ConnectBinance.tsx

View workflow job for this annotation

GitHub Actions / release

React Hook useCallback has a missing dependency: 'detector'. Either include it or remove the dependency array
connect,
connector,
disconnect,
metricsOnClick,
metricsOnConnect,
disconnect,
deeplink,
connectAsync,
connector,
onBeforeConnect,
onConnect,
metricsOnConnect,
]);

return (
<ConnectButton
{...rest}
icon={WalletIcon}
shouldInvertWalletIcon={shouldInvertWalletIcon}
onClick={handleConnect}
onClick={() => {
void handleConnect();
}}
>
{walletName}
</ConnectButton>
Expand Down
9 changes: 9 additions & 0 deletions packages/reef-knot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# reef-knot

## 5.5.2

### Patch Changes

- Updated dependencies
- Updated dependencies
- @reef-knot/connect-wallet-modal@5.3.2
- @reef-knot/wallets-list@2.2.2

## 5.5.1

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/reef-knot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reef-knot",
"version": "5.5.1",
"version": "5.5.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -41,11 +41,11 @@
"lint": "eslint --ext ts,tsx,js,mjs ."
},
"dependencies": {
"@reef-knot/connect-wallet-modal": "5.3.1",
"@reef-knot/connect-wallet-modal": "5.3.2",
"@reef-knot/core-react": "4.2.1",
"@reef-knot/web3-react": "4.0.1",
"@reef-knot/ui-react": "2.1.3",
"@reef-knot/wallets-list": "2.2.1",
"@reef-knot/wallets-list": "2.2.2",
"@reef-knot/wallets-helpers": "2.1.0",
"@reef-knot/types": "2.1.0",
"@reef-knot/ledger-connector": "4.1.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/wallets-list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @reef-knot/wallets-list

## 2.2.2

### Patch Changes

- Updated dependencies
- @reef-knot/wallet-adapter-binance-wallet@1.0.2

## 2.2.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/wallets-list/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reef-knot/wallets-list",
"version": "2.2.1",
"version": "2.2.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"@reef-knot/wallet-adapter-exodus": "2.1.0",
"@reef-knot/wallet-adapter-walletconnect": "2.0.1",
"@reef-knot/wallet-adapter-ambire": "2.0.1",
"@reef-knot/wallet-adapter-binance-wallet": "1.0.1",
"@reef-knot/wallet-adapter-binance-wallet": "1.0.2",
"@reef-knot/wallet-adapter-bitkeep": "2.1.0",
"@reef-knot/wallet-adapter-coin98": "2.1.0",
"@reef-knot/wallet-adapter-brave": "2.1.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/wallets/binance-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @reef-knot/wallet-adapter-binance-wallet

## 1.0.2

### Patch Changes

- Pass chainId to binanceWalletConnector

## 1.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/binance-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reef-knot/wallet-adapter-binance-wallet",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/binance-wallet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const BinanceWeb3Wallet: WalletAdapterType = ({ defaultChain }) => {
walletName: name,
type: binanceWalletConnector.type,
icon: WalletIcon,
createConnectorFn: binanceWalletConnector(),
createConnectorFn: binanceWalletConnector({ chainId: defaultChain.id }),
detector: isInBinance,
deeplink,
};
Expand Down

0 comments on commit 58aeb6b

Please sign in to comment.