Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions app/components/Exchange/AbstractOrderBook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import MarketsActions from "actions/MarketsActions";
import MarketsStore from "stores/MarketsStore";
import {checkFeeStatusAsync} from "common/trxHelper";

class RegularOrderBook {
constructor(props) {
this.activeMarketHistory = MarketsStore.getState().activeMarketHistory; //latest change class
this.marketLimitOrders = MarketsStore.getState().marketLimitOrders; //orders
this.marketCallOrders = MarketsStore.getState().marketCallOrders; //calls
this.invertedCalls = MarketsStore.getState().invertedCalls; //invertedCalls
this.marketData = MarketsStore.getState().marketData; //combinedBids combinedAsks highestBid lowestAsk groupedBids groupedAsks
this.totals = MarketsStore.getState().totals; //totalBids totalAsks
this.trackedGroupsConfig = MarketsStore.getState().trackedGroupsConfig;
this.currentGroupOrderLimit = MarketsStore.getState().currentGroupLimit;
}

createLimitOrder2(orders) {
return MarketsActions.createLimitOrder2(orders);
}

createPredictionShort(order, collateral) {
return MarketsActions.createPredictionShort(order, collateral);
}

getTrackedGroupsConfig() {
return MarketsActions.getTrackedGroupsConfig();
}

cancelLimitOrder(currentAccountId, orderID) {
return MarketsActions.cancelLimitOrder(currentAccountId, orderID);
}

changeCurrentGroupLimit(groupLimit) {
return MarketsActions.changeCurrentGroupLimit(groupLimit);
}

checkFeeStatusAsync(accountID, feeID) {
return checkFeeStatusAsync({
accountID: accountID,
feeID: feeID,
type: "limit_order_create"
});
}
unSubscribeMarket(quoteAssetId, baseAssetId) {
return MarketsActions.unSubscribeMarket(quoteAssetId, baseAssetId);
}
SubscribeMarket(quoteAssetId, baseAssetId, newBucketSize) {
MarketsActions.subscribeMarket(
quoteAssetId,
baseAssetId,
newBucketSize
);
}
}

class HtlcOrderBook {
constructor(props) {}

checkFeeStatusAsync(accountID, feeID) {
return checkFeeStatusAsync({
accountID: accountID,
feeID: feeID,
type: "htlc_create"
});
}
}

const _orderbookCache = {};
const orderBook = prefix => {
return (_orderbookCache[prefix] =
prefix === "htlc" ? new HtlcOrderBook() : new RegularOrderBook());
};

export default orderBook;
85 changes: 45 additions & 40 deletions app/components/Exchange/Exchange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import SimpleDepositBlocktradesBridge from "../Dashboard/SimpleDepositBlocktrade
import {Notification} from "bitshares-ui-style-guide";
import PriceAlert from "./PriceAlert";
import counterpart from "counterpart";
import AbstractOrderBook from "components/Exchange/AbstractOrderBook.js";

class Exchange extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -1872,12 +1873,9 @@ class Exchange extends React.Component {
}

