Search in sources :

Example 1 with WithdrawAddressGrpcTask

use of wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask in project cosmostation-android by cosmostation.

the class ValidatorActivity method onCheckReInvest.

private void onCheckReInvest() {
    if (!mAccount.hasPrivateKey) {
        AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_only_observe_title), getString(R.string.str_only_observe_msg), Html.fromHtml("<font color=\"#9C6CFF\">" + getString(R.string.str_add_mnemonics) + "</font>"), view -> onAddMnemonicForAccount(), getString(R.string.str_close), null);
        return;
    }
    BigDecimal feeAmount = WUtil.getEstimateGasFeeAmount(getBaseContext(), mBaseChain, CONST_PW_TX_REINVEST, 0);
    List<String> availableFeeDenomList = Lists.newArrayList();
    for (String denom : WDp.getGasDenomList(mBaseChain)) {
        if (getBaseDao().getAvailable(denom).compareTo(feeAmount) >= 0) {
            availableFeeDenomList.add(denom);
        }
    }
    if (availableFeeDenomList.isEmpty()) {
        Toast.makeText(getBaseContext(), R.string.error_not_enough_fee, Toast.LENGTH_SHORT).show();
        return;
    }
    if (getBaseDao().getReward(WDp.mainDenom(mBaseChain), mValOpAddress).compareTo(BigDecimal.ZERO) <= 0) {
        Toast.makeText(getBaseContext(), R.string.error_not_enough_reward, Toast.LENGTH_SHORT).show();
        return;
    }
    new WithdrawAddressGrpcTask(getBaseApplication(), new TaskListener() {

        @Override
        public void onTaskResponse(TaskResult result) {
            String rewardAddress = (String) result.resultData;
            if (rewardAddress == null || !rewardAddress.equals(mAccount.address)) {
                Toast.makeText(getBaseContext(), R.string.error_reward_address_changed_msg, Toast.LENGTH_SHORT).show();
                return;
            } else {
                Intent reinvest = new Intent(ValidatorActivity.this, ReInvestActivity.class);
                reinvest.putExtra("valOpAddress", mValOpAddress);
                startActivity(reinvest);
            }
        }
    }, mBaseChain, mAccount).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : WithdrawAddressGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask) TaskListener(wannabit.io.cosmostaion.task.TaskListener) TaskResult(wannabit.io.cosmostaion.task.TaskResult) Intent(android.content.Intent) SpannableString(android.text.SpannableString) BigDecimal(java.math.BigDecimal)

Example 2 with WithdrawAddressGrpcTask

use of wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask in project cosmostation-android by cosmostation.

the class AccountDetailActivity method onInitView.

private void onInitView() {
    if (getIntent() == null || TextUtils.isEmpty(getIntent().getStringExtra("id"))) {
        onBackPressed();
    }
    mAccount = getBaseDao().onSelectAccount(getIntent().getStringExtra("id"));
    if (mAccount == null)
        onBackPressed();
    mBaseChain = BaseChain.getChain(mAccount.baseChain);
    onUpdatePushStatusUI();
    WDp.showChainDp(AccountDetailActivity.this, mBaseChain, mCardName, mCardAlarm, mCardBody, mCardRewardAddress);
    WDp.getChainImg(AccountDetailActivity.this, mBaseChain, mChainImg);
    if (isGRPC(mBaseChain)) {
        new WithdrawAddressGrpcTask(getBaseApplication(), this, mBaseChain, mAccount).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        new NodeInfoGrpcTask(getBaseApplication(), this, mBaseChain).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        new NodeInfoTask(getBaseApplication(), this, BaseChain.getChain(mAccount.baseChain)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
    if (TextUtils.isEmpty(mAccount.nickName)) {
        mAccountName.setText(getString(R.string.str_my_wallet) + mAccount.id);
    } else {
        mAccountName.setText(mAccount.nickName);
    }
    mAccountAddress.setText(mAccount.address);
    mAccountGenTime.setText(WDp.getDpTime(getBaseContext(), mAccount.importTime));
    if (mAccount.hasPrivateKey && mAccount.fromMnemonic) {
        mAccountState.setText(getString(R.string.str_with_mnemonic));
        mAccountPath.setText(WDp.getPath(BaseChain.getChain(mAccount.baseChain), Integer.parseInt(mAccount.path), mAccount.customPath));
        mPathLayer.setVisibility(View.VISIBLE);
        mImportMsg.setVisibility(View.GONE);
        mBtnCheck.setVisibility(View.VISIBLE);
        mBtnCheckKey.setVisibility(View.VISIBLE);
        mBtnCheck.setText(getString(R.string.str_check_mnemonic));
        mBtnCheckKey.setText(getString(R.string.str_check_private_key));
    } else if (mAccount.hasPrivateKey && !mAccount.fromMnemonic) {
        mAccountState.setText(getString(R.string.str_with_privatekey));
        mPathLayer.setVisibility(View.GONE);
        mImportMsg.setVisibility(View.GONE);
        mBtnCheck.setVisibility(View.GONE);
        mView.setVisibility(View.GONE);
        mBtnCheckKey.setVisibility(View.VISIBLE);
        mBtnCheckKey.setText(getString(R.string.str_check_private_key));
        if (mBaseChain.equals(OKEX_MAIN)) {
            mPathLayer.setVisibility(View.VISIBLE);
            mAccountPathTitle.setText("Address Type");
            if (mAccount.customPath > 0) {
                mAccountPath.setText("Ethereum Type Address");
            } else {
                mAccountPath.setText("Legacy Tendermint Type Address");
            }
            mAccountPath.setTextColor(getResources().getColor(R.color.colorPhoton));
        }
    } else {
        mAccountState.setText(getString(R.string.str_only_address));
        mPathLayer.setVisibility(View.GONE);
        mImportMsg.setVisibility(View.VISIBLE);
        mImportMsg.setTextColor(WDp.getChainColor(getBaseContext(), mBaseChain));
        mBtnCheck.setVisibility(View.VISIBLE);
        mBtnCheckKey.setVisibility(View.VISIBLE);
        mBtnCheck.setText(getString(R.string.str_import_mnemonic));
        mBtnCheckKey.setText(getString(R.string.str_import_key));
    }
}
Also used : WithdrawAddressGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask) NodeInfoTask(wannabit.io.cosmostaion.task.FetchTask.NodeInfoTask) NodeInfoGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.NodeInfoGrpcTask)

Example 3 with WithdrawAddressGrpcTask

use of wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask in project cosmostation-android by cosmostation.

the class ClaimRewardActivity method onFetchReward.

private void onFetchReward() {
    if (mTaskCount > 0)
        return;
    mTaskCount = 2;
    new AllRewardGrpcTask(getBaseApplication(), this, mBaseChain, mAccount).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    new WithdrawAddressGrpcTask(getBaseApplication(), this, mBaseChain, mAccount).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : WithdrawAddressGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask) AllRewardGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.AllRewardGrpcTask)

Aggregations

WithdrawAddressGrpcTask (wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask)3 Intent (android.content.Intent)1 SpannableString (android.text.SpannableString)1 BigDecimal (java.math.BigDecimal)1 NodeInfoTask (wannabit.io.cosmostaion.task.FetchTask.NodeInfoTask)1 TaskListener (wannabit.io.cosmostaion.task.TaskListener)1 TaskResult (wannabit.io.cosmostaion.task.TaskResult)1 AllRewardGrpcTask (wannabit.io.cosmostaion.task.gRpcTask.AllRewardGrpcTask)1 NodeInfoGrpcTask (wannabit.io.cosmostaion.task.gRpcTask.NodeInfoGrpcTask)1