Skip to content

Commit

Permalink
Merge pull request #2990 from hollaex/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
abeikverdi authored Aug 26, 2024
2 parents 8ff95f6 + da42473 commit 6dceda9
Show file tree
Hide file tree
Showing 117 changed files with 10,585 additions and 2,249 deletions.
121 changes: 88 additions & 33 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# Prevent to proceed if there are git conflicts on the settings files
function check_git_conflict() {
local file=$1

if grep -q '<< HEAD' "$file" && grep -q '==' "$file" && grep -q '>>' "$file"; then
echo -e "\nError: Git conflict detected in file: $file"
echo "Please check the file and fix the Git conflict to proceed."
exit 1;
fi
}

check_git_conflict settings/configmap;
check_git_conflict settings/secret;

export ARCH=$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/ | sed s/s390x/s390x/)

# Dependencies installer for Debian (Ubuntu) based Linux.
Expand Down Expand Up @@ -60,26 +74,46 @@ if command apt -v > /dev/null 2>&1; then

fi

if ! command docker compose version > /dev/null 2>&1; then

if command docker-compose --version | grep -q '^docker-compose version 1'; then

printf "\n\033[93mHollaEx CLI requires docker compose v2 to operate. Installing it now...\033[39m\n"
echo -e "\n\033[91mWarning: Detected Docker Compose v1 instead of v2.\033[39m"
echo "HollaEx CLI v3+ requires Docker Compose v2."

if [[ ! $IS_APT_UPDATED ]]; then
if command sudo apt list --installed docker-compose; then

echo "Updating APT list"
sudo apt update
echo "Removing Docker-Compose v1 through the APT..."

sudo apt remove -y docker-compose

else

echo "To proceed, please uninstall the current Docker Compose v1 and then run the install.sh script."
echo -e "The install.sh script will automatically install Docker Compose v2 for you.\n"

exit 1;

fi

if command sudo apt install -y docker-compose-v2; then
fi

if ! command -v docker-compose > /dev/null 2>&1; then

printf "\n\033[92mdocker compose v2 has been successfully installed!\033[39m\n"
printf "\n\033[93mHollaEx CLI requires docker-compose v2 to operate. Installing it now...\033[39m\n"

echo "Info: $(docker compose version)"
if command sudo curl -SL https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose; then

chmod +x /usr/local/bin/docker-compose

printf "\n\033[92mdocker compose v2has been successfully installed!\033[39m\n"

echo "Info: $(docker-compose version)"


else

printf "\n\033[91mFailed to install docker compose v2.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'sudo apt install -y docker compose'."
echo "Please review the logs and try to manually install it. - 'https://github.com/docker/compose/releases'."
exit 1;

fi
Expand All @@ -102,6 +136,8 @@ if command apt -v > /dev/null 2>&1; then

echo "Info: $(jq --version)"



else

printf "\n\033[91mFailed to install jq.\033[39m\n"
Expand Down Expand Up @@ -251,26 +287,34 @@ elif command brew -v > /dev/null 2>&1; then

fi

if ! command docker compose version > /dev/null 2>&1; then
if command docker-compose --version | grep -q '^docker-compose version 1'; then

printf "\n\033[93mHollaEx CLI requires docker compose to operate. Installing it now...\033[39m\n"
echo -e "\n\033[91mError: Detected Docker Compose v1 instead of v2.\033[39m"
echo "HollaEx CLI v3+ requires Docker Compose v2."
echo "To proceed, please uninstall the current Docker Compose v1 and then run the install.sh script."
echo -e "The install.sh script will automatically install Docker Compose v2 for you.\n"

if [[ ! $IS_BREW_UPDATED ]]; then
exit 1;

echo "Updating Homebrew list"
brew update
fi
fi

if ! command -v docker-compose > /dev/null 2>&1; then

printf "\n\033[93mHollaEx CLI requires docker-compose v2 to operate. Installing it now...\033[39m\n"

