From 43d5eb3af1d9b9def567a7cf3e1f78a2876c0fe1 Mon Sep 17 00:00:00 2001 From: Kwonhyukjoon Date: Mon, 5 Aug 2024 01:55:10 +0900 Subject: [PATCH 1/6] [APP-1022] private check bug fixed --- .../io/cosmostaion/chain/BaseChain.kt | 2 -- .../chain/cosmosClass/ChainAgoric118.kt | 1 - .../chain/cosmosClass/ChainFetchAi60Old.kt | 1 - .../chain/cosmosClass/ChainFetchAi60Secp.kt | 1 - .../chain/cosmosClass/ChainKava118.kt | 1 - .../chain/cosmosClass/ChainLum118.kt | 1 - .../chain/cosmosClass/ChainPersistence750.kt | 1 - .../chain/cosmosClass/ChainSecret118.kt | 1 - .../wallet/account/PrivateCheckFragment.kt | 22 +++++++++---------- .../ui/wallet/WalletSelectFragment.kt | 2 +- 10 files changed, 11 insertions(+), 22 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 f686159ef..7a7b683dd 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt @@ -158,8 +158,6 @@ open class BaseChain : Parcelable { open var fetched = false open var fetchedState = true - open var isPrivateAdd = true - fun chainIdEvmDecimal(): String { return chainIdEvm.hexToString() } diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainAgoric118.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainAgoric118.kt index 9c6a55a7f..8bed8a181 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainAgoric118.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainAgoric118.kt @@ -12,7 +12,6 @@ class ChainAgoric118 : ChainAgoric564(), Parcelable { override var tag: String = "agoric118" override var isDefault: Boolean = false - override var isPrivateAdd: Boolean = false override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X") override var setParentPath: List = ImmutableList.of( diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Old.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Old.kt index c254b0878..0c2141508 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Old.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Old.kt @@ -19,7 +19,6 @@ class ChainFetchAi60Old : BaseChain(), Parcelable { override var swipeLogo: Int = R.drawable.chain_swipe_fetchai override var isDefault: Boolean = false override var apiName: String = "fetchai" - override var isPrivateAdd: Boolean = false override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/60'/0'/X") override var setParentPath: List = ImmutableList.of( diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Secp.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Secp.kt index 6cba80941..c4f69a9ea 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Secp.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainFetchAi60Secp.kt @@ -19,7 +19,6 @@ class ChainFetchAi60Secp : BaseChain(), Parcelable { override var swipeLogo: Int = R.drawable.chain_swipe_fetchai override var isDefault: Boolean = false override var apiName: String = "fetchai" - override var isPrivateAdd: Boolean = false override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/60'/0'/0/X") override var setParentPath: List = ImmutableList.of( diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt index cecb94b24..5d901ab3d 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt @@ -19,7 +19,6 @@ class ChainKava118 : BaseChain(), Parcelable { override var swipeLogo: Int = R.drawable.chain_swipe_kava override var isDefault: Boolean = false override var apiName: String = "kava" - override var isPrivateAdd: Boolean = false override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X") override var setParentPath: List = ImmutableList.of( diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainLum118.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainLum118.kt index 7a3769314..50a882a6f 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainLum118.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainLum118.kt @@ -19,7 +19,6 @@ class ChainLum118 : BaseChain(), Parcelable { override var swipeLogo: Int = R.drawable.chain_swipe_lum override var isDefault: Boolean = false override var apiName: String = "lum" - override var isPrivateAdd: Boolean = false override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X") override var setParentPath: List = ImmutableList.of( diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainPersistence750.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainPersistence750.kt index c568d92f3..1ef85a40a 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainPersistence750.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainPersistence750.kt @@ -19,7 +19,6 @@ class ChainPersistence750 : BaseChain(), Parcelable { override var swipeLogo: Int = R.drawable.chain_swipe_persistence override var isDefault: Boolean = false override var apiName: String = "persistence" - override var isPrivateAdd: Boolean = false override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/750'/0'/0/X") override var setParentPath: List = ImmutableList.of( diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainSecret118.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainSecret118.kt index d112ffe37..d990d1f80 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainSecret118.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainSecret118.kt @@ -19,7 +19,6 @@ class ChainSecret118 : BaseChain(), Parcelable { override var swipeLogo: Int = R.drawable.chain_swipe_secret override var isDefault: Boolean = false override var apiName: String = "secret" - override var isPrivateAdd: Boolean = false override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X") override var setParentPath: List = ImmutableList.of( diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateCheckFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateCheckFragment.kt index a91431076..0e7d40a98 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateCheckFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateCheckFragment.kt @@ -126,8 +126,8 @@ class PrivateCheckFragment : Fragment() { mainnetChains = allChains.filter { !it.isTestnet && it.tag != "okt996_Secp" }.toMutableList() testnetChains = allChains.filter { it.isTestnet }.toMutableList() - searchMainnetChains = mainnetChains - searchTestnetChains = testnetChains + searchMainnetChains.addAll(mainnetChains) + searchTestnetChains.addAll(testnetChains) withContext(Dispatchers.Main) { updateView() @@ -191,23 +191,21 @@ class PrivateCheckFragment : Fragment() { searchTestnetChains.clear() if (StringUtils.isEmpty(newText)) { - searchMainnetChains.addAll(allChains().filter { !it.isTestnet }) - searchTestnetChains.addAll(allChains().filter { it.isTestnet }) + searchMainnetChains.addAll(mainnetChains) + searchTestnetChains.addAll(testnetChains) } else { newText?.let { searchTxt -> - searchMainnetChains.addAll(allChains().filter { chain -> + searchMainnetChains.addAll(mainnetChains.filter { chain -> chain.name.contains( - searchTxt, - ignoreCase = true - ) && !chain.isTestnet + searchTxt, ignoreCase = true + ) }) - searchTestnetChains.addAll(allChains().filter { chain -> + searchTestnetChains.addAll(testnetChains.filter { chain -> chain.name.contains( - searchTxt, - ignoreCase = true - ) && !chain.isTestnet + searchTxt, ignoreCase = true + ) }) } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/wallet/WalletSelectFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/wallet/WalletSelectFragment.kt index 7c28d1d21..3526bce62 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/wallet/WalletSelectFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/wallet/WalletSelectFragment.kt @@ -127,7 +127,7 @@ class WalletSelectFragment : Fragment() { toAddAccount?.let { account -> account.apply { allChains = allChains() - mainnetChains = allChains.filter { !it.isTestnet && it.isPrivateAdd }.toMutableList() + mainnetChains = allChains.filter { !it.isTestnet && it.isDefault || it.tag == "kava459" }.toMutableList() testnetChains = allChains.filter { it.isTestnet }.toMutableList() withContext(Dispatchers.Main) { updateView() From 1b2b8e3cc2f35b21318384c281e991e8f454b11a Mon Sep 17 00:00:00 2001 From: Kwonhyukjoon Date: Mon, 5 Aug 2024 01:56:17 +0900 Subject: [PATCH 2/6] [APP-1022] compounding broadcast bug fixed --- .../wannabit/io/cosmostaion/ui/tx/step/CompoundingFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CompoundingFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CompoundingFragment.kt index ad743c64a..97c7efdcb 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CompoundingFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CompoundingFragment.kt @@ -370,7 +370,7 @@ class CompoundingFragment : BaseTxFragment() { registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == Activity.RESULT_OK && isAdded) { binding.backdropLayout.visibility = View.VISIBLE - txViewModel.simulate( + txViewModel.broadcast( selectedChain.cosmosFetcher?.getChannel(), onBindCompoundingMsg(), txFee, From 48a8ddd606d2ad17b4a5cd0efdbcc3da02914dd9 Mon Sep 17 00:00:00 2001 From: Kwonhyukjoon Date: Mon, 5 Aug 2024 02:46:12 +0900 Subject: [PATCH 3/6] [APP-1022] compounding crash bug fixed --- .../io/cosmostaion/chain/CosmosFetcher.kt | 4 +-- .../cosmostaion/ui/main/DashboardFragment.kt | 15 ++++++-- .../tx/step/service/AllChainClaimFragment.kt | 31 +--------------- .../service/AllChainCompoundingFragment.kt | 36 +++---------------- .../tx/step/service/AllChainVoteFragment.kt | 11 +----- .../ui/viewmodel/ApplicationViewModel.kt | 5 +++ 6 files changed, 27 insertions(+), 75 deletions(-) diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt index f017c5816..786a844d7 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt @@ -150,7 +150,7 @@ open class CosmosFetcher(private val chain: BaseChain) { fun delegationAmountSum(): BigDecimal { var sum = BigDecimal.ZERO - cosmosDelegations.forEach { delegation -> + for (delegation in cosmosDelegations) { delegation.balance?.let { sum = sum.add(delegation.balance?.amount?.toBigDecimal()) } ?: run { @@ -355,7 +355,7 @@ open class CosmosFetcher(private val chain: BaseChain) { suspend fun lastHeight(): Long { return if (endPointType(chain) == CosmosEndPointType.USE_GRPC) { val blockStub = - ServiceGrpc.newBlockingStub(getChannel()).withDeadlineAfter(8L, TimeUnit.SECONDS) + ServiceGrpc.newBlockingStub(getChannel()).withDeadlineAfter(30L, TimeUnit.SECONDS) val blockRequest = QueryProto.GetLatestBlockRequest.newBuilder().build() val lastBlock = blockStub.getLatestBlock(blockRequest) lastBlock.block.header.height diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt index 604e4f1b7..8a21ab424 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt @@ -444,8 +444,7 @@ class DashboardFragment : Fragment() { } private fun nodeDownPopup(chain: BaseChain) { - NoticeInfoFragment.newInstance( - chain, + NoticeInfoFragment.newInstance(chain, NoticeType.NODE_DOWN_GUIDE, object : NodeDownSelectListener { override fun select(tag: String?) { @@ -567,6 +566,18 @@ class DashboardFragment : Fragment() { } } } + + ApplicationViewModel.shared.serviceTxResult.observe(viewLifecycleOwner) { + lifecycleScope.launch(Dispatchers.IO) { + baseAccount?.sortedDisplayChains()?.forEach { chain -> + chain.fetched = false + } + withContext(Dispatchers.Main) { + initData(baseAccount) + updateViewWithLoadedData(baseAccount) + } + } + } } override fun onDestroyView() { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainClaimFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainClaimFragment.kt index d69416a64..c49267dc4 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainClaimFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/service/AllChainClaimFragment.kt @@ -40,8 +40,6 @@ import wannabit.io.cosmostaion.data.api.RetrofitInstance import wannabit.io.cosmostaion.data.model.req.BroadcastTxReq import wannabit.io.cosmostaion.data.model.req.SimulateTxReq import wannabit.io.cosmostaion.data.repository.tx.TxRepositoryImpl -import wannabit.io.cosmostaion.database.model.BaseAccount -import wannabit.io.cosmostaion.database.model.BaseAccountType import wannabit.io.cosmostaion.databinding.FragmentAllChainClaimBinding import wannabit.io.cosmostaion.ui.password.PasswordCheckActivity import wannabit.io.cosmostaion.ui.tx.step.BaseTxFragment @@ -235,13 +233,8 @@ class AllChainClaimFragment : BaseTxFragment() { } btnConfirm.setOnClickListener { + ApplicationViewModel.shared.serviceTx() dismiss() - BaseData.baseAccount?.let { account -> - for (chain in account.sortedDisplayChains()) { - chain.fetched = false - initDisplayData(account) - } - } } } } @@ -435,28 +428,6 @@ class AllChainClaimFragment : BaseTxFragment() { } } - private fun initDisplayData(baseAccount: BaseAccount) { - baseAccount.apply { - lifecycleScope.launch(Dispatchers.IO) { - for (chain in sortedDisplayChains()) { - if (type == BaseAccountType.MNEMONIC) { - if (chain.publicKey == null) { - chain.setInfoWithSeed(seed, chain.setParentPath, lastHDPath) - } - } else if (type == BaseAccountType.PRIVATE_KEY) { - if (chain.publicKey == null) { - chain.setInfoWithPrivateKey(privateKey) - } - } - - if (!chain.fetched) { - ApplicationViewModel.shared.loadChainData(chain, id, false) - } - } - } - } - } - override fun onDestroyView() { _binding = null super.onDestroyView() 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 cc0fadf58..a2ba1ffa1 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 @@ -39,8 +39,6 @@ import wannabit.io.cosmostaion.data.api.RetrofitInstance import wannabit.io.cosmostaion.data.model.req.BroadcastTxReq import wannabit.io.cosmostaion.data.model.req.SimulateTxReq import wannabit.io.cosmostaion.data.repository.tx.TxRepositoryImpl -import wannabit.io.cosmostaion.database.model.BaseAccount -import wannabit.io.cosmostaion.database.model.BaseAccountType import wannabit.io.cosmostaion.databinding.FragmentAllChainCompoundingBinding import wannabit.io.cosmostaion.ui.password.PasswordCheckActivity import wannabit.io.cosmostaion.ui.tx.step.BaseTxFragment @@ -236,13 +234,8 @@ class AllChainCompoundingFragment : BaseTxFragment() { } btnConfirm.setOnClickListener { + ApplicationViewModel.shared.serviceTx() dismiss() - BaseData.baseAccount?.let { account -> - for (chain in account.sortedDisplayChains()) { - chain.fetched = false - initDisplayData(account) - } - } } } } @@ -266,28 +259,6 @@ class AllChainCompoundingFragment : BaseTxFragment() { } } - private fun initDisplayData(baseAccount: BaseAccount) { - baseAccount.apply { - lifecycleScope.launch(Dispatchers.IO) { - for (chain in sortedDisplayChains()) { - if (type == BaseAccountType.MNEMONIC) { - if (chain.publicKey == null) { - chain.setInfoWithSeed(seed, chain.setParentPath, lastHDPath) - } - } else if (type == BaseAccountType.PRIVATE_KEY) { - if (chain.publicKey == null) { - chain.setInfoWithPrivateKey(privateKey) - } - } - - if (!chain.fetched) { - ApplicationViewModel.shared.loadChainData(chain, id, false) - } - } - } - } - } - private fun checkTx( index: Int, chain: BaseChain, txResponse: AbciProto.TxResponse? ) { @@ -346,7 +317,10 @@ class AllChainCompoundingFragment : BaseTxFragment() { val chain = valueAbleReward.baseChain val txFee = valueAbleReward.fee val broadcastTx = Signer.genBroadcast( - Signer.claimStakingRewardMsg(chain, valueAbleReward.rewards), txFee, "", chain + Signer.compoundingMsg( + chain, valueAbleReward.rewards, valueAbleReward.baseChain.stakeDenom + ), txFee, "", chain + ) val txResponse = if (chain.supportCosmos()) { 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 41b0f7d19..f4b595ea9 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 @@ -487,16 +487,7 @@ class AllChainVoteFragment : BaseTxFragment() { } btnConfirm.setOnClickListener { - BaseData.baseAccount?.let { account -> - account.sortedDisplayChains().forEach { - it.fetched = false - } - account.sortedDisplayChains().asSequence().concurrentForEach { chain -> - ApplicationViewModel.shared.loadChainData( - chain, account.id, false - ) - } - } + ApplicationViewModel.shared.serviceTx() dismiss() } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt index 704576721..3dce474de 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt @@ -97,6 +97,11 @@ class ApplicationViewModel( _changeBgResult.postValue(bg) } + var serviceTxResult = SingleLiveEvent() + fun serviceTx() = viewModelScope.launch(Dispatchers.IO) { + serviceTxResult.postValue(true) + } + private val _chainDataErrorMessage = MutableLiveData() val chainDataErrorMessage: LiveData get() = _chainDataErrorMessage From a91dd7645cef39e3278c9fe09d34e4821c477382 Mon Sep 17 00:00:00 2001 From: Kwonhyukjoon Date: Mon, 5 Aug 2024 14:05:29 +0900 Subject: [PATCH 4/6] [APP-1022] qa bug fixed with crash & data --- .../io/cosmostaion/chain/CosmosFetcher.kt | 2 +- .../io/cosmostaion/chain/OktFetcher.kt | 2 +- .../chain/cosmosClass/ChainKava118.kt | 10 +---- .../chain/cosmosClass/ChainKava459.kt | 10 ++++- .../chain/evmClass/ChainKavaEvm.kt | 2 +- .../cosmostaion/data/api/RetrofitInstance.kt | 21 ---------- .../data/repository/tx/TxRepository.kt | 2 +- .../data/repository/tx/TxRepositoryImpl.kt | 6 +-- .../repository/wallet/WalletRepositoryImpl.kt | 15 +++---- .../cosmostaion/ui/main/DashboardFragment.kt | 2 +- .../ui/main/DashboardViewHolder.kt | 5 ++- .../ui/main/chain/cosmos/CoinFragment.kt | 2 + .../ui/main/edit/ChainEditViewHolder.kt | 42 +++++++++---------- .../ui/main/setting/SettingBottomAdapter.kt | 3 -- .../ui/main/setting/SettingBottomFragment.kt | 3 +- .../ui/tx/step/CommonTransferFragment.kt | 7 ++-- .../ui/tx/step/okt/OktDepositFragment.kt | 20 +++++---- .../tx/step/okt/OktSelectValidatorFragment.kt | 26 ++++++------ .../ui/tx/step/okt/OktWithdrawFragment.kt | 20 +++++---- .../ui/viewmodel/ApplicationViewModel.kt | 12 ++++++ .../ui/viewmodel/tx/TxViewModel.kt | 10 ++--- 21 files changed, 107 insertions(+), 115 deletions(-) diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt index 786a844d7..b5fca2eca 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/CosmosFetcher.kt @@ -428,7 +428,7 @@ fun JsonObject.unDelegations(): MutableList { val unBonding = this["unbonding_responses"].asJsonArray[i] val entries = mutableListOf() for (j in 0 until unBonding.asJsonObject["entries"].asJsonArray.size()) { - val entry = unBonding.asJsonObject["entries"].asJsonArray[i] + val entry = unBonding.asJsonObject["entries"].asJsonArray[j] entry.asJsonObject["completion_time"].asString?.let { date -> val dpTime = dateToLong("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX", date) val time = Timestamp.newBuilder().setSeconds(dpTime).build() diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/OktFetcher.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/OktFetcher.kt index c18c71be9..c8154457b 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/OktFetcher.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/OktFetcher.kt @@ -25,7 +25,7 @@ class OktFetcher(val chain: BaseChain) : CosmosFetcher(chain) { return@launch } - when (val response = safeApiCall { RetrofitInstance.oktApi.oktValidators() }) { + when (val response = safeApiCall { RetrofitInstance.lcdApi(chain).oktValidators() }) { is NetworkResult.Success -> { oktValidatorInfo.clear() response.data.sortWith { o1, o2 -> diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt index 5d901ab3d..29cc5f254 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava118.kt @@ -4,21 +4,15 @@ import android.os.Parcelable import com.google.common.collect.ImmutableList import kotlinx.parcelize.Parcelize import org.bitcoinj.crypto.ChildNumber -import wannabit.io.cosmostaion.R import wannabit.io.cosmostaion.chain.AccountKeyType -import wannabit.io.cosmostaion.chain.BaseChain import wannabit.io.cosmostaion.chain.CosmosEndPointType import wannabit.io.cosmostaion.chain.PubKeyType @Parcelize -class ChainKava118 : BaseChain(), Parcelable { +class ChainKava118 : ChainKava459(), Parcelable { - override var name: String = "Kava" override var tag: String = "kava118" - override var logo: Int = R.drawable.chain_kava - override var swipeLogo: Int = R.drawable.chain_swipe_kava override var isDefault: Boolean = false - override var apiName: String = "kava" override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X") override var setParentPath: List = ImmutableList.of( @@ -26,8 +20,6 @@ class ChainKava118 : BaseChain(), Parcelable { ) override var cosmosEndPointType: CosmosEndPointType? = CosmosEndPointType.USE_GRPC - override var stakeDenom: String = "ukava" - override var accountPrefix: String = "kava" override var grpcHost: String = "grpc-kava.cosmostation.io" override var lcdUrl: String = "https://lcd-kava.cosmostation.io/" } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava459.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava459.kt index f7d7236b6..09cf36970 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava459.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainKava459.kt @@ -9,9 +9,10 @@ import wannabit.io.cosmostaion.chain.AccountKeyType import wannabit.io.cosmostaion.chain.BaseChain import wannabit.io.cosmostaion.chain.CosmosEndPointType import wannabit.io.cosmostaion.chain.PubKeyType +import wannabit.io.cosmostaion.chain.evmClass.ChainKavaEvm @Parcelize -class ChainKava459 : BaseChain(), Parcelable { +open class ChainKava459 : ChainKavaEvm(), Parcelable { override var name: String = "Kava" override var tag: String = "kava459" @@ -30,4 +31,11 @@ class ChainKava459 : BaseChain(), Parcelable { override var accountPrefix: String = "kava" override var grpcHost: String = "grpc-kava.cosmostation.io" override var lcdUrl: String = "https://lcd-kava.cosmostation.io/" + + override var supportEvm: Boolean = false + override var coinSymbol: String = "" + override var coinGeckoId: String = "" + override var coinLogo: Int = -1 + override var addressLogo: Int = -1 + override var evmRpcURL: String = "" } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainKavaEvm.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainKavaEvm.kt index aeaa7bc1e..7a964ebce 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainKavaEvm.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainKavaEvm.kt @@ -14,7 +14,7 @@ import wannabit.io.cosmostaion.chain.PubKeyType import wannabit.io.cosmostaion.common.CosmostationConstants @Parcelize -class ChainKavaEvm : BaseChain(), Parcelable { +open class ChainKavaEvm : BaseChain(), Parcelable { override var name: String = "Kava" override var tag: String = "kava60" diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/api/RetrofitInstance.kt b/app/src/main/java/wannabit/io/cosmostaion/data/api/RetrofitInstance.kt index e3d3f6b23..abfe30119 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/api/RetrofitInstance.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/api/RetrofitInstance.kt @@ -10,7 +10,6 @@ import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.moshi.MoshiConverterFactory import wannabit.io.cosmostaion.chain.BaseChain -import wannabit.io.cosmostaion.chain.cosmosClass.ChainOkt996Keccak import wannabit.io.cosmostaion.common.CosmostationConstants import java.util.concurrent.TimeUnit @@ -39,18 +38,6 @@ object RetrofitInstance { .baseUrl(CosmostationConstants.MINTSCAN_API_URL).build() } - private val oktRetrofit: Retrofit by lazy { - Retrofit.Builder().addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())) - .addCallAdapterFactory(CoroutineCallAdapterFactory()).client(okHttpClient) - .baseUrl(ChainOkt996Keccak().lcdUrl).build() - } - - private val oktTxRetrofit: Retrofit by lazy { - Retrofit.Builder().addConverterFactory(MoshiConverterFactory.create(moshi)) - .addCallAdapterFactory(CoroutineCallAdapterFactory()).client(okHttpClient) - .baseUrl(ChainOkt996Keccak().lcdUrl).build() - } - private val skipRetrofit: Retrofit by lazy { Retrofit.Builder().addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())) .addCallAdapterFactory(CoroutineCallAdapterFactory()).client(okHttpClient) @@ -88,14 +75,6 @@ object RetrofitInstance { return lcdRetrofit(chain).create(LcdApi::class.java) } - val oktApi: LcdApi by lazy { - oktRetrofit.create(LcdApi::class.java) - } - - val oktTxApi: LcdApi by lazy { - oktTxRetrofit.create(LcdApi::class.java) - } - val skipApi: SkipApi by lazy { skipRetrofit.create(SkipApi::class.java) } diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt index 1ec778a92..e67721ca8 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt @@ -129,5 +129,5 @@ interface TxRepository { fee: Fee?, memo: String, selectedChain: BaseChain - ): Any? + ): String } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt index c351ec5d4..7ad56f635 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt @@ -1308,7 +1308,7 @@ class TxRepositoryImpl : TxRepository { ): LegacyRes? { return try { val reqBroadCast = Signer.oktBroadcast(msgs, fee, memo, selectedChain) - RetrofitInstance.oktTxApi.broadTx(reqBroadCast) + RetrofitInstance.lcdApi(selectedChain).broadTx(reqBroadCast) } catch (_: Exception) { null @@ -1354,7 +1354,7 @@ class TxRepositoryImpl : TxRepository { fee: Fee?, memo: String, selectedChain: BaseChain - ): Any? { + ): String { return try { val simulateTx = Signer.genIbcSendSimulate(msgTransfer, fee, memo, selectedChain) if (selectedChain.cosmosFetcher?.endPointType(selectedChain) == CosmosEndPointType.USE_GRPC) { @@ -1368,7 +1368,7 @@ class TxRepositoryImpl : TxRepository { val gasInfo = AbciProto.GasInfo.newBuilder() .setGasUsed(response["gas_info"].asJsonObject["gas_used"].asString.toLong()) .build() - ServiceProto.SimulateResponse.newBuilder().setGasInfo(gasInfo).build() + ServiceProto.SimulateResponse.newBuilder().setGasInfo(gasInfo).build().gasInfo.gasUsed.toString() } } catch (e: Exception) { diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt b/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt index 6b0de6f3e..344638a79 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt @@ -52,7 +52,6 @@ import wannabit.io.cosmostaion.data.api.RetrofitInstance.ecoApi import wannabit.io.cosmostaion.data.api.RetrofitInstance.lcdApi import wannabit.io.cosmostaion.data.api.RetrofitInstance.mintscanApi import wannabit.io.cosmostaion.data.api.RetrofitInstance.mintscanJsonApi -import wannabit.io.cosmostaion.data.api.RetrofitInstance.oktApi import wannabit.io.cosmostaion.data.model.req.Allocation import wannabit.io.cosmostaion.data.model.req.AllocationReq import wannabit.io.cosmostaion.data.model.req.MoonPayReq @@ -404,10 +403,8 @@ class WalletRepositoryImpl : WalletRepository { return if (chain.cosmosFetcher?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { val stub = com.cosmwasm.wasm.v1.QueryGrpc.newBlockingStub(channel) .withDeadlineAfter(duration, TimeUnit.SECONDS) - val request = - QuerySmartContractStateRequest.newBuilder() - .setAddress(NEUTRON_VESTING_CONTRACT_ADDRESS) - .setQueryData(queryData).build() + val request = QuerySmartContractStateRequest.newBuilder() + .setAddress(NEUTRON_VESTING_CONTRACT_ADDRESS).setQueryData(queryData).build() safeApiCall(Dispatchers.IO) { stub.smartContractState(request) } @@ -457,25 +454,25 @@ class WalletRepositoryImpl : WalletRepository { override suspend fun oktAccountInfo(chain: BaseChain): NetworkResult { return safeApiCall(Dispatchers.IO) { - oktApi.oktAccountInfo(chain.address) + lcdApi(chain).oktAccountInfo(chain.address) } } override suspend fun oktDeposit(chain: BaseChain): NetworkResult { return safeApiCall(Dispatchers.IO) { - oktApi.oktDepositInfo(chain.address) + lcdApi(chain).oktDepositInfo(chain.address) } } override suspend fun oktWithdraw(chain: BaseChain): NetworkResult { return safeApiCall(Dispatchers.IO) { - oktApi.oktWithdrawInfo(chain.address) + lcdApi(chain).oktWithdrawInfo(chain.address) } } override suspend fun oktToken(chain: BaseChain): NetworkResult { return safeApiCall(Dispatchers.IO) { - oktApi.oktTokens() + lcdApi(chain).oktTokens() } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt index 8a21ab424..6be3d6853 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardFragment.kt @@ -159,7 +159,7 @@ class DashboardFragment : Fragment() { override fun nodeDown(chain: BaseChain) { if (!chain.fetched) return if (chain is ChainOktEvm) { - if (chain.oktFetcher?.oktAccountInfo?.isJsonNull == true) { + if (chain.oktFetcher?.oktAccountInfo == null) { nodeDownPopup(chain) return } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt index a12627367..7cbc35a2a 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt @@ -3,6 +3,7 @@ package wannabit.io.cosmostaion.ui.main import android.content.Context import android.os.Handler import android.os.Looper +import android.util.Log import android.view.View import androidx.recyclerview.widget.RecyclerView import wannabit.io.cosmostaion.R @@ -380,7 +381,7 @@ class DashboardViewHolder( if (chain.fetched) { if (chain.isEvmCosmos()) { if (chain is ChainOktEvm) { - if (chain.oktFetcher?.oktAccountInfo?.isJsonNull == true) { + if (chain.oktFetcher?.oktAccountInfo == null || chain.web3j == null) { respondLayout.visibility = View.VISIBLE chainValue.visibility = View.GONE return @@ -396,7 +397,7 @@ class DashboardViewHolder( } else if (chain.supportCosmos()) { if (chain is ChainOkt996Keccak) { - if (chain.oktFetcher?.oktAccountInfo?.isJsonNull == true) { + if (chain.oktFetcher?.oktAccountInfo == null) { respondLayout.visibility = View.VISIBLE chainValue.visibility = View.GONE return 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 29c35c211..0c4508e78 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 @@ -107,6 +107,8 @@ class CoinFragment : Fragment() { searchBridgeCoins.clear() tokenCoins.clear() searchTokenCoins.clear() + etcCoins.clear() + searchEtcCoins.clear() when (selectedChain) { is ChainOktEvm -> { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/edit/ChainEditViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/edit/ChainEditViewHolder.kt index dcbfd85d6..0965a9f5e 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/edit/ChainEditViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/edit/ChainEditViewHolder.kt @@ -61,6 +61,17 @@ class ChainEditViewHolder( chainValue.visibility = View.GONE assetCnt.visibility = View.GONE + editView.setOnClickListener { + if (chain.tag == "cosmos118") return@setOnClickListener + if (displayChains.contains(chain.tag)) { + displayChains.removeIf { it == chain.tag } + } else { + displayChains.add(chain.tag) + } + updateView(chain, displayChains) + listener.select(displayChains) + } + if (chain.supportCosmos() && chain.supportEvm) { chainAddress.text = chain.address chainEvmAddress.text = chain.evmAddress @@ -196,17 +207,6 @@ class ChainEditViewHolder( } } } - - editView.setOnClickListener { - if (chain.tag == "cosmos118") return@setOnClickListener - if (displayChains.contains(chain.tag)) { - displayChains.removeIf { it == chain.tag } - } else { - displayChains.add(chain.tag) - } - updateView(chain, displayChains) - listener.select(displayChains) - } } } @@ -222,6 +222,16 @@ class ChainEditViewHolder( chainName.text = chain.name.uppercase() chainLegacy.visibleOrGone(!chain.isDefault) + editView.setOnClickListener { + if (displayChains.contains(chain.tag)) { + displayChains.removeIf { it == chain.tag } + } else { + displayChains.add(chain.tag) + } + updateView(chain, displayChains) + listener.select(displayChains) + } + if (chain.supportCosmos() && chain.supportEvm) { chainAddress.text = chain.address chainEvmAddress.text = chain.evmAddress @@ -304,16 +314,6 @@ class ChainEditViewHolder( } } } - - editView.setOnClickListener { - if (displayChains.contains(chain.tag)) { - displayChains.removeIf { it == chain.tag } - } else { - displayChains.add(chain.tag) - } - updateView(chain, displayChains) - listener.select(displayChains) - } } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt index ed969777c..fcadb5bde 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt @@ -2,7 +2,6 @@ package wannabit.io.cosmostaion.ui.main.setting import android.annotation.SuppressLint import android.content.Context -import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil @@ -13,7 +12,6 @@ import wannabit.io.cosmostaion.chain.BaseChain import wannabit.io.cosmostaion.databinding.ItemBuyCryptoBinding import wannabit.io.cosmostaion.databinding.ItemCurrencyBinding import wannabit.io.cosmostaion.databinding.ItemEndpointBinding -import wannabit.io.cosmostaion.databinding.ItemHeaderBinding import wannabit.io.cosmostaion.databinding.ItemHeaderViewBinding import wannabit.io.cosmostaion.databinding.ItemPriceStyleBinding import wannabit.io.cosmostaion.databinding.ItemSettingBottomBinding @@ -158,7 +156,6 @@ class SettingBottomAdapter( SettingType.END_POINT_COSMOS.ordinal -> { if (holder.itemViewType == VIEW_TYPE_GRPC_ITEM) { val grpcEndpoint = grpcEndpoints?.get(position - 1) as JsonObject - Log.e("Test1234 : ", grpcEndpoint.toString()) if (holder is EndPointViewHolder) { holder.bind(fromChain, grpcEndpoint, listener) } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomFragment.kt index 881e32305..435e01345 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomFragment.kt @@ -2,7 +2,6 @@ package wannabit.io.cosmostaion.ui.main.setting import android.os.Build import android.os.Bundle -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -214,7 +213,7 @@ class SettingBottomFragment : BottomSheetDialogFragment() { grpcEndpoints.add(jsonElement.asJsonObject) } } - Log.e("Test1234 : ", grpcEndpoints.toString()) + val lcdEndpoints: MutableList = ArrayList() fromChain?.getChainListParam()?.getAsJsonArray("lcd_endpoint")?.let { for (jsonElement in it) { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CommonTransferFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CommonTransferFragment.kt index b30b9066f..bf92356c7 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CommonTransferFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/CommonTransferFragment.kt @@ -8,6 +8,7 @@ import android.os.Handler import android.os.Looper import android.text.TextUtils import android.util.Base64 +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -413,9 +414,9 @@ class CommonTransferFragment : BaseTxFragment() { ChainFragment.newInstance(recipientAbleChains, ChainListType.SELECT_TRANSFER, object : ChainSelectListener { - override fun select(chainId: String) { - if (toChain.chainIdCosmos != chainId) { - recipientAbleChains.firstOrNull { it.chainIdCosmos == chainId } + override fun select(chainName: String) { + if (toChain.name != chainName) { + recipientAbleChains.firstOrNull { it.name == chainName } ?.let { chain -> updateToChain(chain) updateRecipientAddressView("") diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktDepositFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktDepositFragment.kt index 364f67eda..fb80837a5 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktDepositFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktDepositFragment.kt @@ -149,16 +149,18 @@ class OktDepositFragment : BaseTxFragment() { feeTokenImg.setTokenImg(chain.assetImg(chain.stakeDenom)) feeToken.text = chain.stakeDenom.uppercase() - oktFetcher?.oktDeposits?.get("validator_address")?.asJsonArray?.size() - ?.let { existCnt -> - gasAmount = BigDecimal(BASE_GAS_AMOUNT) - gasFee = BigDecimal(OKT_BASE_FEE) - if (existCnt > 10) { - val multiplier = if (existCnt > 20) 4 else 3 - gasAmount = gasAmount.multiply(BigDecimal(multiplier.toString())) - gasFee = gasFee.multiply(BigDecimal(multiplier.toString())) + if (oktFetcher?.oktDeposits?.get("validator_address")?.isJsonNull != true) { + oktFetcher?.oktDeposits?.get("validator_address")?.asJsonArray?.size() + ?.let { existCnt -> + gasAmount = BigDecimal(BASE_GAS_AMOUNT) + gasFee = BigDecimal(OKT_BASE_FEE) + if (existCnt > 10) { + val multiplier = if (existCnt > 20) 4 else 3 + gasAmount = gasAmount.multiply(BigDecimal(multiplier.toString())) + gasFee = gasFee.multiply(BigDecimal(multiplier.toString())) + } } - } + } val price = BaseData.getPrice(OKT_GECKO_ID) val value = price.multiply(gasFee).setScale(6, RoundingMode.DOWN) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktSelectValidatorFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktSelectValidatorFragment.kt index 40dd9e210..f40cd155a 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktSelectValidatorFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktSelectValidatorFragment.kt @@ -152,19 +152,21 @@ class OktSelectValidatorFragment : BaseTxFragment() { feeTokenImg.setTokenImg(chain.assetImg(chain.stakeDenom)) feeToken.text = chain.stakeDenom.uppercase() - oktFetcher?.oktDeposits?.get("validator_address")?.asJsonArray?.size() - ?.let { existCnt -> - val noCnt = myValidators.size - val max = if (existCnt >= noCnt) existCnt else noCnt - - gasAmount = BigDecimal(BaseConstant.BASE_GAS_AMOUNT) - gasFee = BigDecimal(OKT_BASE_FEE) - if (max > 10) { - val multiplier = if (max > 20) 4 else 3 - gasAmount = gasAmount.multiply(BigDecimal(multiplier.toString())) - gasFee = gasFee.multiply(BigDecimal(multiplier.toString())) + if (oktFetcher?.oktDeposits?.get("validator_address")?.isJsonNull != true) { + oktFetcher?.oktDeposits?.get("validator_address")?.asJsonArray?.size() + ?.let { existCnt -> + val noCnt = myValidators.size + val max = if (existCnt >= noCnt) existCnt else noCnt + + gasAmount = BigDecimal(BaseConstant.BASE_GAS_AMOUNT) + gasFee = BigDecimal(OKT_BASE_FEE) + if (max > 10) { + val multiplier = if (max > 20) 4 else 3 + gasAmount = gasAmount.multiply(BigDecimal(multiplier.toString())) + gasFee = gasFee.multiply(BigDecimal(multiplier.toString())) + } } - } + } val price = BaseData.getPrice(OKT_GECKO_ID) val value = price.multiply(gasFee).setScale(6, RoundingMode.DOWN) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktWithdrawFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktWithdrawFragment.kt index 60b612624..e47766f00 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktWithdrawFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/step/okt/OktWithdrawFragment.kt @@ -138,16 +138,18 @@ class OktWithdrawFragment : BaseTxFragment() { feeTokenImg.setTokenImg(chain.assetImg(chain.stakeDenom)) feeToken.text = chain.stakeDenom.uppercase() - oktFetcher?.oktDeposits?.get("validator_address")?.asJsonArray?.size() - ?.let { existCnt -> - gasAmount = BigDecimal(BaseConstant.BASE_GAS_AMOUNT) - gasFee = BigDecimal(OKT_BASE_FEE) - if (existCnt > 10) { - val multiplier = if (existCnt > 20) 4 else 3 - gasAmount = gasAmount.multiply(BigDecimal(multiplier.toString())) - gasFee = gasFee.multiply(BigDecimal(multiplier.toString())) + if (oktFetcher?.oktDeposits?.get("validator_address")?.isJsonNull != true) { + oktFetcher?.oktDeposits?.get("validator_address")?.asJsonArray?.size() + ?.let { existCnt -> + gasAmount = BigDecimal(BaseConstant.BASE_GAS_AMOUNT) + gasFee = BigDecimal(OKT_BASE_FEE) + if (existCnt > 10) { + val multiplier = if (existCnt > 20) 4 else 3 + gasAmount = gasAmount.multiply(BigDecimal(multiplier.toString())) + gasFee = gasFee.multiply(BigDecimal(multiplier.toString())) + } } - } + } val price = BaseData.getPrice(OKT_GECKO_ID) val value = price.multiply(gasFee).setScale(6, RoundingMode.DOWN) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt index 3dce474de..059792e32 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/ApplicationViewModel.kt @@ -537,6 +537,8 @@ class ApplicationViewModel( if (accountInfoResult is NetworkResult.Success && accountInfoResult.data is JsonObject) { it.oktAccountInfo = accountInfoResult.data + } else { + it.oktAccountInfo = null } if (depositResult is NetworkResult.Success && depositResult.data is JsonObject) { @@ -723,7 +725,10 @@ class ApplicationViewModel( if (accountInfoResult is NetworkResult.Success && accountInfoResult.data is JsonObject) { oktFetcher()?.oktAccountInfo = accountInfoResult.data + } else { + oktFetcher()?.oktAccountInfo = null } + if (depositResult is NetworkResult.Success && depositResult.data is JsonObject) { oktFetcher()?.oktDeposits = depositResult.data } @@ -734,6 +739,13 @@ class ApplicationViewModel( oktFetcher()?.oktTokens = tokenResult.data } + fetchedState = false + withContext(Dispatchers.Main) { + fetchedResult.value = tag + } + delay(2000) + + fetchedState = true fetched = true if (fetched) { if (oktFetcher()?.oktAccountInfo?.isJsonNull != true) { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/tx/TxViewModel.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/tx/TxViewModel.kt index ade1aabfd..76d17bb70 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/tx/TxViewModel.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/viewmodel/tx/TxViewModel.kt @@ -1,11 +1,9 @@ package wannabit.io.cosmostaion.ui.viewmodel.tx -import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.cosmos.base.abci.v1beta1.AbciProto import com.cosmos.base.v1beta1.CoinProto -import com.cosmos.tx.v1beta1.ServiceProto import com.cosmos.tx.v1beta1.TxProto.Fee import com.google.protobuf.Any import com.ibc.applications.transfer.v1.TxProto.MsgTransfer @@ -401,10 +399,10 @@ class TxViewModel(private val txRepository: TxRepository) : ViewModel() { val response = txRepository.simulateIbcSendTx( managedChannel, msgTransfer, fee, memo, selectedChain ) - when (response) { - is ServiceProto.SimulateResponse -> simulate.postValue(response.gasInfo.gasUsed.toString()) - is String -> errorMessage.postValue(response as? String) - else -> errorMessage.postValue("Unknown Error") + if (response.toLongOrNull() != null) { + simulate.postValue(response) + } else { + errorMessage.postValue(response) } } catch (e: Exception) { From f7b8cb52de8264214955b36a5ec1f188fec7eb72 Mon Sep 17 00:00:00 2001 From: Kwonhyukjoon Date: Mon, 5 Aug 2024 14:51:45 +0900 Subject: [PATCH 5/6] [APP-1022] add token button & chain mange bug fixed --- .../ui/main/chain/cosmos/CosmosDetailFragment.kt | 2 +- .../ui/main/chain/cosmos/HistoryFragment.kt | 4 ++-- .../ui/main/setting/SettingBottomAdapter.kt | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) 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 40eaf54ef..fa44ec78f 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 @@ -272,8 +272,8 @@ class CosmosDetailFragment : Fragment() { viewPager.setCurrentItem(position, false) when (tab?.text.toString()) { "Crypto" -> { + btnAddToken.visibleOrGone(supportToken) btnAddToken.setImageResource(R.drawable.icon_add_token_explain) - btnAddToken.visibility = View.VISIBLE noticeType = NoticeType.TOKEN_GITHUB } 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 2cdd28c09..524e2a78d 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 @@ -204,7 +204,7 @@ class HistoryFragment : Fragment() { allHistoryGroup.addAll(response) response?.let { historyGroup -> if (historyGroup.isNotEmpty()) { - historyAdapter.submitList(allHistoryGroup as List?) + historyAdapter.submitList(allHistoryGroup.toList()) searchAfter = allHistoryGroup[allHistoryGroup.size - 1].second.searchAfter.toString() hasMore = historyGroup.size >= BATCH_CNT @@ -223,7 +223,7 @@ class HistoryFragment : Fragment() { historyViewModel.oktHistoryResult.observe(viewLifecycleOwner) { response -> allOktHistoryGroup.addAll(response) response?.let { - historyAdapter.submitList(allOktHistoryGroup as List?) + historyAdapter.submitList(allOktHistoryGroup.toList()) } binding.loading.visibility = View.GONE diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt index fcadb5bde..7e00c7f8d 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/SettingBottomAdapter.kt @@ -187,10 +187,14 @@ class SettingBottomAdapter( return if (lcdEndpoints.isNotEmpty()) { currentList.size + 2 } else { - if (grpcEndpoints?.isNotEmpty() == true) { - currentList.size + 1 - } else { + if (settingType == SettingType.END_POINT_EVM) { currentList.size + } else { + if (grpcEndpoints?.isNotEmpty() == true) { + currentList.size + 1 + } else { + currentList.size + } } } } From 3d35644088ad319744c2c719a36c2ef3ac297007 Mon Sep 17 00:00:00 2001 From: Kwonhyukjoon Date: Mon, 5 Aug 2024 21:38:25 +0900 Subject: [PATCH 6/6] [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"