1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Fixed API for watchAsset (#14545)

* Fixed API for watchAsset

* Fixed boolean return value for watchAsset
This commit is contained in:
Shane 2022-04-27 07:47:10 -07:00 committed by GitHub
parent 27ad7279cd
commit 74b5401302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { ethErrors } from 'eth-rpc-errors';
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
const watchAsset = {
@ -36,9 +37,14 @@ async function watchAssetHandler(
) {
try {
const { options: asset, type } = req.params;
res.result = await handleWatchAssetRequest(asset, type);
const handleWatchAssetResult = await handleWatchAssetRequest(asset, type);
await handleWatchAssetResult.result;
res.result = true;
return end();
} catch (error) {
if (error.message === 'User rejected to watch the asset.') {
return end(ethErrors.provider.userRejectedRequest());
}
return end(error);
}
}