use of run.wallet.iota.api.responses.error.NetworkError in project run-wallet-android by runplay.
the class BasicApiProvider method processRequest.
@Override
public ApiResponse processRequest(ApiRequest apiRequest) {
ApiResponse response = null;
try {
if (useRequestHandlerMap.containsKey(apiRequest.getClass())) {
RequestHandler requestHandler = useRequestHandlerMap.get(apiRequest.getClass());
response = requestHandler.handle(apiRequest);
}
} catch (IllegalAccessError e) {
NetworkError error = new NetworkError();
error.setErrorType(NetworkErrorType.ACCESS_ERROR);
response = error;
Log.e("ERR-B-API1", "" + e.getMessage());
} catch (Exception e) {
Log.e("ERR-B-API2", e.toString() + " -- " + e.getMessage());
response = new NetworkError();
}
return response == null ? new NetworkError() : response;
}
use of run.wallet.iota.api.responses.error.NetworkError in project run-wallet-android by runplay.
the class IotaMessageApiProvider method processRequest.
@Override
public ApiResponse processRequest(ApiRequest apiRequest) {
ApiResponse response = null;
try {
// Log.e("IotaMessageApiProvider", "");
if (this.requestHandlerMap.containsKey(apiRequest.getClass())) {
// Log.e("IotaMessageApiProvider", "requesting");
RequestHandler requestHandler = this.requestHandlerMap.get(apiRequest.getClass());
response = requestHandler.handle(apiRequest);
}
} catch (IllegalAccessError e) {
NetworkError error = new NetworkError();
error.setErrorType(NetworkErrorType.ACCESS_ERROR);
response = error;
// Log.e("IotaMessageApi ERR",""+e.getMessage());
} catch (Exception e) {
Log.e("ERR-API", "ex: " + e.getMessage());
response = new NetworkError();
}
return response == null ? new NetworkError() : response;
}
use of run.wallet.iota.api.responses.error.NetworkError in project run-wallet-android by runplay.
the class AddressSecurityChangeRequestHandler method handle.
@Override
public ApiResponse handle(ApiRequest request) {
ApiResponse response;
AddressSecurityChangeRequest gnr = ((AddressSecurityChangeRequest) request);
try {
jota.dto.response.GetNewAddressResponse resp = apiProxy.getNewAddress(gnr.getAddress().getAddress(), gnr.getSecurity(), gnr.getAddress().getIndex(), false, 1, true);
// Log.e("ADDRES-SECURITY","has response: "+resp.getAddresses().get(0));
response = new GetNewAddressResponse(gnr.getSeed(), resp);
Store.updateAddressFromSecurity(context, gnr, (GetNewAddressResponse) response);
return new AddressSecurityChangeResponse();
} catch (ArgumentException e) {
response = new NetworkError();
}
return response;
}
use of run.wallet.iota.api.responses.error.NetworkError in project run-wallet-android by runplay.
the class GetBalanceAndFormatRequestHandler method handle.
@Override
public ApiResponse handle(ApiRequest request) {
int notificationId = Utils.createNewID();
ApiResponse response;
try {
StopWatch stopWatch = new StopWatch();
// stopWatch.
// Log.e("BALF","Getting balances and format");
response = new GetBalanceAndFormatResponse(apiProxy.getBalanceAndFormat(((GetBalanceAndFormatRequest) request).addresses, 0L, 0, stopWatch, 0));
List<Input> inputs = ((GetBalanceAndFormatResponse) response).getInputs();
} catch (ArgumentException e) {
NetworkError error = new NetworkError();
if (e instanceof ArgumentException) {
if (e.getMessage().contains("Sending to a used address.") || e.getMessage().contains("Private key reuse detect!")) {
final Activity activity = (Activity) context;
Bundle bundle = new Bundle();
bundle.putString("error", e.getMessage());
KeyReuseDetectedDialog dialog = new KeyReuseDetectedDialog();
dialog.setArguments(bundle);
dialog.show(activity.getFragmentManager(), null);
error.setErrorType(NetworkErrorType.KEY_REUSE_ERROR);
}
}
if (error.getErrorType() != NetworkErrorType.KEY_REUSE_ERROR) {
error.setErrorType(NetworkErrorType.NETWORK_ERROR);
}
response = error;
}
return response;
}
use of run.wallet.iota.api.responses.error.NetworkError in project run-wallet-android by runplay.
the class GetNewAddressRequestHandler method handle.
@Override
public ApiResponse handle(ApiRequest request) {
ApiResponse response;
GetNewAddressRequest gnr = ((GetNewAddressRequest) request);
List<Address> alreadyAddress = Store.getAddresses(context, gnr.getSeed());
gnr.setIndex(alreadyAddress.size());
try {
jota.dto.response.GetNewAddressResponse resp = apiProxy.getNewAddress(String.valueOf(Store.getSeedRaw(context, gnr.getSeed())), gnr.getSecurity(), alreadyAddress.size(), gnr.isChecksum(), 1, gnr.isReturnAll());
/*
jota.dto.response.GetNewAddressResponse resp=apiProxy.getNewAddress(((GetNewAddressRequest) request).getSeedValue(),
((GetNewAddressRequest) request).getSecurity(),
((GetNewAddressRequest) request).getIndex(),
((GetNewAddressRequest) request).isChecksum(),
((GetNewAddressRequest) request).getTotal(),
((GetNewAddressRequest) request).isReturnAll());
*/
response = new GetNewAddressResponse(gnr.getSeed(), resp);
Store.addAddress(context, gnr, (GetNewAddressResponse) response);
AppService.auditAddresses(context, gnr.getSeed());
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
// if (prefs.getBoolean(Constants.PREFERENCES_LOCAL_POW, true)
// && !((GetNewAddressResponse) response).getAddresses().isEmpty()) {
// AppService.attachNewAddress(context,((GetNewAddressRequest) request).getSeed(),((GetNewAddressResponse) response).getAddresses().get(0));
// }
} catch (ArgumentException e) {
response = new NetworkError();
}
return response;
}
Aggregations