Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(wallet): add update seed storage password rpc #2317
base: dev
Are you sure you want to change the base?
feat(wallet): add update seed storage password rpc #2317
Changes from 7 commits
dc16267
4a536c6
5f7830e
cfd85b8
6d798a8
a34ac6b
cda913d
9e50c9f
b02c3f4
509ced8
0f15020
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
reference to this comment #2317 (comment)
Such result representation confuses, I suggest to return just Ok(()) from
update_seed_storage_password_rpc
if success.Or please explain why
SeedPasswordUpdateResponse
with successful: bool is preferable, if I missed the point.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 don't want to return a null value for 200 status rpc response hence why I'm returning successful which is better than
null
I will update the type field to be of type
result: String
instead(looks like a convention already) 9e50c9fThere 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.
well at least string is better then bool
upd: probably worth, string has "infinite" display variants
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 can see we normally return
result: "Success"
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.
string type can have any msg, its not strict type
Not the best choice for successful result
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 guess some existing new rpcs are not used by the GUI yet, so we could change them
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.
@borngraced We should provide new type which is supposed to show successful operation and if there is no need to return other info.
Provided by dimxy here #2317 (comment)
Ok(KdfSuccessRes) is supposed to be used instead of Ok(()), so response will be
at least for update storage password RPCs such approach should be used
@dimxy maybe, but if such RPCs are already in master, then it would be a breaking change, right? Even if some of these RPCs are quite new. I suggest checking if there are any other new RPCs still in dev branch and not in master. If everything is already in master, I don't think we should touch it.
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.
BTW we already have this in code:
pub struct SuccessResponse(&'static str);
which for empty results produces this json:
{"mmrpc":"2.0","result":"success","id":null}
Actually we have yet another empty 'success' result:
pub async fn update_nft(ctx: MmArc, req: UpdateNftReq) -> MmResult<(), UpdateNftError>
which gives json:
{"mmrpc":"2.0","result": null, "id":null}
I think I like this one most of all because it provides simplest deserialisation (no need to switch between object or string for "result" 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.
done
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.
Could you return just Ok(()) pls, as in the end @dimxy came to conclusion that he prefers
MmResult<(), Err>
more (what I suggested to have at the beginning)string is still not a strict type in the response. In such rpcs like update, the 200 status is actually what is expected.
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.
We agreed not to describe function parameters in the function documentation.
Instead, provide documentation for the parameter types themselves (e.g. above SeedPasswordUpdateRequest).
It actually makes docs more readable. If I want to know nuances about each param or result I will go to its type doc comment.
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.
removed
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.
could u actually verify whether this would play well in wasm?
this call eventually does
table.add_item
, which if the item already exists will errorConstraintError
(as per this).We should use
table.replace_item
to be able to supported updates.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.
done thank you 9e50c9f