aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/preferences.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2018-06-19 06:33:50 +0800
committerDan Finlay <dan@danfinlay.com>2018-06-19 06:33:50 +0800
commitf14ed329801ab65c31e84f8e9d8d93700ed56670 (patch)
tree63122081a404e0ae765658770b4da52cea4c44c0 /app/scripts/controllers/preferences.js
parent5d7c2810a701097ef1a4f9de23948418340f9cb4 (diff)
downloadtangerine-wallet-browser-f14ed329801ab65c31e84f8e9d8d93700ed56670.tar
tangerine-wallet-browser-f14ed329801ab65c31e84f8e9d8d93700ed56670.tar.gz
tangerine-wallet-browser-f14ed329801ab65c31e84f8e9d8d93700ed56670.tar.bz2
tangerine-wallet-browser-f14ed329801ab65c31e84f8e9d8d93700ed56670.tar.lz
tangerine-wallet-browser-f14ed329801ab65c31e84f8e9d8d93700ed56670.tar.xz
tangerine-wallet-browser-f14ed329801ab65c31e84f8e9d8d93700ed56670.tar.zst
tangerine-wallet-browser-f14ed329801ab65c31e84f8e9d8d93700ed56670.zip
Begin letting UI show suggested tokens
Diffstat (limited to 'app/scripts/controllers/preferences.js')
-rw-r--r--app/scripts/controllers/preferences.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 8a8b9a335..b76141be4 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -25,7 +25,7 @@ class PreferencesController {
frequentRpcList: [],
currentAccountTab: 'history',
tokens: [],
- suggestedTokens: [],
+ suggestedTokens: {},
useBlockie: false,
featureFlags: {},
currentLocale: opts.initLangCode,
@@ -53,6 +53,13 @@ class PreferencesController {
return this.store.getState().suggestedTokens
}
+ addSuggestedToken (tokenOpts) {
+ // TODO: Validate params
+ const suggested = this.getSuggestedTokens()
+ suggested[tokenOpts.address] = suggested
+ this.store.updateState({ suggestedTokens: suggested })
+ }
+
/**
* RPC engine middleware for requesting new token added
*
@@ -63,13 +70,24 @@ class PreferencesController {
*/
requestAddToken(req, res, next, end) {
if (req.method === 'eth_watchToken') {
- // Validate params!
- // this.suggestedTokens.push(req.params)
+ // TODO: Validate params!
const [ rawAddress, symbol, decimals ] = req.params
- this.addToken(rawAddress, symbol, decimals)
- end(null, rawAddress)
+
+ const tokenOpts = {
+ address: rawAddress,
+ decimals,
+ symbol,
+ }
+
+ this.suggestWatchToken()
+
+ return end(null, {
+ result: rawAddress,
+ "jsonrpc": "2.0",
+ id: req.id,
+ })
} else {
- next()
+ return next()
}
}