Skip to content

Commit

Permalink
Merge pull request #422 from sora-xor/mwr-824
Browse files Browse the repository at this point in the history
mwr-824
  • Loading branch information
arvifox authored Jun 27, 2024
2 parents de7c6e0 + b4b885c commit f3e529c
Show file tree
Hide file tree
Showing 30 changed files with 260 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ package jp.co.soramitsu.common.domain

import android.os.Parcelable
import java.math.BigDecimal
import jp.co.soramitsu.androidfoundation.format.equalTo
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.util.NumbersFormatter
import jp.co.soramitsu.common.util.ext.equalTo
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import java.math.BigDecimal
import jp.co.soramitsu.androidfoundation.format.orZero
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.domain.AssetAmountInputState
import jp.co.soramitsu.common.domain.OptionsProvider
import jp.co.soramitsu.common.presentation.compose.TokenIcon
import jp.co.soramitsu.common.presentation.compose.theme.SoraAppTheme
import jp.co.soramitsu.common.util.ext.orZero
import jp.co.soramitsu.common.util.testTagAsId
import jp.co.soramitsu.ui_core.component.button.properties.Size
import jp.co.soramitsu.ui_core.component.input.number.BasicNumberInput
Expand Down
103 changes: 0 additions & 103 deletions common/src/main/java/jp/co/soramitsu/common/util/ext/BigDecimalExt.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package jp.co.soramitsu.common_wallet.presentation.compose.util

import java.math.BigDecimal
import jp.co.soramitsu.androidfoundation.format.Big100
import jp.co.soramitsu.androidfoundation.format.divideBy
import jp.co.soramitsu.androidfoundation.format.equalTo
import jp.co.soramitsu.androidfoundation.format.safeDivide
import jp.co.soramitsu.common.domain.OptionsProvider
import jp.co.soramitsu.common.util.ext.Big100
import jp.co.soramitsu.common.util.ext.divideBy
import jp.co.soramitsu.common.util.ext.equalTo
import jp.co.soramitsu.common.util.ext.safeDivide
import jp.co.soramitsu.common_wallet.domain.model.WithDesired

