- Added the required deserialization logic to parse the response to the 'get_objects' API call with an asset bitasset data type
- Removed unresponsive node URLs from the sample app
This commit is contained in:
parent
c861c72a31
commit
d72e608807
4 changed files with 20 additions and 6 deletions
|
@ -38,6 +38,8 @@ import cy.agorise.graphenej.api.calls.GetTransaction;
|
||||||
import cy.agorise.graphenej.api.calls.ListAssets;
|
import cy.agorise.graphenej.api.calls.ListAssets;
|
||||||
import cy.agorise.graphenej.api.calls.LookupAssetSymbols;
|
import cy.agorise.graphenej.api.calls.LookupAssetSymbols;
|
||||||
import cy.agorise.graphenej.models.AccountProperties;
|
import cy.agorise.graphenej.models.AccountProperties;
|
||||||
|
import cy.agorise.graphenej.models.AssetFeed;
|
||||||
|
import cy.agorise.graphenej.models.BitAssetData;
|
||||||
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;
|
||||||
|
@ -45,6 +47,7 @@ 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.models.ReportedAssetFeed;
|
||||||
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;
|
||||||
|
@ -125,6 +128,10 @@ public class DeserializationMap {
|
||||||
mClassMap.put(GetObjects.class, List.class);
|
mClassMap.put(GetObjects.class, List.class);
|
||||||
Gson getObjectsGson = new GsonBuilder()
|
Gson getObjectsGson = new GsonBuilder()
|
||||||
.registerTypeAdapter(Asset.class, new Asset.AssetDeserializer())
|
.registerTypeAdapter(Asset.class, new Asset.AssetDeserializer())
|
||||||
|
.registerTypeAdapter(BitAssetData.class, new BitAssetData.BitAssetDataDeserializer())
|
||||||
|
.registerTypeAdapter(ReportedAssetFeed.class, new ReportedAssetFeed.ReportedAssetFeedDeserializer())
|
||||||
|
.registerTypeAdapter(AssetFeed.class, new AssetFeed.AssetFeedDeserializer())
|
||||||
|
.registerTypeAdapter(AssetAmount.class, new AssetAmount.AssetAmountDeserializer())
|
||||||
.create();
|
.create();
|
||||||
mGsonMap.put(GetObjects.class, getObjectsGson);
|
mGsonMap.put(GetObjects.class, getObjectsGson);
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ import cy.agorise.graphenej.api.calls.GetRequiredFees;
|
||||||
import cy.agorise.graphenej.api.calls.ListAssets;
|
import cy.agorise.graphenej.api.calls.ListAssets;
|
||||||
import cy.agorise.graphenej.models.AccountProperties;
|
import cy.agorise.graphenej.models.AccountProperties;
|
||||||
import cy.agorise.graphenej.models.ApiCall;
|
import cy.agorise.graphenej.models.ApiCall;
|
||||||
|
import cy.agorise.graphenej.models.BitAssetData;
|
||||||
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;
|
||||||
|
@ -522,7 +523,6 @@ public class NetworkService extends Service {
|
||||||
*/
|
*/
|
||||||
private void handleJsonRpcResponse(JsonRpcResponse response, String text){
|
private void handleJsonRpcResponse(JsonRpcResponse response, String text){
|
||||||
JsonRpcResponse parsedResponse = null;
|
JsonRpcResponse parsedResponse = null;
|
||||||
|
|
||||||
Class requestClass = mRequestClassMap.get(response.id);
|
Class requestClass = mRequestClassMap.get(response.id);
|
||||||
if(requestClass != null){
|
if(requestClass != null){
|
||||||
// Removing the class entry in the map
|
// Removing the class entry in the map
|
||||||
|
@ -621,8 +621,10 @@ public class NetworkService extends Service {
|
||||||
* @param response Response to a 'get_objects' API call
|
* @param response Response to a 'get_objects' API call
|
||||||
*/
|
*/
|
||||||
private JsonRpcResponse handleGetObject(String response){
|
private JsonRpcResponse handleGetObject(String response){
|
||||||
//TODO: Implement a proper de-serialization logic
|
//TODO: Add support for other types of 'get_objects' request types
|
||||||
return null;
|
Gson gson = mDeserializationMap.getGson(GetObjects.class);
|
||||||
|
Type GetBitAssetResponse = new TypeToken<JsonRpcResponse<List<BitAssetData>>>(){}.getType();
|
||||||
|
return gson.fromJson(response, GetBitAssetResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,6 +34,7 @@ import cy.agorise.graphenej.BlockData;
|
||||||
import cy.agorise.graphenej.BrainKey;
|
import cy.agorise.graphenej.BrainKey;
|
||||||
import cy.agorise.graphenej.Memo;
|
import cy.agorise.graphenej.Memo;
|
||||||
import cy.agorise.graphenej.OperationType;
|
import cy.agorise.graphenej.OperationType;
|
||||||
|
import cy.agorise.graphenej.Price;
|
||||||
import cy.agorise.graphenej.RPC;
|
import cy.agorise.graphenej.RPC;
|
||||||
import cy.agorise.graphenej.Transaction;
|
import cy.agorise.graphenej.Transaction;
|
||||||
import cy.agorise.graphenej.UserAccount;
|
import cy.agorise.graphenej.UserAccount;
|
||||||
|
@ -57,6 +58,8 @@ import cy.agorise.graphenej.api.calls.GetRequiredFees;
|
||||||
import cy.agorise.graphenej.api.calls.GetTransaction;
|
import cy.agorise.graphenej.api.calls.GetTransaction;
|
||||||
import cy.agorise.graphenej.api.calls.ListAssets;
|
import cy.agorise.graphenej.api.calls.ListAssets;
|
||||||
import cy.agorise.graphenej.errors.MalformedAddressException;
|
import cy.agorise.graphenej.errors.MalformedAddressException;
|
||||||
|
import cy.agorise.graphenej.models.AssetFeed;
|
||||||
|
import cy.agorise.graphenej.models.BitAssetData;
|
||||||
import cy.agorise.graphenej.models.JsonRpcResponse;
|
import cy.agorise.graphenej.models.JsonRpcResponse;
|
||||||
import cy.agorise.graphenej.operations.TransferOperation;
|
import cy.agorise.graphenej.operations.TransferOperation;
|
||||||
import cy.agorise.graphenej.operations.TransferOperationBuilder;
|
import cy.agorise.graphenej.operations.TransferOperationBuilder;
|
||||||
|
@ -185,7 +188,6 @@ public class PerformCallActivity extends ConnectedActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(Object message) throws Exception {
|
public void accept(Object message) throws Exception {
|
||||||
Log.d(TAG,"accept. Msg class: "+message.getClass());
|
|
||||||
if(message instanceof ConnectionStatusUpdate){
|
if(message instanceof ConnectionStatusUpdate){
|
||||||
// TODO: Update UI ?
|
// TODO: Update UI ?
|
||||||
}else if(message instanceof JsonRpcResponse){
|
}else if(message instanceof JsonRpcResponse){
|
||||||
|
@ -589,6 +591,11 @@ public class PerformCallActivity extends ConnectedActivity {
|
||||||
Transaction tx = (Transaction) response.result;
|
Transaction tx = (Transaction) response.result;
|
||||||
mResponseView.setText(mResponseView.getText() + String.format("[%s][%s]", tx.toString(), Util.bytesToHex(tx.getHash())));
|
mResponseView.setText(mResponseView.getText() + String.format("[%s][%s]", tx.toString(), Util.bytesToHex(tx.getHash())));
|
||||||
break;
|
break;
|
||||||
|
case RPC.CALL_GET_OBJECTS:
|
||||||
|
List<BitAssetData> bitAssetDataArray = (List<BitAssetData>) response.result;
|
||||||
|
BitAssetData bitAssetData = bitAssetDataArray.get(0);
|
||||||
|
AssetFeed assetFeed = bitAssetData.getCurrentFeed();
|
||||||
|
Price price = assetFeed.getSettlementPrice();
|
||||||
case RPC.CALL_GET_ACCOUNTS:
|
case RPC.CALL_GET_ACCOUNTS:
|
||||||
case RPC.CALL_GET_BLOCK:
|
case RPC.CALL_GET_BLOCK:
|
||||||
case RPC.CALL_GET_BLOCK_HEADER:
|
case RPC.CALL_GET_BLOCK_HEADER:
|
||||||
|
|
|
@ -23,8 +23,6 @@ public class SampleApplication extends Application {
|
||||||
int requestedApis = ApiAccess.API_DATABASE | ApiAccess.API_HISTORY | ApiAccess.API_NETWORK_BROADCAST;
|
int requestedApis = ApiAccess.API_DATABASE | ApiAccess.API_HISTORY | ApiAccess.API_NETWORK_BROADCAST;
|
||||||
|
|
||||||
String[] nodeURLs = new String[]{
|
String[] nodeURLs = new String[]{
|
||||||
"wss://miami.bitshares.apasia.tech/ws",
|
|
||||||
"wss://bitshares.crypto.fans/ws",
|
|
||||||
"wss://bitshares.openledger.info/ws",
|
"wss://bitshares.openledger.info/ws",
|
||||||
"wss://us.nodes.bitshares.ws",
|
"wss://us.nodes.bitshares.ws",
|
||||||
"wss://eu.nodes.bitshares.ws"
|
"wss://eu.nodes.bitshares.ws"
|
||||||
|
|
Loading…
Reference in a new issue