Added support fot the get_dynamic_global_properties API call in the single-connection mode
This commit is contained in:
parent
694572b18d
commit
5a113ad7cc
5 changed files with 56 additions and 4 deletions
|
@ -16,6 +16,7 @@ import cy.agorise.graphenej.Authority;
|
||||||
import cy.agorise.graphenej.BaseOperation;
|
import cy.agorise.graphenej.BaseOperation;
|
||||||
import cy.agorise.graphenej.Extensions;
|
import cy.agorise.graphenej.Extensions;
|
||||||
import cy.agorise.graphenej.LimitOrder;
|
import cy.agorise.graphenej.LimitOrder;
|
||||||
|
import cy.agorise.graphenej.Memo;
|
||||||
import cy.agorise.graphenej.Transaction;
|
import cy.agorise.graphenej.Transaction;
|
||||||
import cy.agorise.graphenej.UserAccount;
|
import cy.agorise.graphenej.UserAccount;
|
||||||
import cy.agorise.graphenej.api.calls.GetAccountByName;
|
import cy.agorise.graphenej.api.calls.GetAccountByName;
|
||||||
|
@ -23,6 +24,7 @@ import cy.agorise.graphenej.api.calls.GetAccountHistoryByOperations;
|
||||||
import cy.agorise.graphenej.api.calls.GetAccounts;
|
import cy.agorise.graphenej.api.calls.GetAccounts;
|
||||||
import cy.agorise.graphenej.api.calls.GetBlock;
|
import cy.agorise.graphenej.api.calls.GetBlock;
|
||||||
import cy.agorise.graphenej.api.calls.GetBlockHeader;
|
import cy.agorise.graphenej.api.calls.GetBlockHeader;
|
||||||
|
import cy.agorise.graphenej.api.calls.GetDynamicGlobalProperties;
|
||||||
import cy.agorise.graphenej.api.calls.GetFullAccounts;
|
import cy.agorise.graphenej.api.calls.GetFullAccounts;
|
||||||
import cy.agorise.graphenej.api.calls.GetLimitOrders;
|
import cy.agorise.graphenej.api.calls.GetLimitOrders;
|
||||||
import cy.agorise.graphenej.api.calls.GetMarketHistory;
|
import cy.agorise.graphenej.api.calls.GetMarketHistory;
|
||||||
|
@ -35,10 +37,10 @@ import cy.agorise.graphenej.models.AccountProperties;
|
||||||
import cy.agorise.graphenej.models.Block;
|
import cy.agorise.graphenej.models.Block;
|
||||||
import cy.agorise.graphenej.models.BlockHeader;
|
import cy.agorise.graphenej.models.BlockHeader;
|
||||||
import cy.agorise.graphenej.models.BucketObject;
|
import cy.agorise.graphenej.models.BucketObject;
|
||||||
|
import cy.agorise.graphenej.models.DynamicGlobalProperties;
|
||||||
import cy.agorise.graphenej.models.FullAccountDetails;
|
import cy.agorise.graphenej.models.FullAccountDetails;
|
||||||
import cy.agorise.graphenej.models.HistoryOperationDetail;
|
import cy.agorise.graphenej.models.HistoryOperationDetail;
|
||||||
import cy.agorise.graphenej.models.OperationHistory;
|
import cy.agorise.graphenej.models.OperationHistory;
|
||||||
import cy.agorise.graphenej.Memo;
|
|
||||||
import cy.agorise.graphenej.operations.CustomOperation;
|
import cy.agorise.graphenej.operations.CustomOperation;
|
||||||
import cy.agorise.graphenej.operations.LimitOrderCreateOperation;
|
import cy.agorise.graphenej.operations.LimitOrderCreateOperation;
|
||||||
import cy.agorise.graphenej.operations.TransferOperation;
|
import cy.agorise.graphenej.operations.TransferOperation;
|
||||||
|
@ -56,7 +58,7 @@ public class DeserializationMap {
|
||||||
|
|
||||||
private HashMap<Class, Gson> mGsonMap = new HashMap<>();
|
private HashMap<Class, Gson> mGsonMap = new HashMap<>();
|
||||||
|
|
||||||
public DeserializationMap(){
|
DeserializationMap(){
|
||||||
Gson genericGson = new Gson();
|
Gson genericGson = new Gson();
|
||||||
|
|
||||||
// GetBlock
|
// GetBlock
|
||||||
|
@ -169,6 +171,13 @@ public class DeserializationMap {
|
||||||
.registerTypeAdapter(AccountOptions.class, new AccountOptions.AccountOptionsDeserializer())
|
.registerTypeAdapter(AccountOptions.class, new AccountOptions.AccountOptionsDeserializer())
|
||||||
.create();
|
.create();
|
||||||
mGsonMap.put(GetFullAccounts.class, getFullAccountsGson);
|
mGsonMap.put(GetFullAccounts.class, getFullAccountsGson);
|
||||||
|
|
||||||
|
// GetDynamicGlobalProperties
|
||||||
|
mClassMap.put(GetDynamicGlobalProperties.class, DynamicGlobalProperties.class);
|
||||||
|
Gson getDynamicGlobalPropertiesGson = new GsonBuilder()
|
||||||
|
.registerTypeAdapter(DynamicGlobalProperties.class, new DynamicGlobalProperties.DynamicGlobalPropertiesDeserializer())
|
||||||
|
.create();
|
||||||
|
mGsonMap.put(GetDynamicGlobalProperties.class, getDynamicGlobalPropertiesGson);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getReceivedClass(Class _class){
|
public Class getReceivedClass(Class _class){
|
||||||
|
|
|
@ -458,6 +458,9 @@ public class NetworkService extends Service {
|
||||||
} else if(responsePayloadClass == HistoryOperationDetail.class){
|
} else if(responsePayloadClass == HistoryOperationDetail.class){
|
||||||
Type GetAccountHistoryByOperationsResponse = new TypeToken<JsonRpcResponse<HistoryOperationDetail>>(){}.getType();
|
Type GetAccountHistoryByOperationsResponse = new TypeToken<JsonRpcResponse<HistoryOperationDetail>>(){}.getType();
|
||||||
parsedResponse = gson.fromJson(text, GetAccountHistoryByOperationsResponse);
|
parsedResponse = gson.fromJson(text, GetAccountHistoryByOperationsResponse);
|
||||||
|
}else if(responsePayloadClass == DynamicGlobalProperties.class){
|
||||||
|
Type GetDynamicGlobalPropertiesResponse = new TypeToken<JsonRpcResponse<DynamicGlobalProperties>>(){}.getType();
|
||||||
|
parsedResponse = gson.fromJson(text, GetDynamicGlobalPropertiesResponse);
|
||||||
}else if(responsePayloadClass == List.class){
|
}else if(responsePayloadClass == List.class){
|
||||||
// If the response payload is a List, further inquiry is required in order to
|
// If the response payload is a List, further inquiry is required in order to
|
||||||
// determine a list of what is expected here
|
// determine a list of what is expected here
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package cy.agorise.graphenej.api.calls;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import cy.agorise.graphenej.RPC;
|
||||||
|
import cy.agorise.graphenej.api.ApiAccess;
|
||||||
|
import cy.agorise.graphenej.models.ApiCall;
|
||||||
|
|
||||||
|
public class GetDynamicGlobalProperties implements ApiCallable {
|
||||||
|
public static final int REQUIRED_API = ApiAccess.API_NONE;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiCall toApiCall(int apiId, long sequenceId) {
|
||||||
|
ArrayList<Serializable> params = new ArrayList<>();
|
||||||
|
return new ApiCall(apiId, RPC.CALL_GET_DYNAMIC_GLOBAL_PROPERTIES, params, RPC.VERSION, sequenceId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,7 +47,8 @@ public class CallsActivity extends AppCompatActivity {
|
||||||
RPC.CALL_GET_LIMIT_ORDERS,
|
RPC.CALL_GET_LIMIT_ORDERS,
|
||||||
RPC.CALL_GET_ACCOUNT_HISTORY_BY_OPERATIONS,
|
RPC.CALL_GET_ACCOUNT_HISTORY_BY_OPERATIONS,
|
||||||
RPC.CALL_GET_FULL_ACCOUNTS,
|
RPC.CALL_GET_FULL_ACCOUNTS,
|
||||||
RPC.CALL_SET_SUBSCRIBE_CALLBACK
|
RPC.CALL_SET_SUBSCRIBE_CALLBACK,
|
||||||
|
RPC.CALL_GET_DYNAMIC_GLOBAL_PROPERTIES
|
||||||
};
|
};
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
@ -33,6 +33,7 @@ import cy.agorise.graphenej.api.calls.GetAccountByName;
|
||||||
import cy.agorise.graphenej.api.calls.GetAccountHistoryByOperations;
|
import cy.agorise.graphenej.api.calls.GetAccountHistoryByOperations;
|
||||||
import cy.agorise.graphenej.api.calls.GetAccounts;
|
import cy.agorise.graphenej.api.calls.GetAccounts;
|
||||||
import cy.agorise.graphenej.api.calls.GetBlock;
|
import cy.agorise.graphenej.api.calls.GetBlock;
|
||||||
|
import cy.agorise.graphenej.api.calls.GetDynamicGlobalProperties;
|
||||||
import cy.agorise.graphenej.api.calls.GetFullAccounts;
|
import cy.agorise.graphenej.api.calls.GetFullAccounts;
|
||||||
import cy.agorise.graphenej.api.calls.GetLimitOrders;
|
import cy.agorise.graphenej.api.calls.GetLimitOrders;
|
||||||
import cy.agorise.graphenej.api.calls.GetObjects;
|
import cy.agorise.graphenej.api.calls.GetObjects;
|
||||||
|
@ -135,6 +136,8 @@ public class PerformCallActivity extends ConnectedActivity {
|
||||||
case RPC.CALL_GET_FULL_ACCOUNTS:
|
case RPC.CALL_GET_FULL_ACCOUNTS:
|
||||||
setupGetFullAccounts();
|
setupGetFullAccounts();
|
||||||
break;
|
break;
|
||||||
|
case RPC.CALL_GET_DYNAMIC_GLOBAL_PROPERTIES:
|
||||||
|
setupGetDynamicGlobalProperties();
|
||||||
default:
|
default:
|
||||||
Log.d(TAG,"Default called");
|
Log.d(TAG,"Default called");
|
||||||
}
|
}
|
||||||
|
@ -250,8 +253,17 @@ public class PerformCallActivity extends ConnectedActivity {
|
||||||
param1.setInputType(InputType.TYPE_CLASS_TEXT);
|
param1.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupGetDynamicGlobalProperties(){
|
||||||
|
requiredInput(0);
|
||||||
|
}
|
||||||
|
|
||||||
private void requiredInput(int inputCount){
|
private void requiredInput(int inputCount){
|
||||||
if(inputCount == 1){
|
if(inputCount == 0){
|
||||||
|
mParam1View.setVisibility(View.GONE);
|
||||||
|
mParam2View.setVisibility(View.GONE);
|
||||||
|
mParam3View.setVisibility(View.GONE);
|
||||||
|
mParam4View.setVisibility(View.GONE);
|
||||||
|
}else if(inputCount == 1){
|
||||||
mParam1View.setVisibility(View.VISIBLE);
|
mParam1View.setVisibility(View.VISIBLE);
|
||||||
mParam2View.setVisibility(View.GONE);
|
mParam2View.setVisibility(View.GONE);
|
||||||
mParam3View.setVisibility(View.GONE);
|
mParam3View.setVisibility(View.GONE);
|
||||||
|
@ -309,6 +321,9 @@ public class PerformCallActivity extends ConnectedActivity {
|
||||||
break;
|
break;
|
||||||
case RPC.CALL_GET_FULL_ACCOUNTS:
|
case RPC.CALL_GET_FULL_ACCOUNTS:
|
||||||
getFullAccounts();
|
getFullAccounts();
|
||||||
|
break;
|
||||||
|
case RPC.CALL_GET_DYNAMIC_GLOBAL_PROPERTIES:
|
||||||
|
getDynamicGlobalProperties();
|
||||||
default:
|
default:
|
||||||
Log.d(TAG,"Default called");
|
Log.d(TAG,"Default called");
|
||||||
}
|
}
|
||||||
|
@ -391,6 +406,11 @@ public class PerformCallActivity extends ConnectedActivity {
|
||||||
responseMap.put(id, mRPC);
|
responseMap.put(id, mRPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getDynamicGlobalProperties(){
|
||||||
|
long id = mNetworkService.sendMessage(new GetDynamicGlobalProperties(), GetDynamicGlobalProperties.REQUIRED_API);
|
||||||
|
responseMap.put(id, mRPC);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method that will decide what to do with each JSON-RPC response
|
* Internal method that will decide what to do with each JSON-RPC response
|
||||||
*
|
*
|
||||||
|
@ -414,6 +434,7 @@ public class PerformCallActivity extends ConnectedActivity {
|
||||||
case RPC.CALL_GET_LIMIT_ORDERS:
|
case RPC.CALL_GET_LIMIT_ORDERS:
|
||||||
case RPC.CALL_GET_ACCOUNT_HISTORY_BY_OPERATIONS:
|
case RPC.CALL_GET_ACCOUNT_HISTORY_BY_OPERATIONS:
|
||||||
case RPC.CALL_GET_FULL_ACCOUNTS:
|
case RPC.CALL_GET_FULL_ACCOUNTS:
|
||||||
|
case RPC.CALL_GET_DYNAMIC_GLOBAL_PROPERTIES:
|
||||||
mResponseView.setText(mResponseView.getText() + gson.toJson(response, JsonRpcResponse.class) + "\n");
|
mResponseView.setText(mResponseView.getText() + gson.toJson(response, JsonRpcResponse.class) + "\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue