diff --git a/src/modules/app/services/DefaultSettings.js b/src/modules/app/services/DefaultSettings.js index 09ae614c1e..1d0c05a437 100644 --- a/src/modules/app/services/DefaultSettings.js +++ b/src/modules/app/services/DefaultSettings.js @@ -31,6 +31,7 @@ lastOpenVersion: '', whatsNewList: [], closedNotification: [], + dontShowSpam: true, withScam: false, scamListUrl: WavesApp.network.scamListUrl, logoutAfterMin: 5, diff --git a/src/modules/app/services/User.js b/src/modules/app/services/User.js index 4c4e34b6e5..360ff75aa3 100644 --- a/src/modules/app/services/User.js +++ b/src/modules/app/services/User.js @@ -2,6 +2,8 @@ (function () { 'use strict'; + const { equals } = require('ramda'); + /* global Mousetrap */ @@ -11,6 +13,7 @@ 'extraFee', 'networkError', 'changeScript', + 'setScamSignal', 'scam' ]; @@ -104,6 +107,10 @@ * @type {Signal} */ changeScript = new tsUtils.Signal(); + /** + * @type {Signal} + */ + setScamSignal = new tsUtils.Signal(); /** * @type {Record} */ @@ -174,7 +181,16 @@ setTimeout(() => { this._scriptInfoPoll = new Poll(() => this.updateScriptAccountData(), () => null, 10000); }, 30000); + }); + + } + + setScam(hash) { + if (!equals(hash, this.scam)) { + this.scam = hash; + this.setScamSignal.dispatch(); + } } /** @@ -341,7 +357,8 @@ hasBackup, lng: i18next.language, theme: themes.getDefaultTheme(), - candle: 'blue' + candle: 'blue', + dontShowSpam: true } }).then(() => { if (restore) { diff --git a/src/modules/app/services/waves/node/content/Assets.js b/src/modules/app/services/waves/node/content/Assets.js index 89bdf03606..91f3a121b9 100644 --- a/src/modules/app/services/waves/node/content/Assets.js +++ b/src/modules/app/services/waves/node/content/Assets.js @@ -3,7 +3,6 @@ 'use strict'; const entities = require('@waves/data-entities'); - const { equals } = require('ramda'); /** * @param {BaseNodeComponent} BaseNodeComponent @@ -21,9 +20,10 @@ constructor() { super(); user.onLogin().then(() => { - - if (!user.getSetting('withScam')) { + if (user.getSetting('scamListUrl')) { this.stopScam(); + } else { + this.giveMyScamBack(); } }); } @@ -133,9 +133,9 @@ } stopScam() { - if (this._pollScam) { - return null; - } + // if (this._pollScam) { + // return null; + // } /** * @type {Poll} * @private @@ -158,7 +158,8 @@ } }); return hash; - }); + }) + .catch(() => Object.create(null)); } /** @@ -166,9 +167,7 @@ * @private */ _setScamAssetList(hash) { - if (!equals(hash, user.scam)) { - user.scam = hash; - } + user.setScam(hash); } /** diff --git a/src/modules/ui/directives/actions/actions.less b/src/modules/ui/directives/actions/actions.less index d4df55faa4..2e75d8105b 100644 --- a/src/modules/ui/directives/actions/actions.less +++ b/src/modules/ui/directives/actions/actions.less @@ -57,6 +57,10 @@ w-actions { height: 4px; border-radius: 100%; background-color: @color-basic-500; + + .spam & { + background-color: @color-basic-200; + } } } diff --git a/src/modules/ui/directives/transaction/Transaction.js b/src/modules/ui/directives/transaction/Transaction.js index 034ff1abee..839d41ab6a 100644 --- a/src/modules/ui/directives/transaction/Transaction.js +++ b/src/modules/ui/directives/transaction/Transaction.js @@ -8,16 +8,26 @@ * @param {INotification} notification * @param {Waves} waves * @param {User} user + * @param {$rootScope.Scope} $scope * @return {Transaction} */ const controller = function (Base, $filter, modalManager, notification, - waves, user) { + waves, user, $scope) { const { SIGN_TYPE } = require('@waves/signature-adapter'); class Transaction extends Base { $postLink() { this.typeName = this.transaction.typeName; + this.setScam(); + + this.receive(user.setScamSignal, () => { + this.setScam(); + $scope.$apply(); + }); + } + + setScam() { this.isScam = !!user.scam[this.transaction.assetId]; if (this.transaction.type === 7) { const isScamAmount = !!user.scam[this.transaction.amount.asset]; @@ -115,7 +125,8 @@ 'modalManager', 'notification', 'waves', - 'user' + 'user', + '$scope' ]; angular.module('app.ui') diff --git a/src/modules/ui/directives/transaction/TransactionInfoRow.js b/src/modules/ui/directives/transaction/TransactionInfoRow.js index b379f460b7..be9f5d2988 100644 --- a/src/modules/ui/directives/transaction/TransactionInfoRow.js +++ b/src/modules/ui/directives/transaction/TransactionInfoRow.js @@ -18,6 +18,7 @@ isScam: this.isScam }; + // TODO: delete setTimeout setTimeout(() => { this.props.isScam = this.isScam; }, 0); diff --git a/src/modules/ui/directives/transaction/types/mass-transfer/MassTransfer.js b/src/modules/ui/directives/transaction/types/mass-transfer/MassTransfer.js index ba65abc8d8..1e208903fd 100644 --- a/src/modules/ui/directives/transaction/types/mass-transfer/MassTransfer.js +++ b/src/modules/ui/directives/transaction/types/mass-transfer/MassTransfer.js @@ -26,6 +26,11 @@ this.isScam = this.props.isScam; }, 0); + // TODO: delete setTimeout + setTimeout(() => { + this.isScam = this.props.isScam; + }, 0); + const TYPES = waves.node.transactions.TYPES; switch (this.typeName) { diff --git a/src/modules/ui/directives/transactionList/TransactionList.js b/src/modules/ui/directives/transactionList/TransactionList.js index 293ee64c21..dda5ca7620 100644 --- a/src/modules/ui/directives/transactionList/TransactionList.js +++ b/src/modules/ui/directives/transactionList/TransactionList.js @@ -27,8 +27,16 @@ * @type {boolean} */ this.pending = false; + /** + * @type {boolean} + */ + this.dontShowSpam = user.getSetting('dontShowSpam'); + + this.syncSettings({ + dontShowSpam: 'dontShowSpam' + }); - this.observe('_transactions', this._onChangeTransactions); + this.observe(['_transactions', 'dontShowSpam'], this._onChangeTransactions); } $postLink() { @@ -39,7 +47,11 @@ * @private */ _onChangeTransactions() { - const transactions = (this._transactions || []); + let transactions = (this._transactions || []); + if (this.dontShowSpam) { + transactions = transactions.filter(this._filterSpam); + } + const hash = Object.create(null); const toDate = tsUtils.date('DD.MM.YYYY'); @@ -61,6 +73,16 @@ })); } + _filterSpam(transaction) { + const isScam = !!user.scam[transaction.assetId]; + let isScamAmount, isScamPrice; + if (transaction.type === 7) { + isScamAmount = !!user.scam[transaction.amount.asset]; + isScamPrice = !!user.scam[transaction.price.asset]; + } + return !(isScam || isScamAmount || isScamPrice); + } + } return new TransactionList(); diff --git a/src/modules/utils/modals/pinAsset/PinAssetCtrl.js b/src/modules/utils/modals/pinAsset/PinAssetCtrl.js index 29a772469b..388d0b5aba 100644 --- a/src/modules/utils/modals/pinAsset/PinAssetCtrl.js +++ b/src/modules/utils/modals/pinAsset/PinAssetCtrl.js @@ -32,6 +32,10 @@ const R = require('ramda'); * @type {boolean} */ this.withScam = null; + /** + * @type {boolean} + */ + this.dontShowSpam = null; /** * @type {Array} */ @@ -52,7 +56,8 @@ const R = require('ramda'); this.syncSettings({ pinnedAssetIdList: 'pinnedAssetIdList', spam: 'wallet.portfolio.spam', - withScam: 'withScam' + withScam: 'withScam', + dontShowSpam: 'dontShowSpam' }); this.observe('search', this._fillList); diff --git a/src/modules/utils/modals/settings/SettingsCtrl.js b/src/modules/utils/modals/settings/SettingsCtrl.js index 06f7b3f35c..8390fa26d5 100644 --- a/src/modules/utils/modals/settings/SettingsCtrl.js +++ b/src/modules/utils/modals/settings/SettingsCtrl.js @@ -61,7 +61,7 @@ matcher = ''; api = ''; scamListUrl = ''; - withScam = false; + dontShowSpam = true; theme = user.getSetting('theme'); candle = user.getSetting('candle'); templatePromise = $templateRequest('modules/utils/modals/settings/loader.html'); @@ -100,10 +100,11 @@ api: 'network.api', logoutAfterMin: 'logoutAfterMin', scamListUrl: 'scamListUrl', - withScam: 'withScam', + dontShowSpam: 'dontShowSpam', theme: 'theme', candle: 'candle', oracleWaves: 'oracleWaves' + }); this.assetsOracleTmp = this.oracleWaves; @@ -158,13 +159,16 @@ // user.changeCandle(this.candle); // }); - this.observe('withScam', () => { - const withScam = this.withScam; - if (withScam) { - waves.node.assets.giveMyScamBack(); - } else { - waves.node.assets.stopScam(); - } + this.observe('dontShowSpam', () => { + const dontShowSpam = this.dontShowSpam; + user.setSetting('dontShowSpam', dontShowSpam); + }); + + this.observe('scamListUrl', () => { + ds.config.setConfig({ + scamListUrl: this.scamListUrl + }); + waves.node.assets.stopScam(); }); this.observe(['node', 'matcher', 'api'], () => { @@ -216,7 +220,7 @@ setNetworkDefault() { this.node = WavesApp.network.node; this.matcher = WavesApp.network.matcher; - this.withScam = false; + this.dontShowSpam = true; this.scamListUrl = WavesApp.network.scamListUrl; this.oracleWaves = WavesApp.oracles.waves; this.api = WavesApp.network.api; diff --git a/src/modules/utils/modals/settings/settings.html b/src/modules/utils/modals/settings/settings.html index babfb14316..de0c3eb89e 100644 --- a/src/modules/utils/modals/settings/settings.html +++ b/src/modules/utils/modals/settings/settings.html @@ -275,14 +275,15 @@
+
- - + +
diff --git a/src/modules/wallet/modules/portfolio/controllers/PortfolioCtrl.js b/src/modules/wallet/modules/portfolio/controllers/PortfolioCtrl.js index 742e438457..4719ade88f 100644 --- a/src/modules/wallet/modules/portfolio/controllers/PortfolioCtrl.js +++ b/src/modules/wallet/modules/portfolio/controllers/PortfolioCtrl.js @@ -81,6 +81,10 @@ * @type {boolean} */ this.pending = true; + /** + * @type {boolean} + */ + this.dontShowSpam = user.getSetting('dontShowSpam'); waves.node.assets.getAsset(this.mirrorId) .then((mirror) => { @@ -132,7 +136,8 @@ this.syncSettings({ pinned: 'pinnedAssetIdList', spam: 'wallet.portfolio.spam', - filter: 'wallet.portfolio.filter' + filter: 'wallet.portfolio.filter', + dontShowSpam: 'dontShowSpam' }); balanceWatcher.ready @@ -144,7 +149,7 @@ this.receive(balanceWatcher.change, onChange); this.receive(utils.observe(user, 'scam'), onChange); - this.observe(['pinned', 'spam'], onChange); + this.observe(['pinned', 'spam', 'dontShowSpam'], onChange); this._updateBalances(); }); @@ -310,16 +315,24 @@ }) .reduce((acc, item) => { const oracleData = ds.dataManager.getOraclesAssetData(item.asset.id); + const spam = item.isOnScamList || item.isSpam; - if (item.asset.sender === user.address) { - acc.my.push(item); - } if (oracleData && oracleData.status > 0) { acc.verified.push(item); } - if (item.isOnScamList || item.isSpam) { - acc.spam.push(item); + + if (spam) { + if (!this.dontShowSpam) { + if (item.asset.sender === user.address) { + acc.my.push(item); + } + acc.spam.push(item); + acc.active.push(item); + } } else { + if (item.asset.sender === user.address) { + acc.my.push(item); + } acc.active.push(item); } diff --git a/src/modules/wallet/modules/portfolio/directives/portfolioRow/PortfolioRow.js b/src/modules/wallet/modules/portfolio/directives/portfolioRow/PortfolioRow.js index 910d5a4b9a..f29adb8c48 100644 --- a/src/modules/wallet/modules/portfolio/directives/portfolioRow/PortfolioRow.js +++ b/src/modules/wallet/modules/portfolio/directives/portfolioRow/PortfolioRow.js @@ -83,7 +83,8 @@ SPONSORSHIP_EDIT: 'js-action-button-sponsorship_edit', SPONSORSHIP_STOP: 'js-action-button-cancel-sponsorship', SET_ASSET_SCRIPT: 'js-action-button-set-asset-script' - } + }, + SUSPICIOUS_LABEL: 'js-suspicious-label' }; const ds = require('data-service'); @@ -249,8 +250,7 @@ canShowToggleSpam: this._canShowToggleSpam(), canSponsored: this._isMyAsset, canPayFee, - canStopSponsored, - isSpam: this.balance.isOnScamList + canStopSponsored }); this.node.innerHTML = html; @@ -260,7 +260,8 @@ set: (value) => { if (this.balance.asset.id !== value.asset.id || !this.balance.available.getTokens().eq(value.available.getTokens()) || - !this.balance.inOrders.getTokens().eq(value.inOrders.getTokens()) + !this.balance.inOrders.getTokens().eq(value.inOrders.getTokens()) || + this.balance.isOnScamList !== value.isOnScamList ) { balance = value; this._onUpdateBalance(); @@ -334,6 +335,21 @@ this._initSpamState(); const balance = this.balance; + + if (balance.isOnScamList) { + this.node.querySelector(`.${SELECTORS.CHANGE_24}`).innerHTML = '—'; + this.node.querySelector(`.${SELECTORS.BASE_ASSET_BALANCE}`).innerHTML = '—'; + this.node.querySelector(`.${SELECTORS.EXCHANGE_RATE}`).innerHTML = '—'; + this.node.querySelector(`.${SELECTORS.SUSPICIOUS_LABEL}`).classList.remove('hidden'); + + return null; + } else { + const suspiciousSelector = this.node.querySelector(`.${SELECTORS.SUSPICIOUS_LABEL}`); + if (suspiciousSelector) { + suspiciousSelector.classList.add('hidden'); + } + } + const baseAssetId = this.user.getSetting('baseAssetId'); if (baseAssetId === balance.asset.id) { @@ -573,10 +589,11 @@ this.node.querySelector(`.${SELECTORS.BUTTONS.TOGGLE_SPAM}`), this.node.querySelector(`.${SELECTORS.ACTION_BUTTONS.TOGGLE_SPAM}`) ]; - elements.forEach(toggleSpam => { - toggleSpam.classList.toggle('icon-hide', !isSpam); - toggleSpam.classList.toggle('icon-show', isSpam); + if (toggleSpam) { + toggleSpam.classList.toggle('icon-hide', !isSpam); + toggleSpam.classList.toggle('icon-show', isSpam); + } }); } diff --git a/src/modules/wallet/modules/portfolio/directives/portfolioRow/portfolio-row.less b/src/modules/wallet/modules/portfolio/directives/portfolioRow/portfolio-row.less index 087ae0f72d..a96b6988f5 100644 --- a/src/modules/wallet/modules/portfolio/directives/portfolioRow/portfolio-row.less +++ b/src/modules/wallet/modules/portfolio/directives/portfolioRow/portfolio-row.less @@ -4,23 +4,27 @@ w-portfolio-row { display: flex; width: 100%; - .asset { - &__logo { - position: relative; - left: 0; + .asset { + &__logo { + position: relative; + left: 0; - .marker { - display: none; - position: absolute; - bottom: calc(50% ~'- 16px'); + .marker { + display: none; + position: absolute; + bottom: calc(50% ~'- 16px'); - &.smart-asset, - &.sponsored-asset { - display: block; - } + &.smart-asset, + &.sponsored-asset { + display: block; } } + + .spam &, .spam & .marker { + background-color: @color-basic-200 !important; + } } + } .asset { &__logo { @@ -71,4 +75,9 @@ w-portfolio-row { } } } -} \ No newline at end of file + + .spam & { + color: @color-basic-500; + } + +} diff --git a/src/modules/wallet/modules/portfolio/directives/portfolioRow/row.hbs b/src/modules/wallet/modules/portfolio/directives/portfolioRow/row.hbs index ce14d5e700..d196585b47 100644 --- a/src/modules/wallet/modules/portfolio/directives/portfolioRow/row.hbs +++ b/src/modules/wallet/modules/portfolio/directives/portfolioRow/row.hbs @@ -22,9 +22,7 @@ {{#if isTokenomica}} {{/if}} - {{#if isSpam}} - - {{/if}} + diff --git a/src/modules/wallet/modules/portfolio/less/portfolio.less b/src/modules/wallet/modules/portfolio/less/portfolio.less index 5912921b41..f1e52eda5c 100644 --- a/src/modules/wallet/modules/portfolio/less/portfolio.less +++ b/src/modules/wallet/modules/portfolio/less/portfolio.less @@ -128,6 +128,16 @@ i.toggler { display: none; } + + &.spam { + .smart-table__cell:last-child { + .cell { + span.icon svg { + fill: @color-basic-200; + } + } + } + } } .z-top { diff --git a/src/modules/wallet/modules/portfolio/templates/portfolio.html b/src/modules/wallet/modules/portfolio/templates/portfolio.html index 8fef20a9a5..910bb1fb01 100644 --- a/src/modules/wallet/modules/portfolio/templates/portfolio.html +++ b/src/modules/wallet/modules/portfolio/templates/portfolio.html @@ -39,7 +39,7 @@ w-i18n-ns="app.wallet.portfolio" params="{count: $ctrl.details.verified.length || 0}"> - + @@ -55,7 +55,7 @@ header-info="$ctrl.tableHeaders"> - + diff --git a/src/modules/wallet/modules/transactions/controllers/TransactionsCtrl.js b/src/modules/wallet/modules/transactions/controllers/TransactionsCtrl.js index f37efdf629..81b90f8a6f 100644 --- a/src/modules/wallet/modules/transactions/controllers/TransactionsCtrl.js +++ b/src/modules/wallet/modules/transactions/controllers/TransactionsCtrl.js @@ -82,7 +82,10 @@ } - allTransactions = allTransactions.concat(transactions.filter(el => !user.scam[el.assetId])); + if (user.getSetting('dontShowSpam')) { + transactions = transactions.filter(el => !user.scam[el.assetId]); + } + allTransactions = allTransactions.concat(transactions); if (transactions.length < MAX_LIMIT || allTransactions.length > maxTransactions) { return { allTransactions, downloadError };