Skip to content

Commit

Permalink
Merge pull request #1990 from hollaex/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
abeikverdi committed Mar 1, 2023
2 parents e3375fe + e203564 commit 266526f
Show file tree
Hide file tree
Showing 51 changed files with 1,560 additions and 4,012 deletions.
2 changes: 1 addition & 1 deletion server/api/swagger/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const definition = {
swagger: '2.0',
info: {
title: 'HollaEx Kit',
version: '2.5.0'
version: '2.5.1'
},
host: 'api.hollaex.com',
basePath: '/v2',
Expand Down
1 change: 1 addition & 0 deletions server/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ exports.INVALID_NETWORK = (network, validNetworks) => `Invalid network: ${networ
exports.NETWORK_REQUIRED = (coin, validNetworks) => `Must specify network for coin: ${coin}${validNetworks ? `. Valid networks: ${validNetworks}` : ''}`;
exports.AUTH_NOT_MATCHED = 'Auth doesn\'t match';
exports.BROKER_NOT_FOUND = 'Broker pair could not be found';
exports.BROKER_SIZE_EXCEED = 'Size should be between minimum and maximum set size of broker'
exports.BROKER_PAUSED = 'Broker pair is paused';
exports.BROKER_ERROR_DELETE_UNPAUSED = 'Broker pair could not be deleted while unpaused';
exports.BROKER_EXISTS = 'A deal for this symbol alreadys exists';
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.5.0",
"version": "2.5.1",
"private": false,
"description": "HollaEx Kit",
"keywords": [
Expand Down
5 changes: 3 additions & 2 deletions server/plugins/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ const putPlugin = async (req, res) => {
'postscript',
'meta',
'public_meta',
'type'
'type',
'author'
]);

try {
Expand Down Expand Up @@ -378,7 +379,7 @@ const putPlugin = async (req, res) => {
switch (field) {
case 'script':
if (value) {
const minifiedScript = uglifyEs.minify(value);
const minifiedScript = uglifyJs.minify(value);

if (minifiedScript.error) {
throw new Error(`Error while minifying script: ${minifiedScript.error.message}`);
Expand Down
57 changes: 56 additions & 1 deletion server/plugins/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,39 @@ const { logEntryRequest, stream, loggerPlugin } = require('../config/logger');
const morganType = process.env.NODE_ENV === 'development' ? 'dev' : 'combined';
const { domainMiddleware, helmetMiddleware } = require('../config/middleware');
const cors = require('cors');
const sequelize = require('sequelize');
const bodyParser = require('body-parser');
const uglifyJs = require('uglify-js');
const fs = require('fs');
const path = require('path');
const toolsLib = require('hollaex-tools-lib');
const expressValidator = require('express-validator');
const lodash = require('lodash');
const npm = require('npm-programmatic');
const _eval = require('eval');
const multer = require('multer');
const moment = require('moment');
const mathjs = require('mathjs');
const bluebird = require('bluebird');
const umzug = require('umzug');
const rp = require('request-promise');
const uuid = require('uuid/v4');
const jwt = require('jsonwebtoken');
const momentTz = require('moment-timezone');
const json2csv = require('json2csv');
const flat = require('flat');
const ws = require('ws');
const cron = require('node-cron');
const randomString = require('random-string');
const bcryptjs = require('bcryptjs');
const expectCt = require('expect-ct');
const validator = require('validator');
const otp = require('otp');
const geoipLite = require('geoip-lite');
const nodemailer = require('nodemailer');
const wsHeartbeatServer = require('ws-heartbeat/server');
const wsHeartbeatClient = require('ws-heartbeat/client');
const winston = require('winston');

let pluginName = 'hello';
if (process.argv.slice(2).length && process.argv.slice(2)[0].split('=')[1]) {
Expand Down Expand Up @@ -68,8 +93,38 @@ checkStatus()
module: module,
toolsLib,
app,
loggerPlugin,
toolsLib,
lodash,
expressValidator,
loggerPlugin,
multer,
moment,
mathjs,
bluebird,
umzug,
rp,
sequelize,
uuid,
jwt,
momentTz,
json2csv,
flat,
ws,
cron,
randomString,
bcryptjs,
expectCt,
validator,
uglifyJs,
otp,
geoipLite,
nodemailer,
wsHeartbeatServer,
wsHeartbeatClient,
cors,
winston,
bodyParser,
morgan,
pluginLibraries: {
app,
toolsLib,
Expand Down
32 changes: 23 additions & 9 deletions server/plugins/plugin-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const uglifyJs = require('uglify-js');
const bodyParser = require('body-parser');
const { isMainThread, workerData } = require('worker_threads');
const { Plugin } = require('../db/models');
const { checkStatus } = require('../init');

const initPluginProcess = async ({ PORT }) => {

Expand Down Expand Up @@ -162,13 +163,26 @@ const initPluginProcess = async ({ PORT }) => {
};

if (!isMainThread) {
try {
initPluginProcess(JSON.parse(workerData));
} catch (err) {
loggerPlugin.error(
'plugins/index/initialization',
'error while starting plugin',
err.message
);
}
checkStatus()
.then(() => {
try {
initPluginProcess(JSON.parse(workerData));
} catch (err) {
loggerPlugin.error(
'plugins/index/initialization',
'error while starting plugin',
err.message
);
}
})
.catch(() => {
loggerPlugin.error(
'plugins/index/initialization',
'API Initialization failed',
err.message
);
setTimeout(() => { process.exit(1); }, 1000 * 5);
})


}
5 changes: 5 additions & 0 deletions server/utils/hollaex-tools-lib/tools/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const {
TOKEN_EXPIRED,
AUTH_NOT_MATCHED,
BROKER_NOT_FOUND,
BROKER_SIZE_EXCEED,
BROKER_PAUSED,
BROKER_ERROR_DELETE_UNPAUSED,
BROKER_EXISTS,
Expand Down Expand Up @@ -566,6 +567,10 @@ const executeBrokerDeal = async (userId, token, size) => {
throw new Error(BROKER_PAUSED);
}

if(size < brokerPair.min_size || size > brokerPair.max_size) {
throw new Error(BROKER_SIZE_EXCEED)
}

const broker = await getUserByKitId(brokerPair.user_id);
const user = await getUserByKitId(userId);

Expand Down
6 changes: 5 additions & 1 deletion server/utils/hollaex-tools-lib/tools/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { SERVER_PATH } = require('../constants');
const { getModel } = require('./database/model');
const { fetchBrokerQuote, generateRandomToken, executeBrokerDeal } = require('./broker');
const { getNodeLib } = require(`${SERVER_PATH}/init`);
const { INVALID_SYMBOL, NO_DATA_FOR_CSV, USER_NOT_FOUND, USER_NOT_REGISTERED_ON_NETWORK, TOKEN_EXPIRED, BROKER_NOT_FOUND, BROKER_PAUSED } = require(`${SERVER_PATH}/messages`);
const { INVALID_SYMBOL, NO_DATA_FOR_CSV, USER_NOT_FOUND, USER_NOT_REGISTERED_ON_NETWORK, TOKEN_EXPIRED, BROKER_NOT_FOUND, BROKER_PAUSED, BROKER_SIZE_EXCEED } = require(`${SERVER_PATH}/messages`);
const { parse } = require('json2csv');
const { subscribedToPair, getKitTier, getDefaultFees, getAssetsPrices, getPublicTrades, validatePair } = require('./common');
const { reject } = require('bluebird');
Expand Down Expand Up @@ -62,6 +62,10 @@ const executeUserOrder = async (user_id, opts, token) => {
throw new Error(BROKER_PAUSED);
}

if(size < brokerPair.min_size || size > brokerPair.max_size) {
throw new Error(BROKER_SIZE_EXCEED)
}

const broker = await getUserByKitId(brokerPair.user_id);
const user = await getUserByKitId(user_id);

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0
2.5.1
2 changes: 1 addition & 1 deletion web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hollaex-kit",
"version": "2.5.0",
"version": "2.5.1",
"private": true,
"dependencies": {
"@ant-design/compatible": "1.0.5",
Expand Down
4 changes: 2 additions & 2 deletions web/src/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export const SORT = {
};

export const SORT_EXP = {
VOL: 'biggest gainers first',
CHANGE: 'most actively traded first',
VOL: 'most actively traded first',
CHANGE: 'biggest gainers first',
};

export const setSortModeVolume = () => ({
Expand Down
128 changes: 0 additions & 128 deletions web/src/actions/quickTradeAction.js

This file was deleted.

13 changes: 13 additions & 0 deletions web/src/actions/quickTradeActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from 'axios';
import querystring from 'query-string';

const ENDPOINTS = {
QUICK_TRADE: '/quick-trade',
EXECUTE: '/order/execute',
};

export const getQuickTrade = (values) =>
axios.get(`${ENDPOINTS.QUICK_TRADE}?${querystring.stringify(values)}`);

export const executeQuickTrade = (token) =>
axios.post(ENDPOINTS.EXECUTE, { token });
5 changes: 1 addition & 4 deletions web/src/components/CurrencyBall/withPrice.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const CurrencyBallWithPrice = ({
size = 'm',
coins = {},
min,
isExistBroker = false,
}) => {
const { display_name, ...rest } = coins[symbol] || DEFAULT_COIN_DATA;
const minValue = rest.increment_unit ?? min;
Expand All @@ -19,9 +18,7 @@ const CurrencyBallWithPrice = ({
<div className="with_price-block_amount d-flex direction_ltr">
<CurrencyBall name={display_name} symbol={symbol} size={size} />
<div className="with_price-block_amount-value d-flex">
{isExistBroker
? amount
: `${formatCurrencyByIncrementalUnit(amount, minValue)}`}
{formatCurrencyByIncrementalUnit(amount, minValue)}
</div>
</div>
);
Expand Down
Loading

0 comments on commit 266526f

Please sign in to comment.