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

feat: transaction to JSON #54

Merged
merged 19 commits into from Feb 4, 2019
Merged

feat: transaction to JSON #54

merged 19 commits into from Feb 4, 2019

Conversation

sleepdefic1t
Copy link
Contributor

Proposed changes

The current implementation does not have a Transaction::toJson() method, and does not use a Json library.

This PR adds the following

  • ArduinoJson library
    • adds ArduinoJson lib dep as submodule.
    • adds ArduinoJson lib dep in PIO configs (src/ & test/).
    • adds helpers/json.h header for ArduinoJson presets and include statement.
  • Message class
    • refactors message.cpp to use Json.
    • drops redundant toString() method in message.cpp.
    • updates Message class to reflect Json lib addition.
  • Transaction class
    • adds Transaction::toArray() method to serve as data source for Transaction::toJson() method.
    • adds Transaction::toArray() tests.
    • adds Transaction::toJson() method.
    • adds Transaction::toJson() tests.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improve a current implementation without adding a new feature or fixing a bug)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Build (changes that affect the build system)
  • Docs (documentation only changes)
  • Test (adding missing tests or fixing existing tests)
  • Other... Please describe:

Checklist

  • I have read the CONTRIBUTING documentation
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Using the changes in this PR, I was also able to successfully use the Transaction::toJson() method to build and POST a transaction using Cpp-Client on an ESP32.

https://dexplorer.ark.io/transaction/045bac9efd544c703891d8c5734791672c9c1f67c818eab08824c14d99f90948

- add 'ArduinoJson' library dep as submodule.
- add 'ArduinoJson' lib dep in PIO configs ('src/' & 'test/').
- add 'json.h' header for 'ArduinoJson' presets and header.
- refactor 'message.cpp' to use json.
- drop redundant 'toString()' in 'message.cpp'.
- update 'test/message.cpp' to reflect Json usage.
- add 'toArray()' method to 'Transaction' class' to better meet SDK standards and serve as data source for 'toJson()' method.
- add 'tx.toArray()' tests.
- add 'toJson()' method to 'Transaction' class.
- add 'tx.toJson()' tests.
@ghost
Copy link

ghost commented Feb 1, 2019

@sleepdefic1t Thanks for submitting this pull request, a maintainer will get back to you shortly!

@ghost
Copy link

ghost commented Feb 1, 2019

@faustbrian @air1one - please review this pull request in the next few days. Be sure to explicitly select labels so I know what's going on.

If no reviewer appears after a week, a reminder will be sent out.

@ghost ghost added Status: Needs Review The issue or pull request needs a review by a developer of the team. Complexity: High More than 256 lines changed. Type: Feature The issue is a request for new functionality. labels Feb 1, 2019
@sleepdefic1t sleepdefic1t changed the title feat: Json [WIP]feat: Json Feb 1, 2019
@ghost
Copy link

ghost commented Feb 1, 2019

@sleepdefic1t The ci/circleci: build-linux-clang-5 job is failing as of 24001fb055a25e205829bc2dd9c5b1f80cc3c067. Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

use 'strcpy', 'strcat', and 'sprintf'.
@codecov-io
Copy link

Codecov Report

Merging #54 into master will increase coverage by 1.27%.
The diff coverage is 86.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   61.76%   63.03%   +1.27%     
==========================================
  Files          40       40              
  Lines        2568     2643      +75     
==========================================
+ Hits         1586     1666      +80     
+ Misses        982      977       -5
Impacted Files Coverage Δ
src/include/cpp-crypto/transactions/transaction.h 0% <ø> (ø) ⬆️
src/utils/message.h 100% <ø> (ø) ⬆️
src/utils/message.cpp 100% <100%> (ø) ⬆️
src/transactions/transaction.cpp 88.7% <84.33%> (+2.66%) ⬆️
src/transactions/builder.cpp 73.33% <0%> (+40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ba41df...b228b90. Read the comment docs.

@sleepdefic1t sleepdefic1t changed the title [WIP]feat: Json feat: Json Feb 1, 2019
@sleepdefic1t
Copy link
Contributor Author

This should be good to go now, @faustbrian 👍

@ghost ghost added the Status: Contributor Approved The pull request has been approved by a contributor. label Feb 4, 2019
@ghost
Copy link

ghost commented Feb 4, 2019

@sleepdefic1t A contributor has approved this PR. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait.

Thank you for your contribution!

@faustbrian faustbrian changed the title feat: Json feat: transaction to JSON Feb 4, 2019
@faustbrian faustbrian merged commit b422905 into ArkEcosystemArchive:master Feb 4, 2019
@ghost
Copy link

ghost commented Feb 4, 2019

@sleepdefic1t Your pull request has been merged but was not assigned a bounty tier. @faustbrian @air1one - please assign a bounty tier to this pull request in the next few days.

@ghost ghost removed the Status: Needs Review The issue or pull request needs a review by a developer of the team. label Feb 4, 2019
@sleepdefic1t sleepdefic1t mentioned this pull request Feb 5, 2019
12 tasks
@sleepdefic1t sleepdefic1t deleted the feat/json branch February 15, 2019 17:54
ciband pushed a commit to ciband/cpp-crypto that referenced this pull request Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: High More than 256 lines changed. Status: Contributor Approved The pull request has been approved by a contributor. Type: Feature The issue is a request for new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants