SteemJ V0.3.4 has been released ~ Use the Steem API in your Java Project

in #steemdev7 years ago

SteemJ v0.3.4 finally allows you to share post/comment rewards with another Steem account.

<p dir="auto"><center><img src="https://images.hive.blog/768x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/http://imgur.com/F54Tflg.png" alt="SteemJV2Logo" srcset="https://images.hive.blog/768x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/http://imgur.com/F54Tflg.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/https://steemitimages.com/0x0/http://imgur.com/F54Tflg.png 2x" /> <p dir="auto"><center><br /> Previous 0.3.x releases: <a href="https://steemit.com/steemdev/@dez1337/steemj-v0-3-3-has-been-released-use-the-steem-api-in-your-java-project" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">v0.3.3 <a href="https://steemit.com/steemdev/@dez1337/steemj-v0-3-2-has-been-released-use-multiple-accounts-update-14" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">v0.3.2 <a href="https://steemit.com/steemdev/@dez1337/steemj-v0-3-1-has-been-released-update-13" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">v0.3.1 <a href="https://steemit.com/steemdev/@dez1337/steemj-v0-3-0-has-been-released-update-12" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">v0.3.0<br /> <h1>SteemJ v0.3.4 has been released <p dir="auto">Hello Steemians! <p dir="auto">I am pleased to announce the last 0.3.x release of SteemJ: Version 0.3.4. Based on this success, we can finally look forward to version 0.4.0 for which some big improvements like a <i>TransactionBuilder are planned. <p dir="auto">This release fixes the remaining issues and increases the overall quality of the project once again. <p dir="auto">At this point: Once again a huge <b><i>Thank you! to everyone submitting issues at <a href="https://github.com/marvin-we/steem-java-api-wrapper" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">GitHub - Everyone of you is making this project better and better. <p dir="auto">As SteemJ is made for third-party apps the most interesting change should be the <b>CommentOptionsExtension fix. You may know that it is possible to add this type of Extension to a <i>CommentOptionsOperation since HF 0.18.0. This Extension allows you to define that a specific account gets a specfic percentage of the reward too. If your app allows users to write posts or comments, this can be one way to earn something with your app. <p dir="auto">I’ve just read some comments on the <a href="https://steemit.chat" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Steemit Chat from users who were wondering how to use this feature, so to avoid this pain for you SteemJ users, here is a small sample: <pre><code> CommentOptionsOperation commentOptionsOperation = new CommentOptionsOperation(); commentOptionsOperation.setAuthor(new AccountName("dez1337")); commentOptionsOperation.setPermlink("steemj-v0-2-4-has-been-released-update-9"); commentOptionsOperation.setAllowVotes(true); commentOptionsOperation.setAllowCurationRewards(true); commentOptionsOperation.setPercentSteemDollars((short) 10000); BeneficiaryRouteType beneficiaryRouteType = new BeneficiaryRouteType(); beneficiaryRouteType.setAccount(new AccountName("steemJ")); beneficiaryRouteType.setWeight((short) 500); ArrayList<BeneficiaryRouteType> beneficiaryRouteTypes = new ArrayList<>(); beneficiaryRouteTypes.add(beneficiaryRouteType); CommentPayoutBeneficiaries commentPayoutBeneficiaries = new CommentPayoutBeneficiaries(); commentPayoutBeneficiaries.setBeneficiaries(beneficiaryRouteTypes); CommentOptionsExtension commentOptionsExtension = new CommentOptionsExtension(commentPayoutBeneficiaries); ArrayList<CommentOptionsExtension> commentOptionsExtensions = new ArrayList<>(); commentOptionsExtensions.add(commentOptionsExtension); commentOptionsOperation.setExtensions(commentOptionsExtensions); ArrayList<Operation> operations = new ArrayList<>(); operations.add(commentOptionsOperation); transaction.setOperations(operations); transaction.sign(); <p dir="auto">For sure, this is still quite complex to achieve, but it is working! SteemJ 0.4.x will hopefully provide some easier ways to add a CommentOptionsExtension to a transcation. <p dir="auto">As always, let’s have a look at the current code quality before moving to the detailed changelog. <h1>Code Quality <p dir="auto"><center><img src="https://images.hive.blog/768x0/http://imgur.com/gEfLi3w.png" alt="SonarQube" srcset="https://images.hive.blog/768x0/http://imgur.com/gEfLi3w.png 1x, https://images.hive.blog/1536x0/http://imgur.com/gEfLi3w.png 2x" /> <p dir="auto">The code coverage slightly increased, because some new test cases have been added to avoid that the reported problems occur again in future versions. Beside that some TODOs could have been removed so that the number of Code Smells went down to 144. <h1>What is new? <p dir="auto">Below you can find all changes made in this release. <h4>Functional Updates <ul> <li>The following issues have been fixed: <li><a href="https://github.com/marvin-we/steem-java-api-wrapper/issues/5" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#5 Add JavaDoc to the follow_api. <li><a href="https://github.com/marvin-we/steem-java-api-wrapper/issues/62" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#62 Unable to add CommentPayoutBeneficiaries Extension to CommentOptionsOperation . <li><a href="https://github.com/marvin-we/steem-java-api-wrapper/issues/42" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#42 Implement core id types (e.g. block_id_type) to offer additional functionalities and a more accurate parsing. <li><a href="https://github.com/marvin-we/steem-java-api-wrapper/issues/30" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#30 Fix CommentOptionsExtension parsing. <li><a href="https://github.com/marvin-we/steem-java-api-wrapper/issues/61" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#61 Unable to use insecure websockets connection. <li><a href="https://github.com/marvin-we/steem-java-api-wrapper/issues/68" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">#68 Deserialization problem in case of 'total_pow' field is -1 (Testnet) <h4>Code Quality Improvements <ul> <li>Additional integration tests have been added. <h4>Documentation <ul> <li>The follow api methods have been added to the <a href="https://github.com/marvin-we/steem-java-api-wrapper/wiki/Available-Methods" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">“Available-Methods” - Page. <li>Additional JavaDoc has been added to several methods and fields <h1>General information <h2>What is SteemJ? <p dir="auto">SteemJ is a project that allows you to communicate with a Steem node using Java. So far, the project supports most of the API calls and is also able to broadcast most of the common operation types. Further information can be found on <a href="https://github.com/marvin-we/steem-java-api-wrapper" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">GitHub. <blockquote> <p dir="auto"><span><a href="https://github.com/marvin-we/steem-java-api-wrapper" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/marvin-we/steem-java-api-wrapper <h2>How to add it to your project? <p dir="auto">SteemJ binaries are pushed into the maven central repository and can be integrated with a bunch of build management tools like Maven. The <a href="https://github.com/marvin-we/steem-java-api-wrapper/wiki/How-to-add-SteemJ-to-your-project" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Wiki provides a lot of examples for the most common build tools. If you do not use a build management tool you can download the binaries as described <a href="https://github.com/marvin-we/steem-java-api-wrapper/wiki/How-to-add-SteemJ-to-your-project#download" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here. <h2>Contribute <p dir="auto">The project became quite big and there is still a lot to do. If you want to support the project simply clone the git repository and submit a pull request. I would really appreciate it =). <blockquote> <p dir="auto"><span>git clone <a href="https://github.com/marvin-we/steem-java-api-wrapper.git" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/marvin-we/steem-java-api-wrapper.git <h2>Get in touch! <p dir="auto">Most of my projects are pretty time consuming and I always try to provide some useful stuff to the community. What keeps me going for that is your feedback and your support. For that reason I would love to get some Feedback from you <3. Just contact me here on <a href="https://steemit.com/@dez1337" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Steemit or ping me on <a href="https://github.com/marvin-we/steem-java-api-wrapper" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">GitHub. <hr /> <p dir="auto"><center>If you want to stay up to date or just like the stuff I am doing it would be great if you could press the button below =). <p dir="auto"><br /><br /> <a href="https://steemit.com/@dez1337" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/http://imgur.com/GlepNAo.png" alt="follow me" srcset="https://images.hive.blog/768x0/http://imgur.com/GlepNAo.png 1x, https://images.hive.blog/1536x0/http://imgur.com/GlepNAo.png 2x" /><br /> <br /> <p dir="auto">Thanks for reading and best regards,<br /><br /> <span> <a href="/@dez1337">@dez1337 <p dir="auto">steemdevsteemopen-sourceprogrammingsteemit
Sort:  

This piece of code teaching how to create a new transaction is not working anymore:

<pre><code>[...] Transaction transaction = new Transaction(); // The expiration date defines how long the transaction is valid. This field is optional and SteemJ will automatically use the current system time and an offset. transaction.setExpirationDate("2016-04-06T08:29:27UTC"); // Define in which block the transaction should be added. In most cases this is the next available block which can be asked using the following lines: GlobalProperties globalProperties = steemApiWrapper.getDynamicGlobalProperties(); int refBlockNum = (globalProperties.getHeadBlockNumber() & 0xFFFF); transaction.setRefBlockNum(refBlockNum); transaction.setRefBlockPrefix(globalProperties.getHeadBlockId()); // There is also the option to add extensions to a transaction which are currently not used by Steem and therefore not supported by SteemJ. // transaction.setExtensions(extensions); // A Transaction accepts one or more Operations which have to be provided as an ArrayList. ArrayList<Operation> operations = new ArrayList<>(); [...]

Hay @discernente,

<p dir="auto">thank you for pointing this out and sorry for the late reply. I've updated the sample at <a href="#" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">GitHub. The following snippet should work again: <pre><code>[...] Transaction transaction = new Transaction(); // The expiration date defines how long the transaction is valid. This field is optional and SteemJ will automatically use the current system time and an offset. transaction.setExpirationDate("2016-04-06T08:29:27UTC"); // Define in which block the transaction should be added. In most cases this is the next available block which can be asked using the following lines: GlobalProperties globalProperties = steemApiWrapper.getDynamicGlobalProperties(); transaction.setRefBlockPrefix(globalProperties.getHeadBlockId().getHashValue()); transaction.setRefBlockNum(globalProperties.getHeadBlockId().getNumberFromHash()); // There is also the option to add extensions to a transaction which are currently not used by Steem and therefore not supported by SteemJ. // transaction.setExtensions(extensions); // A Transaction accepts one or more Operations which have to be provided as an ArrayList. ArrayList<Operation> operations = new ArrayList<>(); [...]