if command brew install docker compose; then
if command sudo curl -SL https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose; then

printf "\n\033[92mdocker compose has been successfully installed!\033[39m\n"
chmod +x /usr/local/bin/docker-compose

echo "Info: $(docker compose version)"
printf "\n\033[92mdocker compose v2has been successfully installed!\033[39m\n"

echo "Info: $(docker-compose version)"


else

printf "\n\033[91mFailed to install docker compose.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'brew install docker compose'."
printf "\n\033[91mFailed to install docker compose v2.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'https://github.com/docker/compose/releases'."
exit 1;

fi
Expand Down Expand Up @@ -414,21 +458,33 @@ elif command yum --version > /dev/null 2>&1; then

fi

if ! command docker compose version > /dev/null 2>&1; then
if command docker-compose --version | grep -q '^docker-compose version 1'; then

echo -e "\n\033[91mError: Detected Docker Compose v1 instead of v2.\033[39m"
echo "HollaEx CLI v3+ requires Docker Compose v2."
echo "To proceed, please uninstall the current Docker Compose v1 and then run the install.sh script."
echo -e "The install.sh script will automatically install Docker Compose v2 for you.\n"

exit 1;

fi

if ! command -v docker-compose > /dev/null 2>&1; then

printf "\n\033[93mHollaEx CLI requires docker compose to operate. Installing it now...\033[39m\n"
printf "\n\033[93mHollaEx CLI requires docker-compose v2 to operate. Installing it now...\033[39m\n"

if command sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker compose; then
if command sudo curl -SL https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose; then

sudo chmod +x /usr/local/bin/docker compose
chmod +x /usr/local/bin/docker-compose

printf "\n\033[92mdocker compose has been successfully installed!\033[39m\n"
printf "\n\033[92mdocker compose v2has been successfully installed!\033[39m\n"

echo "Info: $(docker compose version)"
echo "Info: $(docker-compose version)"


else

printf "\n\033[91mFailed to install docker compose.\033[39m\n"
printf "\n\033[91mFailed to install docker compose v2.\033[39m\n"
echo "Please review the logs and try to manually install it. - 'https://github.com/docker/compose/releases'."
exit 1;

Expand Down Expand Up @@ -518,15 +574,15 @@ elif command yum --version > /dev/null 2>&1; then

fi

if ! command docker -v > /dev/null 2>&1 || ! command docker compose version > /dev/null 2>&1 || ! command curl --version > /dev/null 2>&1 || ! command jq --version > /dev/null 2>&1 || ! command nslookup -version > /dev/null 2>&1 || ! command psql --version > /dev/null 2>&1; then
if ! command docker -v > /dev/null 2>&1 || ! command docker-compose version > /dev/null 2>&1 || ! command curl --version > /dev/null 2>&1 || ! command jq --version > /dev/null 2>&1 || ! command nslookup -version > /dev/null 2>&1 || ! command psql --version > /dev/null 2>&1; then

if command docker -v > /dev/null 2>&1; then

IS_DOCKER_INSTALLED=true

fi

if command docker compose version > /dev/null 2>&1; then
if command docker-compose version > /dev/null 2>&1; then

IS_DOCKER_COMPOSE_INSTALLED=true

Expand Down Expand Up @@ -575,7 +631,7 @@ if ! command docker -v > /dev/null 2>&1 || ! command docker compose version > /d

fi

# docker compose installation status check
# docker compose v2installation status check
if [[ "$IS_DOCKER_COMPOSE_INSTALLED" ]]; then

printf "\033[92mdocker compose: Installed\033[39m\n"
Expand Down Expand Up @@ -669,7 +725,6 @@ if [[ "$DOCKER_USERGROUP_ADDED" ]]; then

fi


