refactor: signature autofilling for Simulate RPC - #5852
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5852 +/- ##
=========================================
- Coverage 79.5% 79.5% -0.0%
=========================================
Files 816 816
Lines 72180 72184 +4
Branches 8278 8276 -2
=========================================
- Hits 57362 57358 -4
- Misses 14818 14826 +8
🚀 New features to boost your workflow:
|
|
@tequdev is this PR ready to merge? |
yes👍 |
| if (sigObject.isMember(jss::Signers)) | ||
| { | ||
| if (!tx_json[jss::Signers].isArray()) | ||
| if (!sigObject[jss::Signers].isArray()) |
There was a problem hiding this comment.
Question/Suggestion: Shouldn't this check !sigObject[jss::Signers].isArray() happen even before this function is called?
There was a problem hiding this comment.
The name of the function suggests that it fills signatures into objects. But this function is also checking if the json object passed-in has the sub-objects created with correct data types. I think this function should only be called if the object types are correct(Json is valid). Hence the check should happen before.
There should be a separate function to check the validity of the json. Separation of concerns and responsibilities.
Right now we return an error if the json object is malformed. At some point we may want to recreate the sub-objects of proper types.
There was a problem hiding this comment.
That feels unnecessary - why look at the jss:Signers field twice in two different places? Makes way more sense to me to just check before you're going to need to work with it.
There was a problem hiding this comment.
My suggestion was to still do it once, just outside this function and before calling this. We then don't call this function if the field data types are not what we expect. Unless there's a case where sigObject[jss::Signers] is expected to be a scalar.
There was a problem hiding this comment.
Instead of adding a precondition to this function that you have to remember to check before you call it, it feels more robust to check it inside the function. That's also generally the pattern in this repo.
This change enables autofilling of signature-related fields in the Simulate RPC.
a6b0eff to
e4ae71b
Compare
This change enables autofilling of signature-related fields in the Simulate RPC. Co-authored-by: Bart Thomee <11445373+bthomee@users.noreply.github.com>
High Level Overview of Change
Refactor to enable autofilling of signature-related fields in the Simulate RPC for use in the Signature field (like for Lending, Sponsor feature) as well
Type of Change