Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sca-116 wip #213

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ android {
}
}

kotlin {
jvmToolchain(11)
}

applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = new File("Sora_" + variant.versionName + "_" + variant.flavorName + "_" + buildType.name + ".apk")
Expand Down Expand Up @@ -184,7 +180,6 @@ dependencies {
implementation androidDep
implementation appCompatResourcesDep
implementation materialDep
implementation cardViewDep
implementation constraintDep

implementation navigationFragmentDep
Expand All @@ -210,7 +205,6 @@ dependencies {
implementation platform(googleFirebaseBomDep)
implementation googleCrashlyticsDep

implementation xNetworkingDep
implementation webSocketLibDep

implementation zXingCoreDep
Expand Down
21 changes: 10 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ buildscript {
insetter : '0.6.0',
truth : '1.1.5',
lottie : '4.2.0',
xNetworking : '0.0.61',
compose : '1.5.1',
composeMaterial : '1.4.3',
xNetworking : '0.2.1',
compose : '1.5.2',
composeCompiler : '1.5.3',
composeConstraintLayout: '1.1.0-alpha05',
uiCore : '0.2.7',
soraCard : '0.1.45',
soraCard : '0.1.48',
lazySodium : '5.0.2',
jna : '5.8.0',
accompanist : '0.30.1',
xserializationjson : '1.5.0',
xserializationjson : '1.5.1',
ktor : '2.3.1',
xbackup : '0.0.2-20231002.173502-3'
]
Expand All @@ -73,7 +72,6 @@ buildscript {
appCompatResourcesDep = "androidx.appcompat:appcompat-resources:1.6.1"
biometricDep = "androidx.biometric:biometric:$versions.biometric"
materialDep = "com.google.android.material:material:1.9.0"
cardViewDep = "androidx.cardview:cardview:1.0.0"
constraintDep = "androidx.constraintlayout:constraintlayout:$versions.constraint"
activityKtxDep = "androidx.activity:activity-ktx:1.7.1"
fragmentKtxDep = "androidx.fragment:fragment-ktx:1.6.1"
Expand Down Expand Up @@ -113,7 +111,8 @@ buildscript {

irohaDep = "com.github.hyperledger.iroha-java:client:$versions.iroha"
soraDep = "com.github.soramitsu:sora-sdk:$versions.soraSdk"
xNetworkingDep = "jp.co.soramitsu:XNetworking-android:$versions.xNetworking"
xNetworkingDep = "jp.co.soramitsu.xnetworking:basic-android:$versions.xNetworking"
xNetworkingSoraWalletDep = "jp.co.soramitsu.xnetworking:sorawallet-android:$versions.xNetworking"
ktorWebSocketDep = "io.ktor:ktor-client-websockets:$versions.ktor"
webSocketLibDep = "com.neovisionaries:nv-websocket-client:$versions.webSocketLib"
uiCoreDep = "jp.co.soramitsu:ui-core:$versions.uiCore"
Expand Down Expand Up @@ -202,12 +201,12 @@ buildscript {
composeAnimationGraphicsDep = "androidx.compose.animation:animation-graphics:$versions.compose"
composeToolingDep = "androidx.compose.ui:ui-tooling:$versions.compose"
composeToolingPreviewDep = "androidx.compose.ui:ui-tooling-preview:$versions.compose"
composeActivityDep = "androidx.activity:activity-compose:1.7.1"
composeViewModelDep = "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
composeLifecycleDep = "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"
composeActivityDep = "androidx.activity:activity-compose:1.7.2"
composeViewModelDep = "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2"
composeLifecycleDep = "androidx.lifecycle:lifecycle-runtime-compose:2.6.2"
composeConstraintLayoutDep = "androidx.constraintlayout:constraintlayout-compose:$versions.composeConstraintLayout"

accompanistNavAnimationDep = "com.google.accompanist:accompanist-navigation-animation:$versions.accompanist"
// accompanistNavAnimationDep = "com.google.accompanist:accompanist-navigation-animation:$versions.accompanist"

lazySodiumDep = "com.goterl:lazysodium-android:$versions.lazySodium@aar"
jnaDep = "net.java.dev.jna:jna:$versions.jna@aar"
Expand Down
3 changes: 1 addition & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":android-foundation")
implementation project(":soracrypro")
implementation project(":network")

implementation activityKtxDep
implementation coreKtxDep
implementation androidDep
implementation appCompatResourcesDep
implementation materialDep
implementation cardViewDep
implementation constraintDep

implementation coroutineAndroidDep
Expand All @@ -132,7 +132,6 @@ dependencies {
implementation googlePlayCoreDep
implementation coilSvgDep

implementation xNetworkingDep
implementation webSocketLibDep
implementation uiCoreDep

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ import jp.co.soramitsu.common.vibration.DeviceVibrator
import jp.co.soramitsu.crypto.ed25519.Ed25519Sha3
import jp.co.soramitsu.shared_utils.encrypt.json.JsonSeedEncoder
import jp.co.soramitsu.xbackup.BackupService
import jp.co.soramitsu.xnetworking.networkclient.SoramitsuHttpClientProvider
import jp.co.soramitsu.xnetworking.networkclient.SoramitsuHttpClientProviderImpl
import jp.co.soramitsu.xnetworking.networkclient.SoramitsuNetworkClient
import jp.co.soramitsu.xnetworking.basic.networkclient.SoramitsuHttpClientProvider
import jp.co.soramitsu.xnetworking.basic.networkclient.SoramitsuHttpClientProviderImpl
import jp.co.soramitsu.xnetworking.basic.networkclient.SoramitsuNetworkClient
import jp.co.soramitsu.xnetworking.sorawallet.blockexplorerinfo.SoraWalletBlockExplorerInfo
import jp.co.soramitsu.xnetworking.sorawallet.mainconfig.SoraRemoteConfigBuilder
import jp.co.soramitsu.xnetworking.sorawallet.mainconfig.SoraRemoteConfigProvider
import jp.co.soramitsu.xnetworking.sorawallet.tokenwhitelist.SoraTokensWhitelistManager
import jp.co.soramitsu.xnetworking.txhistory.client.sorawallet.SubQueryClientForSoraWalletFactory
import jp.co.soramitsu.xnetworking.sorawallet.txhistory.client.SubQueryClientForSoraWalletFactory

@InstallIn(SingletonComponent::class)
@Module
Expand Down
12 changes: 6 additions & 6 deletions common/src/main/res/layout/layout_loading.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/x1"
app:cardCornerRadius="@dimen/x2" >
android:orientation="horizontal"
app:cardCornerRadius="@dimen/x2">

<ProgressBar
style="@style/Widget.Soramitsu.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_margin="@dimen/x2"
style="@style/Widget.Soramitsu.ProgressBar" />
android:indeterminate="true" />

</androidx.cardview.widget.CardView>
</LinearLayout>
3 changes: 1 addition & 2 deletions common_wallet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ dependencies {
implementation project(":common")
implementation project(":feature_blockexplorer_api")
implementation project(":core_db")
implementation project(":network")

implementation coreKtxDep
implementation materialDep
implementation cardViewDep
implementation constraintDep

implementation coroutineAndroidDep
Expand All @@ -76,7 +76,6 @@ dependencies {
implementation googlePlayCoreDep
implementation coilSvgDep

implementation xNetworkingDep
implementation webSocketLibDep
implementation uiCoreDep

Expand Down
3 changes: 1 addition & 2 deletions demeter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dependencies {
implementation project(":feature_blockexplorer_api")
implementation project(":feature_account_api")
implementation project(":sorasubstrate")
implementation project(":network")

implementation daggerDep
kapt daggerKaptDep
Expand All @@ -75,10 +76,8 @@ dependencies {

implementation roomDep
implementation roomKtxDep
//kapt roomKaptDep

implementation sharedUtilsDep
implementation xNetworkingDep

testImplementation project(":test_shared")
testImplementation project(":test_data")
Expand Down
4 changes: 1 addition & 3 deletions feature_assets_api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dependencies {
implementation project(":common")
implementation project(':common_wallet')
implementation project(":sorasubstrate")
implementation project(":network")
implementation sharedUtilsDep

implementation coroutineAndroidDep
Expand All @@ -84,9 +85,6 @@ dependencies {
implementation composeLifecycleDep
debugImplementation composeToolingDep
implementation navigationComposeDep
//implementation accompanistNavAnimationDep

implementation xNetworkingDep

implementation daggerDep
kapt daggerKaptDep
Expand Down
4 changes: 0 additions & 4 deletions feature_assets_impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ dependencies {

implementation androidDep
implementation materialDep
implementation cardViewDep
implementation constraintDep

implementation navigationFragmentDep
Expand Down Expand Up @@ -131,9 +130,6 @@ dependencies {
implementation composeLifecycleDep
debugImplementation composeToolingDep
implementation navigationComposeDep
//implementation accompanistNavAnimationDep

implementation xNetworkingDep

implementation zXingCoreDep
implementation zXingEmbeddedDep
Expand Down
4 changes: 1 addition & 3 deletions feature_blockexplorer_api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ dependencies {

implementation project(":common")
implementation project(":core_db")
implementation project(":network")

implementation androidDep
implementation materialDep
implementation cardViewDep
implementation constraintDep

implementation coilDep
Expand Down Expand Up @@ -106,8 +106,6 @@ dependencies {
implementation navigationFragmentDep
implementation navigationUiDep

implementation xNetworkingDep

implementation daggerDep
kapt daggerKaptDep

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ import jp.co.soramitsu.common.logger.FirebaseWrapper
import jp.co.soramitsu.core_db.AppDatabase
import jp.co.soramitsu.core_db.model.FiatTokenPriceLocal
import jp.co.soramitsu.core_db.model.ReferralLocal
import jp.co.soramitsu.xnetworking.common.Utils.toDoubleNan
import jp.co.soramitsu.xnetworking.networkclient.SoramitsuNetworkClient
import jp.co.soramitsu.xnetworking.basic.common.Utils.toDoubleNan
import jp.co.soramitsu.xnetworking.basic.networkclient.SoramitsuNetworkClient
import jp.co.soramitsu.xnetworking.sorawallet.blockexplorerinfo.SoraWalletBlockExplorerInfo
import jp.co.soramitsu.xnetworking.sorawallet.blockexplorerinfo.sbapy.SbApyInfo
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.serialization.json.Json
import kotlinx.serialization.serializer

Expand All @@ -64,6 +66,8 @@ class BlockExplorerManager @Inject constructor(

private var assetsInfo: List<Pair<String, BigInteger>>? = null

private val mutex = Mutex()

fun getTempApy(id: String) = tempApy.find {
it.id == id
}?.sbApy?.times(100)
Expand All @@ -73,33 +77,40 @@ class BlockExplorerManager @Inject constructor(
assetsInfo = it
}

private suspend fun getAssetsInfoInternal(tokenIds: List<String>): List<Pair<String, BigInteger>> = runCatching {
val selected = soraConfigManager.getSelectedCurrency()
val tokens = db.assetDao().getFiatTokenPriceLocal(selected.code)
val yesterdayHour = yesterday()
val resultList = mutableListOf<Pair<String, BigInteger>>()
val fiats = mutableListOf<FiatTokenPriceLocal>()
info.getAssetsInfo(tokenIds, yesterdayHour).forEach { assetInfo ->
val dbValue = tokens.find { it.tokenIdFiat == assetInfo.tokenId }
val delta = assetInfo.hourDelta
if (dbValue != null && delta != null) {
fiats.add(dbValue.copy(fiatPricePrevH = delta, fiatPricePrevHTime = yesterdayHour))
private suspend fun getAssetsInfoInternal(tokenIds: List<String>): List<Pair<String, BigInteger>> = mutex.withLock {
runCatching {
val selected = soraConfigManager.getSelectedCurrency()
val tokens = db.assetDao().getFiatTokenPriceLocal(selected.code)
val yesterdayHour = yesterday()
val resultList = mutableListOf<Pair<String, BigInteger>>()
val fiats = mutableListOf<FiatTokenPriceLocal>()
info.getAssetsInfo(tokenIds, yesterdayHour).forEach { assetInfo ->
val dbValue = tokens.find { it.tokenIdFiat == assetInfo.tokenId }
val delta = assetInfo.hourDelta
if (dbValue != null && delta != null) {
fiats.add(dbValue.copy(fiatPricePrevH = delta, fiatPricePrevHTime = yesterdayHour))
}
resultList.add(assetInfo.tokenId to BigInteger(assetInfo.liquidity))
}
resultList.add(assetInfo.tokenId to BigInteger(assetInfo.liquidity))
db.assetDao().insertFiatPrice(fiats)
resultList
}.getOrElse {
FirebaseWrapper.recordException(it)
emptyList()
}
db.assetDao().insertFiatPrice(fiats)
resultList
}.getOrElse {
FirebaseWrapper.recordException(it)
emptyList()
}

suspend fun updatePoolsSbApy() {
updateSbApyInternal()
}

suspend fun updateFiat() {
updateFiatInternal()
if (appStateProvider.isForeground) {
runCatching {
val response = info.getFiat()
updateFiatPrices(response.map { FiatInfo(it.id, it.priceUsd) })
}
}
}

suspend fun updateReferrerRewards(
Expand Down Expand Up @@ -136,16 +147,7 @@ class BlockExplorerManager @Inject constructor(
}
}

private suspend fun updateFiatInternal() {
if (appStateProvider.isForeground) {
runCatching {
val response = info.getFiat()
updateFiatPrices(response.map { FiatInfo(it.id, it.priceUsd) })
}
}
}

private suspend fun updateFiatPrices(fiatData: List<FiatInfo>) {
private suspend fun updateFiatPrices(fiatData: List<FiatInfo>) = mutex.withLock {
val selected = soraConfigManager.getSelectedCurrency()
val tokens = db.assetDao().getTokensWithFiatOfCurrency(selected.code)

Expand Down
4 changes: 1 addition & 3 deletions feature_blockexplorer_impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ dependencies {
implementation project(":feature_account_api")
implementation project(":feature_main_api")
implementation project(":feature_wallet_api")
implementation project(":network")

implementation androidDep
implementation materialDep
implementation cardViewDep
implementation constraintDep

implementation coilDep
Expand Down Expand Up @@ -111,8 +111,6 @@ dependencies {
implementation navigationFragmentDep
implementation navigationUiDep

implementation xNetworkingDep

implementation daggerDep
kapt daggerKaptDep

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import jp.co.soramitsu.feature_blockexplorer_api.presentation.txhistory.Transact
import jp.co.soramitsu.sora.substrate.runtime.Pallete
import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider
import jp.co.soramitsu.sora.substrate.substrate.ExtrinsicManager
import jp.co.soramitsu.xnetworking.txhistory.TxHistoryItem
import jp.co.soramitsu.xnetworking.txhistory.client.sorawallet.SubQueryClientForSoraWallet
import jp.co.soramitsu.xnetworking.basic.txhistory.TxHistoryItem
import jp.co.soramitsu.xnetworking.sorawallet.txhistory.client.SubQueryClientForSoraWallet
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.debounce

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import jp.co.soramitsu.feature_blockexplorer_api.presentation.txhistory.Transact
import jp.co.soramitsu.sora.substrate.runtime.Method
import jp.co.soramitsu.sora.substrate.runtime.Pallete
import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider
import jp.co.soramitsu.xnetworking.txhistory.TxHistoryItem
import jp.co.soramitsu.xnetworking.txhistory.TxHistoryItemParam
import jp.co.soramitsu.xnetworking.basic.txhistory.TxHistoryItem
import jp.co.soramitsu.xnetworking.basic.txhistory.TxHistoryItemParam

fun mapHistoryItemsToTransactions(
txs: List<TxHistoryItem>,
Expand Down
Loading