Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/wc crash #1730

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<ChainUi?> {
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Loading