Remove the call to login api as it has been removed and causing SteemJ fail to work

in utopian-io •  7 months ago

Components

Write here the components/parts/sections of the software your suggestion is about.

This submission is on SteemJ - the Steem API Wrapper for Java

We have been using SteemJ for quite some time, to run a bot. Everything was running fine, and suddenly it started failing to work a day before giving this error in the logs : Could not find method login

I was summoned to find out the probable cause and fix it. I tried to connect to @dez1337 who is the one man army behind this project mostly, but did not hear back from him. Looking at his profile it appears he is not active here since few days, so I started analyzing the issue.

Upon investigating the logs more, the source of the error was focused at :

at eu.bittrade.libs.steemj.SteemJ.login(SteemJ.java:1493) ~[steemj-core-0.4.2-jar-with-dependencies.jar:0.4.2]

at eu.bittrade.libs.steemj.SteemJ.(SteemJ.java:136) ~[steemj-core-0.4.2-jar-with-dependencies.jar:0.4.2]
image.png

And it was the public constructor of SteemJ. I had no clue why it would fail suddenly, and I tried to debug to no avail. Then I suspected some change to the API and started looking for clues. Searching on steemit, I stumbled upon this post which indicated that the login api might have been removed. So I started thinking to find out a fix.

Analyzing the SteemJ constructor, I found out that, it tries to log in the constructor to find out the API details, however, they are not very relevant to the vote method which is used to upvote the posts. The same is true about the createComment method which is used to add a comment. So these methods would still work without the login methods being called. However, since the login method was being called in constructor, it needs change in the API.

So as part of this suggestion, I propose the SteemJ API change to remove the call to login method to cater to the new changes in Steem API so that it will work without any issue. Also do the necessary changes to find out the API names based on changes to Steem API.

The story does not end here :) I have an interim fix for you till this comes in the API.

I know we would not get the fix so soon in the API, so I had to find out a fix. Looking at the constructor, the only possibility is to not use the SteemJ class, because the constructor will be called anytime you use the object. So I created a cloned class of SteemJ, named it SteemJClone, defined its own constructor without using the call to the login method.

If you analyze the SteemJ constructor to figure out why it uses a login call, then you will see all it does is to find out the API names supported by the API. It looks like login is needed prior to finding the API details.

image.png

However, for our upvote or comment , these are not essential. So we can use our cloned class without any problem to resume our operation. So if you are using SteemJ, for time being, you can just create this cloned class, name it as SteemJClone, copy everything from SteemJ class ( You need to attach source to see the source code) , change the constructor to just initialize the communicationHandler object. And then use this new object in all your operations.

Mockups / Examples

So this is how your new class constructor would look like. And also similar changes would be needed in the API.

image.png

Benefits

SteemJ API will be usable as is , after this change is implemented. Right now, if someone is using this project, they need to follow the interim fix that I described, till the fix in the API comes.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

·

Hey @princewrites, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

I must say thank you for fixing this and helping us to move ahead.

Lovely contribution, notwithstanding, you should edit to the right category in four hours to avoid rejection of your contribution.

You can contact us on Discord.
[utopian-moderator]

·

Hey, I just saw this, is it now permanently rejected, or still something can be done ?

Your contribution have been approved.

You can contact us on Discord.
[utopian-moderator]

·

Giving a 4 hr ultimatum without definiteness of when its going to be reviewed is certainly not the good thing. There are time zone differences as well. Let me know, if I can still edit and it could be reviewed. And if yes, help me understand which category it would fit to.

And I went through the rules, I am not sure, why it would not fit into the Suggestion Category, my post follows all of this, isn't it ? :

Suggestion Rules

Suggestions are minor features/enhancements that you would like to have in an Open Source project.
Suggestions may be only related to the technical aspects of the project not process or organisational issues.
Suggestions must provide all the details for the requested features to be actually built.
Images, screenshots, links and examples are always welcome in this category.

Also joined discord, but did not get any response. Let me know, if you can still do something.

·

Thank you, the post is almost near close, does it take so much time to get rewarded from utopian ?