Skip to content

Commit

Permalink
Merge pull request #2250 from hollaex/testnet
Browse files Browse the repository at this point in the history
Testnet
  • Loading branch information
abeikverdi authored Jul 7, 2023
2 parents 4162948 + ebba6f4 commit c455e1c
Show file tree
Hide file tree
Showing 18 changed files with 430 additions and 86 deletions.
40 changes: 39 additions & 1 deletion server/api/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,43 @@ const updateQuickTradeConfig = (req, res) => {
});
};

const getBalancesAdmin = (req, res) => {
loggerAdmin.verbose(req.uuid, 'controllers/admin/getBalancesAdmin/auth', req.auth);

const {
user_id,
currency,
format
} = req.swagger.params;


if (format.value && req.auth.scopes.indexOf(ROLES.ADMIN) === -1) {
return res.status(403).json({ message: API_KEY_NOT_PERMITTED });
}

toolsLib.user.getAllBalancesAdmin({
user_id: user_id.value,
currency: currency.value,
format: format.value,
additionalHeaders: {
'x-forwarded-for': req.headers['x-forwarded-for']
}
})
.then((data) => {
if (format.value === 'all') {
res.setHeader('Content-disposition', `attachment; filename=${toolsLib.getKitConfig().api_name}-users.csv`);
res.set('Content-Type', 'text/csv');
return res.status(202).send(data);
} else {
return res.json(data);
}
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/getBalancesAdmin', err.message);
return res.status(err.statusCode || 400).json({ message: errorMessageConverter(err) });
});
}

module.exports = {
createInitialAdmin,
getAdminKit,
Expand Down Expand Up @@ -2519,5 +2556,6 @@ module.exports = {
revokeUserSessionByAdmin,
sendEmailByAdmin,
sendRawEmailByAdmin,
updateQuickTradeConfig
updateQuickTradeConfig,
getBalancesAdmin
};
8 changes: 0 additions & 8 deletions server/api/controllers/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const createBrokerPair = (req, res) => {
user_id,
min_size,
max_size,
increment_size,
type,
quote_expiry_time,
rebalancing_symbol,
Expand All @@ -67,7 +66,6 @@ const createBrokerPair = (req, res) => {
user_id,
min_size,
max_size,
increment_size,
type,
quote_expiry_time,
rebalancing_symbol,
Expand All @@ -84,7 +82,6 @@ const createBrokerPair = (req, res) => {
user_id,
min_size,
max_size,
increment_size,
type,
quote_expiry_time,
rebalancing_symbol,
Expand Down Expand Up @@ -115,13 +112,11 @@ const testBroker = (req, res) => {
const {
formula,
spread,
increment_size
} = req.swagger.params.data.value;

toolsLib.broker.testBroker({
formula,
spread,
increment_size
})
.then((data) => {
return res.json(data);
Expand Down Expand Up @@ -181,7 +176,6 @@ function updateBrokerPair(req, res) {
sell_price,
min_size,
max_size,
increment_size,
paused,
user_id,
type,
Expand All @@ -200,7 +194,6 @@ function updateBrokerPair(req, res) {
sell_price,
min_size,
max_size,
increment_size,
paused,
user_id,
type,
Expand Down Expand Up @@ -264,7 +257,6 @@ function getBrokerPairs(req, res) {
'paused',
'min_size',
'max_size',
'increment_size',
'type',
'quote_expiry_time',
'rebalancing_symbol',
Expand Down
46 changes: 45 additions & 1 deletion server/api/swagger/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3187,4 +3187,48 @@ paths:
- bearer
- hmac
x-security-scopes:
- admin
- admin
/admin/balances:
x-swagger-router-controller: admin
get:
description: Get exchange balances of users for admin
operationId: getBalancesAdmin
tags:
- Admin
parameters:
- name: user_id
in: query
required: false
type: number
- name: currency
in: query
required: false
type: string
- in: query
name: format
description: Specify data format
required: false
enum: ['csv', 'all']
type: string
responses:
200:
description: Success
schema:
$ref: "#/definitions/ObjectResponse"
202:
description: CSV
schema:
type: string
default:
description: Error
schema:
$ref: "#/definitions/MessageResponse"
security:
- Token: []
x-security-types:
- bearer
- hmac
x-security-scopes:
- admin
x-token-permissions:
- can_read
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const TABLE = 'Brokers';
const COLUMN = 'increment_size';

module.exports = {
up: (queryInterface, Sequelize) =>
queryInterface.removeColumn(TABLE, COLUMN),
down: (queryInterface, Sequelize) =>
queryInterface.addColumn(TABLE, COLUMN, {
type: Sequelize.DOUBLE,
allowNull: false
})
};
4 changes: 0 additions & 4 deletions server/db/models/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.DOUBLE,
allowNull: false
},
increment_size: {
type: DataTypes.DOUBLE,
allowNull: false
},
type: {
type: DataTypes.ENUM('manual', 'dynamic'),
defaultValue: 'manual',
Expand Down
2 changes: 1 addition & 1 deletion server/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const checkStatus = () => {
status.constants
),
Tier.findAll(),
Broker.findAll({ attributes: ['id', 'symbol', 'buy_price', 'sell_price', 'paused', 'min_size', 'max_size', 'increment_size']}),
Broker.findAll({ attributes: ['id', 'symbol', 'buy_price', 'sell_price', 'paused', 'min_size', 'max_size']}),
QuickTrade.findAll(),
status.dataValues
]);
Expand Down
Loading

0 comments on commit c455e1c

Please sign in to comment.