Skip to content

Commit

Permalink
[APP-1022] qa bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwonhyukjoon committed Aug 5, 2024
1 parent f7b8cb5 commit 3d35644
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 74 deletions.
6 changes: 2 additions & 4 deletions app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class CoinAdapter(
}

fun setOktItems(
stakeCoins: MutableList<Coin>,
etcCoins: MutableList<Coin>
stakeCoins: MutableList<Coin>, etcCoins: MutableList<Coin>
) {
val tempList = mutableListOf<ListItem>()
if (stakeCoins.isNotEmpty()) {
Expand All @@ -78,9 +77,7 @@ class CoinAdapter(
}

fun setOktEvmItems(
stakeCoins: MutableList<Coin>,
etcCoins: MutableList<Coin>,
tokenCoins: MutableList<Coin>
stakeCoins: MutableList<Coin>, etcCoins: MutableList<Coin>, tokenCoins: MutableList<Coin>
) {
val tempList = mutableListOf<ListItem>()
if (stakeCoins.isNotEmpty()) {
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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<Any>?)
searchAfter =
allHistoryGroup[allHistoryGroup.size - 1].second.searchAfter.toString()
hasMore = historyGroup.size >= BATCH_CNT
Expand All @@ -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<Any>?)
}

binding.loading.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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) { }
}
}

Expand Down Expand Up @@ -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%"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_evm_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3d35644

Please sign in to comment.