diff --git a/.changeset/lemon-bugs-try.md b/.changeset/lemon-bugs-try.md new file mode 100644 index 00000000..07fbcb20 --- /dev/null +++ b/.changeset/lemon-bugs-try.md @@ -0,0 +1,6 @@ +--- +'@node-real/walletkit': minor +--- + +fix: restore BinanceWeb3WalletConnector for mobile in-app browser compatibility + diff --git a/.changeset/moody-shrimps-melt.md b/.changeset/moody-shrimps-melt.md new file mode 100644 index 00000000..5faf1d72 --- /dev/null +++ b/.changeset/moody-shrimps-melt.md @@ -0,0 +1,5 @@ +--- +'@node-real/walletkit': minor +--- + +feat: add desktop extension support for Binance Web3 Wallet diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 00000000..c6c298f3 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,13 @@ +{ + "permissions": { + "allow": [ + "Bash(/tmp/comparison.txt:*)", + "Read(//tmp/**)", + "WebFetch(domain:developers.binance.com)", + "Bash(npm run:*)", + "Bash(git stash:*)", + "Bash(grep \"\"version\"\":*)", + "Bash(npx tsc:*)" + ] + } +} diff --git a/examples/nextjs/pages/_app.tsx b/examples/nextjs/pages/_app.tsx index f4bb463e..2a9c3671 100644 --- a/examples/nextjs/pages/_app.tsx +++ b/examples/nextjs/pages/_app.tsx @@ -10,7 +10,12 @@ import { WalletKitProvider, getDefaultConfig, } from '@node-real/walletkit'; -import { trustWallet, metaMask, walletConnect } from '@node-real/walletkit/wallets'; +import { + binanceWeb3Wallet, + trustWallet, + metaMask, + walletConnect, +} from '@node-real/walletkit/wallets'; const config = createConfig( getDefaultConfig({ @@ -22,7 +27,7 @@ const config = createConfig( walletConnectProjectId: 'e68a1816d39726c2afabf05661a32767', chains, - connectors: [trustWallet(), metaMask(), walletConnect()], + connectors: [binanceWeb3Wallet(), trustWallet(), metaMask(), walletConnect()], }), ); diff --git a/examples/vite/src/App.tsx b/examples/vite/src/App.tsx index 0b236fe8..7f32195c 100644 --- a/examples/vite/src/App.tsx +++ b/examples/vite/src/App.tsx @@ -8,7 +8,12 @@ import { WalletKitOptions, SwitchNetworkModal, } from '@node-real/walletkit'; -import { trustWallet, metaMask, walletConnect } from '@node-real/walletkit/wallets'; +import { + binanceWeb3Wallet, + trustWallet, + metaMask, + walletConnect, +} from '@node-real/walletkit/wallets'; const config = createConfig( getDefaultConfig({ @@ -20,7 +25,7 @@ const config = createConfig( walletConnectProjectId: 'e68a1816d39726c2afabf05661a32767', chains, - connectors: [trustWallet(), metaMask(), walletConnect()], + connectors: [binanceWeb3Wallet(), trustWallet(), metaMask(), walletConnect()], }), ); diff --git a/packages/walletkit/src/typings.d.ts b/packages/walletkit/src/typings.d.ts index 665739dd..af68a23c 100644 --- a/packages/walletkit/src/typings.d.ts +++ b/packages/walletkit/src/typings.d.ts @@ -12,6 +12,7 @@ declare global { tokenpocket: any; okexchain: any; bitkeep: any; + binancew3w: any; } } diff --git a/packages/walletkit/src/wallets/binanceWeb3Wallet/connector.ts b/packages/walletkit/src/wallets/binanceWeb3Wallet/connector.ts index 707eed20..10b280ce 100644 --- a/packages/walletkit/src/wallets/binanceWeb3Wallet/connector.ts +++ b/packages/walletkit/src/wallets/binanceWeb3Wallet/connector.ts @@ -49,4 +49,7 @@ function getProvider() { if (isMobile()) { return window.ethereum; } + + // Desktop: use Binance Web3 Wallet browser extension + return window.binancew3w?.ethereum; } diff --git a/packages/walletkit/src/wallets/binanceWeb3Wallet/index.tsx b/packages/walletkit/src/wallets/binanceWeb3Wallet/index.tsx index 232487ca..e92e1a04 100644 --- a/packages/walletkit/src/wallets/binanceWeb3Wallet/index.tsx +++ b/packages/walletkit/src/wallets/binanceWeb3Wallet/index.tsx @@ -21,13 +21,12 @@ export function binanceWeb3Wallet(props: PartialCustomProps = {}): WalletProps { default: 'https://www.binance.com/en/web3wallet', }, spinnerColor: undefined, - showQRCode: true, + showQRCode: false, isInstalled: isBinanceWeb3Wallet, createConnector: (chains: Chain[]) => { return new BinanceWeb3WalletConnector({ chains, options: { - shimDisconnect: true, ...connectorOptions, }, }); @@ -44,7 +43,8 @@ export function binanceWeb3Wallet(props: PartialCustomProps = {}): WalletProps { } export function isBinanceWeb3Wallet() { - return hasInjectedProvider('isBinance' as any); + if (typeof window === 'undefined') return false; + return !!window.binancew3w?.ethereum || hasInjectedProvider('isBinance' as any); } const getDeepLink = (url: string) => { diff --git a/website/src/pages/index.mdx b/website/src/pages/index.mdx index 9bf9d500..cdb8dffd 100644 --- a/website/src/pages/index.mdx +++ b/website/src/pages/index.mdx @@ -18,7 +18,7 @@ npm i @node-real/walletkit@^1 wagmi@^1 viem@^1 | wallet | mainnet | testnet | | ------------------- | ------- | ------- | -| binanceWeb3Wallet() | ✅ | ❌ | +| binanceWeb3Wallet() | ✅ | ✅ | | bitgetWallet() | ✅ | ❌ | | coinbaseWallet() | ✅ | ✅ | | metaMask() | ✅ | ✅ | @@ -96,7 +96,12 @@ import { WalletKitOptions, SwitchNetworkModal, } from '@node-real/walletkit'; -import { metaMask, trustWallet, walletConnect } from '@node-real/walletkit/wallets'; +import { + binanceWeb3Wallet, + metaMask, + trustWallet, + walletConnect, +} from '@node-real/walletkit/wallets'; const config = createConfig( getDefaultConfig({ @@ -108,7 +113,7 @@ const config = createConfig( walletConnectProjectId: 'xxx', chains, - connectors: [trustWallet(), metaMask(), walletConnect()], + connectors: [binanceWeb3Wallet(), trustWallet(), metaMask(), walletConnect()], }), );