1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

add support for wallet_watchAsset

This commit is contained in:
Esteban MIno 2018-10-19 13:57:11 -03:00
parent ea214945cf
commit 75661673e5
2 changed files with 6 additions and 1 deletions

View File

@ -104,7 +104,7 @@ class PreferencesController {
* @param {Function} - end * @param {Function} - end
*/ */
async requestWatchAsset (req, res, next, end) { async requestWatchAsset (req, res, next, end) {
if (req.method === 'metamask_watchAsset') { if (req.method === 'metamask_watchAsset' || req.method === 'wallet_watchAsset') {
const { type, options } = req.params const { type, options } = req.params
switch (type) { switch (type) {
case 'ERC20': case 'ERC20':

View File

@ -375,6 +375,11 @@ describe('preferences controller', function () {
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end) await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
sandbox.assert.called(stubEnd) sandbox.assert.called(stubEnd)
sandbox.assert.notCalled(stubNext) sandbox.assert.notCalled(stubNext)
req.method = 'wallet_watchAsset'
req.params.type = 'someasset'
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
sandbox.assert.calledTwice(stubEnd)
sandbox.assert.notCalled(stubNext)
}) })
it('should through error if method is supported but asset type is not', async function () { it('should through error if method is supported but asset type is not', async function () {
req.method = 'metamask_watchAsset' req.method = 'metamask_watchAsset'