-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* V28 migration * Add not indexed changes * Fix module name
- Loading branch information
Showing
41 changed files
with
794 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/src/main/java/jp/co/soramitsu/app/root/domain/CompositeUpdater.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package jp.co.soramitsu.app.root.domain | ||
|
||
import jp.co.soramitsu.core_api.data.network.Updater | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.async | ||
import kotlinx.coroutines.awaitAll | ||
import kotlinx.coroutines.withContext | ||
|
||
class CompositeUpdater( | ||
private val updaters: List<Updater> | ||
) : Updater { | ||
|
||
constructor(vararg updaters: Updater) : this(updaters.toList()) | ||
|
||
override suspend fun listenForUpdates(): Unit = withContext(Dispatchers.IO) { | ||
val coroutines = updaters.map { | ||
async { it.listenForUpdates() } | ||
} | ||
|
||
coroutines.awaitAll() | ||
} | ||
} |
21 changes: 7 additions & 14 deletions
21
app/src/main/java/jp/co/soramitsu/app/root/domain/RootInteractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
common/src/main/java/jp/co/soramitsu/common/utils/FearlessLibExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,36 @@ | ||
package jp.co.soramitsu.common.utils | ||
|
||
import io.emeraldpay.polkaj.scale.ScaleCodecReader | ||
import io.emeraldpay.polkaj.scale.ScaleCodecWriter | ||
import jp.co.soramitsu.fearless_utils.extensions.fromHex | ||
import jp.co.soramitsu.fearless_utils.extensions.toHexString | ||
import jp.co.soramitsu.fearless_utils.hash.Hasher.blake2b256 | ||
import jp.co.soramitsu.fearless_utils.scale.EncodableStruct | ||
import jp.co.soramitsu.fearless_utils.scale.Schema | ||
import jp.co.soramitsu.fearless_utils.scale.dataType.DataType | ||
import jp.co.soramitsu.fearless_utils.ss58.SS58Encoder | ||
import jp.co.soramitsu.feature_account_api.domain.model.Node | ||
import java.io.ByteArrayOutputStream | ||
|
||
fun SS58Encoder.encode(publicKey: ByteArray, networkType: Node.NetworkType): String { | ||
return encode(publicKey, networkType.runtimeConfiguration.addressByte) | ||
} | ||
|
||
fun <T> DataType<T>.fromHex(hex: String): T { | ||
val codecReader = ScaleCodecReader(hex.fromHex()) | ||
|
||
return read(codecReader) | ||
} | ||
|
||
fun <T> DataType<T>.toByteArray(value: T): ByteArray { | ||
val stream = ByteArrayOutputStream() | ||
val writer = ScaleCodecWriter(stream) | ||
|
||
write(writer, value) | ||
|
||
return stream.toByteArray() | ||
} | ||
|
||
fun <S : Schema<S>> EncodableStruct<S>.hash(): String { | ||
return schema.toByteArray(this).blake2b256().toHexString(withPrefix = true) | ||
} |
19 changes: 19 additions & 0 deletions
19
common/src/main/java/jp/co/soramitsu/common/utils/SuspendableProperty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package jp.co.soramitsu.common.utils | ||
|
||
import kotlinx.coroutines.channels.BufferOverflow | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.first | ||
|
||
class SuspendableProperty<T> { | ||
private val value = MutableSharedFlow<T>(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) | ||
|
||
fun invalidate() { | ||
value.resetReplayCache() | ||
} | ||
|
||
fun set(new: T) { | ||
value.tryEmit(new) // always successful, since BufferOverflow.DROP_OLDEST is used | ||
} | ||
|
||
suspend fun get(): T = value.first() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apply plugin: 'java-library' | ||
apply plugin: 'kotlin' | ||
|
||
compileKotlin { | ||
kotlinOptions { | ||
freeCompilerArgs = ["-Xallow-result-return-type"] | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation coroutinesDep | ||
} |
8 changes: 8 additions & 0 deletions
8
core-api/src/main/java/jp/co/soramitsu/core_api/data/network/Updater.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package jp.co.soramitsu.core_api.data.network | ||
|
||
interface Updater { | ||
/** | ||
* Implementations should be aware of cancellation | ||
*/ | ||
suspend fun listenForUpdates() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ compileKotlin { | |
|
||
dependencies { | ||
implementation coroutinesDep | ||
|
||
implementation project(':core-api') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
feature-wallet-api/src/main/java/jp/co/soramitsu/feature_wallet_api/di/WalletUpdaters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package jp.co.soramitsu.feature_wallet_api.di | ||
|
||
import jp.co.soramitsu.core_api.data.network.Updater | ||
|
||
class WalletUpdaters(val updaters: List<Updater>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.