function kit_cross_compatibility_converter() {

CONFIG_FILE_PATH=$(pwd)/settings/*
Expand Down Expand Up @@ -718,8 +773,8 @@ function kit_cross_compatibility_converter() {

if command docker ps | grep local.*-nginx > /dev/null ; then

docker compose -f $(pwd)/nginx/docker-compose.yaml down
docker compose -f $(pwd)/nginx/docker-compose.yaml up -d
docker-compose -f $(pwd)/nginx/docker-compose.yaml down
docker-compose -f $(pwd)/nginx/docker-compose.yaml up -d

fi

Expand Down
2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This folder holds the `swagger.yaml` file that contains all the endpoints for th
- Database used is `postgreSQL`
- mail
- This directory holds everything relevant to emails.
- The `strings` directory holds all the strings that contain email messages. They are separated by langauge e.g. `en.js`, `fa.js`, etc.
- The `strings` directory holds all the strings that contain email messages. They are separated by language e.g. `en.js`, `fa.js`, etc.
- The `templates` directory holds all the email templates. They are separated by the emails being send e.g. `welcome.js`, `deposit.js`, etc.
- The library used for emails is `Nodemailer`.
- config
Expand Down
96 changes: 95 additions & 1 deletion server/api/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,96 @@ const createUserReferralCodeByAdmin = (req, res) => {
});
};


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

const { user_id, is_p2p, is_fiat_control, status, limit, page, order_by, order, start_date, end_date } = req.swagger.params;

toolsLib.user.getPaymentDetails(user_id.value,
{
limit: limit.value,
page: page.value,
order_by: order_by.value,
order: order.value,
start_date: start_date.value,
end_date: end_date.value,
is_p2p: is_p2p.value,
is_fiat_control: is_fiat_control.value,
status: status.value,
})
.then((data) => {
return res.json(data);
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/getPaymentDetailsByAdmin', err.message);
return res.status(err.statusCode || 400).json({ message: errorMessageConverter(err) });
});
};

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

const { user_id, name, label, details, is_p2p, is_fiat_control, status } = req.swagger.params.data.value;

toolsLib.user.createPaymentDetail({
user_id,
name,
label,
details,
is_p2p,
is_fiat_control,
status
})
.then((data) => {
return res.json(data);
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/createPaymentDetailByAdmin', err.message);
return res.status(err.statusCode || 400).json({ message: errorMessageConverter(err) });
});
};

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

const { user_id, id, name, label, details, is_p2p, is_fiat_control, status } = req.swagger.params.data.value;

toolsLib.user.updatePaymentDetail(id, {
user_id,
name,
label,
details,
is_p2p,
is_fiat_control,
status
}, true)
.then((data) => {
return res.json(data);
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/updatePaymentDetailByAdmin', err.message);
return res.status(err.statusCode || 400).json({ message: errorMessageConverter(err) });
});
};

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

const { id, user_id } = req.swagger.params.data.value;

toolsLib.user.deletePaymentDetail(id, user_id)
.then(() => {
return res.json({
message: "Success"
});
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/deletePaymentDetailByAdmin', err.message);
return res.status(err.statusCode || 400).json({ message: errorMessageConverter(err) });
});
};

module.exports = {
createInitialAdmin,
getAdminKit,
Expand Down Expand Up @@ -3074,5 +3164,9 @@ module.exports = {
disableUserWithdrawal,
performDirectWithdrawalByAdmin,
getUserReferralCodesByAdmin,
createUserReferralCodeByAdmin
createUserReferralCodeByAdmin,
getPaymentDetailsByAdmin,
createPaymentDetailByAdmin,
updatePaymentDetailByAdmin,
deletePaymentDetailByAdmin
};
2 changes: 1 addition & 1 deletion server/api/controllers/fiat.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createDepositRequest = (req, res) => {
throw new Error('User not found');
}

const { fee } = toolsLib.wallet.validateDeposit(user, amount, currency, 'fiat');
const { fee } = await toolsLib.wallet.validateDeposit(user, amount, currency, 'fiat');

const { count: depositCount } = await toolsLib.wallet.getUserDepositsByKitId(
userId,
Expand Down
Loading

0 comments on commit 6dceda9

Please sign in to comment.