Modified the GetRequiredFees class and adjusted the sample app

develop
Nelson R. Perez 2018-11-16 00:18:29 -05:00
parent 39afcd26c2
commit e1395a9d92
3 changed files with 25 additions and 1 deletions

View File

@ -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;

View File

@ -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<BaseOperation> 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();

View File

@ -28,6 +28,9 @@
<string name="get_relative_account_history_arg3">Limit</string>
<string name="get_relative_account_history_arg4">Start timestamp (Earliest)</string>
<!-- GetRequiredFees input fields -->
<string name="get_required_fees_asset">Enter asset id</string>
<!-- LookupAssetSymbols input fields -->
<string name="lookup_asset_symbols_arg1">Asset 1 id</string>
<string name="lookup_asset_symbols_arg2">Asset 2 id</string>