From fc8fc7ddb542f8fab0bbc268ac0ac03b15c40860 Mon Sep 17 00:00:00 2001 From: cb-jake <95890768+cb-jake@users.noreply.github.com> Date: Wed, 27 Apr 2022 16:07:23 -0600 Subject: [PATCH] Add new flag for coinbase dapp browsers (#491) * Add new flag for coinbase dapp browsers * run prettier * fix default value * prettier --- src/CoinbaseWalletSDK.ts | 8 +++++++- src/provider/CoinbaseWalletProvider.ts | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/CoinbaseWalletSDK.ts b/src/CoinbaseWalletSDK.ts index 22bc9de093..72eca2a575 100644 --- a/src/CoinbaseWalletSDK.ts +++ b/src/CoinbaseWalletSDK.ts @@ -32,6 +32,8 @@ export interface CoinbaseWalletSDKOptions { overrideIsMetaMask?: boolean; /** @optional whether wallet link provider should override the isCoinbaseWallet property. */ overrideIsCoinbaseWallet?: boolean; + /** @optional whether coinbase wallet provider should override the isCoinbaseBrowser property. */ + overrideIsCoinbaseBrowser?: boolean; /** @optional whether or not onboarding overlay popup should be displayed */ headlessMode?: boolean; } @@ -46,6 +48,7 @@ export class CoinbaseWalletSDK { private _storage: ScopedLocalStorage; private _overrideIsMetaMask: boolean; private _overrideIsCoinbaseWallet: boolean; + private _overrideIsCoinbaseBrowser: boolean; private _eventListener?: EventListener; /** @@ -68,6 +71,8 @@ export class CoinbaseWalletSDK { } this._overrideIsCoinbaseWallet = options.overrideIsCoinbaseWallet ?? true; + this._overrideIsCoinbaseBrowser = + options.overrideIsCoinbaseBrowser ?? false; this._eventListener = options.eventListener; @@ -134,7 +139,8 @@ export class CoinbaseWalletSDK { qrUrl: this.getQrUrl(), eventListener: this._eventListener, overrideIsMetaMask: this._overrideIsMetaMask, - overrideIsCoinbaseWallet: this._overrideIsCoinbaseWallet + overrideIsCoinbaseWallet: this._overrideIsCoinbaseWallet, + overrideIsCoinbaseBrowser: this._overrideIsCoinbaseBrowser }); } diff --git a/src/provider/CoinbaseWalletProvider.ts b/src/provider/CoinbaseWalletProvider.ts index 564289a953..64387dddd8 100644 --- a/src/provider/CoinbaseWalletProvider.ts +++ b/src/provider/CoinbaseWalletProvider.ts @@ -52,6 +52,7 @@ export interface CoinbaseWalletProviderOptions { jsonRpcUrl: string; qrUrl?: string | null; overrideIsCoinbaseWallet?: boolean; + overrideIsCoinbaseBrowser?: boolean; overrideIsMetaMask: boolean; relayEventManager: WalletSDKRelayEventManager; relayProvider: () => Promise; @@ -66,6 +67,9 @@ export class CoinbaseWalletProvider { // So dapps can easily identify Coinbase Wallet for enabling features like 3085 network switcher menus public readonly isCoinbaseWallet: boolean; + // So dapps can easily identify Coinbase Dapp Browser for enabling dapp browser specific features + public readonly isCoinbaseBrowser: boolean; + public readonly qrUrl?: string | null; private readonly _filterPolyfill = new FilterPolyfill(this); @@ -110,6 +114,7 @@ export class CoinbaseWalletProvider this._eventListener = options.eventListener; this.isCoinbaseWallet = options.overrideIsCoinbaseWallet ?? true; + this.isCoinbaseBrowser = options.overrideIsCoinbaseBrowser ?? false; this.qrUrl = options.qrUrl;