diff --git a/app/build.gradle b/app/build.gradle index 68a6c4097..75f5676a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -142,7 +142,7 @@ play { serviceAccountCredentials = file(System.env.CI_PLAY_KEY ?: "../key/fake.json") track = "internal" releaseStatus = ReleaseStatus.DRAFT - releaseName = "3.6.0.0 - Improvements on SORA Card Hub" + releaseName = "3.7.0.0 - Night Mode" } dependencies { @@ -213,8 +213,6 @@ dependencies { implementation zXingCoreDep implementation zXingEmbeddedDep - implementation gsonDep - // Tests testImplementation project(":test_shared") } diff --git a/build.gradle b/build.gradle index 209afac28..7099d639a 100644 --- a/build.gradle +++ b/build.gradle @@ -5,13 +5,13 @@ buildscript { coroutines : '1.7.3', dagger : '2.48', hiltWorkManager : '1.0.0', - hiltCompose : '1.0.0', + hiltCompose : '1.1.0', timber : '5.0.1', gson : '2.10.1', - googleFirebaseBom : '31.1.1', - googlePlayCore : '1.10.3', + googleFirebaseBom : '32.5.0', googleApiServicesDrive : 'v3-rev136-1.25.0', - googlePlayServiceAuth : '20.5.0', + googlePlayServiceAuth : '20.7.0', + googleInAppUpdate : '2.1.0', constraint : '2.2.0-alpha05', soraSdk : '0.3.10', iroha : '5.1.2', @@ -43,8 +43,8 @@ buildscript { compose : '1.5.4', composeCompiler : '1.5.3', composeConstraintLayout: '1.1.0-alpha05', - uiCore : '0.2.12', - soraCard : '0.1.64', + uiCore : '0.2.13', + soraCard : '0.1.67', lazySodium : '5.0.2', jna : '5.8.0', xserializationjson : '1.5.1', @@ -55,11 +55,11 @@ buildscript { ] ext { -// soralution 117 3.7.0.1 2023.10.28 -// sora dae 106 3.6.0.0 2023.10.28 +// soralution 119 3.7.0.3 2023.11.08 +// sora dae 107 3.7.0.0 2023.11.09 // appVersionCode = Integer.valueOf(System.env.BUILD_NUMBER ?: 96) - appVersionCode = Integer.valueOf(System.env.CI_BUILD_ID ?: 106) - appVersionName = '3.6.0.0' + appVersionCode = Integer.valueOf(System.env.CI_BUILD_ID ?: 107) + appVersionName = '3.7.0.0' compileVersion = 34 minVersion = 24 @@ -75,7 +75,7 @@ buildscript { materialDep = "com.google.android.material:material:1.10.0" constraintDep = "androidx.constraintlayout:constraintlayout:$versions.constraint" activityKtxDep = "androidx.activity:activity-ktx:1.7.1" - fragmentKtxDep = "androidx.fragment:fragment-ktx:1.6.1" + fragmentKtxDep = "androidx.fragment:fragment-ktx:1.6.2" coreKtxDep = "androidx.core:core-ktx:1.12.0" workManagerDep = "androidx.work:work-runtime-ktx:$versions.workManager" @@ -124,8 +124,9 @@ buildscript { gsonDep = "com.google.code.gson:gson:$versions.gson" + googleInAppUpdateDep = "com.google.android.play:app-update:$versions.googleInAppUpdate" + googleInAppUpdateKtxDep = "com.google.android.play:app-update-ktx:$versions.googleInAppUpdate" googleCrashlyticsDep = "com.google.firebase:firebase-crashlytics-ktx" - googlePlayCoreDep = "com.google.android.play:core:$versions.googlePlayCore" googleFirebaseBomDep = "com.google.firebase:firebase-bom:$versions.googleFirebaseBom" googlePlayServiceAuth = "com.google.android.gms:play-services-auth:$versions.googlePlayServiceAuth" googleApiServicesDrive = "com.google.apis:google-api-services-drive:$versions.googleApiServicesDrive" @@ -135,7 +136,7 @@ buildscript { navigationFragmentDep = "androidx.navigation:navigation-fragment-ktx:$versions.navigation" navigationUiDep = "androidx.navigation:navigation-ui-ktx:$versions.navigation" - navigationComposeDep = "androidx.navigation:navigation-compose:2.7.4" + navigationComposeDep = "androidx.navigation:navigation-compose:2.7.5" zXingCoreDep = "com.google.zxing:core:$versions.zXing" zXingEmbeddedDep = "com.journeyapps:zxing-android-embedded:$versions.zXingEmbedded" @@ -218,7 +219,7 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" classpath "org.jetbrains.kotlin:kotlin-serialization:${versions.kotlin}" - classpath 'com.android.tools.build:gradle:8.2.0-rc01' + classpath 'com.android.tools.build:gradle:8.2.0-rc02' classpath 'com.google.gms:google-services:4.3.15' classpath 'com.google.firebase:firebase-appdistribution-gradle:3.2.0' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9' diff --git a/common/build.gradle b/common/build.gradle index 6f39e33d8..0cdcbfece 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -115,6 +115,9 @@ dependencies { implementation project(":soracrypro") implementation project(":network") + implementation googleInAppUpdateDep + implementation googleInAppUpdateKtxDep + implementation activityKtxDep implementation coreKtxDep implementation androidDep @@ -129,7 +132,6 @@ dependencies { implementation kotlinxSerializationJsonDep - implementation googlePlayCoreDep implementation coilSvgDep implementation webSocketLibDep diff --git a/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/AlertDialogContent.kt b/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/AlertDialogContent.kt index b5d6b09b9..436c5cc80 100644 --- a/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/AlertDialogContent.kt +++ b/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/AlertDialogContent.kt @@ -51,9 +51,9 @@ fun AlertDialogContent(openAlertDialog: MutableState) { val message = openAlertDialog.value.message.message() if (title != null && message != null) { AlertDialog( - backgroundColor = MaterialTheme.customColors.bgPage, - title = { Text(text = title) }, - text = { Text(text = message) }, + backgroundColor = MaterialTheme.customColors.bgSurfaceVariant, + title = { Text(color = MaterialTheme.customColors.fgPrimary, text = title) }, + text = { Text(color = MaterialTheme.customColors.fgPrimary, text = message) }, onDismissRequest = { openAlertDialog.value = AlertDialogData() }, diff --git a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/response/EthRegisterStateResponse.kt b/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/TextWithDelimiter.kt similarity index 57% rename from feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/response/EthRegisterStateResponse.kt rename to common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/TextWithDelimiter.kt index 455116bbe..c81ebcd34 100644 --- a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/response/EthRegisterStateResponse.kt +++ b/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/TextWithDelimiter.kt @@ -30,21 +30,46 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package jp.co.soramitsu.feature_ethereum_impl.data.network.response - -import com.google.gson.annotations.SerializedName -import jp.co.soramitsu.sora.substrate.response.StatusDto - -data class EthRegisterStateResponse( - @SerializedName("status") val status: StatusDto, - @SerializedName("address") val address: String?, - @SerializedName("state") val state: State, - @SerializedName("reason") val reason: String? -) { - - enum class State { - INPROGRESS, - COMPLETED, - FAILED +package jp.co.soramitsu.common.presentation.compose.components + +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.style.TextOverflow + +@Composable +fun TextWithDelimiter(text1: String, text2: String, delimiter: String, color: Color, style: TextStyle) { + Row { + Text( + modifier = Modifier + .wrapContentSize(), + text = text1, + style = style, + overflow = TextOverflow.Ellipsis, + color = color, + maxLines = 1, + ) + Text( + modifier = Modifier + .wrapContentSize(), + text = delimiter, + style = style, + overflow = TextOverflow.Ellipsis, + color = color, + maxLines = 1, + ) + Text( + modifier = Modifier + .wrapContentSize(), + text = text2, + style = style, + overflow = TextOverflow.Ellipsis, + color = color, + maxLines = 1, + ) } } diff --git a/common/src/main/res/values-az/strings.xml b/common/src/main/res/values-az/strings.xml index 3354937d4..49c64ae97 100644 --- a/common/src/main/res/values-az/strings.xml +++ b/common/src/main/res/values-az/strings.xml @@ -283,7 +283,7 @@ QR kodunu açmaq olmur QR-dən istifadəçi tapa bilinmir It\'s loading for a little longer this time - Liquid assets + Aktivlər Bu əməliyyat hesabın bu cihazdan silinməsi ilə nəticələnəcəkdir. Davam etmədən əvvəl parol keçidinizi yedəklədiyinizə əmin olun. \n\nBütün fərdi qovşaqlarınız da silinəcək from the list you have written down diff --git a/common/src/main/res/values-de/strings.xml b/common/src/main/res/values-de/strings.xml index da8b7c146..5683ede49 100644 --- a/common/src/main/res/values-de/strings.xml +++ b/common/src/main/res/values-de/strings.xml @@ -283,7 +283,7 @@ QR-Code kann nicht entziffert werden Keinen Benutzer vom QR-Code gefunden It\'s loading for a little longer this time - Liquid assets + Assets Diese Aktion führt zum Löschen des Kontos von diesem Gerät. Stell sicher, dass du deine Passphrase sicher hinterlegt hast, bevor du fortfährst. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common/src/main/res/values-fa/strings.xml b/common/src/main/res/values-fa/strings.xml index f69e6e438..88bedcc88 100644 --- a/common/src/main/res/values-fa/strings.xml +++ b/common/src/main/res/values-fa/strings.xml @@ -283,7 +283,7 @@ کد QR قابل رمزگشایی نیست کاربری با QR پیدا نمی شود It\'s loading for a little longer this time - Liquid assets + Assets این عملکرد منجر به حذف حساب از این دستگاه می‌شود. قبل از ادامه مطمئن شوید که از کلمات بازیابی والت خود پشتیبان تهیه کرده اید. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common/src/main/res/values-fi/strings.xml b/common/src/main/res/values-fi/strings.xml index 67f610133..e7dd333f7 100644 --- a/common/src/main/res/values-fi/strings.xml +++ b/common/src/main/res/values-fi/strings.xml @@ -283,7 +283,7 @@ QR-koodia ei voi dekoodata Käyttäjää ei löydy QR:stä It\'s loading for a little longer this time - Liquid assets + Assets Tämä toiminto johtaa tilin poistamiseen tältä laitteelta. Varmista, että olet varmuuskopioinut salasanasi, ennen kuin jatkat. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common/src/main/res/values-in/strings.xml b/common/src/main/res/values-in/strings.xml index dfaa4c213..ed1a5f933 100644 --- a/common/src/main/res/values-in/strings.xml +++ b/common/src/main/res/values-in/strings.xml @@ -282,7 +282,7 @@ QR tidak dapat diterjemahkan Tidak dapat menemukan pengguna dari QR It\'s loading for a little longer this time - Liquid assets + Assets Tindakan ini akan mengakibatkan penghapusan akun dari perangkat ini. Pastikan Anda telah membuat cadangan frasa sandi Anda sebelum melanjutkan. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common/src/main/res/values-nb/strings.xml b/common/src/main/res/values-nb/strings.xml index 914223db1..87a2c3f46 100644 --- a/common/src/main/res/values-nb/strings.xml +++ b/common/src/main/res/values-nb/strings.xml @@ -283,7 +283,7 @@ QR kan ikke dekodes Finner ikke bruker fra QR It\'s loading for a little longer this time - Liquid assets + Assets Denne handlingen vil føre til at kontoen slettes fra denne enheten. Forsikre deg om at du har sikkerhetskopiert passordfrasen din før du fortsetter. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common/src/main/res/values-nl/strings.xml b/common/src/main/res/values-nl/strings.xml index f0f57a2fa..5db296637 100644 --- a/common/src/main/res/values-nl/strings.xml +++ b/common/src/main/res/values-nl/strings.xml @@ -283,7 +283,7 @@ QR kan niet worden gedecodeerd Kan geen gebruiker vinden via QR It\'s loading for a little longer this time - Liquid assets + Assets Deze actie zal resulteren in het verwijderen van een account van dit apparaat. Zorg ervoor dat u een back-up hebt gemaakt van uw passphrase voordat u verder gaat. \n\nAlle aangepaste noden worden ook verwijderd from the list you have written down diff --git a/common/src/main/res/values-pt/strings.xml b/common/src/main/res/values-pt/strings.xml index 6eb8378a1..a5193a41a 100644 --- a/common/src/main/res/values-pt/strings.xml +++ b/common/src/main/res/values-pt/strings.xml @@ -283,7 +283,7 @@ O código QR não pode ser descodificado Não foi encontrado um utilizador através do código QR It\'s loading for a little longer this time - Liquid assets + Assets Esta ação resultará na exclusão da sua conta deste dispositivo. Certifique-se de ter guardado a sua passphrase antes de continuar. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common/src/main/res/values-ru/strings.xml b/common/src/main/res/values-ru/strings.xml index 8159f082c..cf7a403b1 100644 --- a/common/src/main/res/values-ru/strings.xml +++ b/common/src/main/res/values-ru/strings.xml @@ -34,7 +34,7 @@ Внешний вид Хотите ли Вы использовать биометрию для входа в приложение? Asset ID - Liquid balance + Ликвидный баланс Recent activity Token price Your %s pools @@ -286,7 +286,7 @@ Не удается декодировать QR Не удается найти пользователя На этот раз загружается немного дольше - Ликвидные активы + Активы Это действие приведет к удалению учетной записи с этого устройства. Перед продолжением убедитесь, что вы создали резервную копию своей ключевой фразы. \n\nВсе добавленные ноды также будут удалены from the list you have written down diff --git a/common/src/main/res/values-tr/strings.xml b/common/src/main/res/values-tr/strings.xml index 66c46569f..dce40fc1f 100644 --- a/common/src/main/res/values-tr/strings.xml +++ b/common/src/main/res/values-tr/strings.xml @@ -283,7 +283,7 @@ QR kodu çözülemiyor QR\'dan bir kullanıcı bulunamadı It\'s loading for a little longer this time - Liquid assets + Assets Bu işlem, hesabın bu cihazdan silinmesine neden olur. Devam etmeden önce Anımsatıcı Dizi\'nizi yedeklediğinizden emin olun. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index d6b9584b5..053478765 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -283,7 +283,7 @@ QR can\'t be decoded Can\'t find a user from QR It\'s loading for a little longer this time - Liquid assets + Assets This action will result in deleting account from this device. Make sure you have backed up your passphrase before proceeding. \n\nAll your custom nodes will be removed as well from the list you have written down diff --git a/common_wallet/build.gradle b/common_wallet/build.gradle index c436f2b6a..151f0999c 100644 --- a/common_wallet/build.gradle +++ b/common_wallet/build.gradle @@ -73,7 +73,6 @@ dependencies { implementation uiCoreDep - implementation googlePlayCoreDep implementation coilSvgDep implementation webSocketLibDep @@ -91,8 +90,6 @@ dependencies { implementation datastoreDep - implementation gsonDep - implementation platform(googleFirebaseBomDep) implementation googleCrashlyticsDep diff --git a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/data/AssetLocalToAssetMapper.kt b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/data/AssetLocalToAssetMapper.kt index b0cbf7977..d542796bc 100644 --- a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/data/AssetLocalToAssetMapper.kt +++ b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/data/AssetLocalToAssetMapper.kt @@ -70,9 +70,8 @@ class AssetLocalToAssetMapper @Inject constructor( } @Throws(IllegalArgumentException::class) - suspend fun map(asset: AssetTokenWithFiatLocal): Asset { - val assetLocal = asset.assetLocal - requireNotNull(assetLocal) + suspend fun map(asset: AssetTokenWithFiatLocal): Asset? { + val assetLocal = asset.assetLocal ?: return null return Asset( token = map(TokenWithFiatLocal(asset.token, asset.price)), balance = BalanceWrapper.mapLocalBalance(assetLocal), diff --git a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/components/PoolsList.kt b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/components/PoolsList.kt index 4c07bc575..760ffe88f 100644 --- a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/components/PoolsList.kt +++ b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/components/PoolsList.kt @@ -32,6 +32,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package jp.co.soramitsu.common_wallet.presentation.compose.components +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -42,17 +43,16 @@ import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalLayoutDirection +import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.constraintlayout.compose.ConstraintLayout import jp.co.soramitsu.common.domain.DEFAULT_ICON_URI import jp.co.soramitsu.common.presentation.compose.TokenIcon +import jp.co.soramitsu.common.presentation.compose.components.TextWithDelimiter import jp.co.soramitsu.common.util.StringPair import jp.co.soramitsu.common_wallet.presentation.compose.states.PoolsListItemState import jp.co.soramitsu.common_wallet.presentation.compose.states.PoolsListState @@ -76,41 +76,40 @@ fun PoolsList( .padding(horizontal = Dimens.x3) .clickable { onPoolClick?.invoke(poolState.tokenIds) } ) { - CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) { - ConstraintLayout( - modifier = Modifier.wrapContentSize() - ) { - val (token1, token2) = createRefs() - TokenIcon( - uri = poolState.token1Icon, size = Size.Small, - modifier = Modifier - .constrainAs(token1) { - top.linkTo(parent.top) - start.linkTo(parent.start) - } - ) - TokenIcon( - uri = poolState.token2Icon, size = Size.Small, - modifier = Modifier - .constrainAs(token2) { - top.linkTo(parent.top) - start.linkTo(token1.start, margin = 24.dp) - } - ) - } + ConstraintLayout( + modifier = Modifier.wrapContentSize() + ) { + val (token1, token2) = createRefs() + TokenIcon( + uri = poolState.token1Icon, size = Size.Small, + modifier = Modifier + .constrainAs(token1) { + top.linkTo(parent.top) + start.linkTo(parent.start) + } + ) + TokenIcon( + uri = poolState.token2Icon, size = Size.Small, + modifier = Modifier + .constrainAs(token2) { + top.linkTo(parent.top) + start.linkTo(token1.start, margin = 24.dp) + } + ) } Column( modifier = Modifier .weight(1f) .padding(start = Dimens.x1, end = Dimens.x1) ) { - Text( + TextWithDelimiter( + text1 = poolState.poolToken1Symbol, + text2 = poolState.poolToken2Symbol, + delimiter = " - ", color = MaterialTheme.customColors.fgPrimary, - style = MaterialTheme.customTypography.textM, - text = poolState.poolName, - maxLines = 1, - overflow = TextOverflow.Ellipsis, + style = MaterialTheme.customTypography.textM ) + Text( color = MaterialTheme.customColors.fgSecondary, style = MaterialTheme.customTypography.textXSBold, @@ -144,7 +143,7 @@ fun PoolsList( @Composable @Preview private fun PreviewPoolsList() { - Column { + Column(Modifier.background(Color.White)) { PoolsList( onPoolClick = {}, cardState = PoolsListState( @@ -153,7 +152,8 @@ private fun PreviewPoolsList() { token1Icon = DEFAULT_ICON_URI, token2Icon = DEFAULT_ICON_URI, poolAmounts = "123.456", - poolName = "XOR - VAL", + poolToken1Symbol = "XOR", + poolToken2Symbol = "VAL", fiat = "$7908", fiatChange = "+23.1 %", tokenIds = "" to "", @@ -162,7 +162,8 @@ private fun PreviewPoolsList() { token1Icon = DEFAULT_ICON_URI, token2Icon = DEFAULT_ICON_URI, poolAmounts = "98.76", - poolName = "DAI - PSWAP", + poolToken1Symbol = "DAI", + poolToken2Symbol = "PSWAP", fiat = "$ 0.00123", fiatChange = "-9.88 %", tokenIds = "" to "", diff --git a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/PoolsListState.kt b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/PoolsListState.kt index d00379d69..ae55ae3fb 100644 --- a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/PoolsListState.kt +++ b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/PoolsListState.kt @@ -46,7 +46,8 @@ class PoolsListState( data class PoolsListItemState( val token1Icon: String, val token2Icon: String, - val poolName: String, + val poolToken1Symbol: String, + val poolToken2Symbol: String, val poolAmounts: String, val fiat: String, val fiatChange: String, @@ -62,11 +63,8 @@ fun mapPoolsData( val state = PoolsListState( poolsData.mapIndexed { i, poolData -> PoolsListItemState( - poolName = String.format( - "%s - %s", - poolData.basic.baseToken.symbol, - poolData.basic.targetToken.symbol, - ), + poolToken1Symbol = poolData.basic.baseToken.symbol, + poolToken2Symbol = poolData.basic.targetToken.symbol, poolAmounts = String.format( "%s - %s", poolData.basic.baseToken.printBalance( diff --git a/feature_account_impl/build.gradle b/feature_account_impl/build.gradle index f1c043bb4..f44710a21 100644 --- a/feature_account_impl/build.gradle +++ b/feature_account_impl/build.gradle @@ -60,8 +60,6 @@ dependencies { implementation xcryptoDep implementation xsubstrateDep - implementation gsonDep - implementation daggerDep kapt daggerKaptDep diff --git a/feature_assets_impl/build.gradle b/feature_assets_impl/build.gradle index 6de3bc414..83bcc8c58 100644 --- a/feature_assets_impl/build.gradle +++ b/feature_assets_impl/build.gradle @@ -107,8 +107,6 @@ dependencies { implementation hiltWorkManagerDep kapt hiltWorkManagerKaptDep - implementation gsonDep - implementation lifecycleProcessDep kapt lifecycleKaptDep diff --git a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/data/AssetsRepositoryImpl.kt b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/data/AssetsRepositoryImpl.kt index 53bbf77a8..f829db525 100644 --- a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/data/AssetsRepositoryImpl.kt +++ b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/data/AssetsRepositoryImpl.kt @@ -150,7 +150,7 @@ class AssetsRepositoryImpl @Inject constructor( override suspend fun getAssetsActive(address: String): List { val selectedCurrency = soraConfigManager.getSelectedCurrency() return db.assetDao().getAssetsActive(address, selectedCurrency.code) - .map { + .mapNotNull { assetLocalToAssetMapper.map(it) } } @@ -160,7 +160,7 @@ class AssetsRepositoryImpl @Inject constructor( val assetsLocal = db.assetDao().getAssetsWhitelist(address, selectedCurrency.code) insertAssetsInternal(address, assetsLocal, false) - return assetsLocal.map { + return assetsLocal.mapNotNull { assetLocalToAssetMapper.map(it) } } @@ -222,7 +222,7 @@ class AssetsRepositoryImpl @Inject constructor( override fun subscribeAssetsActive(address: String): Flow> = flow { val selectedCurrency = soraConfigManager.getSelectedCurrency() val f = db.assetDao().subscribeAssetsActive(address, selectedCurrency.code).map { - it.map { l -> assetLocalToAssetMapper.map(l) } + it.mapNotNull { l -> assetLocalToAssetMapper.map(l) } } emitAll(f) } @@ -230,7 +230,7 @@ class AssetsRepositoryImpl @Inject constructor( override fun subscribeAssetsFavorite(address: String): Flow> = flow { val selectedCurrency = soraConfigManager.getSelectedCurrency() val f = db.assetDao().subscribeAssetsFavorite(address, selectedCurrency.code).map { - it.map { l -> assetLocalToAssetMapper.map(l) } + it.mapNotNull { l -> assetLocalToAssetMapper.map(l) } } emitAll(f) } @@ -238,7 +238,7 @@ class AssetsRepositoryImpl @Inject constructor( override fun subscribeAssetsVisible(address: String): Flow> = flow { val selectedCurrency = soraConfigManager.getSelectedCurrency() val f = db.assetDao().subscribeAssetsVisible(address, selectedCurrency.code).map { - it.map { l -> assetLocalToAssetMapper.map(l) } + it.mapNotNull { l -> assetLocalToAssetMapper.map(l) } } emitAll(f) } diff --git a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsScreen.kt b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsScreen.kt index 828988ccb..01fdddccc 100644 --- a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsScreen.kt +++ b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsScreen.kt @@ -158,7 +158,8 @@ private fun PreviewAssetDetailsScreen01() { token1Icon = DEFAULT_ICON_URI, token2Icon = DEFAULT_ICON_URI, poolAmounts = "123.456", - poolName = "XOR - VAL", + poolToken1Symbol = "XOR", + poolToken2Symbol = "VAL", fiat = "$7908", fiatChange = "+23.1 %", tokenIds = "" to "", @@ -205,7 +206,8 @@ private fun PreviewAssetDetailsScreen02() { token1Icon = DEFAULT_ICON_URI, token2Icon = DEFAULT_ICON_URI, poolAmounts = "123.456", - poolName = "XOR - VAL", + poolToken1Symbol = "XOR", + poolToken2Symbol = "VAL", fiat = "$7908", fiatChange = "+23.1 %", tokenIds = "" to "", diff --git a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt index eac96bf70..d99f4e69e 100644 --- a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt +++ b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt @@ -168,7 +168,8 @@ class AssetDetailsViewModel @AssistedInject constructor( frozenBalance = if (assetId == SubstrateOptionsProvider.feeAssetId) { asset.token.printBalance(xorAssetBalance?.frozen ?: BigDecimal.ZERO, numbersFormatter, AssetHolder.ROUNDING) } else { null }, frozenBalanceFiat = if (assetId == SubstrateOptionsProvider.feeAssetId) { asset.token.printFiat(xorAssetBalance?.frozen ?: BigDecimal.ZERO, numbersFormatter) } else { null }, isTransferableBalanceAvailable = asset.balance.transferable > BigDecimal.ZERO, - buyCryptoAvailable = soraCard && (asset.token.id == SubstrateOptionsProvider.feeAssetId) + buyCryptoAvailable = false, +// buyCryptoAvailable = soraCard && (asset.token.id == SubstrateOptionsProvider.feeAssetId), ) ) } diff --git a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetlist/FullAssetListFragment.kt b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetlist/FullAssetListFragment.kt index de232de42..cdebe1fe3 100644 --- a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetlist/FullAssetListFragment.kt +++ b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetlist/FullAssetListFragment.kt @@ -71,6 +71,7 @@ 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.common.domain.CardHubType import jp.co.soramitsu.common_wallet.presentation.compose.components.AssetItem import jp.co.soramitsu.feature_assets_impl.presentation.components.compose.assetslist.CommonAssetsList import jp.co.soramitsu.ui_core.resources.Dimens @@ -120,7 +121,7 @@ class FullAssetListFragment : SoraBaseFragment() { ) { Text( modifier = Modifier.wrapContentSize(), - text = stringResource(id = R.string.liquid_assets), + text = stringResource(id = CardHubType.ASSETS.userName), style = MaterialTheme.customTypography.headline2, color = MaterialTheme.customColors.fgPrimary, ) diff --git a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetsettings/FullAssetSettingsFragment.kt b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetsettings/FullAssetSettingsFragment.kt index 0c2e0482b..f1d608396 100644 --- a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetsettings/FullAssetSettingsFragment.kt +++ b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/fullassetsettings/FullAssetSettingsFragment.kt @@ -60,6 +60,7 @@ 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.CardHubType import jp.co.soramitsu.common.presentation.view.WrappedRecyclerView import jp.co.soramitsu.common.view.CustomItemTouchHelperCallback import jp.co.soramitsu.common_wallet.R as polkaswapR @@ -109,7 +110,7 @@ class FullAssetSettingsFragment : SoraBaseFragment() ) { Text( modifier = Modifier, - text = stringResource(id = R.string.liquid_assets), + text = stringResource(id = CardHubType.ASSETS.userName), style = MaterialTheme.customTypography.headline2, color = MaterialTheme.customColors.fgPrimary, ) diff --git a/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventLiquidity.kt b/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventLiquidity.kt index d70934419..01b67e155 100644 --- a/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventLiquidity.kt +++ b/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventLiquidity.kt @@ -58,6 +58,7 @@ import androidx.constraintlayout.compose.ConstraintLayout import jp.co.soramitsu.common.R import jp.co.soramitsu.common.domain.DEFAULT_ICON_URI import jp.co.soramitsu.common.presentation.compose.TokenIcon +import jp.co.soramitsu.common.presentation.compose.components.TextWithDelimiter import jp.co.soramitsu.feature_blockexplorer_api.presentation.txhistory.EventUiModel import jp.co.soramitsu.feature_blockexplorer_api.presentation.txhistory.TransactionStatus import jp.co.soramitsu.ui_core.resources.Dimens @@ -123,14 +124,12 @@ internal fun EventLiquidity( maxLines = 1, overflow = TextOverflow.Ellipsis, ) - Text( - modifier = Modifier - .wrapContentSize(), - text = eventUiModel.tickers, - style = MaterialTheme.customTypography.textXSBold, - overflow = TextOverflow.Ellipsis, + TextWithDelimiter( + text1 = eventUiModel.ticker1, + text2 = eventUiModel.ticker2, + delimiter = " / ", color = MaterialTheme.customColors.fgSecondary, - maxLines = 1, + style = MaterialTheme.customTypography.textXSBold ) } Column( @@ -143,7 +142,25 @@ internal fun EventLiquidity( ) { Text( modifier = Modifier.wrapContentSize(), - text = eventUiModel.amounts, + text = eventUiModel.amount1, + textAlign = TextAlign.End, + overflow = TextOverflow.Ellipsis, + style = MaterialTheme.customTypography.textM, + color = if (eventUiModel.add) MaterialTheme.customColors.fgPrimary else MaterialTheme.customColors.statusSuccess, + maxLines = 1, + ) + Text( + modifier = Modifier.wrapContentSize(), + text = " / ", + textAlign = TextAlign.End, + overflow = TextOverflow.Ellipsis, + style = MaterialTheme.customTypography.textM, + color = if (eventUiModel.add) MaterialTheme.customColors.fgPrimary else MaterialTheme.customColors.statusSuccess, + maxLines = 1, + ) + Text( + modifier = Modifier.wrapContentSize(), + text = eventUiModel.amount2, textAlign = TextAlign.End, overflow = TextOverflow.Ellipsis, style = MaterialTheme.customTypography.textM, @@ -197,9 +214,11 @@ private val eventPreview = EventUiModel.EventTxUiModel.EventLiquidityAddUiModel( dateTime = "12.03.1998", icon1 = DEFAULT_ICON_URI, icon2 = DEFAULT_ICON_URI, - amounts = "199994857.134536 XOR / 12332453.2345345 DAI", + amount1 = "199994857.134536 XOR", + amount2 = "12332453.2345345 DAI", type = "Pool add", - tickers = "XOR / DAI", + ticker1 = "XOR", + ticker2 = "XOR", fiat = "$125235235235236", add = false, ) diff --git a/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventSwap.kt b/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventSwap.kt index 56570306e..7aa248903 100644 --- a/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventSwap.kt +++ b/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/screen/EventSwap.kt @@ -59,6 +59,7 @@ import androidx.constraintlayout.compose.ConstraintLayout import jp.co.soramitsu.common.R import jp.co.soramitsu.common.domain.DEFAULT_ICON_URI import jp.co.soramitsu.common.presentation.compose.TokenIcon +import jp.co.soramitsu.common.presentation.compose.components.TextWithDelimiter import jp.co.soramitsu.feature_blockexplorer_api.presentation.txhistory.EventUiModel import jp.co.soramitsu.feature_blockexplorer_api.presentation.txhistory.TransactionStatus import jp.co.soramitsu.ui_core.resources.Dimens @@ -123,14 +124,12 @@ internal fun EventSwap( overflow = TextOverflow.Ellipsis, ) - Text( - modifier = Modifier - .wrapContentSize(), - text = eventUiModel.tickers, - style = MaterialTheme.customTypography.textXSBold, - overflow = TextOverflow.Ellipsis, + TextWithDelimiter( + text1 = eventUiModel.tickerFrom, + text2 = eventUiModel.tickerTo, + delimiter = " -> ", color = MaterialTheme.customColors.fgSecondary, - maxLines = 1, + style = MaterialTheme.customTypography.textXSBold ) } Column( @@ -138,7 +137,9 @@ internal fun EventSwap( horizontalAlignment = Alignment.End, ) { Row( - modifier = Modifier.fillMaxWidth().wrapContentHeight(), + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.End, ) { @@ -197,7 +198,9 @@ internal fun EventSwap( private fun PreviewEventSwap() { EventSwap( eventUiModel = eventPreview, - modifier = Modifier.fillMaxWidth().wrapContentHeight(), + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight(), ) } @@ -207,7 +210,8 @@ private val eventPreview = EventUiModel.EventTxUiModel.EventLiquiditySwapUiModel iconTo = DEFAULT_ICON_URI, amountFrom = "12133123 XOR -> ", amountTo = "34879.987 DAI", - tickers = "XOR -> DAI", + tickerFrom = "XOR ", + tickerTo = "DAI", fiatTo = "$123.4", dateTime = "09.03.2001", timestamp = 1313123132, diff --git a/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/txhistory/SoraTransaction.kt b/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/txhistory/SoraTransaction.kt index 2145aa191..153cddd29 100644 --- a/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/txhistory/SoraTransaction.kt +++ b/feature_blockexplorer_api/src/main/java/jp/co/soramitsu/feature_blockexplorer_api/presentation/txhistory/SoraTransaction.kt @@ -97,7 +97,8 @@ sealed class EventUiModel { val iconTo: String, val amountFrom: String, val amountTo: String, - val tickers: String, + val tickerFrom: String, + val tickerTo: String, val fiatTo: String, val dateTime: String, timestamp: Long, @@ -111,9 +112,11 @@ sealed class EventUiModel { val dateTime: String, val icon1: String, val icon2: String, - val amounts: String, + val amount1: String, + val amount2: String, val type: String, - val tickers: String, + val ticker1: String, + val ticker2: String, val fiat: String, val add: Boolean, ) : EventTxUiModel(hash, timestamp, status) diff --git a/feature_blockexplorer_impl/src/main/java/jp/co/soramitsu/feature_blockexplorer_impl/presentation/txhistory/TransactionMappersImpl.kt b/feature_blockexplorer_impl/src/main/java/jp/co/soramitsu/feature_blockexplorer_impl/presentation/txhistory/TransactionMappersImpl.kt index 21da21b62..c2b394db1 100644 --- a/feature_blockexplorer_impl/src/main/java/jp/co/soramitsu/feature_blockexplorer_impl/presentation/txhistory/TransactionMappersImpl.kt +++ b/feature_blockexplorer_impl/src/main/java/jp/co/soramitsu/feature_blockexplorer_impl/presentation/txhistory/TransactionMappersImpl.kt @@ -65,12 +65,17 @@ class TransactionMappersImpl @Inject constructor( tokenUri = tx.token.iconUri(), ethTokenUri = tx.ethToken.iconUri(), dateTime = dateTimeFormatter.formatTimeWithoutSeconds(Date(tx.base.timestamp)), - amountFormatted = tx.token.printBalance(tx.amount, numbersFormatter, AssetHolder.ACTIVITY_LIST_ROUNDING), + amountFormatted = tx.token.printBalance( + tx.amount, + numbersFormatter, + AssetHolder.ACTIVITY_LIST_ROUNDING + ), fiatFormatted = "~%s".format(tx.token.printFiat(tx.amount, numbersFormatter)), requestHash = tx.requestHash, sidechainAddress = tx.sidechainAddress, ) } + is Transaction.Transfer -> { if (tx.transferType == TransactionTransferType.INCOMING) EventUiModel.EventTxUiModel.EventTransferInUiModel( @@ -104,6 +109,7 @@ class TransactionMappersImpl @Inject constructor( tx.base.status, ) } + is Transaction.Swap -> { EventUiModel.EventTxUiModel.EventLiquiditySwapUiModel( tx.base.txHash, @@ -121,18 +127,28 @@ class TransactionMappersImpl @Inject constructor( numbersFormatter, AssetHolder.ACTIVITY_LIST_ROUNDING ), - "%s -> %s".format( - tx.tokenFrom.symbol, - tx.tokenTo.symbol - ), + tx.tokenFrom.symbol, + tx.tokenTo.symbol, "", dateTimeFormatter.formatTimeWithoutSeconds(Date(tx.base.timestamp)), tx.base.timestamp, tx.base.status, ) } + is Transaction.Liquidity -> { val add = tx.type == TransactionLiquidityType.ADD + val sign = if (add) "" else "+" + val amount1 = + "$sign${ + tx.token1.printBalance( + tx.amount1, + numbersFormatter, + AssetHolder.ACTIVITY_LIST_ROUNDING + ) + }" + val amount2 = + "$sign${tx.token2.printBalance(tx.amount2, numbersFormatter, AssetHolder.ACTIVITY_LIST_ROUNDING)}" EventUiModel.EventTxUiModel.EventLiquidityAddUiModel( tx.base.txHash, tx.base.timestamp, @@ -140,29 +156,16 @@ class TransactionMappersImpl @Inject constructor( dateTimeFormatter.formatTimeWithoutSeconds(Date(tx.base.timestamp)), tx.token1.iconUri(), tx.token2.iconUri(), - "%s%s / %s%s".format( - if (add) "" else "+", - tx.token1.printBalance( - tx.amount1, - numbersFormatter, - AssetHolder.ACTIVITY_LIST_ROUNDING - ), - if (add) "" else "+", - tx.token2.printBalance( - tx.amount2, - numbersFormatter, - AssetHolder.ACTIVITY_LIST_ROUNDING - ) - ), + amount1, + amount2, resourceManager.getString(R.string.activity_pool_title), - "%s / %s".format( - tx.token1.symbol, - tx.token2.symbol, - ), + tx.token1.symbol, + tx.token2.symbol, "", add ) } + is Transaction.ReferralSetReferrer -> { EventUiModel.EventTxUiModel.EventReferralProgramUiModel( hash = tx.base.txHash, @@ -173,9 +176,15 @@ class TransactionMappersImpl @Inject constructor( plusAmount = false, tokenIcon = tx.token.iconUri(), dateTime = dateTimeFormatter.formatTimeWithoutSeconds(Date(tx.base.timestamp)), - amountFormatted = if (tx.myReferrer) "--" else "-1 ${resourceManager.getQuantityString(R.plurals.referral_invitations, 1)}", + amountFormatted = if (tx.myReferrer) "--" else "-1 ${ + resourceManager.getQuantityString( + R.plurals.referral_invitations, + 1 + ) + }", ) } + is Transaction.ReferralUnbond -> { EventUiModel.EventTxUiModel.EventReferralProgramUiModel( hash = tx.base.txHash, @@ -195,6 +204,7 @@ class TransactionMappersImpl @Inject constructor( ), ) } + is Transaction.ReferralBond -> { EventUiModel.EventTxUiModel.EventReferralProgramUiModel( hash = tx.base.txHash, diff --git a/feature_ecosystem_impl/build.gradle b/feature_ecosystem_impl/build.gradle index 8790e0be1..4605d33aa 100644 --- a/feature_ecosystem_impl/build.gradle +++ b/feature_ecosystem_impl/build.gradle @@ -99,8 +99,6 @@ dependencies { implementation hiltNavComposeDep kapt hiltWorkManagerKaptDep - implementation gsonDep - implementation lifecycleProcessDep kapt lifecycleKaptDep diff --git a/feature_ethereum_impl/build.gradle b/feature_ethereum_impl/build.gradle index a3731cdbe..74cfb3566 100644 --- a/feature_ethereum_impl/build.gradle +++ b/feature_ethereum_impl/build.gradle @@ -64,7 +64,6 @@ dependencies { implementation coroutineAndroidDep implementation coroutineDep implementation web3jDep - implementation gsonDep //implementation irohaDep diff --git a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/mappers/EthRegisterStateMapper.kt b/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/mappers/EthRegisterStateMapper.kt index 1754c922f..c8d91890e 100644 --- a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/mappers/EthRegisterStateMapper.kt +++ b/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/mappers/EthRegisterStateMapper.kt @@ -32,22 +32,4 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package jp.co.soramitsu.feature_ethereum_impl.data.mappers -import jp.co.soramitsu.feature_ethereum_api.domain.model.EthRegisterState -import jp.co.soramitsu.feature_ethereum_impl.data.network.response.EthRegisterStateResponse - -class EthRegisterStateMapper { - - fun map(ethRegisterState: EthRegisterStateResponse): EthRegisterState { - return with(ethRegisterState) { - EthRegisterState(mapEthRegisterState(state), null) - } - } - - private fun mapEthRegisterState(remoteState: EthRegisterStateResponse.State): EthRegisterState.State { - return when (remoteState) { - EthRegisterStateResponse.State.INPROGRESS -> EthRegisterState.State.IN_PROGRESS - EthRegisterStateResponse.State.COMPLETED -> EthRegisterState.State.REGISTERED - EthRegisterStateResponse.State.FAILED -> EthRegisterState.State.FAILED - } - } -} +class EthRegisterStateMapper diff --git a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/EthPublicKeyWithProof.kt b/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/EthPublicKeyWithProof.kt deleted file mode 100644 index d11a173d9..000000000 --- a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/EthPublicKeyWithProof.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.feature_ethereum_impl.data.network.model - -import com.google.gson.annotations.SerializedName - -data class EthPublicKeyWithProof( - @SerializedName("publicKey") val publicKey: String, - @SerializedName("signature") val keccakProof: KeccakProof -) diff --git a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/KeccakProof.kt b/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/KeccakProof.kt deleted file mode 100644 index c181c5a5d..000000000 --- a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/KeccakProof.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.feature_ethereum_impl.data.network.model - -import com.google.gson.annotations.SerializedName - -data class KeccakProof( - @SerializedName("v") val v: String, - @SerializedName("r") val r: String, - @SerializedName("s") val s: String -) diff --git a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/WithdrawalProof.kt b/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/WithdrawalProof.kt deleted file mode 100644 index bb0b29eca..000000000 --- a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/network/model/WithdrawalProof.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.feature_ethereum_impl.data.network.model - -import com.google.gson.annotations.SerializedName -import java.math.BigDecimal - -data class WithdrawalProof( - @SerializedName("id") val id: String, - @SerializedName("txTime") val txTime: Long, - @SerializedName("blockNum") val blockNum: Int, - @SerializedName("txIndex") val txIndex: Int, - @SerializedName("accountIdToNotify") val accountIdToNotify: String, - @SerializedName("tokenContractAddress") val tokenContractAddress: String, - @SerializedName("amount") val amount: BigDecimal, - @SerializedName("relay") val relay: String, - @SerializedName("irohaTxHash") val irohaTxHash: String, - @SerializedName("to") val to: String, - @SerializedName("proofs") val proofs: List -) diff --git a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/repository/EthereumRepositoryImpl.kt b/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/repository/EthereumRepositoryImpl.kt index bfcecad6f..d3d57f4f8 100644 --- a/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/repository/EthereumRepositoryImpl.kt +++ b/feature_ethereum_impl/src/main/java/jp/co/soramitsu/feature_ethereum_impl/data/repository/EthereumRepositoryImpl.kt @@ -45,14 +45,11 @@ import jp.co.soramitsu.feature_ethereum_api.domain.model.EthereumCredentials import jp.co.soramitsu.feature_ethereum_api.domain.model.Gas import jp.co.soramitsu.feature_ethereum_api.domain.model.GasEstimation import jp.co.soramitsu.feature_ethereum_impl.data.mappers.EthereumCredentialsMapper -import jp.co.soramitsu.feature_ethereum_impl.data.network.model.EthPublicKeyWithProof -import jp.co.soramitsu.feature_ethereum_impl.data.network.model.KeccakProof import jp.co.soramitsu.feature_ethereum_impl.data.repository.converter.EtherWeiConverter import jp.co.soramitsu.feature_ethereum_impl.util.ContractsApiProvider import jp.co.soramitsu.feature_ethereum_impl.util.Web3jBip32Crypto import jp.co.soramitsu.feature_ethereum_impl.util.Web3jProvider import jp.co.soramitsu.xcrypto.util.fromHex -import jp.co.soramitsu.xcrypto.util.toHexString import org.web3j.crypto.Sign import org.web3j.protocol.core.DefaultBlockParameterName import org.web3j.utils.Numeric @@ -209,16 +206,7 @@ class EthereumRepositoryImpl @Inject constructor( val dataToSign = prepareDataToSign(address) val signature = sign(dataToSign, privateKey) - val proof = EthPublicKeyWithProof( - publicKey.toString(), - KeccakProof( - signature.v.toString(charset("UTF-16")), - signature.r.toHexString(), - signature.s.toHexString() - ) - ) - - return proof.toString() + return "" } private fun sign(message: ByteArray, privateKey: BigInteger): Sign.SignatureData { diff --git a/feature_main_impl/build.gradle b/feature_main_impl/build.gradle index f0c15e8f5..b838234f9 100644 --- a/feature_main_impl/build.gradle +++ b/feature_main_impl/build.gradle @@ -105,9 +105,7 @@ dependencies { implementation composeLifecycleDep debugImplementation composeToolingDep implementation navigationComposeDep - //implementation accompanistNavAnimationDep - implementation gsonDep implementation webSocketLibDep implementation timberDep diff --git a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/MainActivity.kt b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/MainActivity.kt index c30d18203..f97d1a431 100644 --- a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/MainActivity.kt +++ b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/MainActivity.kt @@ -47,7 +47,6 @@ import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog import androidx.core.view.ViewCompat import androidx.core.view.isVisible -import androidx.lifecycle.lifecycleScope import androidx.navigation.NavController import androidx.navigation.findNavController import androidx.navigation.fragment.findNavController @@ -61,7 +60,6 @@ import javax.inject.Inject import jp.co.soramitsu.common.domain.BarsColorHandler import jp.co.soramitsu.common.domain.BottomBarController import jp.co.soramitsu.common.domain.DarkThemeManager -import jp.co.soramitsu.common.inappupdate.InAppUpdateManager import jp.co.soramitsu.common.presentation.view.ToolbarActivity import jp.co.soramitsu.common.util.DebounceClickHandler import jp.co.soramitsu.common.util.ext.attrColor @@ -72,20 +70,17 @@ import jp.co.soramitsu.feature_main_api.domain.model.PinCodeAction import jp.co.soramitsu.feature_main_api.launcher.MainRouter import jp.co.soramitsu.feature_main_impl.R import jp.co.soramitsu.feature_main_impl.databinding.ActivityMainBinding -import jp.co.soramitsu.feature_main_impl.presentation.inappupdate.FlexibleUpdateDialog import jp.co.soramitsu.feature_multiaccount_api.MultiaccountStarter import jp.co.soramitsu.feature_multiaccount_api.OnboardingNavigator import jp.co.soramitsu.feature_polkaswap_api.launcher.PolkaswapRouter import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider -import kotlinx.coroutines.launch @AndroidEntryPoint class MainActivity : ToolbarActivity(), BottomBarController, BarsColorHandler, - OnboardingNavigator, - InAppUpdateManager.UpdateManagerListener { + OnboardingNavigator { companion object { private const val ACTION_INVITE = "jp.co.soramitsu.feature_main_impl.ACTION_INVITE" @@ -145,8 +140,8 @@ class MainActivity : @Inject lateinit var mainRouter: MainRouter - @Inject - lateinit var inAppUpdateManager: InAppUpdateManager +// @Inject +// lateinit var inAppUpdateManager: InAppUpdateManager @Inject lateinit var polkaswapRouter: PolkaswapRouter @@ -170,30 +165,30 @@ class MainActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - lifecycleScope.launch { - inAppUpdateManager.start(this@MainActivity) - } - } - - override fun askUserToInstall() { - findNavController(R.id.fragmentNavHostMain) - .currentBackStackEntry?.savedStateHandle - ?.getLiveData(FlexibleUpdateDialog.UPDATE_REPLY)?.observe(this) { - if (it == true) inAppUpdateManager.startUpdateFlexible() - } - mainRouter.showFlexibleUpdateScreen() - } - - override fun readyToShowFlexible(): Int? { - return REQUEST_CODE_UPDATE +// lifecycleScope.launch { +// inAppUpdateManager.start(this@MainActivity) +// } } - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - if (requestCode == REQUEST_CODE_UPDATE) { - inAppUpdateManager.flexibleDesire(resultCode) - } - } +// override fun askUserToInstall() { +// findNavController(R.id.fragmentNavHostMain) +// .currentBackStackEntry?.savedStateHandle +// ?.getLiveData(FlexibleUpdateDialog.UPDATE_REPLY)?.observe(this) { +// if (it == true) inAppUpdateManager.startUpdateFlexible() +// } +// mainRouter.showFlexibleUpdateScreen() +// } + +// override fun readyToShowFlexible(): Int? { +// return REQUEST_CODE_UPDATE +// } + +// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { +// super.onActivityResult(requestCode, resultCode, data) +// if (requestCode == REQUEST_CODE_UPDATE) { +// inAppUpdateManager.flexibleDesire(resultCode) +// } +// } override fun initViews() { ViewCompat.setOnApplyWindowInsetsListener(binding.bottomNavigationView) { _, insets -> diff --git a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt index 6b5b006e9..a56692b2f 100644 --- a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt +++ b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt @@ -85,15 +85,15 @@ internal fun ProfileItems( icon = R.drawable.ic_buy_crypto, onClick = onSoraCardClick, ) - CategoryItem( - modifier = Modifier - .testTagAsId("BuyXor") - .padding(top = Dimens.x2), - title = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_title), - subtitle = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle), - icon = R.drawable.ic_settings_buy_crypto, - onClick = onBuyCrypto, - ) +// CategoryItem( +// modifier = Modifier +// .testTagAsId("BuyXor") +// .padding(top = Dimens.x2), +// title = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_title), +// subtitle = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle), +// icon = R.drawable.ic_settings_buy_crypto, +// onClick = onBuyCrypto, +// ) } CategoryItem( modifier = Modifier diff --git a/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsViewModel.kt b/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsViewModel.kt index 4c5155e18..499254ca7 100644 --- a/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsViewModel.kt +++ b/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsViewModel.kt @@ -428,8 +428,12 @@ class AccountDetailsViewModel @AssistedInject constructor( viewModelScope.launch { try { _accountDetailsScreenState.value?.let { + if (it.isBackupAvailable == false) { + backupService.getBackupAccounts() + } + if (backupService.isAccountBackedUp(address)) { - backupService.deleteBackupAccount(address) + _accountDetailsScreenState.value = it.copy(isBackupAvailable = true) } else { _createBackupPasswordState.value = CreateBackupPasswordState( password = InputTextState(label = resourceManager.getString(R.string.create_backup_set_password)), diff --git a/feature_polkaswap_api/src/main/java/jp/co/soramitsu/feature_polkaswap_api/domain/interfaces/PolkaswapSubscriptionRepository.kt b/feature_polkaswap_api/src/main/java/jp/co/soramitsu/feature_polkaswap_api/domain/interfaces/PolkaswapSubscriptionRepository.kt index 23bc55973..ee50a6c1e 100644 --- a/feature_polkaswap_api/src/main/java/jp/co/soramitsu/feature_polkaswap_api/domain/interfaces/PolkaswapSubscriptionRepository.kt +++ b/feature_polkaswap_api/src/main/java/jp/co/soramitsu/feature_polkaswap_api/domain/interfaces/PolkaswapSubscriptionRepository.kt @@ -42,6 +42,8 @@ import kotlinx.coroutines.flow.Flow interface PolkaswapSubscriptionRepository { + fun subscribeEachBlock(): Flow + suspend fun getRemotePoolReserves( tokenFrom: Token, tokenTo: Token, diff --git a/feature_polkaswap_impl/build.gradle b/feature_polkaswap_impl/build.gradle index eeb067f9c..ce46d44ca 100644 --- a/feature_polkaswap_impl/build.gradle +++ b/feature_polkaswap_impl/build.gradle @@ -104,8 +104,6 @@ dependencies { implementation hiltWorkManagerDep kapt hiltWorkManagerKaptDep - implementation gsonDep - implementation lifecycleProcessDep kapt lifecycleKaptDep diff --git a/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/data/repository/PolkaswapSubscriptionRepositoryImpl.kt b/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/data/repository/PolkaswapSubscriptionRepositoryImpl.kt index 3b15056a5..94ad9c532 100644 --- a/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/data/repository/PolkaswapSubscriptionRepositoryImpl.kt +++ b/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/data/repository/PolkaswapSubscriptionRepositoryImpl.kt @@ -82,6 +82,7 @@ import jp.co.soramitsu.xsubstrate.wsrpc.request.runtime.RuntimeRequest import jp.co.soramitsu.xsubstrate.wsrpc.request.runtime.storage.GetStorageRequest import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flow @@ -517,6 +518,14 @@ class PolkaswapSubscriptionRepositoryImpl @Inject constructor( } } + override fun subscribeEachBlock(): Flow = flow { + val key = runtimeManager.getRuntimeSnapshot().metadata + .module(Pallete.SYSTEM.palletName) + .storage(Storage.PARENT_HASH.storageName) + .storageKey() + emitAll(substrateCalls.observeStorage(key).debounce(5000)) + } + private suspend fun getReserveAccountOfPool( baseToken: String, targetToken: String, diff --git a/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/domain/SwapInteractorImpl.kt b/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/domain/SwapInteractorImpl.kt index 9eeba9a81..bcd834197 100644 --- a/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/domain/SwapInteractorImpl.kt +++ b/feature_polkaswap_impl/src/main/java/jp/co/soramitsu/feature_polkaswap_impl/domain/SwapInteractorImpl.kt @@ -54,11 +54,9 @@ import jp.co.soramitsu.feature_polkaswap_api.domain.interfaces.SwapInteractor import jp.co.soramitsu.feature_polkaswap_api.domain.model.SwapDetails import kotlin.math.max import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.flow @ExperimentalCoroutinesApi class SwapInteractorImpl( @@ -184,12 +182,7 @@ class SwapInteractorImpl( override fun observeSwap(): Flow = swapResult.observe() - override fun observePoolReserves(): Flow = flow { - while (true) { - emit("observePoolReserves") - delay(5000) - } - } + override fun observePoolReserves(): Flow = polkaswapSubscriptionRepository.subscribeEachBlock() // override fun observePoolReserves(): Flow { // return poolReservesFlowToken.asStateFlow().filterNotNull() diff --git a/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/RemoveNodeAlert.kt b/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/RemoveNodeAlert.kt index 1b43d5a42..0ad050a7a 100644 --- a/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/RemoveNodeAlert.kt +++ b/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/RemoveNodeAlert.kt @@ -48,9 +48,12 @@ fun RemoveNodeAlertDialog( onRemoveConfirmed: () -> Unit ) { AlertDialog( - backgroundColor = MaterialTheme.customColors.bgPage, + backgroundColor = MaterialTheme.customColors.bgSurfaceVariant, title = { - Text(text = stringResource(R.string.remove_node_title)) + Text( + color = MaterialTheme.customColors.fgPrimary, + text = stringResource(R.string.remove_node_title) + ) }, confirmButton = { TextButton( diff --git a/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/SwitchNodeAlert.kt b/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/SwitchNodeAlert.kt index 4cc5af2f1..8b3931049 100644 --- a/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/SwitchNodeAlert.kt +++ b/feature_select_node_impl/src/main/java/jp/co/soramitsu/feature_select_node_impl/presentation/select/ui/SwitchNodeAlert.kt @@ -47,12 +47,18 @@ fun SwitchNodeAlert( onSwitchConfirmed: () -> Unit ) { AlertDialog( - backgroundColor = MaterialTheme.customColors.bgPage, + backgroundColor = MaterialTheme.customColors.bgSurfaceVariant, title = { - Text(text = stringResource(R.string.select_node_switch_alert_title)) + Text( + color = MaterialTheme.customColors.fgPrimary, + text = stringResource(R.string.select_node_switch_alert_title) + ) }, text = { - Text(text = stringResource(R.string.select_node_switch_alert_description)) + Text( + color = MaterialTheme.customColors.fgPrimary, + text = stringResource(R.string.select_node_switch_alert_description) + ) }, confirmButton = { TextButton( diff --git a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/GetSoraCardViewModel.kt b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/GetSoraCardViewModel.kt index 87f1e5071..88448522f 100644 --- a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/GetSoraCardViewModel.kt +++ b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/GetSoraCardViewModel.kt @@ -132,18 +132,20 @@ class GetSoraCardViewModel @AssistedInject constructor( is SoraCardResult.Success -> { soraCardInteractor.setStatus(soraCardResult.status) + mainRouter.popBackStack() } is SoraCardResult.Failure -> { soraCardInteractor.setStatus(soraCardResult.status) + mainRouter.popBackStack() } is SoraCardResult.Canceled -> {} is SoraCardResult.Logout -> { soraCardInteractor.setLogout() + mainRouter.popBackStack() } } - mainRouter.popBackStack() } fun onEnableCard() { diff --git a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/ListTile.kt b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/ListTile.kt index 8786c2f40..9cf17a510 100644 --- a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/ListTile.kt +++ b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/ListTile.kt @@ -42,10 +42,8 @@ import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import jp.co.soramitsu.common.R import jp.co.soramitsu.common.presentation.compose.uikit.tokens.Image @@ -69,8 +67,8 @@ enum class ListTileFlag { data class ListTileState( val testTagId: String? = null, - private val variant: ListTileVariant, - private val flag: ListTileFlag, + val variant: ListTileVariant, + val flag: ListTileFlag, private val title: Text, private val subtitle: Text? = null, private val body: Text? = null, @@ -79,9 +77,6 @@ data class ListTileState( val titleText: Text = title - val paletteColor: Long = if (variant === ListTileVariant.TITLE_NAVIGATION_HINT && flag === ListTileFlag.WARNING) - 0xFFCB0F1F else 0xFF281818 - val isSubtitleVisible = variant === ListTileVariant.TITLE_SUBTITLE_BODY val subtitleText: Text? @@ -108,8 +103,10 @@ fun ListTileView( ) { // TODO Extract to UI lib - val colorInUse = remember(listTileState) { - Color(listTileState.paletteColor) + val colorInUse = if (listTileState.variant === ListTileVariant.TITLE_NAVIGATION_HINT && listTileState.flag === ListTileFlag.WARNING) { + MaterialTheme.customColors.statusError + } else { + MaterialTheme.customColors.fgPrimary } Row( diff --git a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsFragment.kt b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsFragment.kt index 66b65d60f..0d67d81de 100644 --- a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsFragment.kt +++ b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsFragment.kt @@ -102,11 +102,14 @@ class SoraCardDetailsFragment : SoraBaseFragment() { ) if (state.value.logoutDialog) { AlertDialog( - backgroundColor = MaterialTheme.customColors.bgPage, + backgroundColor = MaterialTheme.customColors.bgSurfaceVariant, onDismissRequest = viewModel::onLogoutDismiss, buttons = { Row( - Modifier.fillMaxWidth().wrapContentHeight().padding(Dimens.x1), + Modifier + .fillMaxWidth() + .wrapContentHeight() + .padding(Dimens.x1), horizontalArrangement = Arrangement.spacedBy(Dimens.x2), ) { TextButton( @@ -125,8 +128,18 @@ class SoraCardDetailsFragment : SoraBaseFragment() { ) } }, - title = { Text(text = stringResource(id = R.string.sora_card_option_logout)) }, - text = { Text(text = stringResource(id = R.string.sora_card_option_logout_description)) }, + title = { + Text( + color = MaterialTheme.customColors.fgPrimary, + text = stringResource(id = R.string.sora_card_option_logout) + ) + }, + text = { + Text( + color = MaterialTheme.customColors.fgPrimary, + text = stringResource(id = R.string.sora_card_option_logout_description) + ) + }, ) } } diff --git a/feature_wallet_impl/build.gradle b/feature_wallet_impl/build.gradle index c3388a673..834e4e211 100644 --- a/feature_wallet_impl/build.gradle +++ b/feature_wallet_impl/build.gradle @@ -113,8 +113,6 @@ dependencies { implementation hiltWorkManagerDep kapt hiltWorkManagerKaptDep - implementation gsonDep - implementation lifecycleProcessDep kapt lifecycleKaptDep diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryImpl.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryImpl.kt index 4ac02dce4..0ff2de8a3 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryImpl.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryImpl.kt @@ -129,7 +129,8 @@ class WalletRepositoryImpl @Inject constructor( val card = CardsHubMapper.map(cardLocal) when (card?.cardType) { CardHubType.GET_SORA_CARD -> if (soraCard) card else null - CardHubType.BUY_XOR_TOKEN -> if (soraCard) card else null +// CardHubType.BUY_XOR_TOKEN -> if (soraCard) card else null + CardHubType.BUY_XOR_TOKEN -> null else -> card } } diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt index 07294e527..01b3fc5de 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt @@ -134,6 +134,7 @@ class CardsHubViewModel @Inject constructor( soraCardInteractor.checkSoraCardPending() } } + viewModelScope.launch { cardsHubInteractorImpl .subscribeVisibleCardsHubList() @@ -177,7 +178,8 @@ class CardsHubViewModel @Inject constructor( kycStatus = mapped.first, loading = false, success = mapped.second, - ibanBalance = if (mapped.second) soraCardInteractor.fetchIbanBalance().getOrNull() else null, + ibanBalance = if (mapped.second) soraCardInteractor.fetchIbanBalance() + .getOrNull() else null, needUpdate = soraCardInteractor.needInstallUpdate(), ) } @@ -323,7 +325,7 @@ class CardsHubViewModel @Inject constructor( private fun mapAssetsCard(collapsed: Boolean, assets: List): CardState { return TitledAmountCardState( amount = formatFiatAmount(assets.fiatSum(), assets.fiatSymbol(), numbersFormatter), - title = R.string.liquid_assets, + title = CardHubType.ASSETS.userName, state = FavoriteAssetsCardState(mapAssetsToCardState(assets, numbersFormatter)), collapsedState = collapsed, onCollapseClick = { collapseCardToggle(CardHubType.ASSETS.hubName, !collapsed) }, @@ -335,7 +337,7 @@ class CardsHubViewModel @Inject constructor( val data = mapPoolsData(pools, numbersFormatter) return TitledAmountCardState( amount = formatFiatAmount(data.second, pools.fiatSymbol, numbersFormatter), - title = R.string.pooled_assets, + title = CardHubType.POOLS.userName, state = FavoritePoolsCardState( state = data.first ), @@ -359,6 +361,7 @@ class CardsHubViewModel @Inject constructor( is FavoriteAssetsCardState -> { router.showAssetSettings() } + is FavoritePoolsCardState -> { polkaswapRouter.showPoolSettings() } diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/editcardshub/EditCardsHubScreen.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/editcardshub/EditCardsHubScreen.kt index 6f50d17e3..f67d42e36 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/editcardshub/EditCardsHubScreen.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/editcardshub/EditCardsHubScreen.kt @@ -55,6 +55,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import jp.co.soramitsu.common.R +import jp.co.soramitsu.common.domain.CardHubType import jp.co.soramitsu.ui_core.component.card.ContentCard import jp.co.soramitsu.ui_core.resources.Dimens import jp.co.soramitsu.ui_core.theme.customColors @@ -196,14 +197,14 @@ private fun PreviewEditCardsHubScreen() { HubCardState( "a", HubCardVisibility.VISIBLE_AND_ENABLED, - R.string.common_buy_xor, + CardHubType.BUY_XOR_TOKEN.userName, ) ), disabledCards = listOf( HubCardState( "b", HubCardVisibility.NOT_VISIBLE_ENABLED, - R.string.liquid_assets, + CardHubType.ASSETS.userName, ) ), ), diff --git a/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryTest.kt b/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryTest.kt index 46da4dcf6..18574d456 100644 --- a/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryTest.kt +++ b/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/data/repository/WalletRepositoryTest.kt @@ -32,10 +32,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package jp.co.soramitsu.feature_wallet_impl.data.repository -import android.net.Uri import androidx.arch.core.executor.testing.InstantTaskExecutorRule import jp.co.soramitsu.common.domain.Asset -import jp.co.soramitsu.common.domain.AssetBalance import jp.co.soramitsu.common.domain.DEFAULT_ICON_URI import jp.co.soramitsu.common.domain.Token import jp.co.soramitsu.core_db.AppDatabase @@ -55,7 +53,6 @@ import jp.co.soramitsu.sora.substrate.substrate.ExtrinsicManager import jp.co.soramitsu.sora.substrate.substrate.SubstrateCalls import jp.co.soramitsu.test_data.TestAssets import jp.co.soramitsu.test_shared.MainCoroutineRule -import jp.co.soramitsu.test_shared.TestRuntimeProvider import jp.co.soramitsu.xnetworking.sorawallet.mainconfig.SoraCurrency import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf @@ -70,7 +67,6 @@ import org.mockito.BDDMockito.anyBoolean import org.mockito.BDDMockito.anyString import org.mockito.BDDMockito.given import org.mockito.Mock -import org.mockito.Mockito.mock import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnitRunner import org.mockito.kotlin.any @@ -109,13 +105,12 @@ class WalletRepositoryTest { private val mockedUri = DEFAULT_ICON_URI - private lateinit var runtime: RuntimeSnapshot + //private lateinit var runtime: RuntimeSnapshot private lateinit var walletRepository: WalletRepository @Before fun setUp() = runTest { - runtime = TestRuntimeProvider.buildRuntime("sora2") given(db.globalCardsHubDao()).willReturn(globalCardsHubDao) walletRepository = WalletRepositoryImpl( datasource, diff --git a/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/response/BaseResponse.kt b/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/response/BaseResponse.kt deleted file mode 100644 index a609d4fb2..000000000 --- a/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/response/BaseResponse.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.sora.substrate.response - -import com.google.gson.annotations.SerializedName - -data class BaseResponse( - @SerializedName("status") val status: StatusDto -) diff --git a/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/response/StatusDto.kt b/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/response/StatusDto.kt deleted file mode 100644 index ff6c76b37..000000000 --- a/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/response/StatusDto.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.sora.substrate.response - -import com.google.gson.annotations.SerializedName - -data class StatusDto( - @SerializedName("code") val code: String, - @SerializedName("message") val message: String -) diff --git a/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/runtime/SubstrateOptionsProvider.kt b/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/runtime/SubstrateOptionsProvider.kt index 06016c071..12c5ea1aa 100644 --- a/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/runtime/SubstrateOptionsProvider.kt +++ b/sorasubstrate/src/main/java/jp/co/soramitsu/sora/substrate/runtime/SubstrateOptionsProvider.kt @@ -146,6 +146,7 @@ enum class Storage(val storageName: String) { ASSET_INFOS("AssetInfos"), ACCOUNT("Account"), ACCOUNTS("Accounts"), + PARENT_HASH("ParentHash"), RESERVES("Reserves"), RESERVES_COLLATERAL("CollateralReserves"), LEDGER("Ledger"), diff --git a/sorasubstrate/src/test/java/jp/co/soramitsu/sora/substrate/SendIntegrationTest.kt b/sorasubstrate/src/test/java/jp/co/soramitsu/sora/substrate/SendIntegrationTest.kt deleted file mode 100644 index 756cc70f9..000000000 --- a/sorasubstrate/src/test/java/jp/co/soramitsu/sora/substrate/SendIntegrationTest.kt +++ /dev/null @@ -1,150 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.sora.substrate - -import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import com.google.gson.Gson -import com.neovisionaries.ws.client.WebSocketFactory -import jp.co.soramitsu.xsubstrate.runtime.definitions.types.fromByteArrayOrNull -import jp.co.soramitsu.xsubstrate.runtime.metadata.module -import jp.co.soramitsu.xsubstrate.runtime.metadata.storage -import jp.co.soramitsu.xsubstrate.runtime.metadata.storageKey -import jp.co.soramitsu.xsubstrate.ss58.SS58Encoder.toAccountId -import jp.co.soramitsu.xsubstrate.wsrpc.SocketService -import jp.co.soramitsu.xsubstrate.wsrpc.executeAsync -import jp.co.soramitsu.xsubstrate.wsrpc.logging.Logger -import jp.co.soramitsu.xsubstrate.wsrpc.mappers.nonNull -import jp.co.soramitsu.xsubstrate.wsrpc.mappers.pojo -import jp.co.soramitsu.xsubstrate.wsrpc.recovery.Reconnector -import jp.co.soramitsu.xsubstrate.wsrpc.request.RequestExecutor -import jp.co.soramitsu.xsubstrate.wsrpc.request.runtime.RuntimeRequest -import jp.co.soramitsu.sora.substrate.runtime.Constants -import jp.co.soramitsu.sora.substrate.runtime.Pallete -import jp.co.soramitsu.test_shared.TestRuntimeProvider -import jp.co.soramitsu.xcrypto.util.fromHex -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.junit.After -import org.junit.Assert.assertEquals -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.rules.TestRule -import org.junit.runner.RunWith -import org.mockito.junit.MockitoJUnitRunner -import java.math.BigInteger - -private const val MY_ADDRESS = "5GLphDhkjfuSuxmsCTxWsyUM7mJxRG2FVk5dgVArD857ZH5M" -private const val PUBLIC_KEY = "bd3be03f90f94cfa04890fc22e7d469cf3942e7233782c4079d8fab33ba16855" -private const val PRIVATE_KEY = "fef2663ea72d68472cb2938842424de0a6945418b5ef96f1f75594e666853521" -private const val TO_ADDRESS = "5CaY7JMUpN7uFad6ZzwMGnZGwrZ5XLthENtSm2BbfXXCvBur" - -private const val GENESIS = "f5ded4eac940310dd22ab394288c7598fa92a82c4e5a82f742e443856bab0072" -private const val URL = "wss://ws.framenode-1.s1.dev.sora2.soramitsu.co.jp" - -@ExperimentalCoroutinesApi -@ExperimentalUnsignedTypes -@Ignore("Manual run only") -@RunWith(MockitoJUnitRunner::class) -class SendIntegrationTest { - @Rule - @JvmField - val rule: TestRule = InstantTaskExecutorRule() - - private val gsonMapper = Gson() - private lateinit var socketService: SocketService - - @Before - fun setup() { - socketService = SocketService(gsonMapper, object : Logger { - override fun log(message: String?) { - println("socket log=$message") - } - - override fun log(throwable: Throwable?) { - println("socket log err=${throwable?.message}") - } - }, WebSocketFactory(), Reconnector(), RequestExecutor()) - - socketService.start(URL) - } - - @After - fun tearDown() { - socketService.stop() - } - - @Test - fun `check prefix byte`() { - val runtime = TestRuntimeProvider.buildRuntime("sora2") - val valueConstant = - runtime.metadata.module(Pallete.SYSTEM.palletName).constants[Constants.SS58Prefix.constantName] - val prefix = - (valueConstant?.type?.fromByteArrayOrNull( - runtime, - valueConstant.value - ) as? BigInteger)?.toInt() - ?: 69 - assertEquals(prefix, 42) - } - - @Test - fun `storage assets_assetInfos`() = runTest { - val runtime = TestRuntimeProvider.buildRuntime("sora2") - - val address = "5EcDoG4T1SLbop4bxBjLL9VJaaytZxGXA7mLaY9y84GYpzsR".toAccountId() - val toke = "0x0200040000000000000000000000000000000000000000000000000000000000".fromHex() - val storageKey = runtime.metadata.module("Assets").storage("AssetInfos").storageKey() - val storageKey123 = runtime.metadata.module("Assets").storage("AssetInfos").storageKey() - val stotoac = - runtime.metadata.module("Tokens").storage("Accounts").storageKey(runtime, address, toke) - val stora = runtime.metadata.module("Assets").storage("AssetInfos").type.value - val r = socketService.executeAsync( - request = RuntimeRequest( - "state_getStorage", - listOf( - stotoac - ) - ), - mapper = pojo().nonNull() - ) -// val qwe = stora?.fromHexOrNull(runtime, r[0].changes[0][1]!!) -// val ss = ((qwe as? List<*>)?.get(0) as? ByteArray)?.toString(Charsets.UTF_8) -// val sss = ((qwe as? List<*>)?.get(1) as? ByteArray)?.toString(Charsets.UTF_8) -// val free = r[AccountData.free] -// assertTrue(free == BigInteger.ONE) - } -} - -data class Qwwe(val block: String, val changes: List>) diff --git a/sorasubstrate/src/test/java/jp/co/soramitsu/sora/substrate/SubstrateApiTest.kt b/sorasubstrate/src/test/java/jp/co/soramitsu/sora/substrate/SubstrateApiTest.kt deleted file mode 100644 index b142c39e6..000000000 --- a/sorasubstrate/src/test/java/jp/co/soramitsu/sora/substrate/SubstrateApiTest.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.sora.substrate - -import jp.co.soramitsu.xsubstrate.runtime.RuntimeSnapshot -import jp.co.soramitsu.xsubstrate.wsrpc.SocketService -import jp.co.soramitsu.sora.substrate.runtime.RuntimeManager -import jp.co.soramitsu.sora.substrate.substrate.SubstrateApiImpl -import jp.co.soramitsu.test_shared.RealRuntimeProvider -import jp.co.soramitsu.xcrypto.util.fromHex -import kotlinx.coroutines.test.runTest -import org.junit.Assert.assertEquals -import org.junit.Before -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.junit.MockitoJUnitRunner -import org.mockito.kotlin.mock -import org.mockito.kotlin.whenever - -@RunWith(MockitoJUnitRunner::class) -class SubstrateApiTest { - - private val socket: SocketService = mock() - - private val runtimeManager: RuntimeManager = mock() - - private lateinit var api: SubstrateApiImpl - private lateinit var dev: RuntimeSnapshot - private lateinit var stage: RuntimeSnapshot - - private fun setUpApi() { - api = SubstrateApiImpl(socket, runtimeManager) - } - - @Before - fun before() { - dev = RealRuntimeProvider.buildRuntime(networkName = "sora2", suffix = "_dev") - stage = RealRuntimeProvider.buildRuntime(networkName = "sora2", suffix = "_soralution") - } - - @Test - @Ignore - fun `dev env subscribe getPoolReserveAccount`() = runTest { - //whenever(socket.executeAsync(request = any(), mapper = scale(PoolPropertiesResponse))).thenReturn() - whenever(runtimeManager.getRuntimeSnapshot()).thenReturn(dev) - setUpApi() - - val baseTokenId = "0x0200000000000000000000000000000000000000000000000000000000000000" - val tokenId = "0x0200050000000000000000000000000000000000000000000000000000000000" - val t = api.getPoolReserveAccount(baseTokenId, tokenId.fromHex()) - assertEquals(byteArrayOf(12, 12, 14), t) - } - - @Test - @Ignore - fun `soralution env subscribe getPoolReserveAccount`() = runTest { - whenever(runtimeManager.getRuntimeSnapshot()).thenReturn(stage) - setUpApi() - - val baseTokenId = "0x0200000000000000000000000000000000000000000000000000000000000000" - val tokenId = "0x0200050000000000000000000000000000000000000000000000000000000000" - val t = api.getPoolReserveAccount(baseTokenId, tokenId.fromHex()) - assertEquals(byteArrayOf(12, 12, 14), t) - } -} diff --git a/test_shared/build.gradle b/test_shared/build.gradle index d26d2c75a..81939055b 100644 --- a/test_shared/build.gradle +++ b/test_shared/build.gradle @@ -28,7 +28,6 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) api coroutineTestDep - api gsonDep api xsubstrateDep api jUnitDep diff --git a/test_shared/src/main/java/jp/co/soramitsu/test_shared/RealRuntimeProvider.kt b/test_shared/src/main/java/jp/co/soramitsu/test_shared/RealRuntimeProvider.kt deleted file mode 100644 index b4246739c..000000000 --- a/test_shared/src/main/java/jp/co/soramitsu/test_shared/RealRuntimeProvider.kt +++ /dev/null @@ -1,75 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.test_shared - -import com.google.gson.Gson -import com.google.gson.stream.JsonReader -import jp.co.soramitsu.xsubstrate.runtime.RuntimeSnapshot -import jp.co.soramitsu.xsubstrate.runtime.definitions.TypeDefinitionParser -import jp.co.soramitsu.xsubstrate.runtime.definitions.TypeDefinitionsTree -import jp.co.soramitsu.xsubstrate.runtime.definitions.dynamic.DynamicTypeResolver -import jp.co.soramitsu.xsubstrate.runtime.definitions.registry.TypeRegistry -import jp.co.soramitsu.xsubstrate.runtime.definitions.registry.v14Preset -import jp.co.soramitsu.xsubstrate.runtime.definitions.v14.TypesParserV14 -import jp.co.soramitsu.xsubstrate.runtime.metadata.RuntimeMetadataReader -import jp.co.soramitsu.xsubstrate.runtime.metadata.builder.VersionedRuntimeBuilder -import jp.co.soramitsu.xsubstrate.runtime.metadata.v14.RuntimeMetadataSchemaV14 - -object RealRuntimeProvider { - - fun buildRuntime(networkName: String, suffix: String = ""): RuntimeSnapshot { - val metadataRaw = buildRawMetadata(networkName, suffix) - val parseResult = TypesParserV14.parse( - lookup = metadataRaw.metadata[RuntimeMetadataSchemaV14.lookup], - typePreset = v14Preset() - ) - val nReader = JsonReader(getResourceReader("${networkName}$suffix.json")) - val nTree = - Gson().fromJson(nReader, TypeDefinitionsTree::class.java) - val networkParsed = TypeDefinitionParser.parseNetworkVersioning( - tree = nTree, - typePreset = parseResult.typePreset, - ) - val typeRegistry = TypeRegistry( - networkParsed.typePreset, - DynamicTypeResolver.defaultCompoundResolver() - ) - val metadata = VersionedRuntimeBuilder.buildMetadata(metadataRaw, typeRegistry) - return RuntimeSnapshot(typeRegistry, metadata) - } - - private fun buildRawMetadata(networkName: String, suffix: String = "") = - getFileContentFromResources("${networkName}_metadata$suffix").run { - RuntimeMetadataReader.read(this) - } -} diff --git a/test_shared/src/main/java/jp/co/soramitsu/test_shared/TestRuntimeProvider.kt b/test_shared/src/main/java/jp/co/soramitsu/test_shared/TestRuntimeProvider.kt deleted file mode 100644 index d3ab80db6..000000000 --- a/test_shared/src/main/java/jp/co/soramitsu/test_shared/TestRuntimeProvider.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.test_shared - -import com.google.gson.Gson -import com.google.gson.stream.JsonReader -import jp.co.soramitsu.xsubstrate.runtime.RuntimeSnapshot -import jp.co.soramitsu.xsubstrate.runtime.definitions.TypeDefinitionParser -import jp.co.soramitsu.xsubstrate.runtime.definitions.TypeDefinitionsTree -import jp.co.soramitsu.xsubstrate.runtime.definitions.dynamic.DynamicTypeResolver -import jp.co.soramitsu.xsubstrate.runtime.definitions.registry.TypeRegistry -import jp.co.soramitsu.xsubstrate.runtime.definitions.registry.v14Preset -import jp.co.soramitsu.xsubstrate.runtime.definitions.v14.TypesParserV14 -import jp.co.soramitsu.xsubstrate.runtime.metadata.RuntimeMetadataReader -import jp.co.soramitsu.xsubstrate.runtime.metadata.builder.VersionedRuntimeBuilder -import jp.co.soramitsu.xsubstrate.runtime.metadata.v14.RuntimeMetadataSchemaV14 - -object TestRuntimeProvider { - - fun buildRuntime(networkName: String): RuntimeSnapshot { - val runtimeMetadataReader = buildRawMetadata(networkName) - val typeRegistry = buildRegistry(networkName, runtimeMetadataReader) - - val metadata = VersionedRuntimeBuilder.buildMetadata(runtimeMetadataReader, typeRegistry) - - return RuntimeSnapshot(typeRegistry, metadata) - } - - private fun buildRawMetadata(networkName: String) = - getFileContentFromResources("${networkName}_metadata").run { - RuntimeMetadataReader.read(this) - } - - private fun buildRegistry( - networkName: String, - runtimeMetadataReader: RuntimeMetadataReader - ): TypeRegistry { - val gson = Gson() - val soraReader = JsonReader(getResourceReader("$networkName.json")) - - val soraTree = - gson.fromJson(soraReader, TypeDefinitionsTree::class.java) - - val networkParsed = TypeDefinitionParser.parseNetworkVersioning( - tree = soraTree, - typePreset = TypesParserV14.parse( - runtimeMetadataReader.metadata[RuntimeMetadataSchemaV14.lookup], - v14Preset() - ).typePreset, - currentRuntimeVersion = 1, - upto14 = false, - ) - - return TypeRegistry( - types = networkParsed.typePreset, - dynamicTypeResolver = DynamicTypeResolver.defaultCompoundResolver(), - ) - } -}