From e1395a9d92ca7657fc9b042ffc34567d8099ee5d Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Fri, 16 Nov 2018 00:18:29 -0500 Subject: [PATCH 1/4] Modified the GetRequiredFees class and adjusted the sample app --- .../graphenej/api/calls/GetRequiredFees.java | 2 +- .../labs/sample/PerformCallActivity.java | 21 +++++++++++++++++++ sample/src/main/res/values/strings.xml | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetRequiredFees.java b/graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetRequiredFees.java index 773a208..e187fc0 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetRequiredFees.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetRequiredFees.java @@ -18,7 +18,7 @@ import cy.agorise.graphenej.models.ApiCall; public class GetRequiredFees implements ApiCallable { - public static final int REQUIRED_API = ApiAccess.API_DATABASE; + public static final int REQUIRED_API = ApiAccess.API_NONE; private Transaction mTransaction; private Asset mFeeAsset; diff --git a/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java b/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java index 8a47906..052c653 100644 --- a/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java +++ b/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java @@ -13,6 +13,7 @@ import android.widget.Button; import android.widget.TextView; import android.widget.Toast; +import com.google.common.primitives.UnsignedLong; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -26,6 +27,7 @@ import butterknife.ButterKnife; import butterknife.OnClick; import cy.agorise.graphenej.Asset; import cy.agorise.graphenej.AssetAmount; +import cy.agorise.graphenej.BaseOperation; import cy.agorise.graphenej.Memo; import cy.agorise.graphenej.OperationType; import cy.agorise.graphenej.RPC; @@ -43,9 +45,11 @@ import cy.agorise.graphenej.api.calls.GetFullAccounts; import cy.agorise.graphenej.api.calls.GetKeyReferences; import cy.agorise.graphenej.api.calls.GetLimitOrders; import cy.agorise.graphenej.api.calls.GetObjects; +import cy.agorise.graphenej.api.calls.GetRequiredFees; import cy.agorise.graphenej.api.calls.ListAssets; import cy.agorise.graphenej.errors.MalformedAddressException; import cy.agorise.graphenej.models.JsonRpcResponse; +import cy.agorise.graphenej.operations.TransferOperation; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Consumer; @@ -124,6 +128,7 @@ public class PerformCallActivity extends ConnectedActivity { setupGetRelativeAccountHistory(); break; case RPC.CALL_GET_REQUIRED_FEES: + setupGetRequiredFees(); break; case RPC.CALL_LOOKUP_ASSET_SYMBOLS: setupLookupAssetSymbols(); @@ -209,6 +214,11 @@ public class PerformCallActivity extends ConnectedActivity { mParam4View.setHint(resources.getString(R.string.get_relative_account_history_arg4)); } + private void setupGetRequiredFees(){ + requiredInput(1); + mParam1View.setHint(getString(R.string.get_required_fees_asset)); + } + private void setupLookupAssetSymbols(){ requiredInput(4); Resources resources = getResources(); @@ -328,6 +338,7 @@ public class PerformCallActivity extends ConnectedActivity { case RPC.CALL_GET_RELATIVE_ACCOUNT_HISTORY: break; case RPC.CALL_GET_REQUIRED_FEES: + sendGetRequiredFees(); break; case RPC.CALL_LOOKUP_ASSET_SYMBOLS: break; @@ -383,6 +394,16 @@ public class PerformCallActivity extends ConnectedActivity { } } + private void sendGetRequiredFees(){ + String input = param1.getText().toString(); + ArrayList operations = new ArrayList<>(); + AssetAmount transfer = new AssetAmount(UnsignedLong.valueOf("1000"), new Asset("1.3.0")); + AssetAmount fee = new AssetAmount(UnsignedLong.valueOf("1000"), new Asset("1.3.0")); + operations.add(new TransferOperation(new UserAccount("1.2.12300"), new UserAccount("1.2.12301"), fee, transfer)); + long id = mNetworkService.sendMessage(new GetRequiredFees(operations, new Asset(input)), GetRequiredFees.REQUIRED_API); + responseMap.put(id, mRPC); + } + private void sendListAssets(){ try{ String lowerBound = param1.getText().toString(); diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index d660aaa..73d4a6d 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -28,6 +28,9 @@ Limit Start timestamp (Earliest) + + Enter asset id + Asset 1 id Asset 2 id From 0cba6a9f8df574bea33b414245d0cc38846d0c4a Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Thu, 6 Dec 2018 19:17:32 -0500 Subject: [PATCH 2/4] Added support for the broadcast_transaction API call in the single connection mode --- .../api/calls/BroadcastTransaction.java | 27 +++++++++++ sample/build.gradle | 3 +- .../cy/agorise/labs/sample/CallsActivity.java | 1 + .../labs/sample/PerformCallActivity.java | 48 ++++++++++++++++++- 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 graphenej/src/main/java/cy/agorise/graphenej/api/calls/BroadcastTransaction.java diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/calls/BroadcastTransaction.java b/graphenej/src/main/java/cy/agorise/graphenej/api/calls/BroadcastTransaction.java new file mode 100644 index 0000000..8dc1ba5 --- /dev/null +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/calls/BroadcastTransaction.java @@ -0,0 +1,27 @@ +package cy.agorise.graphenej.api.calls; + +import java.io.Serializable; +import java.util.ArrayList; + +import cy.agorise.graphenej.RPC; +import cy.agorise.graphenej.Transaction; +import cy.agorise.graphenej.api.ApiAccess; +import cy.agorise.graphenej.models.ApiCall; + +public class BroadcastTransaction implements ApiCallable { + public static final int REQUIRED_API = ApiAccess.API_NETWORK_BROADCAST; + + private Transaction mTransaction; + + public BroadcastTransaction(Transaction transaction){ + if(!transaction.hasPrivateKey()) throw new IllegalStateException("The Transaction instance has to be provided with a private key in order to be broadcasted"); + mTransaction = transaction; + } + + @Override + public ApiCall toApiCall(int apiId, long sequenceId) { + ArrayList transactions = new ArrayList<>(); + transactions.add(mTransaction); + return new ApiCall(apiId, RPC.CALL_BROADCAST_TRANSACTION, transactions, RPC.VERSION, sequenceId); + } +} diff --git a/sample/build.gradle b/sample/build.gradle index de76e02..1ca3102 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -29,7 +29,8 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - api project(':graphenej') + implementation project(':graphenej') + implementation 'org.bitcoinj:bitcoinj-core:0.14.3' implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:design:27.1.1' diff --git a/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java b/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java index 28f2e0d..0066bfb 100644 --- a/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java +++ b/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java @@ -78,6 +78,7 @@ public class CallsActivity extends AppCompatActivity { RPC.CALL_GET_DYNAMIC_GLOBAL_PROPERTIES, RPC.CALL_GET_KEY_REFERENCES, RPC.CALL_GET_ACCOUNT_BALANCES, + RPC.CALL_BROADCAST_TRANSACTION, REMOVE_CURRENT_NODE }; diff --git a/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java b/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java index 052c653..651a4a0 100644 --- a/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java +++ b/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java @@ -17,6 +17,8 @@ import com.google.common.primitives.UnsignedLong; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.bitcoinj.core.ECKey; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -28,13 +30,17 @@ import butterknife.OnClick; import cy.agorise.graphenej.Asset; import cy.agorise.graphenej.AssetAmount; import cy.agorise.graphenej.BaseOperation; +import cy.agorise.graphenej.BlockData; +import cy.agorise.graphenej.BrainKey; import cy.agorise.graphenej.Memo; import cy.agorise.graphenej.OperationType; import cy.agorise.graphenej.RPC; +import cy.agorise.graphenej.Transaction; import cy.agorise.graphenej.UserAccount; import cy.agorise.graphenej.api.ConnectionStatusUpdate; import cy.agorise.graphenej.api.android.DeserializationMap; import cy.agorise.graphenej.api.android.RxBus; +import cy.agorise.graphenej.api.calls.BroadcastTransaction; import cy.agorise.graphenej.api.calls.GetAccountBalances; import cy.agorise.graphenej.api.calls.GetAccountByName; import cy.agorise.graphenej.api.calls.GetAccountHistoryByOperations; @@ -50,6 +56,7 @@ import cy.agorise.graphenej.api.calls.ListAssets; import cy.agorise.graphenej.errors.MalformedAddressException; import cy.agorise.graphenej.models.JsonRpcResponse; import cy.agorise.graphenej.operations.TransferOperation; +import cy.agorise.graphenej.operations.TransferOperationBuilder; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Consumer; @@ -155,6 +162,9 @@ public class PerformCallActivity extends ConnectedActivity { break; case RPC.CALL_GET_ACCOUNT_BALANCES: setupGetAccountBalances(); + break; + case RPC.CALL_BROADCAST_TRANSACTION: + setupBroadcastTransaction(); default: Log.d(TAG,"Default called"); } @@ -291,6 +301,12 @@ public class PerformCallActivity extends ConnectedActivity { param2.setHint(R.string.get_account_balances_arg2); } + private void setupBroadcastTransaction(){ + requiredInput(2); + param1.setText("1.2.116354"); + param2.setText("1"); + } + private void requiredInput(int inputCount){ if(inputCount == 0){ mParam1View.setVisibility(View.GONE); @@ -365,6 +381,9 @@ public class PerformCallActivity extends ConnectedActivity { break; case RPC.CALL_GET_ACCOUNT_BALANCES: getAccountBalances(); + break; + case RPC.CALL_BROADCAST_TRANSACTION: + broadcastTransaction(); default: Log.d(TAG,"Default called"); } @@ -486,6 +505,28 @@ public class PerformCallActivity extends ConnectedActivity { responseMap.put(id, mRPC); } + private void broadcastTransaction(){ + String destinationId = param1.getText().toString(); + String amount = param2.getText().toString(); + UnsignedLong transferAmount = UnsignedLong.valueOf(amount).times(UnsignedLong.valueOf(100000)); + TransferOperation operation = new TransferOperationBuilder() + .setSource(new UserAccount("1.2.1029856")) + .setDestination(new UserAccount(destinationId)) + .setTransferAmount(new AssetAmount( transferAmount, new Asset("1.3.0"))) + .setFee(new AssetAmount(UnsignedLong.valueOf("10420"), new Asset("1.3.0"))) + .build(); + ArrayList ops = new ArrayList<>(); + ops.add(operation); + // >> Replace with your brainkey << + BrainKey brainKey = new BrainKey(">> Place your brainkey here <<", 0); + ECKey privKey = brainKey.getPrivateKey(); + // Use valid BlockData + BlockData blockData = new BlockData(44542, 3342959171L, 1544917202L); + Transaction tx = new Transaction(privKey, blockData, ops); + long id = mNetworkService.sendMessage(new BroadcastTransaction(tx), BroadcastTransaction.REQUIRED_API); + responseMap.put(id, mRPC); + } + /** * Internal method that will decide what to do with each JSON-RPC response * @@ -521,7 +562,12 @@ public class PerformCallActivity extends ConnectedActivity { break; default: Log.w(TAG,"Case not handled"); - mResponseView.setText(mResponseView.getText() + response.result.toString()); + if(response.result != null) + mResponseView.setText(mResponseView.getText() + response.result.toString()); + else if(response.error != null) + mResponseView.setText(mResponseView.getText() + String.format("Error code: %d, Msg: %s", response.error.code, response.error.message)); + else + mResponseView.setText(mResponseView.getText() + "\nnull"); } // Remember to remove the used id entry from the map, as it would // otherwise just increase the app's memory usage From 91a5ecdd7b212a2de72d76cb3dcd8efb64b7d7e6 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Sat, 15 Dec 2018 08:51:01 -0600 Subject: [PATCH 3/4] Avoid NPE related carsh in NetworkService when trying to add a very high latency to a malfunctioning node. --- .../java/cy/agorise/graphenej/api/android/NetworkService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java index cb44c48..683b938 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java @@ -710,7 +710,8 @@ public class NetworkService extends Service { // Remove node from nodeLatencyVerifier, so that it publishes its removal nodeLatencyVerifier.removeNode(mSelectedNode); - } else { + // Avoid crash #133 + } else if (mSelectedNode != null){ // Adding a very high latency value to this node in order to prevent // us from getting it again mSelectedNode.addLatencyValue(Long.MAX_VALUE); From b54ae2cbae85466f34ae30250c5bb36e971f3701 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Wed, 19 Dec 2018 12:49:04 -0500 Subject: [PATCH 4/4] Added support for the 'get_assets' API call on the single-connection mode --- .../main/java/cy/agorise/graphenej/RPC.java | 1 + .../api/android/DeserializationMap.java | 8 +++ .../graphenej/api/android/NetworkService.java | 4 ++ .../graphenej/api/calls/GetAssets.java | 54 +++++++++++++++++++ .../cy/agorise/labs/sample/CallsActivity.java | 1 + .../labs/sample/PerformCallActivity.java | 28 ++++++++-- sample/src/main/res/values/strings.xml | 3 ++ 7 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetAssets.java diff --git a/graphenej/src/main/java/cy/agorise/graphenej/RPC.java b/graphenej/src/main/java/cy/agorise/graphenej/RPC.java index c5c68d4..7e2e306 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/RPC.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/RPC.java @@ -24,6 +24,7 @@ public class RPC { public static final String CALL_GET_ACCOUNT_HISTORY_BY_OPERATIONS = "get_account_history_by_operations"; public static final String CALL_LOOKUP_ACCOUNTS = "lookup_accounts"; public static final String CALL_LIST_ASSETS = "list_assets"; + public static final String CALL_GET_ASSETS = "get_assets"; public static final String CALL_GET_OBJECTS = "get_objects"; public static final String CALL_GET_ACCOUNT_BALANCES = "get_account_balances"; public static final String CALL_LOOKUP_ASSET_SYMBOLS = "lookup_asset_symbols"; diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java b/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java index 8d704ee..a7a6b21 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java @@ -23,6 +23,7 @@ import cy.agorise.graphenej.api.calls.GetAccountBalances; import cy.agorise.graphenej.api.calls.GetAccountByName; import cy.agorise.graphenej.api.calls.GetAccountHistoryByOperations; import cy.agorise.graphenej.api.calls.GetAccounts; +import cy.agorise.graphenej.api.calls.GetAssets; import cy.agorise.graphenej.api.calls.GetBlock; import cy.agorise.graphenej.api.calls.GetBlockHeader; import cy.agorise.graphenej.api.calls.GetDynamicGlobalProperties; @@ -193,6 +194,13 @@ public class DeserializationMap { .registerTypeAdapter(AssetAmount.class, new AssetAmount.AssetAmountDeserializer()) .create(); mGsonMap.put(GetAccountBalances.class, getAccountBalancesGson); + + // GetAssets + mClassMap.put(GetAssets.class, List.class); + Gson getAssetsGson = new GsonBuilder() + .registerTypeAdapter(Asset.class, new Asset.AssetDeserializer()) + .create(); + mGsonMap.put(GetAssets.class, getAssetsGson); } public Class getReceivedClass(Class _class){ diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java index cb44c48..afb32fb 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java @@ -34,6 +34,7 @@ import cy.agorise.graphenej.api.ConnectionStatusUpdate; import cy.agorise.graphenej.api.calls.ApiCallable; import cy.agorise.graphenej.api.calls.GetAccountBalances; import cy.agorise.graphenej.api.calls.GetAccounts; +import cy.agorise.graphenej.api.calls.GetAssets; import cy.agorise.graphenej.api.calls.GetFullAccounts; import cy.agorise.graphenej.api.calls.GetKeyReferences; import cy.agorise.graphenej.api.calls.GetLimitOrders; @@ -580,6 +581,9 @@ public class NetworkService extends Service { } else if(requestClass == GetAccountBalances.class){ Type GetAccountBalancesResponse = new TypeToken>>(){}.getType(); parsedResponse = gson.fromJson(text, GetAccountBalancesResponse); + } else if(requestClass == GetAssets.class){ + Type GetAssetsResponse = new TypeToken>>(){}.getType(); + parsedResponse = gson.fromJson(text, GetAssetsResponse); }else { Log.w(TAG,"Unknown request class"); } diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetAssets.java b/graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetAssets.java new file mode 100644 index 0000000..91ca709 --- /dev/null +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/calls/GetAssets.java @@ -0,0 +1,54 @@ +package cy.agorise.graphenej.api.calls; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import cy.agorise.graphenej.Asset; +import cy.agorise.graphenej.RPC; +import cy.agorise.graphenej.api.ApiAccess; +import cy.agorise.graphenej.models.ApiCall; + +public class GetAssets implements ApiCallable { + public static final int REQUIRED_API = ApiAccess.API_NONE; + + private List assetList = new ArrayList<>(); + + /** + * Constructor that will receive a List of Asset instances. + * + * @param assets List of Asset instances. + */ + public GetAssets(List assets){ + assetList.addAll(assets); + } + + /** + * Constructor that will accept a string containing the asset id. + * + * @param id String containing the asset id of the desired asset. + */ + public GetAssets(String id){ + assetList.add(new Asset(id)); + } + + /** + * Constructor that accepts an {@link Asset} object instance. + * + * @param asset Asset class instance. + */ + public GetAssets(Asset asset){ + assetList.add(asset); + } + + @Override + public ApiCall toApiCall(int apiId, long sequenceId) { + ArrayList params = new ArrayList<>(); + ArrayList assetIds = new ArrayList<>(); + for(Asset asset : assetList){ + assetIds.add(asset.getObjectId()); + } + params.add(assetIds); + return new ApiCall(apiId, RPC.CALL_GET_ASSETS, params, RPC.VERSION, sequenceId); + } +} diff --git a/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java b/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java index 0066bfb..c9899c8 100644 --- a/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java +++ b/sample/src/main/java/cy/agorise/labs/sample/CallsActivity.java @@ -70,6 +70,7 @@ public class CallsActivity extends AppCompatActivity { RPC.CALL_GET_REQUIRED_FEES, RPC.CALL_LOOKUP_ASSET_SYMBOLS, RPC.CALL_LIST_ASSETS, + RPC.CALL_GET_ASSETS, RPC.CALL_GET_ACCOUNT_BY_NAME, RPC.CALL_GET_LIMIT_ORDERS, RPC.CALL_GET_ACCOUNT_HISTORY_BY_OPERATIONS, diff --git a/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java b/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java index 651a4a0..650d761 100644 --- a/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java +++ b/sample/src/main/java/cy/agorise/labs/sample/PerformCallActivity.java @@ -45,6 +45,7 @@ import cy.agorise.graphenej.api.calls.GetAccountBalances; import cy.agorise.graphenej.api.calls.GetAccountByName; import cy.agorise.graphenej.api.calls.GetAccountHistoryByOperations; import cy.agorise.graphenej.api.calls.GetAccounts; +import cy.agorise.graphenej.api.calls.GetAssets; import cy.agorise.graphenej.api.calls.GetBlock; import cy.agorise.graphenej.api.calls.GetDynamicGlobalProperties; import cy.agorise.graphenej.api.calls.GetFullAccounts; @@ -143,6 +144,9 @@ public class PerformCallActivity extends ConnectedActivity { case RPC.CALL_LIST_ASSETS: setupListAssets(); break; + case RPC.CALL_GET_ASSETS: + setupGetAssets(); + break; case RPC.CALL_GET_ACCOUNT_BY_NAME: setupAccountByName(); break; @@ -240,12 +244,16 @@ public class PerformCallActivity extends ConnectedActivity { private void setupListAssets(){ requiredInput(2); - Resources resources = getResources(); - mParam1View.setHint(resources.getString(R.string.list_assets_arg1)); - mParam2View.setHint(resources.getString(R.string.list_assets_arg2)); + mParam1View.setHint(getString(R.string.list_assets_arg1)); + mParam2View.setHint(getString(R.string.list_assets_arg2)); param2.setInputType(InputType.TYPE_CLASS_NUMBER); } + private void setupGetAssets(){ + requiredInput(1); + mParam1View.setHint(getString(R.string.get_assets_arg)); + } + private void setupAccountByName(){ requiredInput(1); Resources resources = getResources(); @@ -361,6 +369,9 @@ public class PerformCallActivity extends ConnectedActivity { case RPC.CALL_LIST_ASSETS: sendListAssets(); break; + case RPC.CALL_GET_ASSETS: + sendGetAssets(); + break; case RPC.CALL_GET_ACCOUNT_BY_NAME: getAccountByName(); break; @@ -436,6 +447,16 @@ public class PerformCallActivity extends ConnectedActivity { } } + private void sendGetAssets(){ + String assetIds = param1.getText().toString(); + ArrayList assetList = new ArrayList<>(); + for(String id :assetIds.split(",")){ + assetList.add(new Asset(id)); + } + long id = mNetworkService.sendMessage(new GetAssets(assetList), GetAssets.REQUIRED_API); + responseMap.put(id, mRPC); + } + private void getAccountByName(){ String accountName = param1.getText().toString(); long id = mNetworkService.sendMessage(new GetAccountByName(accountName), GetAccountByName.REQUIRED_API); @@ -552,6 +573,7 @@ public class PerformCallActivity extends ConnectedActivity { case RPC.CALL_GET_REQUIRED_FEES: case RPC.CALL_LOOKUP_ASSET_SYMBOLS: case RPC.CALL_LIST_ASSETS: + case RPC.CALL_GET_ASSETS: case RPC.CALL_GET_ACCOUNT_BY_NAME: case RPC.CALL_GET_LIMIT_ORDERS: case RPC.CALL_GET_ACCOUNT_HISTORY_BY_OPERATIONS: diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index 73d4a6d..63865d5 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -41,6 +41,9 @@ Lower bound of symbol names to retrieve Maximum number of assets to fetch (must not exceed 100) + + List of asset ids separated by commas + Account name