fix: prevent crash when DApp address fails SS58/Ethereum decode

Wrap accountId() in runCatching with fallback for addresses that
cannot be decoded as either SS58 or Ethereum format. Prevents
InvalidChecksumException crash when DApp sends an address with
an unrecognized format to the external signing flow.
This commit is contained in:
2026-02-24 09:33:36 +03:00
parent e13cb18576
commit 94a567c672
@@ -316,14 +316,19 @@ class PolkadotExternalSignInteractor(
} }
private suspend fun PolkadotSignPayload.accountId(): AccountId { private suspend fun PolkadotSignPayload.accountId(): AccountId {
return when (this) { return runCatching {
is PolkadotSignPayload.Json -> { when (this) {
val chain = chainOrNull() is PolkadotSignPayload.Json -> {
val chain = chainOrNull()
chain?.accountIdOf(address) ?: address.anyAddressToAccountId() chain?.accountIdOf(address) ?: address.anyAddressToAccountId()
}
is PolkadotSignPayload.Raw -> address.anyAddressToAccountId()
} }
}.getOrElse {
is PolkadotSignPayload.Raw -> address.anyAddressToAccountId() // Fallback for addresses that fail both SS58 and Ethereum decode
address.toByteArray(Charsets.UTF_8).copyOf(32)
} }
} }