From d2c6c1f3a8faae4abcb2f8d7abd028d3a9d8f0d9 Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Mon, 2 May 2022 15:55:04 -0400 Subject: [PATCH] reject in watchAsset to indicate failure --- packages/coinbase-wallet/src/index.ts | 11 +++++------ packages/metamask/src/index.ts | 11 +++++------ packages/types/src/index.ts | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/coinbase-wallet/src/index.ts b/packages/coinbase-wallet/src/index.ts index 8f11cfd..4df6e63 100644 --- a/packages/coinbase-wallet/src/index.ts +++ b/packages/coinbase-wallet/src/index.ts @@ -195,8 +195,8 @@ export class CoinbaseWallet extends Connector { symbol, decimals, image, - }: Pick & Partial>): Promise { - if (!this.provider) return false + }: Pick & Partial>): Promise { + if (!this.provider) throw new Error('No provider') return this.provider .request({ @@ -211,10 +211,9 @@ export class CoinbaseWallet extends Connector { }, }, }) - .then((success) => success as boolean) - .catch((error) => { - console.debug(error) - return false + .then((success) => { + if (!success) throw new Error('Rejected') + return true }) } } diff --git a/packages/metamask/src/index.ts b/packages/metamask/src/index.ts index 1e6ea06..b58483a 100644 --- a/packages/metamask/src/index.ts +++ b/packages/metamask/src/index.ts @@ -165,8 +165,8 @@ export class MetaMask extends Connector { }) } - public async watchAsset({ address, symbol, decimals, image }: WatchAssetParameters): Promise { - if (!this.provider) return false + public async watchAsset({ address, symbol, decimals, image }: WatchAssetParameters): Promise { + if (!this.provider) throw new Error('No provider') return this.provider .request({ @@ -181,10 +181,9 @@ export class MetaMask extends Connector { }, }, }) - .then((success) => success as boolean) - .catch((error) => { - console.debug(error) - return false + .then((success) => { + if (!success) throw new Error('Rejected') + return true }) } } diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index bdce99e..e13db3e 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -127,5 +127,5 @@ export abstract class Connector { /** * Attempt to add an asset per EIP-747 */ - public watchAsset?(params: WatchAssetParameters): Promise + public watchAsset?(params: WatchAssetParameters): Promise }