Skip to content

Commit

Permalink
Merge pull request #315 from harmony-one/update_payments_v2
Browse files Browse the repository at this point in the history
Temporary remove invoice for hot wallet transfers
  • Loading branch information
ahiipsa authored Sep 27, 2023
2 parents 040d3a6 + df4fc72 commit c812f5b
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/modules/payment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { type Account, type TransactionReceipt } from 'web3-core'
import axios from 'axios'
import bn, { BigNumber } from 'bignumber.js'
import config from '../../config'
import { chatService, invoiceService, statsService } from '../../database/services'
import { chatService, statsService } from '../../database/services'
import { type OnCallBackQueryData, type OnMessageContext } from '../types'
import { LRUCache } from 'lru-cache'
import { freeCreditsFeeCounter } from '../../metrics/prometheus'
import { type BotPaymentLog } from '../../database/stats.service'
import { sendMessage } from '../open-ai/helpers'
import { type InvoiceParams } from '../../database/invoice.service'
import * as Sentry from '@sentry/node'

interface CoinGeckoResponse {
Expand Down Expand Up @@ -65,17 +64,17 @@ export class BotPayments {
userAccount: Account,
amount: BigNumber
): Promise<void> {
const invoiceData: InvoiceParams = {
tgUserId: accountId,
accountId,
amount: Math.round(this.convertBigNumber(amount)),
itemId: 'deposit_one',
currency: 'ONE'
}
const invoice = await invoiceService.create(invoiceData)
// const invoiceData: InvoiceParams = {
// tgUserId: accountId,
// accountId,
// amount: this.convertBigNumber(amount),
// itemId: 'deposit_one',
// currency: 'ONE'
// }
// const invoice = await invoiceService.create(invoiceData)
await this.transferFunds(userAccount, this.holderAddress, amount)
await chatService.depositOneCredits(accountId, amount.toFixed())
await invoiceService.setSuccessStatus({ uuid: invoice.uuid, providerPaymentChargeId: '', telegramPaymentChargeId: '' })
// await invoiceService.setSuccessStatus({ uuid: invoice.uuid, providerPaymentChargeId: '', telegramPaymentChargeId: '' })
}

private async runHotWalletsTask (): Promise<void> {
Expand Down Expand Up @@ -107,7 +106,6 @@ export class BotPayments {
let availableBalance = new BigNumber(0)
try {
availableBalance = await this.getUserBalance(accountId)
// availableBalance = BigNumber.max(availableBalance.minus(txFee), 0)
} catch (e) {
Sentry.captureException(e)
this.logger.error(`Cannot get user balance ${accountId} ${userAccount.address}`)
Expand All @@ -118,7 +116,7 @@ export class BotPayments {
this.logger.info(`User ${accountId} ${userAccount.address} transfer funds ${availableBalance.toFixed()} ONE to multisig wallet: ${this.holderAddress}...`)
await this.transferUserFundsToHolder(accountId, userAccount, availableBalance)
const { totalCreditsAmount } = await chatService.getUserCredits(accountId)
this.logger.info(`User ${accountId} ${userAccount.address} hot wallet funds "${availableBalance.toFixed()}" ONE transferred to holder address ${this.holderAddress}. ONE credits balance: ${totalCreditsAmount.toString()}.`)
this.logger.info(`User ${accountId} ${userAccount.address} hot wallet funds "${availableBalance.toFixed()}" ONE transferred to holder address ${this.holderAddress}. User credits balance: ${totalCreditsAmount.toString()}.`)
} catch (e) {
Sentry.captureException(e)
this.logger.error(
Expand Down

0 comments on commit c812f5b

Please sign in to comment.