render() {
const regularOrderBook = new AbstractOrderBook("regular");
let {
currentAccount,
marketLimitOrders,
marketCallOrders,
marketData,
activeMarketHistory,
invertedCalls,
starredMarkets,
quoteAsset,
Expand All @@ -1887,13 +1885,20 @@ class Exchange extends React.Component {
marketReady,
marketSettleOrders,
bucketSize,
totals,
feedPrice,
buckets,
coreAsset,
coreAsset
} = this.props;

let {
marketLimitOrders,
marketCallOrders,
marketData,
activeMarketHistory,
totals,
trackedGroupsConfig,
currentGroupOrderLimit
} = this.props;
} = regularOrderBook;

const {
combinedBids,
Expand Down Expand Up @@ -2008,8 +2013,8 @@ class Exchange extends React.Component {
latest.getPrice() === second_latest.getPrice()
? ""
: latest.getPrice() - second_latest.getPrice() > 0
? "change-up"
: "change-down";
? "change-up"
: "change-down";
}

// Fees
Expand Down Expand Up @@ -2086,7 +2091,7 @@ class Exchange extends React.Component {
};

let buyForm = isFrozen ? null : tinyScreen &&
!this.state.mobileKey.includes("buySellTab") ? null : (
!this.state.mobileKey.includes("buySellTab") ? null : (
<Tabs
animated={false}
activeKey={
Expand All @@ -2100,10 +2105,10 @@ class Exchange extends React.Component {
verticalOrderForm && !smallScreen
? ""
: centerContainerWidth > 1200
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: "",
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: "",
"small-12 exchange-padded middle-content",
flipBuySell
? `order-${buySellTop ? 2 : 3} large-order-${
Expand Down Expand Up @@ -2252,7 +2257,7 @@ class Exchange extends React.Component {
);

let sellForm = isFrozen ? null : tinyScreen &&
!this.state.mobileKey.includes("buySellTab") ? null : (
!this.state.mobileKey.includes("buySellTab") ? null : (
<Tabs
activeKey={
this.props.viewSettings.get("order-form-ask") || "limit"
Expand All @@ -2266,10 +2271,10 @@ class Exchange extends React.Component {
verticalOrderForm && !smallScreen
? ""
: centerContainerWidth > 1200
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: "",
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: "",
"small-12 exchange-padded middle-content",
flipBuySell
? `order-${buySellTop ? 1 : 2} large-order-${
Expand Down Expand Up @@ -2493,8 +2498,8 @@ class Exchange extends React.Component {
centerContainerWidth > 1200
? "xlarge-8"
: centerContainerWidth > 800
? ""
: "",
? ""
: "",
"medium-12 large-12",
"small-12 grid-block orderbook no-padding align-spaced no-overflow wrap shrink",
`order-${buySellTop ? 3 : 1} xlarge-order-${
Expand All @@ -2505,8 +2510,8 @@ class Exchange extends React.Component {
centerContainerWidth > 1200
? "medium-6"
: centerContainerWidth > 800
? "medium-6 large-6"
: "",
? "medium-6 large-6"
: "",
"small-12 middle-content",
!tinyScreen ? "exchange-padded" : ""
)}
Expand Down Expand Up @@ -2553,8 +2558,8 @@ class Exchange extends React.Component {
? centerContainerWidth > 1200
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: ""
? "medium-6"
: ""
: "medium-12",
"no-padding no-overflow middle-content small-12 order-6"
)}
Expand Down Expand Up @@ -2585,8 +2590,8 @@ class Exchange extends React.Component {
? centerContainerWidth > 1200
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: ""
? "medium-6"
: ""
: "medium-12",
"no-padding no-overflow middle-content small-12",
verticalOrderBook || verticalOrderForm
Expand Down Expand Up @@ -2621,8 +2626,8 @@ class Exchange extends React.Component {
? centerContainerWidth > 1200
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: ""
? "medium-6"
: ""
: "medium-12",
"no-padding no-overflow middle-content small-12 order-7"
)}
Expand Down Expand Up @@ -2660,8 +2665,8 @@ class Exchange extends React.Component {
? centerContainerWidth > 1200
? "medium-6 large-6 xlarge-4"
: centerContainerWidth > 800
? "medium-6"
: ""
? "medium-6"
: ""
: "medium-12",
"no-padding no-overflow middle-content small-12 order-8"
)}
Expand Down Expand Up @@ -3019,10 +3024,10 @@ class Exchange extends React.Component {
? "medium-12 xlarge-4"
: "medium-6 xlarge-4 "
: centerContainerWidth > 800
? groupTabsCount == 1
? "medium-12"
: "medium-6"
: "",
? groupTabsCount == 1
? "medium-12"
: "medium-6"
: "",
"small-12 order-5",
verticalOrderBook ? "xlarge-order-5" : "",
!verticalOrderBook && !verticalOrderForm
Expand Down Expand Up @@ -3050,10 +3055,10 @@ class Exchange extends React.Component {
? "medium-12 xlarge-4"
: "medium-6 xlarge-4 "
: centerContainerWidth > 800
? groupTabsCount == 1
? "medium-12"
: "medium-6"
: "",
? groupTabsCount == 1
? "medium-12"
: "medium-6"
: "",
"small-12 order-6"
)}
style={{paddingRight: 5}}
Expand All @@ -3072,7 +3077,7 @@ class Exchange extends React.Component {
<div
className={cnames(
centerContainerWidth > 1200 &&
(verticalOrderBook || verticalOrderBook)
(verticalOrderBook || verticalOrderBook)
? "xlarge-order-6 xlarge-8 order-9"
: "",
"small-12 grid-block orderbook no-padding align-spaced no-overflow wrap"
Expand Down