Skip to content

Commit

Permalink
Merge pull request #923 from soramitsu/staging
Browse files Browse the repository at this point in the history
staging
  • Loading branch information
PankraSerg authored May 25, 2023
2 parents c41fb2a + 7bfd112 commit bedec9d
Show file tree
Hide file tree
Showing 58 changed files with 639 additions and 306 deletions.
16 changes: 12 additions & 4 deletions app/src/main/java/jp/co/soramitsu/app/root/navigation/Navigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import jp.co.soramitsu.wallet.impl.presentation.balance.detail.BalanceDetailFrag
import jp.co.soramitsu.wallet.impl.presentation.balance.detail.frozen.FrozenAssetPayload
import jp.co.soramitsu.wallet.impl.presentation.balance.detail.frozen.FrozenTokensFragment
import jp.co.soramitsu.wallet.impl.presentation.balance.optionswallet.OptionsWalletFragment
import jp.co.soramitsu.wallet.impl.presentation.balance.walletselector.light.WalletSelectionMode
import jp.co.soramitsu.wallet.impl.presentation.balance.walletselector.light.WalletSelectorFragment
import jp.co.soramitsu.wallet.impl.presentation.beacon.main.BeaconFragment
import jp.co.soramitsu.wallet.impl.presentation.beacon.main.DAppMetadataModel
Expand Down Expand Up @@ -367,8 +368,15 @@ class Navigator :
navController?.navigate(R.id.walletSelectorFragment, WalletSelectorFragment.buildArguments(tag))
}

override fun openWalletSelectorForResult(): Flow<Long> {
val bundle = WalletSelectorFragment.buildArguments(tag = "")
override fun openWalletSelectorForResult(
selectedWalletId: Long?,
walletSelectionMode: WalletSelectionMode
): Flow<Long> {
val bundle = WalletSelectorFragment.buildArguments(
tag = "",
selectedWalletId = selectedWalletId,
walletSelectionMode = walletSelectionMode
)
return openWithResult(
destinationId = R.id.walletSelectorFragment,
bundle = bundle,
Expand Down Expand Up @@ -700,13 +708,13 @@ class Navigator :
override fun openSelectChainForXcm(
selectedChainId: ChainId?,
xcmChainType: XcmChainType,
selectedOriginalChainId: String?,
selectedOriginChainId: String?,
xcmAssetSymbol: String?
) {
val bundle = ChainSelectFragment.getBundleForXcmChains(
selectedChainId = selectedChainId,
xcmChainType = xcmChainType,
xcmSelectedOriginalChainId = selectedOriginalChainId,
xcmSelectedOriginChainId = selectedOriginChainId,
xcmAssetSymbol = xcmAssetSymbol
)
navController?.navigate(R.id.chainSelectFragment, bundle)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apply from: './scripts/secrets.gradle'
buildscript {
ext {
// App version
versionName = '2.2.3'
versionCode = 92
versionName = '2.2.4'
versionCode = 93

// SDK and tools
compileSdkVersion = 33
Expand Down Expand Up @@ -84,7 +84,7 @@ buildscript {
minifyRelease = true
beaconVersion = "3.2.4"

sharedFeaturesVersion = "0.0.24"
sharedFeaturesVersion = "0.0.26_snapshot2"

coilDep = "io.coil-kt:coil:$coilVersion"
coilSvg = "io.coil-kt:coil-svg:$coilVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ fun ActionBar(
) {
Row(Modifier.padding(vertical = 4.dp)) {
state.actionItems.forEachIndexed { index, actionItem ->
val itemClickHandler = remember { { onItemClick(actionItem, state.chainId, state.chainAssetId) } }
val itemClickHandler = remember(actionItem, state.chainId, state.chainAssetId) {
{ onItemClick(actionItem, state.chainId, state.chainAssetId) }
}
val icon = painterResource(id = actionItem.iconId)
val title = stringResource(id = actionItem.titleId)
val actionViewState = remember {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material.Card
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
Expand All @@ -26,16 +27,19 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.valentinilk.shimmer.shimmer
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.compose.theme.FearlessTheme
import jp.co.soramitsu.common.compose.theme.alertYellow
import jp.co.soramitsu.common.compose.theme.bold
import jp.co.soramitsu.common.compose.theme.customColors
import jp.co.soramitsu.common.compose.theme.customTypography
import jp.co.soramitsu.common.compose.theme.white16
import jp.co.soramitsu.common.compose.theme.white64
import jp.co.soramitsu.common.compose.viewstate.AssetListItemShimmerViewState
import jp.co.soramitsu.common.compose.viewstate.AssetListItemViewState

Expand Down Expand Up @@ -88,13 +92,19 @@ fun AssetListItem(
.padding(vertical = 8.dp)
.align(CenterVertically)
) {
Text(
text = state.assetName.uppercase(),
style = MaterialTheme.customTypography.capsTitle2,
modifier = Modifier
.alpha(0.64f)
.testTag("AssetListItem_${state.assetSymbol}_chain_name")
)
Row {
Text(
text = state.assetName.uppercase(),
style = MaterialTheme.customTypography.capsTitle2,
modifier = Modifier
.alpha(0.64f)
.testTag("AssetListItem_${state.assetSymbol}_chain_name")
)
if (state.isTestnet) {
MarginHorizontal(margin = 4.dp)
TestnetBadge()
}
}
Text(
text = state.displayName.uppercase(),
style = MaterialTheme.customTypography.header3,
Expand Down Expand Up @@ -184,6 +194,31 @@ fun AssetListItem(
}
}

@Composable
fun TestnetBadge() {
Card(backgroundColor = white16) {
Row(
modifier = Modifier
.padding(bottom = 2.dp, start = 2.dp, end = 4.dp),
verticalAlignment = CenterVertically
) {
Icon(
modifier = Modifier
.width(16.dp)
.padding(top = 1.dp),
painter = painterResource(R.drawable.ic_token_testnet),
tint = white64,
contentDescription = null
)
MarginHorizontal(margin = 4.dp)
Text(
text = stringResource(id = R.string.label_testnet).uppercase(),
style = MaterialTheme.customTypography.body3.bold().copy(color = white64)
)
}
}
}

@Composable
fun AssetListItemShimmer(
state: AssetListItemShimmerViewState,
Expand Down Expand Up @@ -324,13 +359,14 @@ private fun PreviewAssetListItem() {
hasAccount = true,
priceId = null,
hasNetworkIssue = false,
ecosystem = "Polkadot"
ecosystem = "Polkadot",
isTestnet = false
)
FearlessTheme {
Box(modifier = Modifier.background(Color.Black)) {
Column {
AssetListItem(state) {}
AssetListItem(state.copy(hasAccount = false)) {}
AssetListItem(state.copy(hasAccount = false, isTestnet = true)) {}
AssetListItemShimmer(
state = AssetListItemShimmerViewState(assetIconUrl, assetChainUrlsMap.values.toList())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ fun AssetSelector(
fun Badge(text: String, modifier: Modifier = Modifier) {
Row(modifier = modifier.background(color = white16, shape = RoundedCornerShape(size = 3.dp))) {
MarginHorizontal(margin = 6.dp)
Text(
text = text.uppercase(),
style = MaterialTheme.customTypography.capsTitle2
)
H6(text = text)
MarginHorizontal(margin = 6.dp)
}
}
Expand All @@ -132,7 +129,7 @@ fun Badge(
modifier = Modifier.size(16.dp)
)
MarginHorizontal(margin = 4.dp)
CapsTitle(text = stringResource(id = labelResId))
H6(text = stringResource(id = labelResId))
}
}

Expand All @@ -158,7 +155,7 @@ fun Badge(
)
}
MarginHorizontal(margin = 4.dp)
CapsTitle(text = stringResource(id = labelResId))
H6(text = stringResource(id = labelResId))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,14 @@ fun FullScreenLoading(
.border(4.dp, white08, shape = CircleShape)
.background(transparent, shape = CircleShape)
)
Box(
CircularProgressIndicator(
modifier = Modifier
.fillMaxSize()
.blur(1.dp)
.padding(8.dp)
) {
CircularProgressIndicator(
modifier = Modifier
.fillMaxSize()
.align(Alignment.Center),
color = colorAccentDark,
strokeWidth = 4.dp
)
}
.align(Alignment.Center),
color = colorAccentDark,
strokeWidth = 4.dp
)
Image(
res = R.drawable.ic_fearless_logo,
tint = colorAccentDark,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ private fun AssetItemSwipeBoxPreview() {
hasAccount = true,
priceId = null,
hasNetworkIssue = false,
ecosystem = "Polkadot"
ecosystem = "Polkadot",
isTestnet = false
)

Column(modifier = Modifier.padding(horizontal = 16.dp)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ data class AssetListItemViewState(
val hasAccount: Boolean,
val priceId: String?,
val hasNetworkIssue: Boolean,
val ecosystem: String?
val ecosystem: String?,
val isTestnet: Boolean
) {
val key = listOf(ecosystem, chainAssetId, chainId, isHidden).joinToString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import jp.co.soramitsu.common.validation.ValidationExecutor
import jp.co.soramitsu.common.vibration.DeviceVibrator
import jp.co.soramitsu.core.extrinsic.ExtrinsicBuilderFactory
import jp.co.soramitsu.core.extrinsic.ExtrinsicService
import jp.co.soramitsu.core.extrinsic.KeyPairProvider
import jp.co.soramitsu.core.extrinsic.keypair_provider.KeypairProvider
import jp.co.soramitsu.core.rpc.RpcCalls
import jp.co.soramitsu.shared_utils.encrypt.Signer
import jp.co.soramitsu.shared_utils.icon.IconGenerator
Expand Down Expand Up @@ -74,12 +74,12 @@ class CommonModule {
@Provides
fun provideExtrinsicService(
rpcCalls: RpcCalls,
keyPairProvider: KeyPairProvider,
keypairProvider: KeypairProvider,
extrinsicBuilderFactory: ExtrinsicBuilderFactory
): ExtrinsicService {
return ExtrinsicService(
rpcCalls = rpcCalls,
keyPairProvider = keyPairProvider,
keypairProvider = keypairProvider,
extrinsicBuilderFactory = extrinsicBuilderFactory
)
}
Expand Down
3 changes: 0 additions & 3 deletions common/src/main/res/drawable/ic_token_testnet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
android:viewportWidth="16"
android:viewportHeight="11">
<path
android:fillAlpha="0.64"
android:fillColor="#ffffff"
android:fillType="evenOdd"
android:pathData="M13.0009,5.4985L10.5314,3.0289L11.592,1.9683L15.1221,5.4985L11.592,9.0286L10.5314,7.968L13.0009,5.4985Z" />
<path
android:fillAlpha="0.64"
android:fillColor="#ffffff"
android:fillType="evenOdd"
android:pathData="M3.0037,5.4984L5.4733,7.968L4.4127,9.0286L0.8825,5.4984L4.4127,1.9683L5.4733,3.0289L3.0037,5.4984Z" />
<path
android:fillAlpha="0.64"
android:fillColor="#ffffff"
android:pathData="M9.0266,0.24l1.5662,0.57l-3.6221,9.9517l-1.5662,-0.57z" />
</vector>
4 changes: 3 additions & 1 deletion core-db/src/main/java/jp/co/soramitsu/coredb/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import jp.co.soramitsu.coredb.migrations.Migration_50_51
import jp.co.soramitsu.coredb.migrations.Migration_51_52
import jp.co.soramitsu.coredb.migrations.Migration_52_53
import jp.co.soramitsu.coredb.migrations.Migration_53_54
import jp.co.soramitsu.coredb.migrations.Migration_54_55
import jp.co.soramitsu.coredb.migrations.RemoveAccountForeignKeyFromAsset_17_18
import jp.co.soramitsu.coredb.migrations.RemoveLegacyData_35_36
import jp.co.soramitsu.coredb.migrations.RemoveStakingRewardsTable_22_23
Expand All @@ -81,7 +82,7 @@ import jp.co.soramitsu.coredb.model.chain.ChainTypesLocal
import jp.co.soramitsu.coredb.model.chain.MetaAccountLocal

@Database(
version = 54,
version = 55,
entities = [
AccountLocal::class,
AddressBookContact::class,
Expand Down Expand Up @@ -155,6 +156,7 @@ abstract class AppDatabase : RoomDatabase() {
.addMigrations(Migration_51_52)
.addMigrations(Migration_52_53)
.addMigrations(Migration_53_54)
.addMigrations(Migration_54_55)
.build()
}
return instance!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ package jp.co.soramitsu.coredb.migrations
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase

val Migration_54_55 = object : Migration(54, 55) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("DROP TABLE IF EXISTS `_address_book`")
database.execSQL("CREATE TABLE `_address_book` AS SELECT * FROM `address_book`")
database.execSQL("DELETE FROM `address_book` where `id` NOT IN (SELECT `id` FROM `_address_book` GROUP BY `address`, `chainId`)")
database.execSQL("DROP TABLE IF EXISTS `_address_book`")

database.execSQL(
"""
CREATE UNIQUE INDEX IF NOT EXISTS `index_address_book_address_chainId` ON `address_book` (`address`, `chainId`)
""".trimIndent()
)
}
}

val Migration_53_54 = object : Migration(53, 54) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("DROP TABLE IF EXISTS _chains")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package jp.co.soramitsu.coredb.model

import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey

@Entity(tableName = "address_book")
@Entity(
tableName = "address_book",
indices = [Index(value = ["address", "chainId"], unique = true)]
)
data class AddressBookContact(
val address: String,
val name: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import jp.co.soramitsu.account.api.domain.model.cryptoType
import jp.co.soramitsu.common.data.secrets.v2.SecretStoreV2
import jp.co.soramitsu.common.data.secrets.v2.getChainAccountKeypair
import jp.co.soramitsu.common.data.secrets.v2.getMetaAccountKeypair
import jp.co.soramitsu.core.extrinsic.KeyPairProvider
import jp.co.soramitsu.core.extrinsic.keypair_provider.KeypairProvider
import jp.co.soramitsu.core.models.CryptoType
import jp.co.soramitsu.core.models.IChain
import jp.co.soramitsu.shared_utils.encrypt.keypair.Keypair
Expand All @@ -15,7 +15,7 @@ import jp.co.soramitsu.shared_utils.extensions.toHexString
class KeyPairRepository(
private val secretStoreV2: SecretStoreV2,
private val accountRepository: AccountRepository
) : KeyPairProvider {
) : KeypairProvider {

override suspend fun getCryptoTypeFor(chain: IChain, accountId: ByteArray): CryptoType {
val metaAccount = accountRepository.findMetaAccount(accountId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import jp.co.soramitsu.common.interfaces.FileProvider
import jp.co.soramitsu.common.resources.ClipboardManager
import jp.co.soramitsu.common.resources.LanguagesHolder
import jp.co.soramitsu.common.resources.ResourceManager
import jp.co.soramitsu.core.extrinsic.KeyPairProvider
import jp.co.soramitsu.core.extrinsic.keypair_provider.KeypairProvider
import jp.co.soramitsu.coredb.dao.AccountDao
import jp.co.soramitsu.coredb.dao.AssetDao
import jp.co.soramitsu.coredb.dao.MetaAccountDao
Expand Down Expand Up @@ -96,7 +96,7 @@ class AccountFeatureModule {
fun provideKeyPairRepository(
secretStoreV2: SecretStoreV2,
accountRepository: AccountRepository
): KeyPairProvider {
): KeypairProvider {
return KeyPairRepository(secretStoreV2, accountRepository)
}

Expand Down
Loading

0 comments on commit bedec9d

Please sign in to comment.