Skip to content

Commit

Permalink
Merge pull request #81 from bittorrent/fix-balance-data-rate
Browse files Browse the repository at this point in the history
Fix balance data rate
  • Loading branch information
lulu-tro authored Nov 5, 2024
2 parents d88d701 + 3ed4fb6 commit bfb99b4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/APIClient/APIClient10.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import xhr from "axios/index";
import { PRECISION_RATE } from "utils/constants";
import { MULTIPLE_CURRENCY_RATE} from "utils/constants";
import Cookies from 'js-cookie';


Expand Down Expand Up @@ -97,7 +97,7 @@ class APIClient10 {
return this.request('/api/v1/cheque/price-all').then((res) => {
Object.keys(res).forEach((key) => {
const item = res[key];
item.rate = +item.rate * PRECISION_RATE;
item.rate = MULTIPLE_CURRENCY_RATE[key] //+item.rate * PRECISION_RATE;
})
return res;
}).catch(e => {
Expand Down
1 change: 1 addition & 0 deletions src/components/Modals/WithdrawDepositModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function WithdrawDepositModal({ color }) {
let currentObj = {};
const token = tokenCurrent || 'WBTT';
let maxnum = 0
setTokenCurrent(token)
if (params.type === 'withdraw') {
setTitle('chequebook_withdraw');
setDescription('amount_to_withdraw');
Expand Down
1 change: 0 additions & 1 deletion src/components/Stats/NodeRevenueStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ export default function NodeRevenueStats({ color }) {
dataList: chequeEarningDetailList,
});
};

return (
<div className="w-full h-full common-card shadow-none lg:shadow-md p-0">
<div className="flex flex-wrap h-full">
Expand Down
24 changes: 8 additions & 16 deletions src/services/dashboardService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Client10 from "APIClient/APIClient10.js";
import BigNumber from 'bignumber.js';
import { switchStorageUnit2, switchBalanceUnit, toThousands, getTimes,formatNumber } from "utils/BTFSUtil.js";
import { PRECISION, PRECISION_RATE, PRECISION_OLD, FEE, NEW_SCORE_VERSION, INIT_MULTI_CURRENCY_DATA, MULTIPLE_CURRENCY_LIST,MULTIPLE_CURRENCY_RATE } from "utils/constants.js";
import { PRECISION, PRECISION_RATE, PRECISION_OLD, FEE, NEW_SCORE_VERSION, INIT_MULTI_CURRENCY_DATA, MULTIPLE_CURRENCY_LIST } from "utils/constants.js";
export const getHostInfo = () => {
return Client10.getHostInfo();
}
Expand Down Expand Up @@ -150,13 +150,7 @@ export const getNodeRevenueStats = async () => {
: 0;
const chequeExpense = +result[0]["totalSent"];
const hasTotalExpense = gasFee || chequeExpense;
const currencyRateList = [];
currencyRateList.push(
1,
result[5]?.data?.rate,
result[6]?.data?.rate,
result[7]?.data?.rate
);

const checksExpenseDetailsData = [];
const chequeEarningDetailData = [];
INIT_MULTI_CURRENCY_DATA.forEach((item, index) => {
Expand All @@ -177,17 +171,15 @@ export const getNodeRevenueStats = async () => {
priceItem?.rate
)
expenseItem.bttValue = switchBalanceUnit(
(+totalData.total_issued || 0) *
(currencyRateList[index] ? 1 / currencyRateList[index] : 1),
(+totalData.total_issued || 0) ,
priceItem?.rate * exchangeRate
)
earningItem.value = switchBalanceUnit(
+totalData.total_received || 0,
priceItem?.rate
)
earningItem.bttValue = switchBalanceUnit(
(+totalData.total_received || 0) *
(currencyRateList[index] ? 1 / currencyRateList[index] : 1),
(+totalData.total_received || 0) ,
priceItem?.rate * exchangeRate
)
checksExpenseDetailsData.push(expenseItem)
Expand Down Expand Up @@ -320,8 +312,8 @@ export const getNodeWalletStats = async () => {
newItem.bookBalanceValue = 0
newItem.maxBookBalanceCount = 0
if (allBalanceData?.[item.key]) {
// newItem.addressValue = switchBalanceUnit(allBalanceData?.[item.key], priceList?.[item.key]?.rate)
newItem.addressValue = switchBalanceUnit(allBalanceData?.[item.key], MULTIPLE_CURRENCY_RATE?.[item.key])
newItem.addressValue = switchBalanceUnit(allBalanceData?.[item.key], priceList?.[item.key]?.rate)
// newItem.addressValue = switchBalanceUnit(allBalanceData?.[item.key], MULTIPLE_CURRENCY_RATE?.[item.key])
newItem.maxAddressCount = new BigNumber(allBalanceData?.[item.key])
.dividedBy(priceList?.[item.key]?.rate)
.toNumber()
Expand Down Expand Up @@ -410,10 +402,10 @@ export const getFilesStorage = async () => {

const formAmount = (amount, currencyType = '') => {
let precision = PRECISION;
if (!['btt', 'wbtt'].includes(currencyType.toLowerCase())) {
if (!['btt', 'wbtt','usdd'].includes(currencyType.toLowerCase())) {
precision = PRECISION_RATE;
}
console.log(amount, currencyType, PRECISION_RATE);
console.log(amount, currencyType, precision);
let amount_str = new BigNumber(amount).multipliedBy(precision).toFixed();
return amount_str;
};
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export const SAMPLE_PAGE_MODE = 'SimpleMode';
export const MULTIPLE_CURRENCY_RATE = {
WBTT:1000000000000000000 ,
USDD:1000000000000000000,
TST:1000000,
TRX:1000000,
USDT:1000000,
USDD_t:1000000000000000000,
Expand Down

0 comments on commit bfb99b4

Please sign in to comment.