Skip to content

Commit

Permalink
Merge branch 'develop' into rc/7.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
antonijzelinskij committed Mar 15, 2024
2 parents 129a2c7 + cc78349 commit aa2454f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ val RuntimeMetadata.assetRegistry: AssetRegistryApi
get() = AssetRegistryApi(assetRegistry())

context(StorageQueryContext)
val AssetRegistryApi.assetMetadataMap: QueryableStorageEntry1<HydraDxAssetId, Int>
val AssetRegistryApi.assetMetadataMap: QueryableStorageEntry1<HydraDxAssetId, Int?>
get() = storage1(
name = "AssetMetadataMap",
name = "Assets",
binding = { decoded, _ -> bindMetadataDecimals(decoded) },
)

private fun bindMetadataDecimals(decoded: Any): Int {
return bindInt(decoded.castToStruct()["decimals"])
private fun bindMetadataDecimals(decoded: Any): Int? {
return decoded.castToStruct().get<Any?>("decimals")?.let(::bindInt)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.gson.Gson
import io.novafoundation.nova.common.data.network.runtime.binding.BlockNumber
import io.novafoundation.nova.common.data.network.runtime.binding.orEmpty
import io.novafoundation.nova.common.utils.MultiMapList
import io.novafoundation.nova.common.utils.filterNotNull
import io.novafoundation.nova.common.utils.graph.Edge
import io.novafoundation.nova.common.utils.graph.Graph
import io.novafoundation.nova.common.utils.graph.create
Expand Down Expand Up @@ -223,7 +224,7 @@ private class StableSwapSource(
private fun CoroutineScope.fetchAssetsPrecisionsAsync(): Deferred<Map<HydraDxAssetId, Int>> {
return async {
remoteStorageSource.query(chain.id) {
metadata.assetRegistry.assetMetadataMap.entries()
metadata.assetRegistry.assetMetadataMap.entries().filterNotNull()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fun <T : Any> QueryableModule.storage0(name: String, binding: QueryableStorageBi
}

context(StorageQueryContext)
fun <I, T : Any> QueryableModule.storage1(
fun <I, T> QueryableModule.storage1(
name: String,
binding: QueryableStorageBinder1<I, T>,
keyBinding: QueryableStorageKeyBinder<I>? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.filterNotNull

typealias QueryableStorageBinder1<K, V> = (dynamicInstance: Any, key: K) -> V

interface QueryableStorageEntry1<I, T : Any> {
interface QueryableStorageEntry1<I, T> {

context(StorageQueryContext)
suspend fun keys(): List<I>
Expand Down Expand Up @@ -46,7 +46,7 @@ fun <I, T : Any> QueryableStorageEntry1<I, T>.observeNonNull(argument: I): Flow<
context(StorageQueryContext)
suspend fun <I, T : Any> QueryableStorageEntry1<I, T>.queryNonNull(argument: I): T = requireNotNull(query(argument))

internal class RealQueryableStorageEntry1<I, T : Any>(
internal class RealQueryableStorageEntry1<I, T>(
private val storageEntry: StorageEntry,
private val binding: QueryableStorageBinder1<I, T>,
@Suppress("UNCHECKED_CAST") private val keyBinding: QueryableStorageKeyBinder<I>? = null
Expand Down

0 comments on commit aa2454f

Please sign in to comment.