Skip to content

Commit

Permalink
test: Test binance web3 wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Feb 2, 2024
1 parent 95137ce commit b0d2f5f
Show file tree
Hide file tree
Showing 4 changed files with 1,785 additions and 5,343 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
- alpha
- dev-docs

jobs:
release:
Expand Down
8 changes: 8 additions & 0 deletions packages/walletkit/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Connector as WagmiConnector } from 'wagmi';

import type { InjectedProviderFlags as WagmiInjectedProviderFlags } from 'wagmi/window';

import { WalletProps } from './wallets/types';

declare global {
Expand All @@ -17,3 +19,9 @@ declare module 'wagmi' {
_wallet: WalletProps;
}
}

declare module 'wagmi/window' {
type InjectedProviderFlags = WagmiInjectedProviderFlags & {
isBinance?: string | undefined;
};
}
21 changes: 17 additions & 4 deletions packages/walletkit/src/wallets/binanceWeb3Wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PartialCustomProps, WalletProps } from '..';
import { CustomConnector } from '../custom/connector';
import { BinanceWeb3WalletIcon, BinanceWeb3WalletTransparentIcon } from './icon';
import { isMobile } from '@/base/utils/mobile';
import { hasInjectedProvider } from '../utils';

export const BINANCE_WEB3_WALLET_ID = 'binanceWeb3Wallet';

Expand Down Expand Up @@ -41,7 +42,8 @@ export function binanceWeb3Wallet(props: PartialCustomProps = {}): WalletProps {
});
},
getDeepLink: () => {
return undefined; //`bnc://app.binance.com/cedefi/wc?uri=${encodeURIComponent(uri)}`;
const { http } = getDeepLink(window.location.href);
return http;
},
getQRCodeUri(uri) {
return uri;
Expand All @@ -51,7 +53,18 @@ export function binanceWeb3Wallet(props: PartialCustomProps = {}): WalletProps {
}

export function isBinanceWeb3Wallet() {
if (typeof window === 'undefined') return false;

return false;
return hasInjectedProvider('isBinance' as any);
}

const getDeepLink = (url: string) => {
const base = 'bnc://app.binance.com/mp/app';
const appId = 'yFK5FCqYprrXDiVFbhyRx7';

const startPagePath = window.btoa('/pages/browser/index');
const startPageQuery = window.btoa(`url=${url}`);
const deeplink = `${base}?appId=${appId}&startPagePath=${startPagePath}&startPageQuery=${startPageQuery}`;
const dp = window.btoa(deeplink);
const http = `https://app.binance.com/en/download?_dp=${dp}`;

return { http, bnc: deeplink };
};
Loading

0 comments on commit b0d2f5f

Please sign in to comment.