Skip to content

Commit

Permalink
release soralution v3.8.0.2 124
Browse files Browse the repository at this point in the history
  • Loading branch information
arvifox committed Dec 3, 2023
1 parent b0aa8e5 commit d655ad9
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 119 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ play {
serviceAccountCredentials = file(System.env.CI_PLAY_KEY ?: "../key/fake.json")
track = "internal"
releaseStatus = ReleaseStatus.DRAFT
releaseName = "3.8.0.1 - Demeter Farming"
releaseName = "3.8.0.2 - Demeter Farming"
}

dependencies {
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ buildscript {
]

ext {
// soralution 123 3.8.0.1 2023.12.01
// soralution 124 3.8.0.2 2023.12.02
// sora dae 98 3.3.0.0 2023.08.18
// appVersionCode = Integer.valueOf(System.env.BUILD_NUMBER ?: 96)
appVersionCode = Integer.valueOf(System.env.CI_BUILD_ID ?: 123)
appVersionName = '3.8.0.1'
appVersionCode = Integer.valueOf(System.env.CI_BUILD_ID ?: 124)
appVersionName = '3.8.0.2'

compileVersion = 34
minVersion = 24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ package jp.co.soramitsu.demeter.data

import java.math.BigDecimal
import java.math.BigInteger
import jp.co.soramitsu.common.util.StringTriple
import jp.co.soramitsu.common.util.ext.isZero
import jp.co.soramitsu.common.util.ext.safeCast
import jp.co.soramitsu.common.util.mapBalance
Expand Down Expand Up @@ -112,7 +111,7 @@ internal class DemeterFarmingRepositoryImpl(
private const val BLOCKS_PER_YEAR = 5256000
}

private var cachedFarmedPools: MutableMap<String, List<DemeterFarmingPool>> = mutableMapOf()
private val cachedFarmedPools: MutableMap<String, List<DemeterFarmingPool>> = mutableMapOf()
private var cachedFarmedBasicPools: List<DemeterFarmingBasicPool>? = null

override suspend fun getStakedFarmedAmountOfAsset(
Expand All @@ -134,14 +133,12 @@ internal class DemeterFarmingRepositoryImpl(
val selectedCurrency = soraConfigManager.getSelectedCurrency()
val calculated = getDemeter(soraAccountAddress)
?.filter { it.farm && it.amount.isZero().not() }
?.map {
val base = baseFarms.first { base ->
StringTriple(
base.tokenBase.id,
base.tokenTarget.id,
base.tokenReward.id
) == StringTriple(it.base, it.pool, it.reward)
}
?.mapNotNull {
val base = baseFarms.firstOrNull { base ->
base.tokenBase.id == it.base &&
base.tokenTarget.id == it.pool &&
base.tokenReward.id == it.reward
} ?: return@mapNotNull null
val baseTokenMapped = assetLocalToAssetMapper.map(
tokenLocal = db.assetDao().getToken(it.base, selectedCurrency.code)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal class DemeterFarmingInteractorImpl(

override suspend fun getUsersFarmedPool(ids: StringTriple): DemeterFarmingPool? {
return getFarmedPools()?.firstOrNull {
Triple(it.tokenBase.id, it.tokenTarget.id, it.tokenReward.id) == ids
it.tokenBase.id == ids.first && it.tokenTarget.id == ids.second && it.tokenReward.id == ids.third
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,18 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped
import jp.co.soramitsu.common.domain.CoroutineManager
import jp.co.soramitsu.feature_assets_api.data.AssetsRepository
import jp.co.soramitsu.feature_blockexplorer_api.data.BlockExplorerManager
import jp.co.soramitsu.feature_ecosystem_impl.domain.EcoSystemPoolsInteractor
import jp.co.soramitsu.feature_ecosystem_impl.domain.EcoSystemPoolsInteractorImpl
import jp.co.soramitsu.feature_ecosystem_impl.domain.EcoSystemTokensInteractor
import jp.co.soramitsu.feature_ecosystem_impl.domain.EcoSystemTokensInteractorImpl
import jp.co.soramitsu.feature_ecosystem_impl.domain.PoolsUpdateSubscription
import jp.co.soramitsu.feature_ecosystem_impl.domain.PoolsUpdateSubscriptionImpl
import jp.co.soramitsu.feature_polkaswap_api.domain.interfaces.PolkaswapRepository
import jp.co.soramitsu.feature_polkaswap_api.domain.interfaces.PolkaswapSubscriptionRepository

@Module
@InstallIn(ViewModelComponent::class)
object EcoSystemModule {

@Provides
@ViewModelScoped
internal fun providePoolsUpdateSubscription(
repo: PolkaswapSubscriptionRepository,
manager: CoroutineManager,
): PoolsUpdateSubscription {
return PoolsUpdateSubscriptionImpl(
repo,
manager,
)
}

@Provides
@ViewModelScoped
internal fun provideEcoSystemPoolsInteractor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,26 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_ecosystem_impl.presentation.allpools

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -63,13 +69,15 @@ import jp.co.soramitsu.ui_core.theme.customTypography
@Composable
internal fun AllPoolsScreen(
onPoolClicked: (StringPair) -> Unit,
onAddPoolClicked: () -> Unit,
viewModel: AllPoolsViewModel = hiltViewModel(),
) {
Column(modifier = Modifier.fillMaxSize()) {
val state = viewModel.poolsState.collectAsStateWithLifecycle().value
AllPoolsInternal(
state = state,
onPoolClicked = onPoolClicked,
onAddPoolClicked = onAddPoolClicked,
)
}
}
Expand All @@ -78,6 +86,7 @@ internal fun AllPoolsScreen(
private fun AllPoolsInternal(
state: EcoSystemPoolsState,
onPoolClicked: (StringPair) -> Unit,
onAddPoolClicked: () -> Unit,
) {
ContentCardEndless(
modifier = Modifier
Expand All @@ -102,31 +111,49 @@ private fun AllPoolsInternal(
)
}
} else {
Column {
Text(
modifier = Modifier.padding(
start = Dimens.x3,
end = Dimens.x1
),
text = stringResource(id = R.string.discovery_polkaswap_pools),
style = MaterialTheme.customTypography.headline2,
color = MaterialTheme.customColors.fgPrimary
)

Text(
modifier = Modifier.padding(
start = Dimens.x3,
end = Dimens.x1,
bottom = Dimens.x1
),
text = stringResource(id = R.string.explore_provide_and_earn),
style = MaterialTheme.customTypography.textXSBold,
color = MaterialTheme.customColors.fgSecondary
)
Column(
modifier = Modifier.fillMaxSize(),
) {
Row(
modifier = Modifier
.padding(bottom = Dimens.x1)
.fillMaxWidth()
.wrapContentHeight(),
verticalAlignment = Alignment.CenterVertically,
) {
Column(
modifier = Modifier
.weight(1f)
.padding(start = Dimens.x3, end = Dimens.x1),
) {
Text(
text = stringResource(id = R.string.discovery_polkaswap_pools),
style = MaterialTheme.customTypography.headline2,
color = MaterialTheme.customColors.fgPrimary,
maxLines = 1,
)

Text(
text = stringResource(id = R.string.explore_provide_and_earn),
style = MaterialTheme.customTypography.textXSBold,
color = MaterialTheme.customColors.fgSecondary,
maxLines = 1,
)
}
Icon(
modifier = Modifier
.size(Dimens.x3)
.clickable(onClick = onAddPoolClicked),
painter = painterResource(
id = jp.co.soramitsu.common.R.drawable.ic_plus,
),
contentDescription = "",
tint = MaterialTheme.customColors.fgSecondary,
)
}
if (state.pools.isEmpty()) {
Box(
modifier = Modifier.fillMaxSize(),
modifier = Modifier.weight(1f),
contentAlignment = Alignment.Center
) {
Text(
Expand All @@ -137,7 +164,7 @@ private fun AllPoolsInternal(
}
} else {
val listState = rememberLazyListState()
LazyColumn(state = listState, modifier = Modifier.fillMaxSize()) {
LazyColumn(state = listState, modifier = Modifier.weight(1f)) {
items(
count = state.pools.size,
) { position ->
Expand All @@ -163,6 +190,7 @@ private fun PreviewAllPoolsInternal() {
pools = previewBasicPoolListItemState,
),
onPoolClicked = {},
onAddPoolClicked = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_ecosystem_impl.presentation.explore

import android.os.Bundle
import android.view.View
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.ScrollState
Expand All @@ -56,8 +58,9 @@ import androidx.navigation.compose.composable
import dagger.hilt.android.AndroidEntryPoint
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.base.SoraBaseFragment
import jp.co.soramitsu.common.base.theOnlyRoute
import jp.co.soramitsu.common.domain.BottomBarController
import jp.co.soramitsu.feature_ecosystem_impl.presentation.ExploreRoutes
import jp.co.soramitsu.common.util.ext.safeCast
import jp.co.soramitsu.feature_ecosystem_impl.presentation.allcurrencies.AllCurrenciesScreen
import jp.co.soramitsu.feature_ecosystem_impl.presentation.alldemeter.AllDemeterScreen
import jp.co.soramitsu.feature_ecosystem_impl.presentation.allpools.AllPoolsScreen
Expand All @@ -74,24 +77,17 @@ class ExploreFragment : SoraBaseFragment<ExploreViewModel>() {

override val viewModel: ExploreViewModel by viewModels()

override fun onDestinationChanged(destination: String) {
when (destination) {
ExploreRoutes.START -> {
(activity as BottomBarController).showBottomBar()
}

else -> {
(activity as BottomBarController).hideBottomBar()
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
activity?.safeCast<BottomBarController>()?.showBottomBar()
}

@OptIn(ExperimentalFoundationApi::class, ExperimentalAnimationApi::class)
override fun NavGraphBuilder.content(
scrollState: ScrollState, navController: NavHostController
) {
composable(
route = ExploreRoutes.START,
route = theOnlyRoute,
) {
val pagerState = rememberPagerState { ExplorePages.entries.size }
val scope = rememberCoroutineScope()
Expand Down Expand Up @@ -153,6 +149,7 @@ class ExploreFragment : SoraBaseFragment<ExploreViewModel>() {
ExplorePages.POOLS.ordinal -> {
AllPoolsScreen(
onPoolClicked = viewModel::onPoolClicked,
onAddPoolClicked = viewModel::onPoolPlus,
)
}

Expand All @@ -166,14 +163,4 @@ class ExploreFragment : SoraBaseFragment<ExploreViewModel>() {
}
}
}

override fun onResume() {
super.onResume()

if (viewModel.isBottomBarNeeded()) {
(activity as BottomBarController).showBottomBar()
} else {
(activity as BottomBarController).hideBottomBar()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,22 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_ecosystem_impl.presentation.explore

import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import jp.co.soramitsu.common.presentation.viewmodel.BaseViewModel
import jp.co.soramitsu.common.util.StringPair
import jp.co.soramitsu.common.util.StringTriple
import jp.co.soramitsu.feature_assets_api.presentation.AssetsRouter
import jp.co.soramitsu.feature_ecosystem_impl.domain.PoolsUpdateSubscription
import jp.co.soramitsu.feature_ecosystem_impl.presentation.ExploreRoutes
import jp.co.soramitsu.feature_polkaswap_api.launcher.PolkaswapRouter
import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider
import jp.co.soramitsu.ui_core.component.toolbar.Action
import jp.co.soramitsu.ui_core.component.toolbar.BasicToolbarState
import jp.co.soramitsu.ui_core.component.toolbar.SoramitsuToolbarState
import jp.co.soramitsu.ui_core.component.toolbar.SoramitsuToolbarType
import kotlinx.coroutines.launch

@HiltViewModel
class ExploreViewModel @Inject constructor(
private val polkaswapRouter: PolkaswapRouter,
private val assetsRouter: AssetsRouter,
private val poolsUpdateSubscription: PoolsUpdateSubscription,
) : BaseViewModel() {

init {
Expand All @@ -66,22 +60,6 @@ class ExploreViewModel @Inject constructor(
searchEnabled = false,
),
)

viewModelScope.launch {
poolsUpdateSubscription.updateBasicPools()
}
}

override fun startScreen(): String = ExploreRoutes.START

override fun onMenuItem(action: Action) {
when (action) {
is Action.Plus -> {
onPoolPlus()
}

else -> {}
}
}

fun onTokenClicked(tokenId: String) {
Expand All @@ -96,9 +74,7 @@ class ExploreViewModel @Inject constructor(
polkaswapRouter.showFarmDetails(ids)
}

private fun onPoolPlus() {
fun onPoolPlus() {
polkaswapRouter.showAddLiquidity(SubstrateOptionsProvider.feeAssetId)
}

fun isBottomBarNeeded() = currentDestination == ExploreRoutes.START
}

0 comments on commit d655ad9

Please sign in to comment.