Skip to content

Commit 3a120ae

Browse files
authored
Merge pull request #935 from soramitsu/staging
hotfix_2.2.5(94)
2 parents bedec9d + fc8e06f commit 3a120ae

File tree

22 files changed

+135
-101
lines changed

22 files changed

+135
-101
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ apply from: './scripts/secrets.gradle'
33
buildscript {
44
ext {
55
// App version
6-
versionName = '2.2.4'
7-
versionCode = 93
6+
versionName = '2.2.5'
7+
versionCode = 94
88

99
// SDK and tools
1010
compileSdkVersion = 33

common/src/main/java/jp/co/soramitsu/common/utils/FlowExt.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ data class ListDiff<T>(
8989

9090
fun <T> Flow<List<T>>.diffed(): Flow<ListDiff<T>> {
9191
return zipWithPrevious().map { (previous, new) ->
92-
val addedOrModified = new - previous.orEmpty()
93-
val removed = if (previous != null && previous.size != new.size) previous.orEmpty() - new else emptyList()
92+
val addedOrModified = new - previous.orEmpty().toSet()
93+
val removed = if (previous != null && previous.size != new.size) previous - new.toSet() else emptyList()
9494

9595
ListDiff(removed = removed, addedOrModified = addedOrModified, all = new)
9696
}

common/src/main/res/values-ru/strings.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@
655655
<string name="wallet_manage_assets">Управление активами</string>
656656
<string name="moonbeam_ethereum_address_incorrect">Формат адреса Moonbeam Ethereum неверен, попробуйте еще раз</string>
657657
<string name="moonbeam_ethereum_reward">Вознаграждения будут выплачиваться на этот адрес. Вы можете использовать существующий адрес Ethereum. ПОЖАЛУЙСТА, УБЕДИТЕСЬ, ЧТО У ВАС ЕСТЬ ПРИВАТНЫЕ КЛЮЧИ ДЛЯ ЭТОГО АДРЕСА.</string>
658-
<string name="manage_assets_search_hint">Поиск по токену или сети</string>
658+
<string name="manage_assets_search_hint">Поиск по активу</string>
659659
<string name="assets_search_hint">Поиск по токену</string>
660660
<string name="crowdloan_email_hint">Адрес электронной почты</string>
661661
<string name="crowdloan_referral_code_hint">Реферальный код</string>
@@ -994,4 +994,9 @@
994994
<string name="cross_chain_wallet_my">Мой кошелек</string>
995995
<string name="cross_chain_wallet_external">Внешний кошелек</string>
996996

997+
<string name="specify_network">Specify Network</string>
998+
<string name="specify_network_description">The address prefix matches several networks please specify the network</string>
999+
<string name="select_another_network_description">The address doesn\'t match the destination network. You should select another network</string>
1000+
<string name="select_network_template">Select %s network</string>
1001+
<string name="input_address_unrecognised">Input doesn\'t match known network\'s address</string>
9971002
</resources>

common/src/main/res/values/strings.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ Please note that this signing transaction will be subject to transaction fees on
696696
<string name="wallet_manage_assets">Manage assets</string>
697697
<string name="moonbeam_ethereum_address_incorrect">Moonbeam Ethereum address format is incorrect, please try again</string>
698698
<string name="moonbeam_ethereum_reward">Rewards will be paid out to this address. You can use an existing Ethereum address. PLEASE ENSURE YOU HAVE THE PRIVATE KEYS FOR THIS ADDRESS.</string>
699-
<string name="manage_assets_search_hint">Search by token or network</string>
699+
<string name="manage_assets_search_hint">Search by asset</string>
700700
<string name="assets_search_hint">Search by token</string>
701701
<string name="crowdloan_email_hint">Email address</string>
702702
<string name="crowdloan_referral_code_hint">Referral code</string>
@@ -1089,4 +1089,9 @@ Remember to make a backup of your key and keep it in a safe and private place (e
10891089
<string name="sora_card_blacklisted_countires_title">Excluded of application</string>
10901090
<string name="sora_card_blacklisted_countires_warning"><![CDATA[Residents from <b>certain countries<br>can not apply</b> for SORA Card at this moment<br><a href=\"https://soracard.com/blacklist/\">See the list</a>]]></string>
10911091

1092+
<string name="specify_network">Specify Network</string>
1093+
<string name="specify_network_description">The address prefix matches several networks please specify the network</string>
1094+
<string name="select_another_network_description">The address doesn\'t match the destination network. You should select another network</string>
1095+
<string name="select_network_template">Select %s network</string>
1096+
<string name="input_address_unrecognised">Input doesn\'t match known network\'s address</string>
10921097
</resources>

feature-account-impl/src/main/java/jp/co/soramitsu/account/impl/domain/NodesSettingsScenarioImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NodesSettingsScenarioImpl(private val chainRegistry: ChainRegistry) : Node
1515

1616
override suspend fun getNode(id: NodeId): ChainNode = chainRegistry.getNode(id)
1717

18-
override suspend fun selectNode(id: NodeId) = chainRegistry.selectNode(id)
18+
override suspend fun selectNode(id: NodeId) = chainRegistry.switchNode(id)
1919

2020
override suspend fun addNode(chainId: ChainId, nodeName: String, nodeHost: String) =
2121
try {

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/presentation/common/rewardDestination/ObserveRewardDestinationChooser.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package jp.co.soramitsu.staking.impl.presentation.common.rewardDestination
22

3+
import androidx.core.view.isVisible
34
import jp.co.soramitsu.common.address.AddressChooserBottomSheetDialog
45
import jp.co.soramitsu.common.base.BaseFragment
56
import jp.co.soramitsu.common.base.BaseViewModel
@@ -53,4 +54,8 @@ fun <V> BaseFragment<V>.observeRewardDestinationChooser(
5354
chooser.destinationRestake.setOnClickListener { viewModel.restakeClicked(viewModel) }
5455
chooser.payoutTarget.setWholeClickListener { viewModel.payoutTargetClicked(viewModel) }
5556
chooser.learnMore.setOnClickListener { viewModel.learnMoreClicked(viewModel) }
57+
58+
viewModel.canRestake.observe {
59+
chooser.destinationRestake.isVisible = it
60+
}
5661
}

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/presentation/common/rewardDestination/RewardDestinationMixin.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ interface RewardDestinationMixin : Browserable {
4242
amount: BigDecimal
4343
)
4444
}
45+
46+
val canRestake: Flow<Boolean>
4547
}

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/presentation/common/rewardDestination/RewardDestinationProvider.kt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import jp.co.soramitsu.common.utils.Event
1212
import jp.co.soramitsu.common.view.bottomSheet.list.dynamic.DynamicListBottomSheet
1313
import jp.co.soramitsu.runtime.ext.addressOf
1414
import jp.co.soramitsu.staking.api.data.StakingSharedState
15+
import jp.co.soramitsu.staking.api.data.SyntheticStakingType
16+
import jp.co.soramitsu.staking.api.data.syntheticStakingType
1517
import jp.co.soramitsu.staking.api.domain.model.RewardDestination
1618
import jp.co.soramitsu.staking.api.domain.model.StakingAccount
1719
import jp.co.soramitsu.staking.api.domain.model.StakingState
@@ -29,6 +31,8 @@ import kotlinx.coroutines.channels.BufferOverflow
2931
import kotlinx.coroutines.flow.MutableSharedFlow
3032
import kotlinx.coroutines.flow.combine
3133
import kotlinx.coroutines.flow.first
34+
import kotlinx.coroutines.flow.map
35+
import kotlinx.coroutines.flow.onEach
3236
import kotlinx.coroutines.flow.onStart
3337
import kotlinx.coroutines.launch
3438
import jp.co.soramitsu.core.models.Asset as CoreAsset
@@ -59,11 +63,23 @@ class RewardDestinationProvider(
5963
initial != current
6064
}.onStart { emit(false) }
6165

66+
override val canRestake = sharedState.assetWithChain.map {
67+
it.asset.syntheticStakingType() != SyntheticStakingType.SORA
68+
}.onEach {
69+
if (!it) {
70+
selectPayout()
71+
}
72+
}
73+
6274
override fun payoutClicked(scope: CoroutineScope) {
6375
scope.launch {
64-
interactor.getSelectedAccountProjection()?.let { currentAccount ->
65-
rewardDestinationModelFlow.emit(RewardDestinationModel.Payout(generateDestinationModel(currentAccount)))
66-
}
76+
selectPayout()
77+
}
78+
}
79+
80+
private suspend fun selectPayout() {
81+
interactor.getSelectedAccountProjection()?.let { currentAccount ->
82+
rewardDestinationModelFlow.emit(RewardDestinationModel.Payout(generateDestinationModel(currentAccount)))
6783
}
6884
}
6985

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/presentation/setup/SetupStakingFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.lifecycle.lifecycleScope
66
import coil.ImageLoader
77
import dagger.hilt.android.AndroidEntryPoint
88
import dev.chrisbanes.insetter.applyInsetter
9+
import javax.inject.Inject
910
import jp.co.soramitsu.common.address.AddressModel
1011
import jp.co.soramitsu.common.base.BaseFragment
1112
import jp.co.soramitsu.common.mixin.impl.observeBrowserEvents
@@ -21,7 +22,6 @@ import jp.co.soramitsu.feature_staking_impl.databinding.FragmentSetupStakingBind
2122
import jp.co.soramitsu.staking.impl.presentation.common.rewardDestination.observeRewardDestinationChooser
2223
import jp.co.soramitsu.wallet.api.presentation.mixin.fee.FeeViews
2324
import jp.co.soramitsu.wallet.api.presentation.mixin.fee.displayFeeStatus
24-
import javax.inject.Inject
2525

2626
@AndroidEntryPoint
2727
class SetupStakingFragment : BaseFragment<SetupStakingViewModel>(R.layout.fragment_setup_staking) {

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/presentation/setup/SetupStakingViewModel.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import androidx.lifecycle.MutableLiveData
55
import androidx.lifecycle.liveData
66
import androidx.lifecycle.viewModelScope
77
import dagger.hilt.android.lifecycle.HiltViewModel
8+
import java.math.BigDecimal
9+
import java.math.BigInteger
10+
import javax.inject.Inject
11+
import javax.inject.Named
812
import jp.co.soramitsu.common.address.AddressIconGenerator
913
import jp.co.soramitsu.common.address.createEthereumAddressModel
1014
import jp.co.soramitsu.common.base.BaseViewModel
@@ -46,10 +50,6 @@ import kotlinx.coroutines.flow.map
4650
import kotlinx.coroutines.flow.mapNotNull
4751
import kotlinx.coroutines.flow.onEach
4852
import kotlinx.coroutines.launch
49-
import java.math.BigDecimal
50-
import java.math.BigInteger
51-
import javax.inject.Inject
52-
import javax.inject.Named
5353

5454
@HiltViewModel
5555
class SetupStakingViewModel @Inject constructor(
@@ -157,6 +157,7 @@ class SetupStakingViewModel @Inject constructor(
157157
setupStakingInteractor.estimateMaxSetupStakingFee(address)
158158
}.orZero()
159159
}
160+
160161
is SetupStakingProcess.SetupStep.Parachain -> {
161162
setupStakingInteractor.estimateParachainFee()
162163
}

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/presentation/staking/redeem/RedeemViewModel.kt

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import androidx.lifecycle.MutableLiveData
55
import androidx.lifecycle.SavedStateHandle
66
import androidx.lifecycle.viewModelScope
77
import dagger.hilt.android.lifecycle.HiltViewModel
8+
import java.math.BigDecimal
9+
import javax.inject.Inject
10+
import javax.inject.Named
811
import jp.co.soramitsu.account.api.presentation.actions.ExternalAccountActions
912
import jp.co.soramitsu.common.R
1013
import jp.co.soramitsu.common.address.AddressIconGenerator
@@ -31,24 +34,14 @@ import jp.co.soramitsu.staking.impl.presentation.StakingRouter
3134
import jp.co.soramitsu.staking.impl.scenarios.StakingScenarioInteractor
3235
import jp.co.soramitsu.wallet.api.data.mappers.mapAssetToAssetModel
3336
import jp.co.soramitsu.wallet.api.presentation.mixin.fee.FeeLoaderMixin
34-
import kotlinx.coroutines.FlowPreview
3537
import kotlinx.coroutines.flow.MutableSharedFlow
3638
import kotlinx.coroutines.flow.combine
37-
import kotlinx.coroutines.flow.debounce
3839
import kotlinx.coroutines.flow.filterIsInstance
3940
import kotlinx.coroutines.flow.first
40-
import kotlinx.coroutines.flow.launchIn
4141
import kotlinx.coroutines.flow.map
4242
import kotlinx.coroutines.flow.mapNotNull
4343
import kotlinx.coroutines.flow.onEach
4444
import kotlinx.coroutines.launch
45-
import java.math.BigDecimal
46-
import javax.inject.Inject
47-
import javax.inject.Named
48-
import kotlin.time.DurationUnit
49-
import kotlin.time.toDuration
50-
51-
private const val DEBOUNCE_DURATION_MILLIS = 500
5245

5346
@HiltViewModel
5447
class RedeemViewModel @Inject constructor(
@@ -127,7 +120,7 @@ class RedeemViewModel @Inject constructor(
127120
}.asLiveData()
128121

129122
init {
130-
listenFee()
123+
loadFee()
131124
}
132125

133126
fun confirmClicked() {
@@ -138,30 +131,24 @@ class RedeemViewModel @Inject constructor(
138131
router.back()
139132
}
140133

141-
@OptIn(FlowPreview::class)
142-
private fun listenFee() {
143-
parsedAmountFlow
144-
.debounce(DEBOUNCE_DURATION_MILLIS.toDuration(DurationUnit.MILLISECONDS))
145-
.onEach { loadFee(it) }
146-
.launchIn(viewModelScope)
147-
}
148-
149-
private fun loadFee(amount: BigDecimal) {
150-
feeLoaderMixin.loadFee(
151-
coroutineScope = viewModelScope,
152-
feeConstructor = { token ->
153-
val stashState = accountStakingFlow.first()
154-
155-
redeemInteractor.estimateFee(stashState) {
156-
stakingScenarioInteractor.confirmRevoke(
157-
this,
158-
candidate = payload.collatorAddress,
159-
stashState = stashState
160-
)
161-
}
162-
},
163-
onRetryCancelled = ::backClicked
164-
)
134+
private fun loadFee() {
135+
launch {
136+
feeLoaderMixin.loadFee(
137+
coroutineScope = viewModelScope,
138+
feeConstructor = {
139+
val stashState = accountStakingFlow.first()
140+
141+
redeemInteractor.estimateFee(stashState) {
142+
stakingScenarioInteractor.confirmRevoke(
143+
this,
144+
candidate = payload.collatorAddress,
145+
stashState = stashState
146+
)
147+
}
148+
},
149+
onRetryCancelled = ::backClicked
150+
)
151+
}
165152
}
166153

167154
fun originAccountClicked() = launch {

feature-wallet-impl/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ android {
2626
buildConfigField "String", "SORA_CONFIG_MOBILE_STAGE", "\"https://config.polkaswap2.io/stage/mobile.json\""
2727
buildConfigField "String", "SORA_CONFIG_COMMON_PROD", "\"https://config.polkaswap2.io/prod/common.json\""
2828
buildConfigField "String", "SORA_CONFIG_MOBILE_PROD", "\"https://config.polkaswap2.io/prod/mobile.json\""
29+
30+
buildConfigField "String", "SCAM_DETECTION_CONFIG", "\"https://raw.githubusercontent.com/soramitsu/shared-features-utils/develop/scamDetection/Polkadot_Hot_Wallet_Attributions.csv\""
2931
}
3032

3133
buildTypes {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package jp.co.soramitsu.wallet.impl.data.network.phishing
22

3+
import jp.co.soramitsu.feature_wallet_impl.BuildConfig
34
import okhttp3.ResponseBody
45
import retrofit2.http.GET
56
import retrofit2.http.Streaming
67

78
interface PhishingApi {
8-
// todo find a better place for url
9+
910
@Streaming
10-
@GET("https://raw.githubusercontent.com/soramitsu/fearless-utils/master/Polkadot_Hot_Wallet_Attributions.csv")
11+
@GET(BuildConfig.SCAM_DETECTION_CONFIG)
1112
suspend fun getPhishingAddresses(): ResponseBody
1213
}

feature-wallet-impl/src/main/java/jp/co/soramitsu/wallet/impl/domain/WalletInteractorImpl.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package jp.co.soramitsu.wallet.impl.domain
22

3+
import java.math.BigDecimal
4+
import java.math.BigInteger
35
import jp.co.soramitsu.account.api.domain.interfaces.AccountRepository
46
import jp.co.soramitsu.account.api.domain.model.MetaAccount
57
import jp.co.soramitsu.account.api.domain.model.accountId
@@ -50,8 +52,6 @@ import kotlinx.coroutines.flow.flatMapMerge
5052
import kotlinx.coroutines.flow.map
5153
import kotlinx.coroutines.flow.withIndex
5254
import kotlinx.coroutines.withContext
53-
import java.math.BigDecimal
54-
import java.math.BigInteger
5555
import jp.co.soramitsu.core.models.Asset as CoreAsset
5656

5757
private const val QR_PREFIX_SUBSTRATE = "substrate"
@@ -103,15 +103,14 @@ class WalletInteractorImpl(
103103
it.isNotEmpty()
104104
}
105105
.distinctUntilChanged()
106-
.flatMapLatest { ratesUpdating ->
106+
.flatMapLatest {
107107
accountRepository.selectedMetaAccountFlow()
108-
.flatMapLatest {
109-
walletRepository.assetsFlow(it)
110-
}
111-
.filter { it.isNotEmpty() }
112-
.map { assets ->
113-
assets.sortedWith(defaultAssetListSort())
114-
}
108+
}.flatMapLatest {
109+
walletRepository.assetsFlow(it)
110+
}
111+
.filter { it.isNotEmpty() }
112+
.map { assets ->
113+
assets.sortedWith(defaultAssetListSort())
115114
}
116115
}
117116

0 commit comments

Comments
 (0)