Navigation Menu

Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
sell-orders-persist-through-app-restart-but-are-not-cancellable (#39)
Browse files Browse the repository at this point in the history
**General Checklist:**

- [x] Tests added for this feature/bug
- [x] All tests are passed
- [x] No lint error
- Review

  - [x] Has been reviewed

- [x] Conform by the [merge request performance guides]
- [x] Conform by the [style guides]
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

**Tasks Checklist**

- [x] Study requirement
- [x] Reproduce the bug
- [ ] Barterdex api
  - [x] get_enabled_coins
  - [x] my_orders
  - [x] my_recent_swaps
  - [ ] my_tx_history
  - [ ] order_status
  - [x] stop
- [x] Remove myorder - list
- [x] Update test
- [ ] Test production

**What are the relevant issue numbers?**

Closes #34
  • Loading branch information
particle4dev committed Sep 1, 2019
1 parent 6fdea33 commit fc24dc7
Show file tree
Hide file tree
Showing 33 changed files with 362 additions and 183 deletions.
Expand Up @@ -31,7 +31,7 @@ import validate from '../../../components/Form/validate';
import type { BuyCoinPayload } from '../schema';
import { calculateDexfee } from '../utils';
import { STATE_SWAPS, NA, FINISHED_SWAPS_STATE } from '../../../constants';
import { AUTO_HIDE_SNACKBAR_TIME, DEXFEE } from '../constants';
import { AUTO_HIDE_SNACKBAR_TIME } from '../constants';
import {
loadBuyCoin,
loadRecentSwaps,
Expand Down
Expand Up @@ -65,7 +65,7 @@ Object {
"biddepth": 0,
"bids": Array [
Object {
"address": "RAwv8JhfvmFx2V3QpY7ehiYpBJ1eqxxdxR",
"address": "RRVJBpA5MoeTo3beA1iP6euWWrWcJdJtXu",
"age": 1,
"avevolume": 0,
"coin": "KMD",
Expand Down
Expand Up @@ -93,7 +93,7 @@ describe('containers/OrderPage/reducers/loadOrderbookSuccess', () => {
expect(buyReducer(initialState, loadOrderbookSuccess(payload))).toEqual(
fromJS({
selectCoinModal: { open: false },
myorder: { fetchStatus: null, errors: null, list: [] },
myorder: { fetchStatus: null, errors: null },
orders: {
'12fj3npPKwTNxUgDMN8XcCDcR2Z4DBehj6-KMD-BTC': {
pubkey:
Expand All @@ -106,6 +106,7 @@ describe('containers/OrderPage/reducers/loadOrderbookSuccess', () => {
rel: 'KMD',
type: 'ORDER_BOB_SIDE',
id: '12fj3npPKwTNxUgDMN8XcCDcR2Z4DBehj6-KMD-BTC',
uuid: null,
maxvolume: 0.15931538
},
'1JsAjr6d21j9T8EMsYnQ6GXf1mM523JAv1-KMD-BTC': {
Expand All @@ -119,19 +120,21 @@ describe('containers/OrderPage/reducers/loadOrderbookSuccess', () => {
rel: 'KMD',
type: 'ORDER_BOB_SIDE',
id: '1JsAjr6d21j9T8EMsYnQ6GXf1mM523JAv1-KMD-BTC',
uuid: null,
maxvolume: 0.10416148
},
'RAwv8JhfvmFx2V3QpY7ehiYpBJ1eqxxdxR-KMD-BTC': {
'RRVJBpA5MoeTo3beA1iP6euWWrWcJdJtXu-KMD-BTC': {
pubkey:
'dbd8c73e2e80e4f3cf88d2f04a9d2d0df4269496608b14a3e17556fdcb01e0c1',
meta: { coin: 'KMD', numutxos: 0, depth: 0, age: 1, zcredits: 0 },
price: 11636.025133814292,
avevolume: 0,
base: 'BTC',
address: 'RAwv8JhfvmFx2V3QpY7ehiYpBJ1eqxxdxR',
address: 'RRVJBpA5MoeTo3beA1iP6euWWrWcJdJtXu',
rel: 'KMD',
type: 'ORDER_ALICE_SIDE',
id: 'RAwv8JhfvmFx2V3QpY7ehiYpBJ1eqxxdxR-KMD-BTC',
id: 'RRVJBpA5MoeTo3beA1iP6euWWrWcJdJtXu-KMD-BTC',
uuid: null,
maxvolume: 570.67205239
},
'RT9MpMyucqXiX8bZLimXBnrrn2ofmdGNKd-KMD-BTC': {
Expand All @@ -145,6 +148,7 @@ describe('containers/OrderPage/reducers/loadOrderbookSuccess', () => {
rel: 'KMD',
type: 'ORDER_ALICE_SIDE',
id: 'RT9MpMyucqXiX8bZLimXBnrrn2ofmdGNKd-KMD-BTC',
uuid: null,
maxvolume: 19956.77585582
},
'RHy2obsEHhAdTag4fDsC4SfCEqm5ZzTUSH-KMD-BTC': {
Expand All @@ -158,6 +162,7 @@ describe('containers/OrderPage/reducers/loadOrderbookSuccess', () => {
rel: 'KMD',
type: 'ORDER_ALICE_SIDE',
id: 'RHy2obsEHhAdTag4fDsC4SfCEqm5ZzTUSH-KMD-BTC',
uuid: null,
maxvolume: 208.21649055
}
},
Expand All @@ -177,7 +182,7 @@ describe('containers/OrderPage/reducers/loadOrderbookSuccess', () => {
list: [
'12fj3npPKwTNxUgDMN8XcCDcR2Z4DBehj6-KMD-BTC',
'1JsAjr6d21j9T8EMsYnQ6GXf1mM523JAv1-KMD-BTC',
'RAwv8JhfvmFx2V3QpY7ehiYpBJ1eqxxdxR-KMD-BTC',
'RRVJBpA5MoeTo3beA1iP6euWWrWcJdJtXu-KMD-BTC',
'RT9MpMyucqXiX8bZLimXBnrrn2ofmdGNKd-KMD-BTC',
'RHy2obsEHhAdTag4fDsC4SfCEqm5ZzTUSH-KMD-BTC'
]
Expand Down Expand Up @@ -236,7 +241,7 @@ describe('containers/OrderPage/reducers/setNewOrderSuccess', () => {
expect(buyReducer(initialState, setNewOrderSuccess(result))).toEqual(
fromJS({
selectCoinModal: { open: false },
myorder: { fetchStatus: null, errors: null, list: ['address'] },
myorder: { fetchStatus: null, errors: null },
orders: {
address: {
meta: { matches: {}, started_swaps: [] },
Expand Down
Expand Up @@ -18,7 +18,6 @@ import {
makeSelectOrderbookFullList,
makeSelectOrderbookFetchStatus,
makeSelectMyOrder,
makeSelectMyOrderList,
makeSelectMyOrderFetchStatus,
makeSelectMyOrderErrors,
makeSelectConfirmNewOrderModal,
Expand Down Expand Up @@ -113,10 +112,10 @@ describe('containers/OrderPage/selectors/makeSelectOrderbook', () => {
avevolume: 0,
minvolume: 0,
base: 'BEER',
address: 'RRVJBpA5MoeTo3beA1iP6euWWrWcJdJtXu',
address: '12fj3npPKwTNxUgDMN8XcCDcR2Z4DBehj6',
rel: 'COQUI',
type: 'ORDER_ALICE_SIDE',
id: 'RRVJBpA5MoeTo3beA1iP6euWWrWcJdJtXu',
id: '12fj3npPKwTNxUgDMN8XcCDcR2Z4DBehj6',
createdAt: 1559705142940,
uuid: '61e7fa64-43ff-4858-a148-62d16d0da0d8',
maxvolume: 6729.6392886
Expand Down Expand Up @@ -175,9 +174,6 @@ describe('containers/OrderPage/selectors/makeSelectMyOrder', () => {

const selectMyOrderFetchStatus = makeSelectMyOrderFetchStatus();
expect(selectMyOrderFetchStatus(mockedState)).toEqual(null);

const selectMyOrderList = makeSelectMyOrderList();
expect(selectMyOrderList(mockedState)).toEqual(fromJS([]));
});
});

Expand Down
Expand Up @@ -21,7 +21,8 @@ import ExplorerLink from '../../../components/ExplorerLink';
import { covertSymbolToName } from '../../../utils/coin';
import {
makeSelectBalanceFetchStatus,
makeSelectBalanceErrors
makeSelectBalanceErrors,
makeSelectBalanceEntities
} from '../../App/selectors';
import {
makeSelectOrderbookDeposit,
Expand Down Expand Up @@ -138,13 +139,11 @@ const styles = theme => ({
},

root__orderSelected: {
// backgroundColor: '#80BB41',
border: '1px solid #80BB41'
}
});

type IOrderProps = {
selected: boolean,
classes: Styles,
// eslint-disable-next-line flowtype/no-weak-types
fetchStatus: List<*>,
Expand Down Expand Up @@ -180,10 +179,10 @@ class Order extends React.PureComponent<IOrderProps, IOrderState> {
};

renderActions = () => {
const { classes, data, error, fetchStatus, selected } = this.props;
const { classes, data, error, fetchStatus } = this.props;
const loading = fetchStatus === LOADING;
const id = data.get('id');

const selected = !!data.get('uuid');
return error ? (
<Button
disabled={loading}
Expand Down Expand Up @@ -239,10 +238,11 @@ class Order extends React.PureComponent<IOrderProps, IOrderState> {
render() {
debug(`render`);

const { classes, error, data, deposit, recevie, selected } = this.props;
const { classes, error, data, deposit, recevie } = this.props;
const isError = !!error;
const symbol =
data.get('type') === ORDER_BOB_SIDE ? data.get('base') : data.get('rel');
const selected = !!data.get('uuid');

return (
<Card
Expand Down
@@ -1,70 +1,19 @@
// @flow
import React from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import { makeStyles } from '@material-ui/core/styles';
import getCoinMemoize from '../../../components/CryptoIcons';

const debug = require('debug')('atomicapp:containers:OrdersPage:OrderItem');

const useStyles = makeStyles(theme => ({
transactionRecord__listItem: {
paddingLeft: 0
},

transactionRecord__ItemDay: {
flex: 'none'
},

transactionRecord__ItemText: {
// flex: '5 1 auto'
},

transactionRecord__ItemTextRight: {
textAlign: 'right',
top: '50%',
right: 4,
position: 'absolute',
transform: 'translateY(-50%)'
},

transactionRecord__linearProgress: {
height: 2
},

transactionRecord__success: {
color: theme.colors.success
},

transactionRecord__danger: {
color: theme.colors.danger
}
}));
const useStyles = makeStyles(theme => ({}));

type IOrderItemProps = {};

function OrderItem(props: IOrderItemProps) {
debug(`render`);
const classes = useStyles();

return (
<List>
<ListItem button className={classes.transactionRecord__listItem}>
<ListItemText
primary="05"
secondary="02"
className={classes.transactionRecord__ItemDay}
/>
{getCoinMemoize('KMD')}
<ListItemText
primary="12fj3npPKwTNxUgDMN8XcCDcR2Z4DBehj6"
secondary="Bob Side"
className={classes.transactionRecord__ItemText}
/>
</ListItem>
</List>
);
return <div>OrderItem</div>;
}

OrderItem.defaultProps = {};
Expand Down
@@ -0,0 +1,74 @@
// @flow
import React from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import { makeStyles } from '@material-ui/core/styles';
import getCoinMemoize from '../../../components/CryptoIcons';

const debug = require('debug')('atomicapp:containers:OrdersPage:OrderItem');

const useStyles = makeStyles(theme => ({
transactionRecord__listItem: {
paddingLeft: 0
},

transactionRecord__ItemDay: {
flex: 'none'
},

transactionRecord__ItemText: {
// flex: '5 1 auto'
},

transactionRecord__ItemTextRight: {
textAlign: 'right',
top: '50%',
right: 4,
position: 'absolute',
transform: 'translateY(-50%)'
},

transactionRecord__linearProgress: {
height: 2
},

transactionRecord__success: {
color: theme.colors.success
},

transactionRecord__danger: {
color: theme.colors.danger
}
}));

type IOrderItemProps = {};

function OrderItem(props: IOrderItemProps) {
debug(`render`);
const classes = useStyles();

return (
<List>
<ListItem button className={classes.transactionRecord__listItem}>
<ListItemText
primary="05"
secondary="02"
className={classes.transactionRecord__ItemDay}
/>
{getCoinMemoize('KMD')}
<ListItemText
primary="12fj3npPKwTNxUgDMN8XcCDcR2Z4DBehj6"
secondary="Bob Side"
className={classes.transactionRecord__ItemText}
/>
</ListItem>
</List>
);
}

OrderItem.defaultProps = {};

OrderItem.displayName = 'OrdersPage__OrderItem';

export default OrderItem;
Expand Up @@ -9,10 +9,7 @@ import CloudOff from '@material-ui/icons/CloudOff';
import WarningPlate from '../../../components/WarningPlate';
import Order from './Order';
// import OrderItem from './OrderItem';
import {
makeSelectOrderbookFullList,
makeSelectMyOrderList
} from '../selectors';
import { makeSelectOrderbookFullList } from '../selectors';

const debug = require('debug')('atomicapp:containers:OrdersPage:Orderbook');

Expand All @@ -28,15 +25,13 @@ const useStyles = makeStyles(() => ({

type IOrderbookProps = {
// eslint-disable-next-line flowtype/no-weak-types
orderbook: List<*>,
// eslint-disable-next-line flowtype/no-weak-types
myOrderList: List<*>
orderbook: List<*>
};

function Orderbook(props: IOrderbookProps) {
debug(`render`);
const classes = useStyles();
const { orderbook, myOrderList } = props;
const { orderbook } = props;

if (!orderbook || orderbook.size === 0) {
return (
Expand Down Expand Up @@ -80,11 +75,7 @@ function Orderbook(props: IOrderbookProps) {
<br />
{orderbook.map((order, key) => (
<>
<Order
key={`orderbook-${key}`}
selected={myOrderList.contains(order.get('id'))}
data={order}
/>
<Order key={`orderbook-${key}`} data={order} />
{/* <OrderItem /> */}
<br />
</>
Expand All @@ -98,8 +89,7 @@ Orderbook.defaultProps = {};
Orderbook.displayName = 'OrdersPage__Orderbook';

const mapStateToProps = createStructuredSelector({
orderbook: makeSelectOrderbookFullList(),
myOrderList: makeSelectMyOrderList()
orderbook: makeSelectOrderbookFullList()
});

const withConnect = connect(
Expand Down

0 comments on commit fc24dc7

Please sign in to comment.