-
Notifications
You must be signed in to change notification settings - Fork 290
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
add backward compatibility for AccountProviderConfig #3633
add backward compatibility for AccountProviderConfig #3633
Conversation
add serde default for AccountProviderConfig's field named from_env
Codecov Report
@@ Coverage Diff @@
## master #3633 +/- ##
==========================================
- Coverage 28.76% 28.70% -0.06%
==========================================
Files 591 591
Lines 50428 50573 +145
Branches 23766 23849 +83
==========================================
+ Hits 14503 14511 +8
- Misses 21742 21825 +83
- Partials 14183 14237 +54
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
另一个参数 secret_file 是不是也要加一下 ? |
@@ -25,6 +25,7 @@ pub struct AccountProviderConfig { | |||
pub secret_file: Option<PathBuf>, | |||
|
|||
/// Read private from env variable `STARCOIN_PRIVATE_KEY`. | |||
#[serde(default)] |
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.
这个是不是应该设置成 Optoin, 然后加上
#[serde(skip_serializing_if = "Option::is_none")]
这样默认就不会变更配置文件。
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 what #[serde(skip_serializing_if)] does
Call a function to determine whether to skip serializing this field. The given function must be callable as fn(&T) -> bool, although it may be generic over T. For example skip_serializing_if = "Option::is_none" would skip an Option that is None.
Change the type to Option is a choice, but seem like there is no need to change a boolean value to Option, right?
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.
有一些区别。bool 会默认序列化成 false 写到配置中。但使用的时候需要指定 --from-env true
, 我们有一部分 bool 的 CLI 选项用的是 Option。不过 from-env 这个在配置文件中应该用不到,默认序列化成 false 也没问题。
@JerryKwan 给这个加上
吧 |
add skip_serializing_if to secret_file
@jolestar @0xpause #[serde(skip_serializing_if = "Option::is_none")] added to secret_file |
add serde default for AccountProviderConfig's field named from_env
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #3630
What is the new behavior?
backward to old version of config.toml
Other information