Ok, thank you. Now this piece of code is running fine, but I found another error while trying to run the method "getActiveVotes:

Exception in thread "main" eu.bittrade.libs.steemj.exceptions.SteemTransformationException: Could not transform the response into an object.
at eu.bittrade.libs.steemj.communication.CommunicationHandler.performRequest(CommunicationHandler.java:173)
at eu.bittrade.libs.steemj.SteemJ.getActiveVotes(SteemJ.java:311)

Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "author" (class eu.bittrade.libs.steemj.base.models.error.SteemData), not marked as ignorable (8 known properties: "call.method", "posting", "what", "call.params", "type", "name", "id", "api"])

at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:60)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:822)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1148)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1547) at [Source: (String)"{"id":9,"error":{"code":1,"message":"13 N5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE: unknown key\nunknown key: \n {"author":"discernente","permlink":"https://steemit.com/chart/@discernente/bitscreener-a-good-cryptocurrencies-free-real-time-charts-screener","what":"unknown key"}\n th_a database.cpp:385 get_comment\n\n {"call.method":"call","call.params":["database_api","get_active_votes",["discernente","https://steemit.co"[truncated 1007 chars]; line: 1, column: 976] (through reference chain: eu.bittrade.libs.steemj.base.models.error.SteemError["error"]->eu.bittrade.libs.steemj.base.models.error.SteemErrorDetails["data"]->eu.bittrade.libs.steemj.base.models.error.SteemErrorData["stack"]->java.lang.Object[][0]->eu.bittrade.libs.steemj.base.models.error.SteemStack["data"]->eu.bittrade.libs.steemj.base.models.error.SteemData["author"])

After having a closer look I guess the problem is that you've used the whole link instead of only providing the permlink part. So instead of

https://steemit.com/chart/@discernente/bitscreener-a-good-cryptocurrencies-free-real-time-charts-screener

use:

bitscreener-a-good-cryptocurrencies-free-real-time-charts-screener

ok thank you

Thank you once again - This may be connected to the new Steem version 0.19.2 - I've created #72 at GitHub for this :)

Nice feed @dez1337 thanks for sharing

It looks very interesting your project, I will follow you to continue reading

You have my support @dez1337. I don't code but I understand the usefulless of SteemJ and how it can help Java developers build great app on Steem. Keep on!

Hay @pnc,

thank you for your support - It really motivates me :)

Very interesting information sir. good post. 100% like and resteem

Nice read. This might be a bit off topic but when will steem add DM and notifications?

Hay @littleboy,

if you are talking about notifications I sadly can't answer your question :( - For Steem in general you currently have the possibilty to get informed by every new block like explained in this sample.

Thank you and best regards! :)

Congratulations @dez1337! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

<p dir="auto"><a href="http://steemitboard.com/@dez1337" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png 2x" /> Award for the number of upvotes <p dir="auto">Click on any badge to view your own Board of Honor on SteemitBoard.<br /> For more information about SteemitBoard, click <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here <p dir="auto">If you no longer want to receive notifications, reply to this comment with the word <code>STOP <blockquote> <p dir="auto">By upvoting this notification, you can help all Steemit users. Learn how <a href="https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here!

Congratulations @dez1337! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

<p dir="auto"><a href="http://steemitboard.com/@dez1337" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/commented.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/commented.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/commented.png 2x" /> Award for the number of comments received <p dir="auto">Click on any badge to view your own Board of Honor on SteemitBoard.<br /> For more information about SteemitBoard, click <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here <p dir="auto">If you no longer want to receive notifications, reply to this comment with the word <code>STOP <blockquote> <p dir="auto">By upvoting this notification, you can help all Steemit users. Learn how <a href="https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here!