Updated on 2026-08-14
This commit is contained in:
parent
6fcb7fa502
commit
0b82dcbeb7
2 changed files with 37 additions and 7 deletions
|
|
@ -6,7 +6,6 @@ import android.util.Log;
|
|||
import com.tangem.wallet.CoinData;
|
||||
import com.tangem.wallet.CoinEngine;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.stellar.sdk.KeyPair;
|
||||
import org.stellar.sdk.responses.AccountResponse;
|
||||
import org.stellar.sdk.responses.LedgerResponse;
|
||||
|
|
@ -31,11 +30,13 @@ public class XlmData extends CoinData {
|
|||
private Long sequenceNumber = 0L;
|
||||
private CoinEngine.Amount baseReserve = new CoinEngine.Amount("0.5", "XLM");
|
||||
private CoinEngine.Amount baseFee = new CoinEngine.Amount("0.00001", "XLM");
|
||||
private boolean error404 = false;
|
||||
|
||||
@Override
|
||||
public void clearInfo() {
|
||||
super.clearInfo();
|
||||
balance = null;
|
||||
error404 = false;
|
||||
}
|
||||
|
||||
CoinEngine.Amount getBalance() {
|
||||
|
|
@ -77,6 +78,14 @@ public class XlmData extends CoinData {
|
|||
sequenceNumber++;
|
||||
}
|
||||
|
||||
public boolean isError404() {
|
||||
return error404;
|
||||
}
|
||||
|
||||
public void setError404(boolean error404) {
|
||||
this.error404 = error404;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromBundle(Bundle B) {
|
||||
super.loadFromBundle(B);
|
||||
|
|
@ -104,6 +113,9 @@ public class XlmData extends CoinData {
|
|||
} else {
|
||||
baseFee = new CoinEngine.Amount("0.00001", "XLM");
|
||||
}
|
||||
|
||||
if (B.containsKey("Error404")) error404 = B.getBoolean("Error404");
|
||||
else error404 = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -129,6 +141,8 @@ public class XlmData extends CoinData {
|
|||
B.putString("BaseFeeDecimal", baseFee.toValueString());
|
||||
}
|
||||
|
||||
if (error404) B.putBoolean("Error404", true);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("Can't save to bundle ", e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,10 +202,16 @@ public class XlmEngine extends CoinEngine {
|
|||
public boolean validateBalance(BalanceValidator balanceValidator) {
|
||||
try {
|
||||
if (((ctx.getCard().getOfflineBalance() == null) && !ctx.getCoinData().isBalanceReceived()) || (!ctx.getCoinData().isBalanceReceived() && (ctx.getCard().getRemainingSignatures() != ctx.getCard().getMaxSignatures()))) {
|
||||
balanceValidator.setScore(0);
|
||||
balanceValidator.setFirstLine("Unknown balance");
|
||||
balanceValidator.setSecondLine("Balance cannot be verified. Swipe down to refresh.");
|
||||
return false;
|
||||
if (coinData.isError404()) {
|
||||
balanceValidator.setScore(0);
|
||||
balanceValidator.setFirstLine("No account or network error");
|
||||
balanceValidator.setSecondLine("To create account send 1+ XLM to this address");
|
||||
} else {
|
||||
balanceValidator.setScore(0);
|
||||
balanceValidator.setFirstLine("Unknown balance");
|
||||
balanceValidator.setSecondLine("Balance cannot be verified. Swipe down to refresh.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Workaround before new back-end
|
||||
|
|
@ -441,9 +447,19 @@ public class XlmEngine extends CoinEngine {
|
|||
@Override
|
||||
public void onFail(StellarRequest.Base request) {
|
||||
Log.i(TAG, "onFail: " + request.getClass().getSimpleName() + " " + request.getError());
|
||||
ctx.setError(request.getError());
|
||||
|
||||
if (request.errorResponse.getCode() == 404) {
|
||||
coinData.setError404(true);
|
||||
} else {
|
||||
ctx.setError(request.getError());
|
||||
}
|
||||
|
||||
if (serverApi.isRequestsSequenceCompleted()) {
|
||||
blockchainRequestsCallbacks.onComplete(false);
|
||||
if (ctx.hasError()) {
|
||||
blockchainRequestsCallbacks.onComplete(false);
|
||||
} else {
|
||||
blockchainRequestsCallbacks.onComplete(true);
|
||||
}
|
||||
} else {
|
||||
blockchainRequestsCallbacks.onProgress();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue