diff options
author | Dan Finlay <dan@danfinlay.com> | 2018-06-19 06:05:41 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2018-06-19 06:07:08 +0800 |
commit | 5d7c2810a701097ef1a4f9de23948418340f9cb4 (patch) | |
tree | 4f360d34d94691ed8b673728c7a2b142c5b900b9 /app/scripts | |
parent | d910c35e90d0d725e86b7743538b6c6c429f26f0 (diff) | |
download | tangerine-wallet-browser-5d7c2810a701097ef1a4f9de23948418340f9cb4.tar tangerine-wallet-browser-5d7c2810a701097ef1a4f9de23948418340f9cb4.tar.gz tangerine-wallet-browser-5d7c2810a701097ef1a4f9de23948418340f9cb4.tar.bz2 tangerine-wallet-browser-5d7c2810a701097ef1a4f9de23948418340f9cb4.tar.lz tangerine-wallet-browser-5d7c2810a701097ef1a4f9de23948418340f9cb4.tar.xz tangerine-wallet-browser-5d7c2810a701097ef1a4f9de23948418340f9cb4.tar.zst tangerine-wallet-browser-5d7c2810a701097ef1a4f9de23948418340f9cb4.zip |
Begin adding eth_watchToken
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/background.js | 2 | ||||
-rw-r--r-- | app/scripts/controllers/preferences.js | 25 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index 2451cddb6..2be600c4b 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -248,6 +248,7 @@ function setupController (initState, initLangCode) { showUnconfirmedMessage: triggerUi, unlockAccountMessage: triggerUi, showUnapprovedTx: triggerUi, + showAddTokenUi: triggerUi, // initial state initState, // initial locale code @@ -436,3 +437,4 @@ extension.runtime.onInstalled.addListener(function (details) { extension.tabs.create({url: 'https://metamask.io/#how-it-works'}) } }) + diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 8411e3a28..8a8b9a335 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -25,6 +25,7 @@ class PreferencesController { frequentRpcList: [], currentAccountTab: 'history', tokens: [], + suggestedTokens: [], useBlockie: false, featureFlags: {}, currentLocale: opts.initLangCode, @@ -48,6 +49,30 @@ class PreferencesController { this.store.updateState({ useBlockie: val }) } + getSuggestedTokens () { + return this.store.getState().suggestedTokens + } + + /** + * RPC engine middleware for requesting new token added + * + * @param req + * @param res + * @param {Function} - next + * @param {Function} - end + */ + requestAddToken(req, res, next, end) { + if (req.method === 'eth_watchToken') { + // Validate params! + // this.suggestedTokens.push(req.params) + const [ rawAddress, symbol, decimals ] = req.params + this.addToken(rawAddress, symbol, decimals) + end(null, rawAddress) + } else { + next() + } + } + /** * Getter for the `useBlockie` property * diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d40a351a5..0af7c5051 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1077,6 +1077,7 @@ module.exports = class MetamaskController extends EventEmitter { engine.push(createOriginMiddleware({ origin })) engine.push(createLoggerMiddleware({ origin })) engine.push(filterMiddleware) + engine.push(this.preferencesController.requestAddToken.bind(this.preferencesController)) engine.push(createProviderMiddleware({ provider: this.provider })) // setup connection |