Skip to content

Commit

Permalink
Add a warning for disabled markets and disable buy/sell
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Jan 13, 2017
1 parent 3a117ed commit 4f44418
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 12 deletions.
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@
"zoom_all": "显示全部",
"settings": "图表选项",
"featured": "热门市场",
"new": "新增"
"new": "新增",
"market_frozen": "The owner of %(asset)s has disabled trading in this market."
},
"markets": {
"title": "交易所",
Expand Down
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,8 @@
"borrow": "Leihen",
"no_balance": "Ungenügendes Guthaben",
"invalid_amount": "Ungültiger Betrag",
"invalid_price": "Ungültiger Preis"
"invalid_price": "Ungültiger Preis",
"market_frozen": "The owner of %(asset)s has disabled trading in this market."
},
"fees": {
"title": "Gebühren"
Expand Down
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@
"zoom_all": "All",
"settings": "Chart options",
"featured": "Featured Markets",
"new": "New"
"new": "New",
"market_frozen": "The owner of %(asset)s has disabled trading in this market."
},
"fees": {
"title": "Fee Schedule"
Expand Down
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@
"vertical": "Vertical",
"horizontal": "Horizontal",
"confirm_buy": "Your order is %(diff)s times higher than the lowest ask, are you sure?",
"confirm_sell": "Your order is %(diff)s times lower than the highest bid, are you sure?"
"confirm_sell": "Your order is %(diff)s times lower than the highest bid, are you sure?",
"market_frozen": "The owner of %(asset)s has disabled trading in this market."
},
"markets": {
"base": "Activo base",
Expand Down
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@
"buy": "Acheter",
"sell": "Vendre",
"confirm_buy": "Your order is %(diff)s times higher than the lowest ask, are you sure?",
"confirm_sell": "Your order is %(diff)s times lower than the highest bid, are you sure?"
"confirm_sell": "Your order is %(diff)s times lower than the highest bid, are you sure?",
"market_frozen": "The owner of %(asset)s has disabled trading in this market."
},
"markets": {
"choose_base": "Selectionner l'actif de base",
Expand Down
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@
"confirm_sell": "Your order is %(diff)s times lower than the highest bid, are you sure?",
"market_name": "종목명",
"quote_supply": "유통량",
"base_supply": "유통량"
"base_supply": "유통량",
"market_frozen": "The owner of %(asset)s has disabled trading in this market."
},
"markets": {
"base": "기초 자산",
Expand Down
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@
"zoom_all": "Tümü",
"settings": "Çizelge tercihleri",
"featured": "Öne Çıkan Piyasalar",
"new": "Yeni"
"new": "Yeni",
"market_frozen": "The owner of %(asset)s has disabled trading in this market."
},
"fees": {
"title": "Ücret Tarifesi"
Expand Down
36 changes: 31 additions & 5 deletions web/app/components/Exchange/Exchange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ import IndicatorModal from "./IndicatorModal";
import OpenSettleOrders from "./OpenSettleOrders";
import Highcharts from "highcharts/highstock";
import ExchangeHeader from "./ExchangeHeader";
import Translate from "react-translate-component";

require("./exchange.scss");

let SATOSHI = 8;

Highcharts.setOptions({
global: {
useUTC: false
Expand Down Expand Up @@ -783,6 +782,31 @@ class Exchange extends React.Component {
this.forceUpdate();
}

isMarketFrozen() {
let {baseAsset, quoteAsset} = this.props;

let baseWhiteList = baseAsset.getIn(["options", "whitelist_markets"]).toJS();
let quoteWhiteList = quoteAsset.getIn(["options", "whitelist_markets"]).toJS();
let baseBlackList = baseAsset.getIn(["options", "blacklist_markets"]).toJS();
let quoteBlackList = quoteAsset.getIn(["options", "blacklist_markets"]).toJS();

if (quoteWhiteList.length && quoteWhiteList.indexOf(baseAsset.get("id") === -1)) {
return {isFrozen: true, frozenAsset: quoteAsset.get("symbol")};
}
if (baseWhiteList.length && baseWhiteList.indexOf(quoteAsset.get("id") === -1)) {
return {isFrozen: true, frozenAsset: baseAsset.get("symbol")};
}

if (quoteBlackList.length && quoteBlackList.indexOf(baseAsset.get("id") !== -1)) {
return {isFrozen: true, frozenAsset: quoteAsset.get("symbol")};
}
if (baseBlackList.length && baseBlackList.indexOf(quoteAsset.get("id") !== -1)) {
return {isFrozen: true, frozenAsset: baseAsset.get("symbol")};
}

return {isFrozen: false};
}

render() {
let { currentAccount, marketLimitOrders, marketCallOrders, marketData, activeMarketHistory,
invertedCalls, starredMarkets, quoteAsset, baseAsset, lowestCallPrice,
Expand All @@ -795,7 +819,8 @@ class Exchange extends React.Component {
let {bid, ask, leftOrderBook, showDepthChart,
buyDiff, sellDiff, indicators, indicatorSettings, width, buySellTop} = this.state;

// console.log("bid:", bid.price.base.asset_id + "_" + bid.price.quote.asset_id, bid.price.toReal(), "ask:", ask.price.base.asset_id + "_" + ask.price.quote.asset_id, ask.price.toReal());
const {isFrozen, frozenAsset} = this.isMarketFrozen();

let base = null, quote = null, accountBalance = null, quoteBalance = null,
baseBalance = null, coreBalance = null, quoteSymbol, baseSymbol,
showCallLimit = false, latestPrice, changeClass;
Expand Down Expand Up @@ -900,7 +925,7 @@ class Exchange extends React.Component {

let orderMultiplier = leftOrderBook ? 2 : 1;

let buyForm = (
let buyForm = isFrozen ? null : (
<BuySell
smallScreen={smallScreen}
isOpen={this.state.buySellOpen}
Expand Down Expand Up @@ -939,7 +964,7 @@ class Exchange extends React.Component {
/>
);

let sellForm = (
let sellForm = isFrozen ? null : (
<BuySell
smallScreen={smallScreen}
isOpen={this.state.buySellOpen}
Expand Down Expand Up @@ -1101,6 +1126,7 @@ class Exchange extends React.Component {
<div className="grid-block no-overflow wrap shrink" >
{hasPrediction ? <div className="small-12 no-overflow" style={{margin: "0 10px", lineHeight: "1.2rem"}}><p>{description}</p></div> : null}

{isFrozen ? <div className="error small-12 no-overflow" style={{margin: "0 10px", lineHeight: "1.2rem"}}><Translate content="exchange.market_frozen" asset={frozenAsset} component="p"/></div> : null}
{buyForm}
{sellForm}

Expand Down

0 comments on commit 4f44418

Please sign in to comment.