Skip to content

Commit

Permalink
Merge pull request #647 from cosmostation/feature/APP-main_hyuk_dev
Browse files Browse the repository at this point in the history
v1.10.8[Hot Fix]
  • Loading branch information
Kwonhyukjoon authored Aug 5, 2024
2 parents 0dc9dac + 3d35644 commit 8e5928f
Show file tree
Hide file tree
Showing 42 changed files with 233 additions and 289 deletions.
8 changes: 2 additions & 6 deletions app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -423,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 @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -428,7 +428,7 @@ fun JsonObject.unDelegations(): MutableList<UnbondingDelegation> {
val unBonding = this["unbonding_responses"].asJsonArray[i]
val entries = mutableListOf<StakingProto.UnbondingDelegationEntry>()
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChildNumber> = ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChildNumber> = ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChildNumber> = ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,22 @@ 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 isPrivateAdd: Boolean = false

override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X")
override var setParentPath: List<ChildNumber> = ImmutableList.of(
ChildNumber(44, true), ChildNumber(118, true), ChildNumber.ZERO_HARDENED, ChildNumber.ZERO
)

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/"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 = ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChildNumber> = ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChildNumber> = ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChildNumber> = ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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 @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ interface TxRepository {
fee: Fee?,
memo: String,
selectedChain: BaseChain
): Any?
): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -457,25 +454,25 @@ class WalletRepositoryImpl : WalletRepository {

override suspend fun oktAccountInfo(chain: BaseChain): NetworkResult<JsonObject?> {
return safeApiCall(Dispatchers.IO) {
oktApi.oktAccountInfo(chain.address)
lcdApi(chain).oktAccountInfo(chain.address)
}
}

override suspend fun oktDeposit(chain: BaseChain): NetworkResult<JsonObject?> {
return safeApiCall(Dispatchers.IO) {
oktApi.oktDepositInfo(chain.address)
lcdApi(chain).oktDepositInfo(chain.address)
}
}

override suspend fun oktWithdraw(chain: BaseChain): NetworkResult<JsonObject?> {
return safeApiCall(Dispatchers.IO) {
oktApi.oktWithdrawInfo(chain.address)
lcdApi(chain).oktWithdrawInfo(chain.address)
}
}

override suspend fun oktToken(chain: BaseChain): NetworkResult<JsonObject?> {
return safeApiCall(Dispatchers.IO) {
oktApi.oktTokens()
lcdApi(chain).oktTokens()
}
}

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

0 comments on commit 8e5928f

Please sign in to comment.