Skip to content

Commit

Permalink
switch to v1 wallet (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
hichri-louay authored Sep 11, 2023
2 parents c61af23 + fae0303 commit 309274a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
1 change: 0 additions & 1 deletion routes/login.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ passport.use(
passReqToCallback: true,
},
async function (req, profile, cb) {
console.log('signup_telegram_function passport')
signup_telegram_function(req, profile, cb)
}
)
Expand Down
29 changes: 20 additions & 9 deletions web3/wallets.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,13 @@ exports.getAccountV2 = async (req, res) => {
tronPromise,
sattPromise,
])

let totalBalance =
ether_balance +
bnb_balance +
polygon_balance +
btt_balance +
trx_balance +
satt_balance
var result = {
btc: account.btc ? btcAddress : '',
address: address,
Expand All @@ -355,6 +361,7 @@ exports.getAccountV2 = async (req, res) => {
btt_balance: btt_balance,
trx_balance: trx_balance,
version: account.mnemo ? 2 : 1,
totalBalance: totalBalance,
}
result.btc_balance = 0
if (process.env.NODE_ENV === 'mainnet' && btcAddress) {
Expand Down Expand Up @@ -1037,18 +1044,21 @@ exports.getListCryptoByUid = async (req, res) => {

// CryptoPrices => 200 cryptos
var CryptoPrices = crypto
var ret = (
req.body.version === null
? !user.migrated
: req.body.version === 'v1'
)
? await this.getAccount(req, res)
: await this.getAccountV2(req, res)
const totalBalanceV2 = await this.getAccountV2(req, res)

req.body.version === 'v1'

var ret =
req.body.version === 'v1' || totalBalanceV2.totalBalance <= 0
? await this.getAccount(req, res)
: await this.getAccountV2(req, res)

let tronAddress = ret.tronAddress
delete ret.btc
delete ret.version
delete ret.tronAddress
delete ret.tronValue

// => userTokens : token ajoutés manuellemnt
let userTokens = await CustomToken.find({
sn_users: { $in: [id] },
Expand Down Expand Up @@ -1199,6 +1209,7 @@ exports.getListCryptoByUid = async (req, res) => {
delete ret.matic_balance
delete ret.btt_balance
delete ret.trx_balance
delete ret.totalBalance

for (const Amount in ret) {
let crypto = {}
Expand Down Expand Up @@ -1398,7 +1409,7 @@ exports.getBalanceByUid = async (req, res) => {
}

delete ret?.address

delete ret?.totalBalance
for (const Amount in ret) {
let tokenSymbol = Amount.split('_')[0].toUpperCase()
tokenSymbol = tokenSymbol === 'ETHER' ? 'ETH' : tokenSymbol
Expand Down

0 comments on commit 309274a

Please sign in to comment.