mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-04-21 23:48:00 +00:00
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:
+6
-1
@@ -316,7 +316,8 @@ class PolkadotExternalSignInteractor(
|
||||
}
|
||||
|
||||
private suspend fun PolkadotSignPayload.accountId(): AccountId {
|
||||
return when (this) {
|
||||
return runCatching {
|
||||
when (this) {
|
||||
is PolkadotSignPayload.Json -> {
|
||||
val chain = chainOrNull()
|
||||
|
||||
@@ -325,6 +326,10 @@ class PolkadotExternalSignInteractor(
|
||||
|
||||
is PolkadotSignPayload.Raw -> address.anyAddressToAccountId()
|
||||
}
|
||||
}.getOrElse {
|
||||
// Fallback for addresses that fail both SS58 and Ethereum decode
|
||||
address.toByteArray(Charsets.UTF_8).copyOf(32)
|
||||
}
|
||||
}
|
||||
|
||||
private class ActualMetadataHash(val modifiedOriginal: Boolean, val checkMetadataHash: CheckMetadataHashMode) {
|
||||
|
||||
Reference in New Issue
Block a user