Skip to content
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

Merged
merged 2 commits into from
Jan 17, 2025
Merged

Conversation

S0naliThakur
Copy link
Member

Linear: https://linear.app/shm/issue/SHARD-1708
Summary: Add network account listOfChanges update script

}

// Utility function to validate and parse input based on expected type
const parseInput = (value: string, expectedType: string, defaultValue: any): any => {
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Member Author

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()
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

added

urnotsam
urnotsam previously approved these changes Jan 13, 2025
@justin-shardeum justin-shardeum dismissed urnotsam’s stale review January 13, 2025 20:38

He approved by accident

const expectedType = typeof defaultConfig[section][key]
const parsedValue = parseInput(value, expectedType, defaultConfig[section][key])

if (parsedValue !== defaultConfig[section][key] || value === '') {

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?

Copy link
Member Author

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 + '): '),

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?

Copy link
Member Author

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

@urnotsam urnotsam merged commit 424925f into dev Jan 17, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants