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

rpc: Add default config options to settings. #1981

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

JoeGruffins
Copy link
Member

If user does not supply some default values over rpc when creating
wallets, use default values. Add the eth test token, zec, and doge to
the simnet client set up script.

This is mostly to assist testing on simnet.

@JoeGruffins
Copy link
Member Author

Inserting the defaults in core would be less code and more strait forward, but web already has these values saved and in the forms...

Comment on lines 8406 to 8687
// WalletDefinition gets the registered WalletDefinition for the asset and
// wallet type.
func walletDefinition(assetID uint32, walletType string) (*asset.WalletDefinition, error) {
func WalletDefinition(assetID uint32, walletType string) (*asset.WalletDefinition, error) {
Copy link
Member

@chappjc chappjc Dec 2, 2022

Choose a reason for hiding this comment

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

Kinda funky that this is a core function. It only uses the client/asset package internally, and it returns a client/asset type.
I think we should move this to client/asset.WalletDefinition

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved. But the function name mirrors the type name, so the function renamed to WalletDef

@JoeGruffins JoeGruffins force-pushed the adddefaulttorpc branch 2 times, most recently from 611f2fa to 78da726 Compare December 5, 2022 02:14
If user does not supply some default values over rpc when creating
wallets, use default values. Add the eth test token, zec, and doge to
the simnet client set up script.
@JoeGruffins
Copy link
Member Author

@chappjc chappjc self-requested a review December 5, 2022 15:55
Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

LGTM, with the one noted caveat regarding the correct way to go from a configopt item to a string in the map[string]string given to the wallet form.

// Apply default config options if they exist.
for _, opt := range walletDef.ConfigOpts {
if _, has := form.config[opt.Key]; !has && opt.DefaultValue != nil {
form.config[opt.Key] = fmt.Sprintf("%v", opt.DefaultValue)
Copy link
Member

Choose a reason for hiding this comment

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

fmt.Sprintf("%v", ...) should do the trick for all the types we give in DefaultValue, but in our other uses of this field (WalletConfigForm.map) we consider the other flags like isdateand repeatable. I don't feel like we need to replicate all that at this time though.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify, nothing to change unless another reviewer sees an issue related to this.

@chappjc chappjc merged commit e0ff921 into decred:master Dec 6, 2022
@chappjc chappjc added this to the 0.6 milestone Dec 27, 2022
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.

3 participants