From 3d35644088ad319744c2c719a36c2ef3ac297007 Mon Sep 17 00:00:00 2001 From: Kwonhyukjoon Date: Mon, 5 Aug 2024 21:38:25 +0900 Subject: [PATCH] [APP-1022] qa bug fixed --- .../io/cosmostaion/chain/BaseChain.kt | 6 ++-- .../io/cosmostaion/common/Extensions.kt | 4 +-- .../ui/main/chain/cosmos/CoinAdapter.kt | 19 +++++----- .../ui/main/chain/cosmos/CoinFragment.kt | 2 +- .../main/chain/cosmos/CosmosDetailFragment.kt | 2 +- .../ui/main/chain/cosmos/HistoryFragment.kt | 16 ++++++--- .../ui/main/chain/evm/EvmDetailFragment.kt | 2 +- .../dapp/option/PopUpCosmosSignFragment.kt | 34 ++++++++++++------ .../io/cosmostaion/ui/tx/step/SwapFragment.kt | 20 ++--------- .../service/AllChainCompoundingFragment.kt | 12 ++++--- .../tx/step/service/AllChainVoteFragment.kt | 36 ++++++++++--------- .../main/res/layout/fragment_evm_detail.xml | 2 +- 12 files changed, 81 insertions(+), 74 deletions(-) diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt index 7a7b683dd..efbe2d765 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt @@ -421,12 +421,10 @@ open class BaseChain : Parcelable { return getChainListParam()?.get("moblie_dapp")?.asBoolean ?: false } - fun explorerAccount(): Uri? { + fun explorerAccount(address: String): Uri? { getChainListParam()?.getAsJsonObject("explorer") ?.get("account")?.asString?.let { urlString -> - address.let { - return Uri.parse(urlString.replace("\${address}", it)) - } + return Uri.parse(urlString.replace("\${address}", address)) } return null } diff --git a/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt b/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt index b16ed8089..5bb3853eb 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt @@ -440,9 +440,9 @@ fun gapTime(finishTime: Long): String { result = if (left >= CONSTANT_D) { "D-" + left / CONSTANT_D } else if (left >= BaseConstant.CONSTANT_H) { - (left / BaseConstant.CONSTANT_H).toString() + " hours ago" + (left / BaseConstant.CONSTANT_H).toString() + " hours left" } else if (left >= BaseConstant.CONSTANT_M) { - (left / BaseConstant.CONSTANT_M).toString() + " minutes ago" + (left / BaseConstant.CONSTANT_M).toString() + " minutes left" } else { "0 days" } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt index 3fe7acbb7..2e4ea0ab6 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt @@ -62,8 +62,7 @@ class CoinAdapter( } fun setOktItems( - stakeCoins: MutableList, - etcCoins: MutableList + stakeCoins: MutableList, etcCoins: MutableList ) { val tempList = mutableListOf() if (stakeCoins.isNotEmpty()) { @@ -78,9 +77,7 @@ class CoinAdapter( } fun setOktEvmItems( - stakeCoins: MutableList, - etcCoins: MutableList, - tokenCoins: MutableList + stakeCoins: MutableList, etcCoins: MutableList, tokenCoins: MutableList ) { val tempList = mutableListOf() if (stakeCoins.isNotEmpty()) { @@ -291,18 +288,18 @@ class CoinAdapter( headerCnt.text = bridgeCoins.size.toString() } else if (getItemViewType(position) == VIEW_TYPE_ETC_HEADER) { - headerTitle.text = if (chain is ChainOkt996Keccak) { - context.getString(R.string.str_kip10_coins) - } else { - context.getString(R.string.str_kip20_tokens) - } + headerTitle.text = context.getString(R.string.str_native_coins) headerCnt.text = etcCoins.size.toString() } else { headerTitle.text = if (selectedChain.supportCw20) { context.getString(R.string.str_contract_tokens) } else { - context.getString(R.string.str_erc20_tokens) + if (selectedChain is ChainOktEvm) { + context.getString(R.string.str_kip20_tokens) + } else { + context.getString(R.string.str_erc20_tokens) + } } headerCnt.text = tokenCoins.size.toString() } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt index 0c4508e78..7aa107733 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt @@ -305,7 +305,7 @@ class CoinFragment : Fragment() { return@setOnItemClickListener } - if (chain is ChainOkt996Keccak || chain is ChainOktEvm && position != 0) { + if (chain is ChainOkt996Keccak || chain is ChainOktEvm && sendAssetType == SendAssetType.ONLY_COSMOS_COIN) { startLegacyTransfer(chain, denom) } else { startTransfer(chain, denom, sendAssetType) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt index fa44ec78f..5a9d40dad 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt @@ -340,7 +340,7 @@ class CosmosDetailFragment : Fragment() { } btnAccount.setOnClickListener { - selectedChain.explorerAccount()?.let { url -> + selectedChain.explorerAccount(selectedChain.address)?.let { url -> startActivity(Intent(Intent.ACTION_VIEW, url)) Prefs.foreToBack = false } ?: run { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryFragment.kt index 524e2a78d..55684e9b3 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryFragment.kt @@ -169,13 +169,18 @@ class HistoryFragment : Fragment() { ) } } - binding.refresher.isRefreshing = false + if (binding.refresher.isRefreshing) { + binding.recycler.suppressLayout(true) + } } private fun scrollView() { binding.recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) + if (binding.refresher.isRefreshing) { + return + } if (historyAdapter.itemCount == 0) { return } @@ -201,10 +206,12 @@ class HistoryFragment : Fragment() { private fun checkHistory() { historyViewModel.historyResult.observe(viewLifecycleOwner) { response -> - allHistoryGroup.addAll(response) + binding.refresher.isRefreshing = false + binding.recycler.suppressLayout(false) response?.let { historyGroup -> + allHistoryGroup.addAll(historyGroup) if (historyGroup.isNotEmpty()) { - historyAdapter.submitList(allHistoryGroup.toList()) + historyAdapter.submitList(allHistoryGroup as List?) searchAfter = allHistoryGroup[allHistoryGroup.size - 1].second.searchAfter.toString() hasMore = historyGroup.size >= BATCH_CNT @@ -221,9 +228,10 @@ class HistoryFragment : Fragment() { } historyViewModel.oktHistoryResult.observe(viewLifecycleOwner) { response -> + binding.refresher.isRefreshing = false allOktHistoryGroup.addAll(response) response?.let { - historyAdapter.submitList(allOktHistoryGroup.toList()) + historyAdapter.submitList(allOktHistoryGroup as List?) } binding.loading.visibility = View.GONE diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmDetailFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmDetailFragment.kt index 07665dcdb..8c0022401 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmDetailFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmDetailFragment.kt @@ -197,7 +197,7 @@ class EvmDetailFragment : Fragment() { } btnAccount.setOnClickListener { - selectedEvmChain.explorerAccount()?.let { url -> + selectedEvmChain.explorerAccount(selectedEvmChain.evmAddress)?.let { url -> startActivity(Intent(Intent.ACTION_VIEW, url)) Prefs.foreToBack = false diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/option/PopUpCosmosSignFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/option/PopUpCosmosSignFragment.kt index 3aea8746c..db1580c5e 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/option/PopUpCosmosSignFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/option/PopUpCosmosSignFragment.kt @@ -103,9 +103,13 @@ class PopUpCosmosSignFragment( val txJsonObject = JsonParser.parseString(data).asJsonObject val txJsonSignDoc = txJsonObject.getAsJsonObject("signDoc") ?: txJsonObject.getAsJsonObject("doc") - val chainIdJson = - txJsonSignDoc["chain_id"] ?: txJsonSignDoc.getAsJsonObject("chainName") - val chainId = chainIdJson.asString + val chainId = if (txJsonSignDoc != null) { + val chainIdJson = txJsonSignDoc.asJsonObject["chain_id"] + ?: txJsonSignDoc.asJsonObject["chainName"] + chainIdJson.asString + } else { + txJsonObject["chainName"].asString ?: txJsonObject["chain_id"].asString + } allChains?.filter { it.isDefault && !it.isTestnet && it.supportCosmos() } ?.firstOrNull { it.chainIdCosmos.lowercase() == chainId.lowercase() } @@ -153,11 +157,13 @@ class PopUpCosmosSignFragment( chain.cosmosFetcher()?.let { fetcher -> try { fetcher.getChannel()?.let { channel -> - val loadInputAuthDeferred = async { loadAuth(channel, chain.address) } + val loadInputAuthDeferred = + async { loadAuth(channel, chain.address) } val loadInputBalanceDeferred = async { loadBalance(channel, chain.address) } - chain.cosmosFetcher?.cosmosAuth = loadInputAuthDeferred.await()?.account + chain.cosmosFetcher?.cosmosAuth = + loadInputAuthDeferred.await()?.account chain.cosmosFetcher?.cosmosBalances = loadInputBalanceDeferred.await().balancesList BaseUtils.onParseVesting(chain) @@ -210,8 +216,7 @@ class PopUpCosmosSignFragment( gasTitle = mutableListOf( getString(R.string.str_fixed) ) - val segmentView = - ItemDappSegmentedFeeBinding.inflate(layoutInflater) + val segmentView = ItemDappSegmentedFeeBinding.inflate(layoutInflater) feeSegment.addView( segmentView.root, 0, @@ -227,8 +232,7 @@ class PopUpCosmosSignFragment( "sign_direct" -> { feeInfos = chain.getFeeInfos(requireContext()) for (i in feeInfos.indices) { - val segmentView = - ItemDappSegmentedFeeBinding.inflate(layoutInflater) + val segmentView = ItemDappSegmentedFeeBinding.inflate(layoutInflater) feeSegment.addView( segmentView.root, i, LinearLayout.LayoutParams( 0, dpToPx(requireContext(), 32), 1f @@ -506,7 +510,17 @@ class PopUpCosmosSignFragment( private fun updateFeeInfoInDirectMessage(txJsonObject: JsonObject): JsonObject { val doc = txJsonObject["doc"].asJsonObject var authInfo = TxProto.AuthInfo.parseFrom(Utils.hexToBytes(doc["auth_info_bytes"].asString)) - authInfo = authInfo.toBuilder().setFee(txFee).build() + if (authInfo.fee.payer.isEmpty() || authInfo.fee.payer == null) { + authInfo = authInfo.toBuilder().setFee(txFee).build() + } else { + txFee?.let { fee -> + val dpFee = Fee.newBuilder().setGasLimit(fee.gasLimit).addAmount( + CoinProto.Coin.newBuilder().setDenom(fee.getAmount(0).denom) + .setAmount(fee.getAmount(0).amount) + ).setPayer(authInfo.fee.payer).build() + authInfo = authInfo.toBuilder().setFee(dpFee).build() + } + } val txBody = TxProto.TxBody.parseFrom(Utils.hexToBytes(doc["body_bytes"].asString)) val fee = authInfo.fee diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/SwapFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/SwapFragment.kt index 6544fe192..6e4badedb 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/SwapFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/SwapFragment.kt @@ -317,13 +317,7 @@ class SwapFragment : BaseTxFragment() { chain.cosmosFetcher?.cosmosBalances = loadInputBalanceDeferred.await() BaseUtils.onParseVesting(chain) - } catch (e: Exception) { - withContext(Dispatchers.Main) { - if (isAdded) { - activity?.makeToast(R.string.str_unknown_error) - } - } - } + } catch (e: Exception) { } } } outputChain?.let { chain -> @@ -336,13 +330,7 @@ class SwapFragment : BaseTxFragment() { chain.cosmosFetcher?.cosmosBalances = loadOutputBalanceDeferred.await() BaseUtils.onParseVesting(chain) - } catch (e: Exception) { - withContext(Dispatchers.Main) { - if (isAdded) { - activity?.makeToast(R.string.str_unknown_error) - } - } - } + } catch (e: Exception) { } } } @@ -389,7 +377,7 @@ class SwapFragment : BaseTxFragment() { ?.setScale(0, RoundingMode.DOWN) outputAsset.decimals?.let { outputDecimal -> val dpAmount = dpOutputAmount?.movePointLeft(outputDecimal) - ?.setScale(6, RoundingMode.DOWN)?.toPlainString() + ?.setScale(outputDecimal, RoundingMode.DOWN)?.toPlainString() outputAmount.text = formatAmount(dpAmount.toString(), outputDecimal) slippage.text = "$skipSlippage%" @@ -682,7 +670,6 @@ class SwapFragment : BaseTxFragment() { } catch (e: Exception) { withContext(Dispatchers.Main) { - activity?.makeToast(R.string.str_unknown_error) loading.visibility = View.GONE } return@launch @@ -775,7 +762,6 @@ class SwapFragment : BaseTxFragment() { } catch (e: Exception) { withContext(Dispatchers.Main) { - activity?.makeToast(R.string.str_unknown_error) loading.visibility = View.GONE } return@launch diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainCompoundingFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainCompoundingFragment.kt index a2ba1ffa1..7f86fa244 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainCompoundingFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainCompoundingFragment.kt @@ -94,12 +94,14 @@ class AllChainCompoundingFragment : BaseTxFragment() { .forEach { chain -> val compoundAble = chain.cosmosFetcher?.compoundAbleRewards() val txFee = chain.getInitPayableFee(requireContext()) - if (compoundAble?.isNotEmpty() == true && txFee != null) { - compoundAbleRewards.add( - ClaimAllModel( - chain, compoundAble + if (chain.cosmosFetcher?.rewardAddress == chain.address) { + if (compoundAble?.isNotEmpty() == true && txFee != null) { + compoundAbleRewards.add( + ClaimAllModel( + chain, compoundAble + ) ) - ) + } } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainVoteFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainVoteFragment.kt index f4b595ea9..fe867ff99 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainVoteFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainVoteFragment.kt @@ -501,23 +501,25 @@ class AllChainVoteFragment : BaseTxFragment() { ) { lifecycleScope.launch(Dispatchers.IO) { voteAllModel.basechain?.let { chain -> - val gasLimit = - (gasUsed.toLong().toDouble() * chain.gasMultiply()).toLong().toBigDecimal() - chain.getBaseFeeInfo(requireContext()).feeDatas.firstOrNull { - it.denom == txFee?.getAmount( - 0 - )?.denom - }?.let { gasRate -> - val feeCoinAmount = - gasRate.gasRate?.multiply(gasLimit)?.setScale(0, RoundingMode.UP) - val feeCoin = CoinProto.Coin.newBuilder().setDenom(txFee?.getAmount(0)?.denom) - .setAmount(feeCoinAmount.toString()).build() - - voteAllModel.isBusy = false - voteAllModel.txFee = - TxProto.Fee.newBuilder().setGasLimit(gasLimit.toLong()).addAmount(feeCoin) - .build() - voteAllModel.toVotes = toVotes + if (gasUsed.toLongOrNull() != null) { + val gasLimit = + (gasUsed.toLong().toDouble() * chain.gasMultiply()).toLong().toBigDecimal() + chain.getBaseFeeInfo(requireContext()).feeDatas.firstOrNull { + it.denom == txFee?.getAmount( + 0 + )?.denom + }?.let { gasRate -> + val feeCoinAmount = + gasRate.gasRate?.multiply(gasLimit)?.setScale(0, RoundingMode.UP) + val feeCoin = CoinProto.Coin.newBuilder().setDenom(txFee?.getAmount(0)?.denom) + .setAmount(feeCoinAmount.toString()).build() + + voteAllModel.isBusy = false + voteAllModel.txFee = + TxProto.Fee.newBuilder().setGasLimit(gasLimit.toLong()).addAmount(feeCoin) + .build() + voteAllModel.toVotes = toVotes + } } } diff --git a/app/src/main/res/layout/fragment_evm_detail.xml b/app/src/main/res/layout/fragment_evm_detail.xml index b56e762c4..0646152b0 100644 --- a/app/src/main/res/layout/fragment_evm_detail.xml +++ b/app/src/main/res/layout/fragment_evm_detail.xml @@ -70,7 +70,7 @@ android:layout_width="@dimen/space_28" android:layout_height="@dimen/space_28" android:layout_marginRight="@dimen/space_15" - android:src="@drawable/icon_add_token_explain" + android:src="@drawable/icon_add_token" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/btn_account"