aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-06-28 07:54:43 +0800
committerEsteban MIno <efmino@uc.cl>2018-06-28 07:54:43 +0800
commit0e863d5fab00eb83c908fb49f2939534bdfe1162 (patch)
tree92c0b24e569687fe97a77aa6cb08140f33de99ba /app/scripts/controllers
parentbfac9c2c2dfd0c5f55cb794214791cf78cca75c0 (diff)
downloadtangerine-wallet-browser-0e863d5fab00eb83c908fb49f2939534bdfe1162.tar.gz
tangerine-wallet-browser-0e863d5fab00eb83c908fb49f2939534bdfe1162.tar.zst
tangerine-wallet-browser-0e863d5fab00eb83c908fb49f2939534bdfe1162.zip
network store to detect token
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r--app/scripts/controllers/detect-tokens.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/app/scripts/controllers/detect-tokens.js b/app/scripts/controllers/detect-tokens.js
index a7ddace19..4d364bd37 100644
--- a/app/scripts/controllers/detect-tokens.js
+++ b/app/scripts/controllers/detect-tokens.js
@@ -10,7 +10,7 @@ const {
} = require('./network/enums')
// By default, poll every 3 minutes
-const DEFAULT_INTERVAL = 180 * 1000
+const DEFAULT_INTERVAL = 15 * 1000
/**
* A controller that polls for token exchange
@@ -26,23 +26,23 @@ class DetectTokensController {
this.preferences = preferences
this.interval = interval
this.network = network
+ this.contracts = contracts
}
/**
- * For each token in eth-contract=metada, find check selectedAddress balance.
+ * For each token in eth-contract-metada, find check selectedAddress balance.
*
*/
async exploreNewTokens () {
if (!this.isActive) { return }
- if (this._network.getProviderConfig().type !== MAINNET) { return }
- var tokens = this._preferences.store.getState().tokens
+ if (this._network.getState().provider.type !== MAINNET) { return }
let detectedTokenAddress, token
- for (const address in contracts) {
- const contract = contracts[address]
- if (contract.erc20 && !(address in tokens)) {
+ for (const address in this.contracts) {
+ const contract = this.contracts[address]
+ if (contract.erc20 && !(address in this.tokens)) {
detectedTokenAddress = await this.fetchContractAccountBalance(address)
if (detectedTokenAddress) {
- token = contracts[detectedTokenAddress]
+ token = this.contracts[detectedTokenAddress]
this._preferences.addToken(detectedTokenAddress, token['symbol'], token['decimals'])
}
}
@@ -83,6 +83,8 @@ class DetectTokensController {
set preferences (preferences) {
if (!preferences) { return }
this._preferences = preferences
+ this.tokens = preferences.store.getState().tokens
+
}
/**