Skip to content

Commit 7ab0f9c

Browse files
committed
chore: fix debug log %s formatting
Ticket: WP-00000
1 parent 8f8da0f commit 7ab0f9c

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/api/enclaved/signMultisigTransaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { KmsClient } from '../../kms/kmsClient';
2-
import { RequestTracer, TransactionPrebuild } from 'bitgo';
2+
import { TransactionPrebuild } from 'bitgo';
33
import logger from '../../logger';
44
import { EnclavedApiSpecRouteRequest } from '../../enclavedBitgoExpress/routers/enclavedApiSpec';
55

src/logger.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,17 @@ winston.addColors(colors);
3232
const format = winston.format.combine(
3333
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),
3434
winston.format.colorize({ all: true }),
35-
winston.format.printf(
36-
(info: winston.Logform.TransformableInfo) => `${info.timestamp} ${info.level}: ${info.message}`,
37-
),
35+
winston.format.printf((info: winston.Logform.TransformableInfo) => {
36+
// Handle both string interpolation and object logging
37+
const message = typeof info.message === 'string' ? info.message : JSON.stringify(info.message);
38+
39+
// If there are additional arguments, format them
40+
const args = (info[Symbol.for('splat')] as any[]) || [];
41+
const formattedMessage =
42+
args.length > 0 ? message.replace(/%s/g, () => String(args.shift() || '')) : message;
43+
44+
return `${info.timestamp} ${info.level}: ${formattedMessage}`;
45+
}),
3846
);
3947

4048
// Define which transports the logger must use

src/masterBitgoExpress/handleSendMany.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { RequestTracer, PrebuildTransactionOptions, Memo } from '@bitgo/sdk-core';
2-
import { BitGoRequest } from '../types/request';
32
import { createEnclavedExpressClient } from './enclavedExpressClient';
43
import logger from '../logger';
54
import { MasterApiSpecRouteRequest } from './routers/masterApiSpec';
5+
import { isMasterExpressConfig } from '../config';
66

77
/**
88
* Defines the structure for a single recipient in a send-many transaction.
@@ -18,6 +18,9 @@ interface Recipient {
1818
}
1919

2020
export async function handleSendMany(req: MasterApiSpecRouteRequest<'v1.wallet.sendMany', 'post'>) {
21+
if (!isMasterExpressConfig(req.config)) {
22+
throw new Error('Configuration must be in master express mode');
23+
}
2124
const enclavedExpressClient = createEnclavedExpressClient(req.config, req.params.coin);
2225
if (!enclavedExpressClient) {
2326
throw new Error('Please configure enclaved express configs to sign the transactions.');
@@ -35,10 +38,10 @@ export async function handleSendMany(req: MasterApiSpecRouteRequest<'v1.wallet.s
3538
throw new Error(`Wallet ${walletId} not found`);
3639
}
3740

38-
// @ts-ignore
39-
if (wallet.type() !== 'cold' || wallet.subType() !== 'onPrem') {
40-
throw new Error('Wallet is not an on-prem wallet');
41-
}
41+
// TODO: uncomment when on-prem type is added to SDK
42+
// if (wallet.type() !== 'cold' || wallet.subType() !== 'onPrem') {
43+
// throw new Error('Wallet is not an on-prem wallet');
44+
// }
4245

4346
// Get the signing keychains
4447
const signingKeychains = await baseCoin.keychains().getKeysForSigning({

0 commit comments

Comments
 (0)