-
Notifications
You must be signed in to change notification settings - Fork 8
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
SHARD-1708: Add network account listOfChanges update script #126
Conversation
…ling in GlobalAccount
} | ||
|
||
// Utility function to validate and parse input based on expected type | ||
const parseInput = (value: string, expectedType: string, defaultValue: any): any => { |
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 am not sure how I feel about assigning a defaultValue. If we're using this code to overwrite the network account, I somewhat feel that there should only be intentional and explicit changes.
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.
Clarifying... the question is should we treat the results differently if we ended up with value or defaultValue?
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 default values are there to make it quicker and easier to input values from the terminal. Users are always asked what they want to use as input, so the default values get replaced with whatever they enter. Of course, you can also tweak the inputs directly in the script if you wish. The parameters are completely flexible and can be changed as needed.
Right now, we’re keeping it simple by starting with just baselineNodes, minNodes, and maxNodes
console.log('❌ Changes were not applied.') | ||
} | ||
|
||
await dbstore.closeDatabase() |
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.
Should we have a try/finally setup here to ensure DB closure?
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.
added
const expectedType = typeof defaultConfig[section][key] | ||
const parsedValue = parseInput(value, expectedType, defaultConfig[section][key]) | ||
|
||
if (parsedValue !== defaultConfig[section][key] || value === '') { |
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.
parsedValue == defaultConfig[section][key]
this can be a genuine case right? I mean not an error. We can suppress this error or simply say you have not updated the value.
Also what's the purpose of value === ''
condition?
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 value === '' condition is checking for when the user just hits enter without typing anything, indicating they want to accept the default value.
let cycleNumberInput: number | ||
do { | ||
cycleNumberInput = parseInt( | ||
await askQuestion('Enter cycle number (must be less than the latest cycle number, latest cycle number is: ' + latestCycleNumber + '): '), |
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.
why this has to be lesser and greater? won't the change be applied in future cycles?
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.
This is implemented as per the ticket specification
…ount update script
Linear: https://linear.app/shm/issue/SHARD-1708
Summary: Add network account listOfChanges update script