Skip to content

Commit

Permalink
🚸 Use window.keplr automatically in keplr mobile in-app browser
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Oct 16, 2023
1 parent 3a53475 commit 31d7577
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from './utils/wallet-connect-v2';
import { initMetaMaskLeap } from './utils/metamask-leap';
import {
checkIsInKeplrMobileInAppBrowser,
initKeplr,
listenKeplrKeyStoreChange,
removeKeplrKeyStoreChangeListener,
Expand Down Expand Up @@ -184,6 +185,8 @@ export class LikeCoinWalletConnector {
connectWithMethod(
LikeCoinWalletConnectorMethodType.CosmostationMobile
);
} else if (checkIsInKeplrMobileInAppBrowser()) {
connectWithMethod(LikeCoinWalletConnectorMethodType.Keplr);
} else if (this._isConnectionMethodSelectDialogOpen) {
resolve(undefined);
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/keplr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import {
LikeCoinWalletConnectorOptions,
} from '../types';

export function checkIsInKeplrMobileInAppBrowser() {
// https://github.com/chainapsis/keplr-wallet/blob/3842af168145491681a76a4ce0f57a6c684992d4/packages/types/src/wallet/keplr.ts#L60
return window && window?.keplr?.mode === 'mobile-web';
}

export async function initKeplr(
options: LikeCoinWalletConnectorOptions,
trys = 0
Expand Down

0 comments on commit 31d7577

Please sign in to comment.