@Test public void checkDelegateParam(){ EstimateGasResult estimateGasResult = new EstimateGasResult(); estimateGasResult.setBlockGasLimit("500000000000"); estimateGasResult.setFree("5983375239628300134343588424455034335218"); estimateGasResult.setGasLimit("1379820"); estimateGasResult.setGasPrice("500000000000"); estimateGasResult.setLock("0"); estimateGasResult.setMinDelegation("20000000000000000000"); estimateGasResult.setNonce("44"); StakingAmountType stakingAmountType = StakingAmountType.getStakingAmountType(1000); presenter.setmEstimateGasResult(estimateGasResult); }
public String checkDelegateParam(EstimateGasResult estimateGasResult, StakingAmountType stakingAmountType) { BigDecimal feeAmount = new BigDecimal(getView().getFeeAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal delegateAmount = new BigDecimal(getView().getDelegateAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal freeAmount = new BigDecimal(estimateGasResult.getFree()); BigDecimal lockAmount = new BigDecimal(estimateGasResult.getLock()); boolean isFreeAmountNotEnoughDelegateAmount = freeAmount.compareTo(feeAmount.add(delegateAmount)) < 0; boolean isFreeAmountNotEnoughFeeAmount = freeAmount.compareTo(feeAmount) < 0; boolean isLockAmountNotEnough = lockAmount.compareTo(delegateAmount) < 0; boolean isNotEnough = stakingAmountType == StakingAmountType.FREE_AMOUNT_TYPE ? isFreeAmountNotEnoughDelegateAmount : isFreeAmountNotEnoughFeeAmount || isLockAmountNotEnough; if (isNotEnough) { return string(R.string.insufficient_balance_unable_to_delegate); } return ""; }
DelegatePresenter extends BasePresenter<DelegateContract.View> implements DelegateContract.Presenter { public String checkDelegateParam(EstimateGasResult estimateGasResult, StakingAmountType stakingAmountType) { BigDecimal feeAmount = new BigDecimal(getView().getFeeAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal delegateAmount = new BigDecimal(getView().getDelegateAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal freeAmount = new BigDecimal(estimateGasResult.getFree()); BigDecimal lockAmount = new BigDecimal(estimateGasResult.getLock()); boolean isFreeAmountNotEnoughDelegateAmount = freeAmount.compareTo(feeAmount.add(delegateAmount)) < 0; boolean isFreeAmountNotEnoughFeeAmount = freeAmount.compareTo(feeAmount) < 0; boolean isLockAmountNotEnough = lockAmount.compareTo(delegateAmount) < 0; boolean isNotEnough = stakingAmountType == StakingAmountType.FREE_AMOUNT_TYPE ? isFreeAmountNotEnoughDelegateAmount : isFreeAmountNotEnoughFeeAmount || isLockAmountNotEnough; if (isNotEnough) { return string(R.string.insufficient_balance_unable_to_delegate); } return ""; } }
DelegatePresenter extends BasePresenter<DelegateContract.View> implements DelegateContract.Presenter { public String checkDelegateParam(EstimateGasResult estimateGasResult, StakingAmountType stakingAmountType) { BigDecimal feeAmount = new BigDecimal(getView().getFeeAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal delegateAmount = new BigDecimal(getView().getDelegateAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal freeAmount = new BigDecimal(estimateGasResult.getFree()); BigDecimal lockAmount = new BigDecimal(estimateGasResult.getLock()); boolean isFreeAmountNotEnoughDelegateAmount = freeAmount.compareTo(feeAmount.add(delegateAmount)) < 0; boolean isFreeAmountNotEnoughFeeAmount = freeAmount.compareTo(feeAmount) < 0; boolean isLockAmountNotEnough = lockAmount.compareTo(delegateAmount) < 0; boolean isNotEnough = stakingAmountType == StakingAmountType.FREE_AMOUNT_TYPE ? isFreeAmountNotEnoughDelegateAmount : isFreeAmountNotEnoughFeeAmount || isLockAmountNotEnough; if (isNotEnough) { return string(R.string.insufficient_balance_unable_to_delegate); } return ""; }  }
DelegatePresenter extends BasePresenter<DelegateContract.View> implements DelegateContract.Presenter { public String checkDelegateParam(EstimateGasResult estimateGasResult, StakingAmountType stakingAmountType) { BigDecimal feeAmount = new BigDecimal(getView().getFeeAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal delegateAmount = new BigDecimal(getView().getDelegateAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal freeAmount = new BigDecimal(estimateGasResult.getFree()); BigDecimal lockAmount = new BigDecimal(estimateGasResult.getLock()); boolean isFreeAmountNotEnoughDelegateAmount = freeAmount.compareTo(feeAmount.add(delegateAmount)) < 0; boolean isFreeAmountNotEnoughFeeAmount = freeAmount.compareTo(feeAmount) < 0; boolean isLockAmountNotEnough = lockAmount.compareTo(delegateAmount) < 0; boolean isNotEnough = stakingAmountType == StakingAmountType.FREE_AMOUNT_TYPE ? isFreeAmountNotEnoughDelegateAmount : isFreeAmountNotEnoughFeeAmount || isLockAmountNotEnough; if (isNotEnough) { return string(R.string.insufficient_balance_unable_to_delegate); } return ""; }  EstimateGasResult getmEstimateGasResult(); void setmEstimateGasResult(EstimateGasResult mEstimateGasResult); String getWalletAddress(); @Override void init(DelegateItemInfo delegateItemInfo); @Override void showSelectWalletDialogFragment(); @Override void showWalletInfo(); @Override void checkDelegateAmount(String delegateAmount); @Override void updateDelegateButtonState(); @SuppressLint("CheckResult") @Override void getGasProvider(StakingAmountType stakingAmountType); @Override void loadData(int walletTypeSearch, String keywords); @Override ArrayList<Wallet> getDataSource(); @Override void updateSelectedWalletnotifyData(Wallet selectedWallet); boolean checkKeywordsAddress(String input); void getAllPrice(StakingAmountType stakingAmountType, String amount, boolean keepBalance); String checkDelegateParam(EstimateGasResult estimateGasResult, StakingAmountType stakingAmountType); @SuppressLint("CheckResult") @Override void submitDelegate(StakingAmountType stakingAmountType); Wallet getWalletByAddress(String address); void getEstimateGas(String prefixAddress, String nodeId); }
DelegatePresenter extends BasePresenter<DelegateContract.View> implements DelegateContract.Presenter { public String checkDelegateParam(EstimateGasResult estimateGasResult, StakingAmountType stakingAmountType) { BigDecimal feeAmount = new BigDecimal(getView().getFeeAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal delegateAmount = new BigDecimal(getView().getDelegateAmount()).multiply(new BigDecimal(DEFAULT_EXCHANGE_RATE)); BigDecimal freeAmount = new BigDecimal(estimateGasResult.getFree()); BigDecimal lockAmount = new BigDecimal(estimateGasResult.getLock()); boolean isFreeAmountNotEnoughDelegateAmount = freeAmount.compareTo(feeAmount.add(delegateAmount)) < 0; boolean isFreeAmountNotEnoughFeeAmount = freeAmount.compareTo(feeAmount) < 0; boolean isLockAmountNotEnough = lockAmount.compareTo(delegateAmount) < 0; boolean isNotEnough = stakingAmountType == StakingAmountType.FREE_AMOUNT_TYPE ? isFreeAmountNotEnoughDelegateAmount : isFreeAmountNotEnoughFeeAmount || isLockAmountNotEnough; if (isNotEnough) { return string(R.string.insufficient_balance_unable_to_delegate); } return ""; }  EstimateGasResult getmEstimateGasResult(); void setmEstimateGasResult(EstimateGasResult mEstimateGasResult); String getWalletAddress(); @Override void init(DelegateItemInfo delegateItemInfo); @Override void showSelectWalletDialogFragment(); @Override void showWalletInfo(); @Override void checkDelegateAmount(String delegateAmount); @Override void updateDelegateButtonState(); @SuppressLint("CheckResult") @Override void getGasProvider(StakingAmountType stakingAmountType); @Override void loadData(int walletTypeSearch, String keywords); @Override ArrayList<Wallet> getDataSource(); @Override void updateSelectedWalletnotifyData(Wallet selectedWallet); boolean checkKeywordsAddress(String input); void getAllPrice(StakingAmountType stakingAmountType, String amount, boolean keepBalance); String checkDelegateParam(EstimateGasResult estimateGasResult, StakingAmountType stakingAmountType); @SuppressLint("CheckResult") @Override void submitDelegate(StakingAmountType stakingAmountType); Wallet getWalletByAddress(String address); void getEstimateGas(String prefixAddress, String nodeId);  }