Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/integration/checkout/services/checkout.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export class CheckoutService {
this.checkout = new Checkout();
}

isAvailable(): boolean {
return process.env.CKO_SECRET_KEY != null && Config.checkout.entityId != null;
}

async createPaymentLink(
remittanceInfo: string,
fiatAmount: number,
Expand Down
7 changes: 6 additions & 1 deletion src/integration/exchange/services/exchange-tx.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { ExchangeRegistryService } from './exchange-registry.service';
export class ExchangeTxService {
private readonly logger = new DfxLogger(ExchangeTxService);

private readonly syncWarningsLogged = new Set<string>();

constructor(
private readonly exchangeTxRepo: ExchangeTxRepository,
private readonly registryService: ExchangeRegistryService,
Expand Down Expand Up @@ -171,7 +173,10 @@ export class ExchangeTxService {

return transactions;
} catch (e) {
this.logger.error(`Failed to synchronize transactions from ${sync.exchange}:`, e);
if (!this.syncWarningsLogged.has(sync.exchange)) {
this.logger.warn(`Failed to synchronize transactions from ${sync.exchange}:`, e);
this.syncWarningsLogged.add(sync.exchange);
}
}

return [];
Expand Down
10 changes: 10 additions & 0 deletions src/subdomains/core/monitoring/observers/checkout.observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface CheckoutData {
export class CheckoutObserver extends MetricObserver<CheckoutData[]> {
protected readonly logger = new DfxLogger(CheckoutObserver);

private unavailableWarningLogged = false;

constructor(
monitoringService: MonitoringService,
private readonly checkoutService: CheckoutService,
Expand All @@ -30,6 +32,14 @@ export class CheckoutObserver extends MetricObserver<CheckoutData[]> {

@DfxCron(CronExpression.EVERY_MINUTE, { process: Process.MONITORING, timeout: 1800 })
async fetch() {
if (!this.checkoutService.isAvailable()) {
if (!this.unavailableWarningLogged) {
this.logger.warn('Checkout not configured - skipping fetch');
this.unavailableWarningLogged = true;
}
return [];
}

const data = await this.getCheckout();

this.emit(data);
Expand Down
4 changes: 2 additions & 2 deletions src/subdomains/core/monitoring/observers/payment.observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export class PaymentObserver extends MetricObserver<PaymentData> {
return {
buyCrypto: await this.repos.buyCrypto
.findOne({ where: {}, order: { outputDate: 'DESC' } })
.then((b) => b.outputDate),
buyFiat: await this.repos.buyFiat.findOne({ where: {}, order: { outputDate: 'DESC' } }).then((b) => b.outputDate),
.then((b) => b?.outputDate),
buyFiat: await this.repos.buyFiat.findOne({ where: {}, order: { outputDate: 'DESC' } }).then((b) => b?.outputDate),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { Util } from 'src/shared/utils/util';
export class PaymentBalanceService implements OnModuleInit {
private readonly logger = new DfxLogger(PaymentBalanceService);

private readonly unavailableWarningsLogged = new Set<Blockchain>();

private readonly chainsWithoutPaymentBalance = [
Blockchain.LIGHTNING,
Blockchain.MONERO,
Expand Down Expand Up @@ -65,17 +67,27 @@ export class PaymentBalanceService implements OnModuleInit {
await Promise.all(
groupedAssets.map(async ([chain, assets]) => {
const client = this.blockchainRegistryService.getClient(chain);
if (!client) {
if (!this.unavailableWarningsLogged.has(chain)) {
this.logger.warn(`Blockchain client not configured for ${chain} - skipping payment balance`);
this.unavailableWarningsLogged.add(chain);
}
return;
}

const targetAddress = this.getDepositAddress(chain);
if (!targetAddress) return;

const coin = assets.find((a) => a.type === AssetType.COIN);
const tokens = assets.filter((a) => a.type !== AssetType.COIN);

balanceMap.set(coin.id, {
owner: targetAddress,
contractAddress: coin.chainId,
balance: await client.getNativeCoinBalanceForAddress(targetAddress),
});
if (coin) {
balanceMap.set(coin.id, {
owner: targetAddress,
contractAddress: coin.chainId,
balance: await client.getNativeCoinBalanceForAddress(targetAddress),
});
}

if (tokens.length) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export class BankTxService implements OnModuleInit {
private readonly logger = new DfxLogger(BankTxService);
private readonly bankBalanceSubject: Subject<BankBalanceUpdate> = new Subject<BankBalanceUpdate>();

private olkyUnavailableWarningLogged = false;

constructor(
private readonly bankTxRepo: BankTxRepository,
private readonly bankTxBatchRepo: BankTxBatchRepository,
Expand Down Expand Up @@ -164,7 +166,10 @@ export class BankTxService implements OnModuleInit {

const olkyBank = await this.bankService.getBankInternal(IbanBankName.OLKY, 'EUR');
if (!olkyBank) {
this.logger.warn('Olky bank not configured - skipping checkTransactions');
if (!this.olkyUnavailableWarningLogged) {
this.logger.warn('Olky bank not configured - skipping checkTransactions');
this.olkyUnavailableWarningLogged = true;
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { CheckoutTxService } from './checkout-tx.service';
export class FiatPayInSyncService {
private readonly logger = new DfxLogger(FiatPayInSyncService);

private unavailableWarningLogged = false;

constructor(
private readonly checkoutService: CheckoutService,
private readonly checkoutTxRepo: CheckoutTxRepository,
Expand All @@ -32,6 +34,14 @@ export class FiatPayInSyncService {

@DfxCron(CronExpression.EVERY_MINUTE, { process: Process.FIAT_PAY_IN, timeout: 1800 })
async syncCheckout() {
if (!this.checkoutService.isAvailable()) {
if (!this.unavailableWarningLogged) {
this.logger.warn('Checkout not configured - skipping syncCheckout');
this.unavailableWarningLogged = true;
}
return;
}

const syncDate = await this.checkoutTxService.getSyncDate();
const payments = await this.checkoutService.getPayments(syncDate);

Expand Down
9 changes: 9 additions & 0 deletions src/subdomains/supporting/log/log-job.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import { LogService } from './log.service';
export class LogJobService {
private readonly logger = new DfxLogger(LogJobService);

private readonly unavailableClientWarningsLogged = new Set<Blockchain>();

constructor(
private readonly tradingRuleService: TradingRuleService,
private readonly assetService: AssetService,
Expand Down Expand Up @@ -218,6 +220,13 @@ export class LogJobService {
Array.from(customAssetMap.entries()).map(async ([b, a]) => {
try {
const client = this.blockchainRegistryService.getClient(b);
if (!client) {
if (!this.unavailableClientWarningsLogged.has(b)) {
this.logger.warn(`Blockchain client not configured for ${b} - skipping custom balances`);
this.unavailableClientWarningsLogged.add(b);
}
return { blockchain: b, balances: [] };
}

const balances = await this.getCustomBalances(client, a, Config.financialLog.customAddresses).then((b) =>
b.flat(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export class BitcoinStrategy extends PollingStrategy {

@Inject() private readonly depositService: DepositService;

private unavailableWarningLogged = false;

constructor(private readonly payInBitcoinService: PayInBitcoinService) {
super();
}
Expand All @@ -32,7 +34,10 @@ export class BitcoinStrategy extends PollingStrategy {
@DfxCron(CronExpression.EVERY_SECOND, { process: Process.PAY_IN, timeout: 7200 })
async checkPayInEntries(): Promise<void> {
if (!this.payInBitcoinService.isAvailable()) {
this.logger.warn('Bitcoin node not configured - skipping checkPayInEntries');
if (!this.unavailableWarningLogged) {
this.logger.warn('Bitcoin node not configured - skipping checkPayInEntries');
this.unavailableWarningLogged = true;
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class TransactionHelper implements OnModuleInit {

private readonly addressBalanceCache = new AsyncCache<number>(CacheItemResetPeriod.EVERY_HOUR);
private readonly user30dVolumeCache = new AsyncCache<number>(CacheItemResetPeriod.EVERY_HOUR);
private readonly unavailableClientWarningsLogged = new Set<Blockchain>();

private transactionSpecifications: TransactionSpecification[];

Expand Down Expand Up @@ -606,6 +607,14 @@ export class TransactionHelper implements OnModuleInit {

try {
const client = this.blockchainRegistryService.getClient(to.blockchain);
if (!client) {
if (!this.unavailableClientWarningsLogged.has(to.blockchain)) {
this.logger.warn(`Blockchain client not configured for ${to.blockchain} - skipping network start fee`);
this.unavailableClientWarningsLogged.add(to.blockchain);
}
return 0;
}

const userBalance = await this.addressBalanceCache.get(`${user.address}-${to.blockchain}`, () =>
client.getNativeCoinBalanceForAddress(user.address),
);
Expand Down