Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary remove invoice for hot wallet transfers #315

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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