Merge pull request #5555 from MetaMask/support-wallet-watch-asset

Support for prefix wallet_watchAsset
feature/default_network_editable
kumavis 6 years ago committed by GitHub
commit b0c649a4e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/scripts/controllers/preferences.js
  2. 5
      test/unit/app/controllers/preferences-controller-test.js

@ -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':

@ -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'

Loading…
Cancel
Save