diff --git a/build.gradle b/build.gradle index acffd89dc6..4716250319 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ buildscript { ext { // App version - versionName = '9.0.2' - versionCode = 161 + versionName = '9.0.3' + versionCode = 162 applicationId = "io.novafoundation.nova" releaseApplicationSuffix = "market" diff --git a/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/polkadot/PolkadotExternalSignInteractor.kt b/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/polkadot/PolkadotExternalSignInteractor.kt index bd36f264a4..d9b2aab568 100644 --- a/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/polkadot/PolkadotExternalSignInteractor.kt +++ b/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/polkadot/PolkadotExternalSignInteractor.kt @@ -3,7 +3,6 @@ package io.novafoundation.nova.feature_external_sign_impl.domain.sign.polkadot import com.google.gson.Gson import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.address.AddressModel -import io.novafoundation.nova.common.address.createAddressModel import io.novafoundation.nova.common.utils.asHexString import io.novafoundation.nova.common.utils.bigIntegerFromHex import io.novafoundation.nova.common.utils.intFromHex @@ -27,6 +26,7 @@ import io.novafoundation.nova.feature_external_sign_impl.domain.sign.ExternalSig import io.novafoundation.nova.feature_wallet_api.domain.interfaces.TokenRepository import io.novafoundation.nova.feature_wallet_api.domain.model.Token import io.novafoundation.nova.runtime.ext.accountIdOf +import io.novafoundation.nova.runtime.ext.anyAddressToAccountId import io.novafoundation.nova.runtime.ext.utilityAsset import io.novafoundation.nova.runtime.extrinsic.CustomSignedExtensions import io.novafoundation.nova.runtime.extrinsic.metadata.MetadataShortenerService @@ -38,6 +38,7 @@ import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain import io.novafoundation.nova.runtime.multiNetwork.getChainOrNull import io.novafoundation.nova.runtime.multiNetwork.getRuntime import io.novasama.substrate_sdk_android.extensions.fromHex +import io.novasama.substrate_sdk_android.runtime.AccountId import io.novasama.substrate_sdk_android.runtime.RuntimeSnapshot import io.novasama.substrate_sdk_android.runtime.definitions.types.fromHex import io.novasama.substrate_sdk_android.runtime.definitions.types.generics.EraType @@ -104,12 +105,13 @@ class PolkadotExternalSignInteractor( override val validationSystem: ConfirmDAppOperationValidationSystem = EmptyValidationSystem() override suspend fun createAccountAddressModel(): AddressModel { - return addressIconGenerator.createAddressModel( - accountAddress = signPayload.address, + val icon = addressIconGenerator.createAddressIcon( + accountId = signPayload.accountId(), sizeInDp = AddressIconGenerator.SIZE_MEDIUM, - accountName = null, - background = AddressIconGenerator.BACKGROUND_TRANSPARENT + backgroundColorRes = AddressIconGenerator.BACKGROUND_TRANSPARENT ) + + return AddressModel(signPayload.address, icon, name = null) } override suspend fun chainUi(): Result { @@ -293,6 +295,18 @@ class PolkadotExternalSignInteractor( } } + private suspend fun PolkadotSignPayload.accountId(): AccountId { + return when (this) { + is PolkadotSignPayload.Json -> { + val chain = chainOrNull() + + chain?.accountIdOf(address) ?: address.anyAddressToAccountId() + } + + is PolkadotSignPayload.Raw -> address.anyAddressToAccountId() + } + } + private class ActualMetadataHash(val modifiedOriginal: Boolean, val checkMetadataHash: CheckMetadataHash) { constructor(modifiedOriginal: Boolean, hash: ByteArray?) : this(modifiedOriginal, CheckMetadataHash(hash)) diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/ext/ChainExt.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/ext/ChainExt.kt index f796f0351e..80114ca33d 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/ext/ChainExt.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/ext/ChainExt.kt @@ -263,6 +263,16 @@ fun Chain.accountIdOf(address: String): ByteArray { } } +fun String.anyAddressToAccountId(): ByteArray { + return runCatching { + // Substrate + toAccountId() + }.recoverCatching { + // Evm + asEthereumAddress().toAccountId().value + }.getOrThrow() +} + fun Chain.accountIdOrNull(address: String): ByteArray? { return runCatching { accountIdOf(address) }.getOrNull() }