-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jrpc): parse json object args as CBOR (#964)
Description --- feat(jrpc): parses json object args as CBOR Motivation and Context --- Given this template function ```rust pub struct MyStruct { a: String, few: u64, fields: Vec<String>, inside: Map<String, MyStruct>, my: Option<String>, template: ComponentAddress, } // (...) pub fn set_struct(&mut self, my_struct: MyStruct) { self.my_struct = my_struct; } ``` This can be called in json with this instruction ```json5 { // (...) "instructions": [{"CallMethod": {"component_address": "...", "method": "set_struct", "args":[ // MyStruct { "a": "b", "few": 123, "fields: ["a"], "inside": {"a":"b"}, "my": null, "template": "component_xxxxx" } ] }] } ``` This is done by converting a serde_json Value to a ciborium Value enum, as they happen to be almost identical. How Has This Been Tested? --- New unit test. Manually by calling template method with custom struct in args. What process can a PR reviewer use to test or verify this change? --- Call a template with a custom struct in the args using transactions.submit in the wallet Breaking Changes --- - [x] None - [ ] Requires data directory to be deleted - [ ] Other - Please specify
- Loading branch information
Showing
1 changed file
with
165 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters