Skip to content

Commit

Permalink
Change JRPC Requests to the new Appbase way
Browse files Browse the repository at this point in the history
  • Loading branch information
neutralleiter committed Jan 14, 2018
1 parent de2498d commit 70f69f5
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 398 deletions.
10 changes: 1 addition & 9 deletions core/src/main/java/eu/bittrade/libs/steemj/SteemJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -1362,15 +1362,7 @@ public List<String> lookupWitnessAccounts(String pattern, int limit)
*/
public boolean verifyAuthority(SignedTransaction signedTransaction)
throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.VERIFY_AUTHORITY);
requestObject.setSteemApi(SteemApiType.DATABASE_API);

Object[] parameters = { signedTransaction };
requestObject.setAdditionalParameters(parameters);
// The method does not simply return false, it throws an error
// describing the problem.
return communicationHandler.performRequest(requestObject, Boolean.class).get(0);
return DatabaseApi.verifyAccountAuthority(communicationHandler, null);
}

// #########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class SteemJConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(SteemJConfig.class);
/** The endpoint URI used by default. */
private static final String DEFAULT_STEEM_API_URI = "https://api.steemit.com";
private static final String DEFAULT_STEEM_API_URI = "https://api.steemitstage.com";
/** The SteemJ account. */
private static final AccountName STEEMJ_ACCOUNT = new AccountName("steemj");
/** The SteemJ version. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,8 @@ private AccountByKeyApi() {
*/
public static GetKeyReferencesReturn getKeyReferences(CommunicationHandler communicationHandler,
GetKeyReferencesArgs publicKeys) throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.GET_KEY_REFERENCES);
requestObject.setSteemApi(SteemApiType.ACCOUNT_BY_KEY_API);
Object[] parameters = { publicKeys };
requestObject.setAdditionalParameters(parameters);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_BY_KEY_API,
RequestMethod.GET_KEY_REFERENCES, publicKeys);

return communicationHandler.performRequest(requestObject, GetKeyReferencesReturn.class).get(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ private AccountHistoryApi() {
*/
public static GetOpsInBlockReturn getOpsInBlock(CommunicationHandler communicationHandler,
GetOpsInBlockArgs getOpsInBlockArgs) throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.GET_OPS_IN_BLOCK);
requestObject.setSteemApi(SteemApiType.ACCOUNT_HISTORY_API);
requestObject.setAdditionalParameters(getOpsInBlockArgs);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_HISTORY_API,
RequestMethod.GET_OPS_IN_BLOCK, getOpsInBlockArgs);

return communicationHandler.performRequest(requestObject, GetOpsInBlockReturn.class).get(0);
}
Expand Down Expand Up @@ -109,10 +107,8 @@ public static GetOpsInBlockReturn getOpsInBlock(CommunicationHandler communicati
*/
public static AnnotatedSignedTransaction getTransaction(CommunicationHandler communicationHandler,
GetAccountHistoryArgs getTransactionArgs) throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.GET_TRANSACTION);
requestObject.setSteemApi(SteemApiType.ACCOUNT_HISTORY_API);
requestObject.setAdditionalParameters(getTransactionArgs);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_HISTORY_API,
RequestMethod.GET_TRANSACTION, getTransactionArgs);

return communicationHandler.performRequest(requestObject, AnnotatedSignedTransaction.class).get(0);
}
Expand Down Expand Up @@ -150,10 +146,8 @@ public static AnnotatedSignedTransaction getTransaction(CommunicationHandler com
*/
public static GetAccountHistoryReturn getAccountHistory(CommunicationHandler communicationHandler,
GetAccountHistoryArgs getAccountHistoryArgs) throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setSteemApi(SteemApiType.ACCOUNT_HISTORY_API);
requestObject.setApiMethod(RequestMethod.GET_ACCOUNT_HISTORY);
requestObject.setAdditionalParameters(getAccountHistoryArgs);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_HISTORY_API,
RequestMethod.GET_ACCOUNT_HISTORY, getAccountHistoryArgs);

return communicationHandler.performRequest(requestObject, GetAccountHistoryReturn.class).get(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ private BlockApi() {
*/
public static GetBlockHeaderReturn getBlockHeader(CommunicationHandler communicationHandler,
GetBlockHeaderArgs getBlockHeaderArgs) throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.GET_BLOCK_HEADER);
requestObject.setSteemApi(SteemApiType.BLOCK_API);
requestObject.setAdditionalParameters(getBlockHeaderArgs);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.BLOCK_API, RequestMethod.GET_BLOCK_HEADER,
getBlockHeaderArgs);

return communicationHandler.performRequest(requestObject, GetBlockHeaderReturn.class).get(0);
}
Expand Down Expand Up @@ -106,10 +104,8 @@ public static GetBlockHeaderReturn getBlockHeader(CommunicationHandler communica
*/
public static GetBlockReturn getBlock(CommunicationHandler communicationHandler, GetBlockArgs getBlockArgs)
throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.GET_BLOCK);
requestObject.setSteemApi(SteemApiType.BLOCK_API);
requestObject.setAdditionalParameters(getBlockArgs);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.BLOCK_API, RequestMethod.GET_BLOCK,
getBlockArgs);

return communicationHandler.performRequest(requestObject, GetBlockReturn.class).get(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ private ChainApi() {

public static PushBlockReturn pushBlock(CommunicationHandler communicationHandler, PushBlockArgs pushBlockArgs)
throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.PUSH_BLOCK);
requestObject.setSteemApi(SteemApiType.CHAIN_API);
requestObject.setAdditionalParameters(pushBlockArgs);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.CHAIN_API, RequestMethod.PUSH_BLOCK,
pushBlockArgs);

return communicationHandler.performRequest(requestObject, PushBlockReturn.class).get(0);
}
Expand All @@ -60,10 +58,8 @@ public static PushBlockReturn pushBlock(CommunicationHandler communicationHandle
*/
public static PushTransactionReturn pushTransaction(CommunicationHandler communicationHandler,
SignedTransaction signedTransaction) throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.PUSH_TRANSACTION);
requestObject.setSteemApi(SteemApiType.CHAIN_API);
requestObject.setAdditionalParameters(signedTransaction);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.CHAIN_API, RequestMethod.PUSH_TRANSACTION,
signedTransaction);

return communicationHandler.performRequest(requestObject, PushTransactionReturn.class).get(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ public class CondenserApi {
*/
public static State getState(CommunicationHandler communicationHandler, Permlink path)
throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.GET_STATE);
requestObject.setSteemApi(SteemApiType.DATABASE_API);
String[] parameters = {};
requestObject.setAdditionalParameters(parameters);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.DATABASE_API, RequestMethod.GET_STATE, null);

return communicationHandler.performRequest(requestObject, State.class).get(0);
}
Expand All @@ -87,11 +83,8 @@ public static State getState(CommunicationHandler communicationHandler, Permlink
*/
public static String getHardforkVersion(CommunicationHandler communicationHandler)
throws SteemCommunicationException, SteemResponseException {
JsonRPCRequest requestObject = new JsonRPCRequest();
requestObject.setApiMethod(RequestMethod.GET_HARDFORK_VERSION);
requestObject.setSteemApi(SteemApiType.DATABASE_API);
String[] parameters = {};
requestObject.setAdditionalParameters(parameters);
JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.DATABASE_API, RequestMethod.GET_HARDFORK_VERSION,
null);

return communicationHandler.performRequest(requestObject, String.class).get(0);
}
Expand Down
Loading

0 comments on commit 70f69f5

Please sign in to comment.