diff --git a/data-service/api/API.ts b/data-service/api/API.ts index 380efa0a76..9e3243ca15 100644 --- a/data-service/api/API.ts +++ b/data-service/api/API.ts @@ -18,6 +18,7 @@ import * as addressModule from './address'; import { getLastPrice } from './matcher/getLastPrice'; import { getAddressByAlias, getAliasesByAddress } from './aliases/aliases'; import * as pairsModule from './pairs/pairs'; +import * as ratingModule from './rating/rating'; import * as dataModule from './data'; @@ -39,6 +40,10 @@ export const pairs = { ...pairsModule }; +export const rating = { + ...ratingModule +}; + export const data = { ...dataModule }; diff --git a/data-service/api/rating/rating.ts b/data-service/api/rating/rating.ts new file mode 100644 index 0000000000..3f5ef1117f --- /dev/null +++ b/data-service/api/rating/rating.ts @@ -0,0 +1,33 @@ +import { request } from '../../utils/request'; +import { ITokenRating, IParsedRating } from '../../interface'; +import { stringifyJSON, toArray } from '../../utils/utils'; +// import { get } from '../../config'; + +const ratingApiUrl = 'https://tokenrating.wavesexplorer.com/api/v1'; + +export function getAssetsRating(assets: string | Array): Promise> { + return request( + { + url: `${ratingApiUrl}/token/`, + fetchOptions: { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json;charset=UTF-8' + }, + body: stringifyJSON({ + "assetIds": toArray(assets), + "page": 1, + "limit": 25 + }) + } + }) + .then((tokensList: any) => { + return Object.values(tokensList).map((ratingItem: ITokenRating) => { + return { + assetId: ratingItem.assetId, + rating: ratingItem.averageScore + }; + }) + }); +} \ No newline at end of file diff --git a/data-service/config.ts b/data-service/config.ts index 3904d36fab..4c19c347b2 100644 --- a/data-service/config.ts +++ b/data-service/config.ts @@ -69,7 +69,6 @@ export interface IConfigParams { assets: IHash; minimalSeedLength: number; remappedAssetNames: IHash; - // oracleAddress: string; oracleWaves: string; oracleTokenomica: string; } diff --git a/data-service/interface.d.ts b/data-service/interface.d.ts index 48996a9c05..eb323ca46b 100644 --- a/data-service/interface.d.ts +++ b/data-service/interface.d.ts @@ -28,3 +28,26 @@ export interface IMoneyFactory { export interface IPriceMoneyFactory { (data: string | number | BigNumber, pair: AssetPair): Money; } + +export interface ITokenRating { + assetId: string; + assetName: string; + averageScore: number; + createdAt: string; + details: object; + lastAverageScore: number; + scoreBoard: object; + sender: string + sumTokens: number; + timestamp: number; + top: boolean; + txId: string + voted: boolean; + votes: array; + votesCount: number; +} + +export interface IParsedRating { + assetId: string; + rating: number; +} \ No newline at end of file diff --git a/src/img/icons/rating-basic-200.svg b/src/img/icons/rating-basic-200.svg new file mode 100644 index 0000000000..a8a43b580d --- /dev/null +++ b/src/img/icons/rating-basic-200.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/img/icons/rating-submit-300.svg b/src/img/icons/rating-submit-300.svg new file mode 100644 index 0000000000..b09778508c --- /dev/null +++ b/src/img/icons/rating-submit-300.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/img/icons/transaction-icons-30.svg b/src/img/icons/transaction-icons-30.svg index 6918471889..decb38ee6b 100644 --- a/src/img/icons/transaction-icons-30.svg +++ b/src/img/icons/transaction-icons-30.svg @@ -1,11 +1,11 @@ - - - Group 2 + + + 30 Created with Sketch. - - + + @@ -14,20 +14,20 @@ - - + + - - + + - + - + @@ -37,11 +37,11 @@ - + - + @@ -55,109 +55,87 @@ - + - + - + - + - - - - - - - - - + + - + - + - - - - - - - - - - - - - - - - - + + - - - - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/index.hbs b/src/index.hbs index a62255652a..cc6b363c60 100644 --- a/src/index.hbs +++ b/src/index.hbs @@ -398,6 +398,7 @@ CANCEL_LEASING: 'cancel-leasing', CREATE_ALIAS: 'create-alias', DATA: 'data', + DATA_VOTE: 'data-vote', SET_SCRIPT: 'set-script', SCRIPT_CANCEL: 'set-script-cancel', SPONSORSHIP_START: 'sponsorship-start', diff --git a/src/modules/app/less/app-icons.less b/src/modules/app/less/app-icons.less index 3f027dc925..a1f25c7f38 100644 --- a/src/modules/app/less/app-icons.less +++ b/src/modules/app/less/app-icons.less @@ -263,6 +263,14 @@ background-color: rgba(90, 129, 234, 0.1); } +.icon-tx-data-vote { + &::before { + display: block; + background-position-x: -@tx-icon-size * 23; + } + background-color: rgba(90, 129, 234, 0.1); +} + .icon-tx-sponsorship-start { &::before { display: block; diff --git a/src/modules/ui/directives/assetInfoHead/AssetInfoHead.js b/src/modules/ui/directives/assetInfoHead/AssetInfoHead.js index cd956f7af0..02edf242a4 100644 --- a/src/modules/ui/directives/assetInfoHead/AssetInfoHead.js +++ b/src/modules/ui/directives/assetInfoHead/AssetInfoHead.js @@ -7,9 +7,10 @@ * @param user * @param waves * @param utils + * @param createPoll * @return {AssetInfoHead} */ - const controller = function (Base, $scope, user, waves, utils) { + const controller = function (Base, $scope, user, waves, utils, createPoll) { class AssetInfoHead extends Base { @@ -21,6 +22,7 @@ $postLink() { this._getAssetInfo(); this.observe('assetId', this._getAssetInfo); + createPoll(this, this._getTokenRating, this._setTokenRating, 60 * 1000); } /** @@ -30,20 +32,33 @@ waves.node.assets.getAsset(this.assetId).then(asset => { this.assetName = asset.name; this.ticker = asset.ticker; - const { hasLabel } = utils.getDataFromOracles(asset.id); + const { hasLabel, isGateway } = utils.getDataFromOracles(asset.id); this.hasLabel = hasLabel; + this.isGateway = isGateway && this.assetId !== WavesApp.defaultAssets.VST; $scope.$apply(); }); this.state = { assetId: this.assetId }; } + _getTokenRating() { + return ds.api.rating.getAssetsRating(this.assetId); + } + + _setTokenRating([asset]) { + if (!asset) { + return null; + } + this.rating = asset.rating; + $scope.$apply(); + } + } return new AssetInfoHead(); }; - controller.$inject = ['Base', '$scope', 'user', 'waves', 'utils']; + controller.$inject = ['Base', '$scope', 'user', 'waves', 'utils', 'createPoll']; angular.module('app.ui') .component('wAssetInfoHead', { diff --git a/src/modules/ui/directives/assetInfoHead/asset-info-head.html b/src/modules/ui/directives/assetInfoHead/asset-info-head.html index dfac83f7f8..91539beede 100644 --- a/src/modules/ui/directives/assetInfoHead/asset-info-head.html +++ b/src/modules/ui/directives/assetInfoHead/asset-info-head.html @@ -11,12 +11,27 @@

-
{{$ctrl.ticker}}
+
+ + + + +
+
+
+ +
+
+
+
+ +
+
-
- -
- diff --git a/src/modules/ui/directives/footer/footer.html b/src/modules/ui/directives/footer/footer.html index 0d98719ab7..aef48574e4 100644 --- a/src/modules/ui/directives/footer/footer.html +++ b/src/modules/ui/directives/footer/footer.html @@ -1,4 +1,4 @@ -