Skip to content
Closed
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
11 changes: 10 additions & 1 deletion packages/adapters/cache/src/lib/caches/cache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import Redis from 'ioredis';
import { Logger } from '@chimera-monorepo/utils';

import { CacheParams, RedisClearFailure } from '../entities';

/**
* @classdesc Manages storage, updates, and retrieval of a set of data determined by use-case.
*/
const logger = new Logger({
level: 'info',
name: 'cache',
formatters: {
level: (label) => ({ level: label.toUpperCase() }),
},
});

export abstract class Cache {
protected readonly data!: Redis;

Expand All @@ -22,7 +31,7 @@ export abstract class Cache {
});
// Handle Redis connection errors to prevent unhandled exceptions
this.data.on('error', (err) => {
console.error('Redis connection error:', err);
logger.error('Redis connection error', undefined, undefined, undefined, { error: err });
});
Comment on lines 33 to 35
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger.error sets error from its 4th argument and overwrites any ctx.error. Because the 4th argument is undefined here, the Redis error won’t be captured. Pass jsonifyError(err as Error) as the 4th param (and keep extra fields in the final context param).

Copilot uses AI. Check for mistakes.
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/chainservice/src/aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class RpcProviderAggregator {
* @returns The TransactionResponse.
*/
public async sendTransaction(transaction: OnchainTransaction) {
console.log(`=== sendTransaction called with domain ${this.domain} ===`);
this.logger.debug(`sendTransaction called with domain ${this.domain}`);
this.checkSigner();

const toSend = {
Expand Down
6 changes: 3 additions & 3 deletions packages/adapters/chainservice/src/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export class TransactionDispatch {
* @returns A list of receipts or errors that occurred for each.
*/
public async send(minTx: WriteTransaction, context: RequestContext): Promise<ITransactionReceipt> {
console.log(`=== DISPATCH SEND called for domain ${this.domain} ===`);
this.logger.debug(`Dispatch send called for domain ${this.domain}`);
const method = this.send.name;
const { requestContext, methodContext } = createLoggingContext(method, context);
const txsId = getUuid();
Expand Down Expand Up @@ -544,7 +544,7 @@ export class TransactionDispatch {
* @param transaction - OnchainTransaction object to modify based on submit result.
*/
private async submit(transaction: OnchainTransaction) {
console.log(`=== DISPATCH SUBMIT called for domain ${this.domain} ===`);
this.logger.debug(`Dispatch submit called for domain ${this.domain}`);
const method = this.submit.name;
const { requestContext, methodContext } = createLoggingContext(method, transaction.context);
this.logger.debug('Method start', requestContext, methodContext, {
Expand All @@ -562,7 +562,7 @@ export class TransactionDispatch {

// Send the tx.
try {
console.log(`=== DISPATCH SUBMIT about to call sendTransaction ===`);
this.logger.debug('Dispatch submit about to call sendTransaction');
const response = await this.rpcProvider.sendTransaction(transaction);
// Add this response to our local response history.
if (transaction.hashes.includes(response.hash)) {
Expand Down
15 changes: 11 additions & 4 deletions packages/adapters/chainservice/src/shared/rpc/eth/provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { EverclearError, delay, domainToChainId, parseHostname, ERC20Abi } from '@chimera-monorepo/utils';
import { EverclearError, Logger, delay, domainToChainId, parseHostname, ERC20Abi } from '@chimera-monorepo/utils';
import { chainWrapper, type PublicClient } from '@chimera-monorepo/utils';

const ethProviderLogger = new Logger({
level: 'debug',
name: 'eth-provider',
formatters: {
level: (label) => ({ level: label.toUpperCase() }),
},
});

import { parseError, RpcError, ServerError, StallTimeout } from '../../errors';
import { ISigner, ReadTransaction, WriteTransaction, ITransactionReceipt, ITransactionResponse, IBlock } from '../../types';
Comment on lines +4 to 13
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s an import statement after executable code (const ethProviderLogger = ...). TypeScript/ESM requires all imports to be at the top level before other statements, so this will not compile. Move the ethProviderLogger initialization below the last import (or convert the later imports into the initial import block).

Copilot uses AI. Check for mistakes.
import { RpcProvider } from '..';
Expand Down Expand Up @@ -144,7 +152,7 @@ class BaseSyncProvider {
try {
sendTimestamp = Date.now();
this.cpsTimestamps.push(sendTimestamp);
console.log(`=== ETH PROVIDER SEND called with method: ${method}, domain: ${this.domain}, params:`, params);
this.debugLog('ETH_PROVIDER_SEND', method, this.domain, params);
return await Promise.race(
[
new Promise(async (resolve, reject) => {
Expand Down Expand Up @@ -248,8 +256,7 @@ class BaseSyncProvider {

private debugLog(message: string, ...args: unknown[]) {
if (this.debugLogging) {
// eslint-disable-next-line
console.log(`[${Date.now()}]`, `(${this.name})`, message, ...args);
ethProviderLogger.debug(`(${this.name}) ${message}`, undefined, undefined, { args });
}
}

Expand Down
Loading
Loading