-
Notifications
You must be signed in to change notification settings - Fork 758
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
logger, config, deprecate legacy tx #1302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly a bunch of nitpicks, main one is probably the one concerning doc generation visibility, in general lgtm.
I would also suggest adding a doc entry for the Guides
section, but that can also be added afterwards.
src/channel/rpc_0_6.ts
Outdated
@@ -448,6 +449,11 @@ export class RpcChannel { | |||
nonce: toHex(details.nonce), | |||
}, | |||
}); | |||
|
|||
logger.warn( | |||
'You are using deprecated transaction version (V0,V1,V2)!, \n Update to the latest V3 transactions!', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'You are using deprecated transaction version (V0,V1,V2)!, \n Update to the latest V3 transactions!', | |
'You are using a deprecated transaction version (V0,V1,V2)!\nUpdate to the latest V3 transactions!', |
Might also make sense to move the message into a const enum
so that it gets both defined in one place and inlined.
@@ -0,0 +1,63 @@ | |||
import { DEFAULT_GLOBAL_CONFIG } from './constants'; | |||
|
|||
type ConfigData = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worthwhile to interlace the keys with DEFAULT_GLOBAL_CONFIG
for IDE autocompletion but we can revisit that in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, I managed to break this one too in the late-night refactor
|
||
public get<K extends keyof ConfigData>( | ||
key: K, | ||
defaultValue?: ConfigData[K] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaultValue
parameter looks like it doesn't provide much utility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be useful sometimes; I'll leave that one.
/** | ||
* Logging class providing different levels of log | ||
*/ | ||
class Logger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably makes sense to export
so it is exposed to the documentation generator for the API
section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll just add manual docs because it could confuse some users in this case.
src/global/logger.ts
Outdated
try { | ||
formattedMessage += `\n${JSON.stringify(data, null, 2)}`; | ||
} catch (error) { | ||
formattedMessage += `\n[JSON.stringify Error/Circular]`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to propagate the error message since stringify
could also fail for e.g. bigint values in data.
src/global/logger.ts
Outdated
const logLevelStringKeys = Object.keys(LogLevelIndex).filter( | ||
(v) => Number.isNaN(Number(v)) && v !== 'OFF' | ||
); | ||
const logLevels = logLevelStringKeys.filter((s) => { | ||
return this.shouldLog(LogLevelIndex[s as LogLevel]); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Number.isNaN(Number(v))
check doesn't seem necessary so the two filters could be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover after refactoring from enum to const pattern
src/global/logger.type.ts
Outdated
|
||
export type LogLevelIndex = ValuesType<typeof LogLevelIndex>; | ||
|
||
export type LogLevel = keyof typeof LogLevelIndex & string & NonNullable<unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the & string & NonNullable<unknown>
segment can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you are right, it looks like autocomplete with the keyof typeof work without shenanigans.
# [6.23.0](v6.22.0...v6.23.0) (2025-01-29) ### Features * logger, config, deprecate legacy tx ([#1302](#1302)) ([d0ffbcc](d0ffbcc))
🎉 This PR is included in version 6.23.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Motivation and Resolution
Implement logger and config
deprecate warning for old transaction versions
Development related changes
Use logger for console logging
Use config for global configuration
Checklist: