Skip to content

Commit 89559ac

Browse files
authored
Merge pull request #1149 from soramitsu/staging
staging
2 parents f20e08e + 831f446 commit 89559ac

File tree

61 files changed

+639
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+639
-274
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ apply plugin: "org.sonarqube"
55
buildscript {
66
ext {
77
// App version
8-
versionName = '3.4.3'
9-
versionCode = 168
8+
versionName = '3.4.4'
9+
versionCode = 172
1010

1111
// SDK and tools
1212
compileSdkVersion = 34
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package jp.co.soramitsu.core.model
22

3-
class StorageEntry(
3+
data class StorageEntry(
44
val storageKey: String,
55
val content: String?
66
)

core-api/src/main/java/jp/co/soramitsu/core/updater/Updater.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ interface UpdateScope {
1818
fun invalidationFlow(): Flow<Any>
1919
}
2020

21-
object GlobalScope : UpdateScope {
21+
object GlobalUpdaterScope : UpdateScope {
2222

2323
override fun invalidationFlow() = flowOf(Unit)
2424
}
2525

2626
interface GlobalScopeUpdater : Updater {
2727

2828
override val scope
29-
get() = GlobalScope
29+
get() = GlobalUpdaterScope
3030
}
3131

3232
interface Updater : SideEffectScope {

core-db/src/main/java/jp/co/soramitsu/coredb/AppDatabase.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import jp.co.soramitsu.coredb.migrations.Migration_59_60
6666
import jp.co.soramitsu.coredb.migrations.Migration_60_61
6767
import jp.co.soramitsu.coredb.migrations.Migration_61_62
6868
import jp.co.soramitsu.coredb.migrations.Migration_62_63
69+
import jp.co.soramitsu.coredb.migrations.Migration_63_64
6970
import jp.co.soramitsu.coredb.migrations.RemoveAccountForeignKeyFromAsset_17_18
7071
import jp.co.soramitsu.coredb.migrations.RemoveLegacyData_35_36
7172
import jp.co.soramitsu.coredb.migrations.RemoveStakingRewardsTable_22_23
@@ -91,7 +92,7 @@ import jp.co.soramitsu.coredb.model.chain.FavoriteChainLocal
9192
import jp.co.soramitsu.coredb.model.chain.MetaAccountLocal
9293

9394
@Database(
94-
version = 63,
95+
version = 64,
9596
entities = [
9697
AccountLocal::class,
9798
AddressBookContact::class,
@@ -175,6 +176,7 @@ abstract class AppDatabase : RoomDatabase() {
175176
.addMigrations(Migration_60_61)
176177
.addMigrations(Migration_61_62)
177178
.addMigrations(Migration_62_63)
179+
.addMigrations(Migration_63_64)
178180
.build()
179181
}
180182
return instance!!

core-db/src/main/java/jp/co/soramitsu/coredb/migrations/Migrations.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ package jp.co.soramitsu.coredb.migrations
33
import androidx.room.migration.Migration
44
import androidx.sqlite.db.SupportSQLiteDatabase
55

6+
val Migration_63_64 = object : Migration(63, 64) {
7+
override fun migrate(db: SupportSQLiteDatabase) {
8+
db.execSQL("ALTER TABLE chains ADD COLUMN `isUsesAppId` INTEGER NOT NULL DEFAULT 0")
9+
}
10+
}
11+
612
val Migration_62_63 = object : Migration(62, 63) {
713
override fun migrate(db: SupportSQLiteDatabase) {
814
db.execSQL("ALTER TABLE assets ADD COLUMN `status` TEXT NULL")

core-db/src/main/java/jp/co/soramitsu/coredb/model/chain/ChainLocal.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class ChainLocal(
2222
val supportStakingPool: Boolean,
2323
val isEthereumChain: Boolean,
2424
val isChainlinkProvider: Boolean,
25-
val supportNft: Boolean
25+
val supportNft: Boolean,
26+
val isUsesAppId: Boolean
2627
) {
2728

2829
class ExternalApi(

feature-crowdloan-impl/src/main/java/jp/co/soramitsu/crowdloan/impl/domain/contribute/CrowdloanContributeInteractor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class CrowdloanContributeInteractor(
139139
}
140140

141141
return runCatching {
142-
walletRepository.performTransfer(accountId, chain, transfer, fee, null, additional, batchAll)
142+
walletRepository.performTransfer(accountId, chain, transfer, fee, null, null, additional, batchAll)
143143
}
144144
}
145145

feature-staking-api/src/main/java/jp/co/soramitsu/staking/api/data/StakingSharedState.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class StakingSharedState(
8585
val assetWithChain: Flow<SingleAssetSharedState.AssetWithChain> = selectionItem.map {
8686
val (chain, asset) = chainRegistry.chainWithAsset(it.chainId, it.chainAssetId)
8787
SingleAssetSharedState.AssetWithChain(chain, asset)
88-
}.shareIn(scope, SharingStarted.Eagerly, replay = 1)
88+
}
89+
.distinctUntilChanged()
90+
.shareIn(scope, SharingStarted.Eagerly, replay = 1)
8991

9092
suspend fun assetWithChain(selectionItem: StakingAssetSelection) {
9193
val (chain, asset) = chainRegistry.chainWithAsset(
@@ -112,7 +114,7 @@ class StakingSharedState(
112114
chainAsset = chainAsset,
113115
minSupportedVersion = chain.minSupportedVersion
114116
)
115-
}.shareIn(scope, SharingStarted.Eagerly, replay = 1)
117+
}.distinctUntilChanged().shareIn(scope, SharingStarted.Eagerly, replay = 1)
116118

117119
suspend fun availableAssetsToSelect(): List<Asset> {
118120
val metaAccount = accountRepository.getSelectedMetaAccount()

feature-staking-api/src/main/java/jp/co/soramitsu/staking/api/domain/model/Exposure.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ package jp.co.soramitsu.staking.api.domain.model
22

33
import java.math.BigInteger
44

5-
class IndividualExposure(val who: ByteArray, val value: BigInteger)
5+
interface ValidatorExposure {
6+
val nominatorCount: Int
7+
val total: BigInteger
8+
val own: BigInteger
9+
}
610

7-
class Exposure(val total: BigInteger, val own: BigInteger, val others: List<IndividualExposure>)
11+
class LegacyExposure(
12+
override val total: BigInteger, override val own: BigInteger, val others: List<IndividualExposure>
13+
): ValidatorExposure{
14+
override val nominatorCount: Int = others.size
15+
}
16+
17+
class Exposure(override val total: BigInteger, override val own: BigInteger, override val nominatorCount: Int, val pageCount: BigInteger): ValidatorExposure
18+
data class ExposurePage(val pageTotal: BigInteger, val others: List<IndividualExposure>)
19+
20+
class IndividualExposure(val who: ByteArray, val value: BigInteger)

feature-staking-api/src/main/java/jp/co/soramitsu/staking/api/domain/model/Validator.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,20 @@ class RootIdentity(
2727
override val pgpFingerprint: String?,
2828
override val image: String?,
2929
override val twitter: String?
30-
) : Identity
30+
) : Identity {
31+
companion object {
32+
fun empty() = RootIdentity(
33+
display = null,
34+
legal = null,
35+
web = null,
36+
riot = null,
37+
email = null,
38+
pgpFingerprint = null,
39+
image = null,
40+
twitter = null
41+
)
42+
}
43+
}
3144

3245
class ChildIdentity(
3346
childName: String?,
@@ -37,7 +50,7 @@ class ChildIdentity(
3750
override val display: String = "${parentIdentity.display} / ${childName.orEmpty()}"
3851
}
3952

40-
class SuperOf(
53+
data class SuperOf(
4154
val parentIdHex: String,
4255
val childName: String?
4356
)

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/bindings/BindStaked.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import jp.co.soramitsu.shared_utils.runtime.RuntimeSnapshot
88
import java.math.BigInteger
99

1010
@UseCaseBinding
11-
fun bindStaked(
11+
fun bindTotal(
1212
scale: String,
1313
runtime: RuntimeSnapshot
1414
): BigInteger {
15-
val returnType = runtime.metadata.storageReturnType("ParachainStaking", "Staked")
15+
val returnType = runtime.metadata.storageReturnType("ParachainStaking", "Total")
1616

1717
return bindNumber(returnType.fromHexOrIncompatible(scale, runtime))
1818
}

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/bindings/Era.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ import java.math.BigInteger
2929
*/
3030
@UseCaseBinding
3131
fun bindActiveEra(
32-
scale: String,
32+
scale: String?,
3333
runtime: RuntimeSnapshot
3434
): BigInteger {
35+
scale ?: return BigInteger.ZERO
3536
val returnType = runtime.metadata.storageReturnType("Staking", "ActiveEra")
3637
val decoded = returnType.fromHexOrNull(runtime, scale) as? Struct.Instance ?: incompatible()
3738

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
package jp.co.soramitsu.staking.impl.data.network.blockhain.bindings
22

3+
import java.math.BigInteger
34
import jp.co.soramitsu.common.data.network.runtime.binding.HelperBinding
45
import jp.co.soramitsu.common.data.network.runtime.binding.UseCaseBinding
56
import jp.co.soramitsu.common.data.network.runtime.binding.incompatible
67
import jp.co.soramitsu.common.data.network.runtime.binding.requireType
8+
import jp.co.soramitsu.common.utils.staking
9+
import jp.co.soramitsu.core.runtime.storage.returnType
710
import jp.co.soramitsu.shared_utils.runtime.RuntimeSnapshot
811
import jp.co.soramitsu.shared_utils.runtime.definitions.types.Type
912
import jp.co.soramitsu.shared_utils.runtime.definitions.types.composite.Struct
1013
import jp.co.soramitsu.shared_utils.runtime.definitions.types.fromHexOrNull
14+
import jp.co.soramitsu.shared_utils.runtime.metadata.storage
1115
import jp.co.soramitsu.staking.api.domain.model.Exposure
16+
import jp.co.soramitsu.staking.api.domain.model.ExposurePage
1217
import jp.co.soramitsu.staking.api.domain.model.IndividualExposure
13-
import java.math.BigInteger
18+
import jp.co.soramitsu.staking.api.domain.model.LegacyExposure
1419

15-
/*
16-
IndividualExposure: {
17-
who: AccountId; // account id of the nominator
18-
value: Compact<Balance>; // nominator’s stake
19-
}
20-
*/
2120
@HelperBinding
22-
fun bindIndividualExposure(dynamicInstance: Any?, runtime: RuntimeSnapshot): IndividualExposure {
21+
fun bindIndividualExposure(dynamicInstance: Any?): IndividualExposure {
2322
requireType<Struct.Instance>(dynamicInstance)
2423

2524
val who = dynamicInstance.get<ByteArray>("who") ?: incompatible()
@@ -28,21 +27,41 @@ fun bindIndividualExposure(dynamicInstance: Any?, runtime: RuntimeSnapshot): Ind
2827
return IndividualExposure(who, value)
2928
}
3029

31-
/*
32-
Exposure: {
33-
total: Compact<Balance>; // total stake of the validator
34-
own: Compact<Balance>; // own stake of the validator
35-
others: Vec<IndividualExposure>; // nominators stakes
36-
}
37-
*/
3830
@UseCaseBinding
39-
fun bindExposure(scale: String, runtime: RuntimeSnapshot, type: Type<*>): Exposure? {
31+
fun bindLegacyExposure(scale: String, runtime: RuntimeSnapshot, type: Type<*>): LegacyExposure? {
4032
val decoded = type.fromHexOrNull(runtime, scale) as? Struct.Instance ?: return null
4133

4234
val total = decoded.get<BigInteger>("total") ?: return null
4335
val own = decoded.get<BigInteger>("own") ?: return null
4436

45-
val others = decoded.get<List<*>>("others")?.map { bindIndividualExposure(it, runtime) } ?: return null
37+
val others = decoded.get<List<*>>("others")?.map { bindIndividualExposure(it) } ?: return null
4638

47-
return Exposure(total, own, others)
39+
return LegacyExposure(total, own, others)
4840
}
41+
42+
@UseCaseBinding
43+
fun bindExposure(scale: String, runtime: RuntimeSnapshot): Exposure? {
44+
val storageType = runtime.metadata.staking().storage("ErasStakersOverview").returnType()
45+
46+
val decoded = storageType.fromHexOrNull(runtime, scale) as? Struct.Instance ?: return null
47+
48+
val total = decoded.get<BigInteger>("total") ?: return null
49+
val own = decoded.get<BigInteger>("own") ?: return null
50+
51+
val nominatorCount = decoded.get<BigInteger>("nominatorCount") ?: return null
52+
val pageCount = decoded.get<BigInteger>("pageCount") ?: return null
53+
54+
return Exposure(total, own, nominatorCount.toInt(), pageCount)
55+
}
56+
57+
@UseCaseBinding
58+
fun bindExposurePage(scale: String, runtime: RuntimeSnapshot): ExposurePage? {
59+
return runCatching {
60+
val storageType = runtime.metadata.staking().storage("ErasStakersPaged").returnType()
61+
val decoded = storageType.fromHexOrNull(runtime, scale) as? Struct.Instance ?: return null
62+
val pageTotal = decoded.get<BigInteger>("pageTotal") ?: return null
63+
val others =
64+
decoded.get<List<*>>("others")?.map { bindIndividualExposure(it) } ?: return null
65+
ExposurePage(pageTotal, others)
66+
}.getOrNull()
67+
}

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/bindings/Identity.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ fun bindIdentity(
4040
runtime: RuntimeSnapshot,
4141
type: Type<*>
4242
): Identity {
43-
val decoded = type.fromHexOrNull(runtime, scale) as? Struct.Instance ?: incompatible()
43+
val decoded = type.fromHexOrNull(runtime, scale)// as? Struct.Instance ?: incompatible()
44+
val struct = when (decoded) {
45+
is Struct.Instance -> decoded.cast<Struct.Instance>()
46+
is ArrayList<*> -> decoded.cast<ArrayList<*>>().first() as Struct.Instance
47+
else -> return RootIdentity.empty()
48+
}
4449

45-
val identityInfo = decoded.get<Struct.Instance>("info") ?: incompatible()
50+
val identityInfo = struct.get<Struct.Instance>("info") ?: incompatible()
4651

4752
val pgpFingerprint = identityInfo.get<ByteArray?>("pgpFingerprint")
4853

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/bindings/StakingMinMaxStorages.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ fun bindDelegationScheduledRequests(
9999
}
100100
}
101101

102-
private fun bindNumber(scale: String, runtimeSnapshot: RuntimeSnapshot, type: Type<*>): BigInteger {
102+
fun bindNumber(scale: String, runtimeSnapshot: RuntimeSnapshot, type: Type<*>): BigInteger {
103103
return bindNumber(type.fromHexOrNull(runtimeSnapshot, scale) ?: return scale.fromHex().fromUnsignedBytes())
104104
}
105105

106-
private fun bindNumberOrNull(scale: String, runtimeSnapshot: RuntimeSnapshot, type: Type<*>): BigInteger? {
106+
fun bindNumberOrNull(scale: String, runtimeSnapshot: RuntimeSnapshot, type: Type<*>): BigInteger? {
107107
return bindNumber(type.fromHexOrNull(runtimeSnapshot, scale) ?: return null)
108108
}

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/updaters/AccountValidatorPrefsUpdater.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/updaters/ActiveEraUpdater.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package jp.co.soramitsu.staking.impl.data.network.blockhain.updaters
22

33
import jp.co.soramitsu.common.utils.staking
44
import jp.co.soramitsu.core.storage.StorageCache
5-
import jp.co.soramitsu.core.updater.GlobalScope
5+
import jp.co.soramitsu.core.updater.GlobalUpdaterScope
66
import jp.co.soramitsu.runtime.multiNetwork.ChainRegistry
77
import jp.co.soramitsu.runtime.network.updaters.SingleStorageKeyUpdater
88
import jp.co.soramitsu.shared_utils.runtime.RuntimeSnapshot
@@ -15,7 +15,7 @@ class ActiveEraUpdater(
1515
stakingSharedState: StakingSharedState,
1616
chainRegistry: ChainRegistry,
1717
storageCache: StorageCache
18-
) : SingleStorageKeyUpdater<GlobalScope>(GlobalScope, stakingSharedState, chainRegistry, storageCache), StakingUpdater {
18+
) : SingleStorageKeyUpdater<GlobalUpdaterScope>(GlobalUpdaterScope, stakingSharedState, chainRegistry, storageCache), StakingUpdater {
1919

2020
override suspend fun storageKey(runtime: RuntimeSnapshot): String {
2121
return runtime.metadata.staking().storage("ActiveEra").storageKey()

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/updaters/CounterForNominatorsUpdater.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package jp.co.soramitsu.staking.impl.data.network.blockhain.updaters
22

33
import jp.co.soramitsu.common.utils.Modules
44
import jp.co.soramitsu.core.storage.StorageCache
5-
import jp.co.soramitsu.core.updater.GlobalScope
5+
import jp.co.soramitsu.core.updater.GlobalUpdaterScope
66
import jp.co.soramitsu.runtime.multiNetwork.ChainRegistry
77
import jp.co.soramitsu.runtime.network.updaters.SingleStorageKeyUpdater
88
import jp.co.soramitsu.shared_utils.runtime.RuntimeSnapshot
@@ -16,7 +16,7 @@ class CounterForNominatorsUpdater(
1616
stakingSharedState: StakingSharedState,
1717
chainRegistry: ChainRegistry,
1818
storageCache: StorageCache
19-
) : SingleStorageKeyUpdater<GlobalScope>(GlobalScope, stakingSharedState, chainRegistry, storageCache), StakingUpdater {
19+
) : SingleStorageKeyUpdater<GlobalUpdaterScope>(GlobalUpdaterScope, stakingSharedState, chainRegistry, storageCache), StakingUpdater {
2020

2121
override suspend fun storageKey(runtime: RuntimeSnapshot): String? {
2222
return runtime.metadata.moduleOrNull(Modules.STAKING)?.storageOrNull("CounterForNominators")?.storageKey()

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/data/network/blockhain/updaters/CurrentEraUpdater.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package jp.co.soramitsu.staking.impl.data.network.blockhain.updaters
22

33
import jp.co.soramitsu.common.utils.staking
44
import jp.co.soramitsu.core.storage.StorageCache
5-
import jp.co.soramitsu.core.updater.GlobalScope
5+
import jp.co.soramitsu.core.updater.GlobalUpdaterScope
66
import jp.co.soramitsu.runtime.multiNetwork.ChainRegistry
77
import jp.co.soramitsu.runtime.network.updaters.SingleStorageKeyUpdater
88
import jp.co.soramitsu.shared_utils.runtime.RuntimeSnapshot
@@ -15,7 +15,7 @@ class CurrentEraUpdater(
1515
stakingSharedState: StakingSharedState,
1616
chainRegistry: ChainRegistry,
1717
storageCache: StorageCache
18-
) : SingleStorageKeyUpdater<GlobalScope>(GlobalScope, stakingSharedState, chainRegistry, storageCache), StakingUpdater {
18+
) : SingleStorageKeyUpdater<GlobalUpdaterScope>(GlobalUpdaterScope, stakingSharedState, chainRegistry, storageCache), StakingUpdater {
1919

2020
override suspend fun storageKey(runtime: RuntimeSnapshot): String {
2121
return runtime.metadata.staking().storage("CurrentEra").storageKey()

0 commit comments

Comments
 (0)