object PolkaswapFormulas {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package jp.co.soramitsu.common_wallet.presentation

import java.math.BigDecimal
import jp.co.soramitsu.common.util.ext.Big100
import jp.co.soramitsu.common.util.ext.divideBy
import jp.co.soramitsu.common.util.ext.equalTo
import jp.co.soramitsu.common.util.ext.safeDivide
import jp.co.soramitsu.androidfoundation.format.Big100
import jp.co.soramitsu.androidfoundation.format.divideBy
import jp.co.soramitsu.androidfoundation.format.equalTo
import jp.co.soramitsu.androidfoundation.format.safeDivide
import jp.co.soramitsu.common_wallet.domain.model.WithDesired
import jp.co.soramitsu.common_wallet.presentation.compose.util.PolkaswapFormulas
import org.junit.Assert.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ package jp.co.soramitsu.demeter.data
import java.math.BigDecimal
import java.math.BigInteger
import java.util.concurrent.ConcurrentHashMap
import jp.co.soramitsu.androidfoundation.format.isZero
import jp.co.soramitsu.androidfoundation.format.safeCast
import jp.co.soramitsu.common.domain.OptionsProvider
import jp.co.soramitsu.common.util.ext.isZero
import jp.co.soramitsu.common.util.mapBalance
import jp.co.soramitsu.common_wallet.data.AssetLocalToAssetMapper
import jp.co.soramitsu.core_db.AppDatabase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package jp.co.soramitsu.feature_assets_api.data

import java.math.BigDecimal
import java.math.BigInteger
import jp.co.soramitsu.common.account.SoraAccount
import jp.co.soramitsu.common.domain.Asset
import jp.co.soramitsu.common.domain.Token
Expand Down Expand Up @@ -121,4 +122,6 @@ interface AssetsRepository {
suspend fun updateBalancesVisibleAssets(address: String)

suspend fun updateWhitelistBalances(address: String)

suspend fun fetchBalance(address: String, ids: List<String>): List<BigInteger>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package jp.co.soramitsu.feature_assets_api.domain
import java.math.BigDecimal
import jp.co.soramitsu.common.account.SoraAccount
import jp.co.soramitsu.common.domain.Asset
import jp.co.soramitsu.common.domain.OptionsProvider
import jp.co.soramitsu.common.domain.Token
import jp.co.soramitsu.common_wallet.data.XorAssetBalance
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -94,4 +95,10 @@ interface AssetsInteractor {
suspend fun updateWhitelistBalances()

suspend fun updateBalanceVisibleAssets()

suspend fun fetchBalance(
address: String,
ids: List<String>,
precision: Int = OptionsProvider.defaultScale,
): List<BigDecimal>
}
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ class AssetsRepositoryImpl @Inject constructor(
return balances to xorBalance
}

override suspend fun fetchBalance(
address: String,
ids: List<String>,
): List<BigInteger> {
return substrateCalls.fetchBalances(address, ids)
}

private suspend fun checkDefaultNeed(address: String, code: String) {
if (db.assetDao().getAssetsWhitelist(address, code)
.all { it.assetLocal == null }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ package jp.co.soramitsu.feature_assets_impl.domain

import java.math.BigDecimal
import java.util.Date
import jp.co.soramitsu.androidfoundation.format.isZero
import jp.co.soramitsu.androidfoundation.format.orZero
import jp.co.soramitsu.common.account.SoraAccount
import jp.co.soramitsu.common.domain.Asset
import jp.co.soramitsu.common.domain.AssetHolder
import jp.co.soramitsu.common.domain.CoroutineManager
import jp.co.soramitsu.common.domain.Token
import jp.co.soramitsu.common.util.BuildUtils
import jp.co.soramitsu.common.util.Flavor
import jp.co.soramitsu.common.util.ext.isZero
import jp.co.soramitsu.common.util.ext.orZero
import jp.co.soramitsu.common.util.mapBalance
import jp.co.soramitsu.common_wallet.data.XorAssetBalance
import jp.co.soramitsu.feature_account_api.domain.interfaces.CredentialsRepository
import jp.co.soramitsu.feature_account_api.domain.interfaces.UserRepository
Expand Down Expand Up @@ -211,6 +212,16 @@ class AssetsInteractorImpl constructor(
assetsRepository.updateBalancesVisibleAssets(soraAccount.substrateAddress)
}

override suspend fun fetchBalance(
address: String,
ids: List<String>,
precision: Int,
): List<BigDecimal> {
return assetsRepository.fetchBalance(address, ids).map {
mapBalance(it, precision)
}
}

override suspend fun updateWhitelistBalances() {
val soraAccount = userRepository.getCurSoraAccount()
assetsRepository.updateWhitelistBalances(soraAccount.substrateAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.math.BigDecimal
import jp.co.soramitsu.androidfoundation.format.isZero
import jp.co.soramitsu.androidfoundation.fragment.SingleLiveEvent
import jp.co.soramitsu.androidfoundation.fragment.trigger
import jp.co.soramitsu.androidfoundation.phone.BasicClipboardManager
Expand All @@ -57,7 +58,6 @@ import jp.co.soramitsu.common.presentation.compose.components.initSmallTitle2
import jp.co.soramitsu.common.presentation.viewmodel.BaseViewModel
import jp.co.soramitsu.common.util.NumbersFormatter
import jp.co.soramitsu.common.util.StringPair
import jp.co.soramitsu.common.util.ext.isZero
import jp.co.soramitsu.common_wallet.data.XorAssetBalance
import jp.co.soramitsu.common_wallet.domain.model.fiatSymbol
import jp.co.soramitsu.common_wallet.presentation.compose.states.mapPoolsData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.math.BigDecimal
import jp.co.soramitsu.androidfoundation.format.isZero
import jp.co.soramitsu.androidfoundation.format.nullZero
import jp.co.soramitsu.androidfoundation.format.orZero
import jp.co.soramitsu.androidfoundation.fragment.SingleLiveEvent
import jp.co.soramitsu.androidfoundation.fragment.trigger
import jp.co.soramitsu.androidfoundation.phone.BasicClipboardManager
Expand All @@ -52,9 +55,6 @@ import jp.co.soramitsu.common.domain.subtractFee
import jp.co.soramitsu.common.presentation.compose.components.initSmallTitle2
import jp.co.soramitsu.common.presentation.viewmodel.BaseViewModel
import jp.co.soramitsu.common.util.NumbersFormatter
import jp.co.soramitsu.common.util.ext.isZero
import jp.co.soramitsu.common.util.ext.nullZero
import jp.co.soramitsu.common.util.ext.orZero
import jp.co.soramitsu.common.view.ViewHelper
import jp.co.soramitsu.common_wallet.presentation.compose.util.PolkaswapFormulas
import jp.co.soramitsu.feature_assets_api.domain.AssetsInteractor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.verify
import java.util.StringJoiner
import jp.co.soramitsu.androidfoundation.format.Big100
import jp.co.soramitsu.androidfoundation.phone.BasicClipboardManager
import jp.co.soramitsu.androidfoundation.resource.ResourceManager
import jp.co.soramitsu.common.account.AccountAvatarGenerator
Expand All @@ -53,7 +54,6 @@ import jp.co.soramitsu.common.domain.CoroutineManager
import jp.co.soramitsu.common.io.FileManager
import jp.co.soramitsu.common.util.NumbersFormatter
import jp.co.soramitsu.common.util.QrCodeGenerator
import jp.co.soramitsu.common.util.ext.Big100
import jp.co.soramitsu.feature_assets_api.domain.AssetsInteractor
import jp.co.soramitsu.feature_assets_api.domain.QrCodeInteractor
import jp.co.soramitsu.feature_assets_impl.presentation.screens.receiverequest.QRCodeFlowViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.junit4.MockKRule
import java.math.BigDecimal
import jp.co.soramitsu.androidfoundation.format.equalTo
import jp.co.soramitsu.androidfoundation.phone.BasicClipboardManager
import jp.co.soramitsu.androidfoundation.resource.ResourceManager
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.account.AccountAvatarGenerator
import jp.co.soramitsu.common.util.NumbersFormatter
import jp.co.soramitsu.common.util.ext.equalTo
import jp.co.soramitsu.feature_assets_api.domain.AssetsInteractor
import jp.co.soramitsu.feature_assets_api.presentation.AssetsRouter
import jp.co.soramitsu.feature_assets_impl.presentation.screens.send.TransferAmountViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ import java.math.BigDecimal
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton
import jp.co.soramitsu.androidfoundation.format.toDoubleInfinite
import jp.co.soramitsu.common.config.BuildConfigWrapper
import jp.co.soramitsu.common.domain.AppStateProvider
import jp.co.soramitsu.common.domain.RetryStrategyBuilder
import jp.co.soramitsu.common.domain.fiatChange
import jp.co.soramitsu.common.logger.FirebaseWrapper
import jp.co.soramitsu.common.util.ext.toDoubleInfinite
import jp.co.soramitsu.common.util.mapBalance
import jp.co.soramitsu.core_db.AppDatabase
import jp.co.soramitsu.core_db.model.FiatTokenPriceLocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_ecosystem_impl.domain

import jp.co.soramitsu.common.util.ext.compareNullDesc
import jp.co.soramitsu.androidfoundation.format.compareNullDesc
import jp.co.soramitsu.feature_polkaswap_api.domain.interfaces.PolkaswapRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_ecosystem_impl.domain

import jp.co.soramitsu.common.util.ext.compareNullDesc
import jp.co.soramitsu.androidfoundation.format.compareNullDesc
import jp.co.soramitsu.feature_assets_api.data.AssetsRepository
import jp.co.soramitsu.feature_blockexplorer_api.data.BlockExplorerManager
import kotlinx.coroutines.flow.Flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.math.BigDecimal
import jp.co.soramitsu.androidfoundation.format.Big100
import jp.co.soramitsu.androidfoundation.format.divideBy
import jp.co.soramitsu.androidfoundation.resource.ResourceManager
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.domain.Asset
import jp.co.soramitsu.common.presentation.viewmodel.BaseViewModel
import jp.co.soramitsu.common.util.NumbersFormatter
import jp.co.soramitsu.common.util.StringPair
import jp.co.soramitsu.common.util.StringTriple
import jp.co.soramitsu.common.util.ext.Big100
import jp.co.soramitsu.common.util.ext.divideBy
import jp.co.soramitsu.common_wallet.domain.model.CommonUserPoolData
import jp.co.soramitsu.common_wallet.presentation.compose.util.PolkaswapFormulas
import jp.co.soramitsu.demeter.domain.DemeterFarmingInteractor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ 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.androidfoundation.format.compareNullDesc
import jp.co.soramitsu.androidfoundation.format.formatFiatSuffix
import jp.co.soramitsu.androidfoundation.resource.ResourceManager
import jp.co.soramitsu.common.domain.iconUri
Expand All @@ -44,7 +45,6 @@ import jp.co.soramitsu.common.presentation.viewmodel.BaseViewModel
import jp.co.soramitsu.common.util.NumbersFormatter
import jp.co.soramitsu.common.util.StringPair
import jp.co.soramitsu.common.util.StringTriple
import jp.co.soramitsu.common.util.ext.compareNullDesc
import jp.co.soramitsu.common_wallet.domain.model.isFilterMatch
import jp.co.soramitsu.common_wallet.presentation.compose.BasicFarmListItemState
import jp.co.soramitsu.common_wallet.presentation.compose.BasicPoolListItemState
Expand Down
Loading

0 comments on commit f3e529c

Please sign in to comment.