Skip to content

Commit

Permalink
reject in watchAsset to indicate failure
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahZinsmeister committed May 2, 2022
1 parent 320a2e1 commit d2c6c1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
11 changes: 5 additions & 6 deletions packages/coinbase-wallet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ export class CoinbaseWallet extends Connector {
symbol,
decimals,
image,
}: Pick<WatchAssetParameters, 'address'> & Partial<Omit<WatchAssetParameters, 'address'>>): Promise<boolean> {
if (!this.provider) return false
}: Pick<WatchAssetParameters, 'address'> & Partial<Omit<WatchAssetParameters, 'address'>>): Promise<true> {
if (!this.provider) throw new Error('No provider')

return this.provider
.request({
Expand All @@ -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
})
}
}
11 changes: 5 additions & 6 deletions packages/metamask/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export class MetaMask extends Connector {
})
}

public async watchAsset({ address, symbol, decimals, image }: WatchAssetParameters): Promise<boolean> {
if (!this.provider) return false
public async watchAsset({ address, symbol, decimals, image }: WatchAssetParameters): Promise<true> {
if (!this.provider) throw new Error('No provider')

return this.provider
.request({
Expand All @@ -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
})
}
}
2 changes: 1 addition & 1 deletion packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,5 @@ export abstract class Connector {
/**
* Attempt to add an asset per EIP-747
*/
public watchAsset?(params: WatchAssetParameters): Promise<boolean>
public watchAsset?(params: WatchAssetParameters): Promise<true>
}

0 comments on commit d2c6c1f

Please sign in to comment.