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

fix cli opts bug with multiple accountOptions #250

Merged
merged 5 commits into from
Oct 21, 2024
Merged

Conversation

mixmix
Copy link
Contributor

@mixmix mixmix commented Oct 3, 2024

tiny PRs!

Comment on lines -23 to -24
.addOption(accountOption())
.addOption(endpointOption())
Copy link
Contributor Author

@mixmix mixmix Oct 3, 2024

Choose a reason for hiding this comment

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

THIS was a squirrely bug - tj/commander.js#2260

selectedAccount: account
})
}
.argParser(addressOrName => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 - this cannot be async!

See comments

Comment on lines +76 to +89
export async function setSelectedAccount (account: EntropyAccountConfig, configPath = CONFIG_PATH) {
const storedConfig = await get(configPath)

if (storedConfig.selectedAccount === account.name) return storedConfig
// no need for update

const newConfig = {
...storedConfig,
selectedAccount: account.name
}
await set(newConfig, configPath)
return newConfig
}

Copy link
Contributor Author

@mixmix mixmix Oct 3, 2024

Choose a reason for hiding this comment

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

🔥 one bug I saw was inconsistent setting of config.selectedAccount as account.name OR account.address

I decided to fix it to be name because then in the --help you will see e.g (default: naynay) instead of (default: 0x12312231231232) 💀

I then changed

  • accountOption to deal with name
  • added a special method setSelectedAccount to handle the persistence of the right thing

Things I'm not happy about 1. repeated `config.get`... 2. this is all gonna be a pain when we want to add `-c, --config ` 3. `src/account/utils.js` still has hard-coded `config.set` for `selectedAccount` because... we need to persist the whole config anyway...

@mixmix mixmix requested a review from rh0delta October 14, 2024 00:49
@mixmix mixmix mentioned this pull request Oct 14, 2024
@rh0delta
Copy link
Contributor

@mixmix you able to update this PR and rebase off of the current version of dev? can complete my full review after that's done.

@mixmix
Copy link
Contributor Author

mixmix commented Oct 20, 2024

@rh0delta merged in dev (not doing rebase because our merge/squash strategy makes rebasing a sad time)

@rh0delta rh0delta merged commit a3950e1 into dev Oct 21, 2024
2 checks passed
@rh0delta rh0delta deleted the mixmix/fix-cli-opts branch October 21, 2024 18:04
@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants