aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/blockchain.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-06-29 01:47:43 +0800
committerGitHub <noreply@github.com>2018-06-29 01:47:43 +0800
commit0fcbd02d50bd564a9c888f247a4b0a565d928cc6 (patch)
tree5212c6e17bf377bbdf3b5dc3053c9a55e58ba044 /packages/website/ts/blockchain.ts
parent988a3347582cd812aadeaa0cdaef67389c8d833d (diff)
parent4969797c2327ba0eb92a9723842ab312b6631008 (diff)
downloaddexon-sol-tools-0fcbd02d50bd564a9c888f247a4b0a565d928cc6.tar
dexon-sol-tools-0fcbd02d50bd564a9c888f247a4b0a565d928cc6.tar.gz
dexon-sol-tools-0fcbd02d50bd564a9c888f247a4b0a565d928cc6.tar.bz2
dexon-sol-tools-0fcbd02d50bd564a9c888f247a4b0a565d928cc6.tar.lz
dexon-sol-tools-0fcbd02d50bd564a9c888f247a4b0a565d928cc6.tar.xz
dexon-sol-tools-0fcbd02d50bd564a9c888f247a4b0a565d928cc6.tar.zst
dexon-sol-tools-0fcbd02d50bd564a9c888f247a4b0a565d928cc6.zip
Merge pull request #762 from 0xProject/feature/website/scroll-to-token
Sort wallet tokens by timestamp added and scroll to newly added token
Diffstat (limited to 'packages/website/ts/blockchain.ts')
-rw-r--r--packages/website/ts/blockchain.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 46a4d6629..b65debced 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -30,6 +30,7 @@ import {
import { BigNumber, intervalUtils, logUtils, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
+import * as moment from 'moment';
import * as React from 'react';
import contract = require('truffle-contract');
import { BlockchainWatcher } from 'ts/blockchain_watcher';
@@ -559,6 +560,7 @@ export class Blockchain {
tokenRegistryTokenSymbols,
configs.DEFAULT_TRACKED_TOKEN_SYMBOLS,
);
+ const currentTimestamp = moment().unix();
if (defaultTrackedTokensInRegistry.length !== configs.DEFAULT_TRACKED_TOKEN_SYMBOLS.length) {
this._dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
this._dispatcher.encounteredBlockchainError(BlockchainErrs.DefaultTokensNotInTokenRegistry);
@@ -573,7 +575,7 @@ export class Blockchain {
if (_.isEmpty(trackedTokensByAddress)) {
_.each(configs.DEFAULT_TRACKED_TOKEN_SYMBOLS, symbol => {
const token = _.find(tokenRegistryTokens, t => t.symbol === symbol);
- token.isTracked = true;
+ token.trackedTimestamp = currentTimestamp;
trackedTokensByAddress[token.address] = token;
});
if (!_.isUndefined(this._userAddressIfExists)) {
@@ -582,10 +584,10 @@ export class Blockchain {
});
}
} else {
- // Properly set all tokenRegistry tokens `isTracked` to true if they are in the existing trackedTokens array
- _.each(trackedTokensByAddress, (_trackedToken: Token, address: string) => {
+ // Properly set all tokenRegistry tokens `trackedTimestamp` if they are in the existing trackedTokens array
+ _.each(trackedTokensByAddress, (trackedToken: Token, address: string) => {
if (!_.isUndefined(tokenRegistryTokensByAddress[address])) {
- tokenRegistryTokensByAddress[address].isTracked = true;
+ tokenRegistryTokensByAddress[address].trackedTimestamp = trackedToken.trackedTimestamp;
}
});
}
@@ -765,7 +767,7 @@ export class Blockchain {
name: t.name,
symbol: t.symbol,
decimals: t.decimals,
- isTracked: false,
+ trackedTimestamp: undefined,
isRegistered: true,
};
tokenByAddress[token.address] = token;