Skip to content

Commit 2016736

Browse files
committed
fix: remove module level loggers that were not updated if sdk logger is updated after import
1 parent cc83252 commit 2016736

File tree

12 files changed

+65
-67
lines changed

12 files changed

+65
-67
lines changed

packages/access-control-conditions/src/lib/hashing.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { InvalidAccessControlConditions } from '@lit-protocol/constants';
2-
import { getChildLogger } from '@lit-protocol/logger';
2+
import { logger } from '@lit-protocol/logger';
33
import {
44
AccessControlConditions,
55
EvmContractConditions,
@@ -19,8 +19,6 @@ import {
1919
canonicalUnifiedAccessControlConditionFormatter,
2020
} from './canonicalFormatter';
2121

22-
const logger = getChildLogger({ module: 'hashing' });
23-
2422
// Same as:
2523
// const unifiedAccs = [
2624
// {

packages/access-control-conditions/src/lib/humanizer.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
LitEVMChainKeys,
88
InvalidUnifiedConditionType,
99
} from '@lit-protocol/constants';
10-
import { getChildLogger } from '@lit-protocol/logger';
10+
import { logger } from '@lit-protocol/logger';
1111
import {
1212
AccessControlConditions,
1313
AccsCOSMOSParams,
@@ -17,8 +17,6 @@ import {
1717
UnifiedAccessControlConditions,
1818
} from '@lit-protocol/types';
1919

20-
const logger = getChildLogger({ module: 'humanizer' });
21-
2220
export const ERC20ABI = [
2321
{
2422
constant: true,

packages/auth/src/lib/authenticators/metamask/eth.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
LIT_CHAINS_KEYS,
2828
} from '@lit-protocol/constants';
2929
import { validateSessionSig } from '@lit-protocol/lit-node-client';
30-
import { getChildLogger } from '@lit-protocol/logger';
30+
import { getChildLogger, logger } from '@lit-protocol/logger';
3131
import {
3232
getStorageItem,
3333
setStorageItem,
@@ -38,7 +38,6 @@ import { AuthCallbackParams, AuthSig } from '@lit-protocol/types';
3838
import LitConnectModal from './connect-modal/modal';
3939

4040
const deprecated = depd('lit-js-sdk:auth:metamask-authenticator:index');
41-
const logger = getChildLogger({ module: 'eth' });
4241

4342
if (globalThis && typeof globalThis.Buffer === 'undefined') {
4443
globalThis.Buffer = BufferPolyfill;
@@ -237,10 +236,11 @@ export const getMustResign = (
237236
);
238237
mustResign = true;
239238
}
240-
} catch (e) {
239+
} catch (error) {
241240
logger.error({
241+
function: 'getMustResign',
242242
msg: 'error parsing siwe sig. Making the user sign again',
243-
e,
243+
error,
244244
});
245245
mustResign = true;
246246
}
@@ -335,11 +335,11 @@ export const connectWeb3 = async ({
335335
);
336336
// @ts-expect-error provider is not typed
337337
await provider.enable();
338-
} catch (e) {
339-
logger.info(
340-
"error enabling provider but swallowed it because it's not important. most wallets use a different function now to enable the wallet so you can ignore this error, because those other methods will be tried.",
341-
e
342-
);
338+
} catch (error) {
339+
logger.info({
340+
msg: "error enabling provider but swallowed it because it's not important. Most wallets use a different function now to enable the wallet so you can ignore this error, those other methods will be tried.",
341+
error,
342+
});
343343
}
344344

345345
logger.info('listing accounts');
@@ -398,10 +398,11 @@ export const checkAndSignEVMAuthMessage = async ({
398398
walletConnectProjectId,
399399
nonce,
400400
}: AuthCallbackParams): Promise<AuthSig> => {
401+
const logger = getChildLogger({ function: 'checkAndSignEVMAuthMessage' });
401402
// -- check if it's Node.js
402403
if (Environment.isNode) {
403404
logger.info(
404-
'checkAndSignEVMAuthMessage is not supported in nodejs. You can create a SIWE on your own using the SIWE package.'
405+
'checkAndSignEVMAuthMessage is not supported in nodejs. You can create a SIWE on your own using the SIWE package.'
405406
);
406407
return {
407408
sig: '',
@@ -509,10 +510,10 @@ export const checkAndSignEVMAuthMessage = async ({
509510
logger.info('checking if sig is in local storage');
510511
const authSigString = getStorageItem(LOCAL_STORAGE_KEYS.AUTH_SIGNATURE);
511512
authSig = JSON.parse(authSigString);
512-
} catch (e) {
513+
} catch (error) {
513514
logger.warn({
514515
msg: 'Could not get sig from local storage',
515-
error: e,
516+
error,
516517
});
517518
}
518519

@@ -789,7 +790,7 @@ export const signMessageAsync = async (
789790
): Promise<any | JsonRpcSigner> => {
790791
// check if it's nodejs
791792
if (Environment.isNode) {
792-
logger.info('signMessageAsync is not supported in nodejs.');
793+
logger.warn('signMessageAsync is not supported in nodejs.');
793794
return null;
794795
}
795796

@@ -803,14 +804,16 @@ export const signMessageAsync = async (
803804
address.toLowerCase(),
804805
]);
805806
return signature;
806-
} catch (e: any) {
807-
logger.info(
808-
'Signing with personal_sign failed, trying signMessage as a fallback'
809-
);
810-
if (e.message.includes('personal_sign')) {
807+
} catch (error: any) {
808+
logger.warn({
809+
function: 'signMessageAsync',
810+
msg: 'Signing with personal_sign failed, trying signMessage as a fallback',
811+
error,
812+
});
813+
if (error.message.includes('personal_sign')) {
811814
return await signer.signMessage(messageBytes);
812815
}
813-
throw e;
816+
throw error;
814817
}
815818
} else {
816819
logger.info('signing with signMessage');

packages/auth/src/lib/authenticators/validators.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { getChildLogger } from '@lit-protocol/logger';
22
import { MintRequestBody } from '@lit-protocol/types';
33

4-
const logger = getChildLogger({ module: 'validators' });
5-
64
export const validateMintRequestBody = (
75
customArgs: Partial<MintRequestBody>
86
): boolean => {
7+
const logger = getChildLogger({ function: 'validateMintRequestBody' });
98
let isValid = true;
109
const validKeys = [
1110
'keyType',
@@ -83,7 +82,7 @@ export const validateMintRequestBody = (
8382
))
8483
) {
8584
logger.error(
86-
'Invalid type for permittedAuthMethodScopes: expected an array of arrays of numberr.'
85+
'Invalid type for permittedAuthMethodScopes: expected an array of arrays of number.'
8786
);
8887
isValid = false;
8988
}

packages/contracts-sdk/src/lib/helpers/addresses.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import {
1212
ParamsMissingError,
1313
} from '@lit-protocol/constants';
1414
import { publicKeyCompress } from '@lit-protocol/crypto';
15-
import { getChildLogger } from '@lit-protocol/logger';
15+
import { logger } from '@lit-protocol/logger';
1616
import { getStorageItem, setStorageItem } from '@lit-protocol/misc-browser';
1717
import { DerivedAddresses } from '@lit-protocol/types';
1818

19-
const logger = getChildLogger({ module: 'addresses' });
20-
2119
/**
2220
* Derives a Bitcoin address (P2PKH) from a public key.
2321
*
@@ -188,6 +186,7 @@ export const derivedAddresses = async (
188186
}
189187
} catch (e) {
190188
logger.error({
189+
function: 'derivedAddresses',
191190
msg: `Could not get ${CACHE_KEY} from storage. Continuing...`,
192191
error: e,
193192
});
@@ -235,6 +234,7 @@ export const derivedAddresses = async (
235234
setStorageItem(CACHE_KEY, JSON.stringify(cachedPkpJSON));
236235
} catch (e) {
237236
logger.error({
237+
function: 'derivedAddresses',
238238
msg: `Could not get ${CACHE_KEY} from storage. Continuing...`,
239239
error: e,
240240
});

packages/crypto/src/lib/crypto.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
UnknownError,
1212
UnknownSignatureError,
1313
} from '@lit-protocol/constants';
14-
import { getChildLogger } from '@lit-protocol/logger';
14+
import { logger } from '@lit-protocol/logger';
1515
import { getStorageItem, setStorageItem } from '@lit-protocol/misc-browser';
1616
import { NodeAttestation, SessionKeyPair, SigShare } from '@lit-protocol/types';
1717
import {
@@ -28,8 +28,6 @@ import {
2828
sevSnpVerify,
2929
} from '@lit-protocol/wasm';
3030

31-
const logger = getChildLogger({ module: 'crypto' });
32-
3331
/** ---------- Exports ---------- */
3432
const LIT_CORS_PROXY = `https://cors.litgateway.com`;
3533

@@ -409,21 +407,26 @@ async function getAmdCert(url: string): Promise<Uint8Array> {
409407

410408
try {
411409
return await fetchAsUint8Array(proxyUrl);
412-
} catch (e) {
413-
logger.info({
414-
msg: `[getAmdCert] Failed to fetch AMD cert from proxy:`,
415-
e,
410+
} catch (error) {
411+
logger.error({
412+
function: 'getAmdCert',
413+
msg: `Failed to fetch AMD cert from proxy`,
414+
error,
416415
});
417416
}
418417

419418
// Try direct fetch only if proxy fails
420-
logger.info('[getAmdCert] Attempting to fetch directly without proxy.');
419+
logger.info('Attempting to fetch directly without proxy.');
421420

422421
try {
423422
return await fetchAsUint8Array(url);
424-
} catch (e) {
425-
logger.error({ msg: '[getAmdCert] Direct fetch also failed', e });
426-
throw e; // Re-throw to signal that both methods failed
423+
} catch (error) {
424+
logger.error({
425+
function: 'getAmdCert',
426+
msg: 'Direct fetch also failed',
427+
error,
428+
});
429+
throw error; // Re-throw to signal that both methods failed
427430
}
428431
}
429432

packages/lit-node-client/src/lib/helpers/get-signatures.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ import {
99
} from '@lit-protocol/constants';
1010
import { mostCommonValue } from '@lit-protocol/core';
1111
import { combineEcdsaShares } from '@lit-protocol/crypto';
12-
import { getChildLogger } from '@lit-protocol/logger';
12+
import { logger } from '@lit-protocol/logger';
1313
import {
1414
EcdsaSignedMessageShareParsed,
1515
SigResponse,
1616
} from '@lit-protocol/types';
1717

18-
const logger = getChildLogger({ module: 'get-signatures' });
19-
2018
/**
2119
* Retrieves and combines signature shares from multiple nodes to generate the final signatures.
2220
*
@@ -54,6 +52,7 @@ export const getSignatures = async (params: {
5452

5553
if (signedMessageShares.length < threshold) {
5654
logger.error({
55+
function: 'getSignatures',
5756
requestId,
5857
msg: `not enough nodes to get the signatures. Expected ${threshold}, got ${signedMessageShares.length}`,
5958
});
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { getChildLogger } from '@lit-protocol/logger';
2-
3-
const logger = getChildLogger({ module: 'parseAsJsonOrString' });
1+
import { logger } from '@lit-protocol/logger';
42

53
/**
64
* Parses a response string into a JS object.
@@ -14,10 +12,11 @@ export const parseAsJsonOrString = (
1412
try {
1513
return JSON.parse(responseString);
1614
} catch (e) {
17-
logger.info(
18-
'[parseResponses] Error parsing response as json. Swallowing and returning as string.',
19-
responseString
20-
);
15+
logger.warn({
16+
function: 'parseAsJsonOrString',
17+
msg: 'Error parsing response as json. Swallowing and returning as string.',
18+
responseString,
19+
});
2120
return responseString;
2221
}
2322
};

packages/lit-node-client/src/lib/helpers/process-lit-action-response-strategy.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import { getChildLogger } from '@lit-protocol/logger';
1+
import { logger } from '@lit-protocol/logger';
22
import { LitActionResponseStrategy, NodeShare } from '@lit-protocol/types';
33

4-
const logger = getChildLogger({
5-
module: 'process-lit-action-response-strategy',
6-
});
7-
84
/**
95
* Finds the most and least common object within an of objects array
106
* @param responses T[]
@@ -44,6 +40,7 @@ export const processLitActionResponseStrategy = (
4440
}
4541
} catch (e) {
4642
logger.error({
43+
function: 'processLitActionResponseStrategy',
4744
msg: 'Error while executing custom response filter, defaulting to most common',
4845
error: (e as Error).toString(),
4946
});

packages/lit-node-client/src/lib/helpers/session-sigs-reader.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { InvalidArgumentException } from '@lit-protocol/constants';
2-
import { getChildLogger } from '@lit-protocol/logger';
2+
import { logger } from '@lit-protocol/logger';
33

44
import { parseSignedMessage } from './session-sigs-validator';
55

6-
const logger = getChildLogger({ module: 'serssion-sigs-reader' });
7-
86
function formatDuration(start: Date, end: Date): string {
97
const diff = end.getTime() - start.getTime();
108
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
@@ -132,6 +130,7 @@ export function formatSessionSigs(
132130
} catch (e) {
133131
// swallow error
134132
logger.info({
133+
function: 'formatSessionSigs',
135134
msg: 'Error parsing attenuation',
136135
error: e,
137136
});

0 commit comments

Comments
 (0)