Skip to content

Commit

Permalink
Merge pull request #1314 from radixdlt/feature/sargon-1.1.117
Browse files Browse the repository at this point in the history
Bump sargon to 1.1.117
  • Loading branch information
micbakos-rdx authored Jan 23, 2025
2 parents a51354e + 374b93c commit 90a0e67
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

package com.babylon.wallet.android.data.dapp

import com.babylon.wallet.android.data.dapp.model.Curve
import com.babylon.wallet.android.data.dapp.model.LedgerInteractionRequest
import com.babylon.wallet.android.domain.RadixWalletException
import com.babylon.wallet.android.domain.model.messages.LedgerResponse
import com.radixdlt.sargon.HierarchicalDeterministicPublicKey
import com.radixdlt.sargon.extensions.string
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filter
Expand Down Expand Up @@ -100,10 +98,7 @@ class LedgerMessengerImpl @Inject constructor(
val ledgerRequest: LedgerInteractionRequest = LedgerInteractionRequest.SignTransaction(
interactionId = interactionId,
signers = hdPublicKeys.map {
LedgerInteractionRequest.KeyParameters(
Curve.from(it.publicKey),
it.derivationPath.string
)
LedgerInteractionRequest.KeyParameters.from(it.derivationPath)
},
ledgerDevice = ledgerDevice,
displayHash = displayHashOnLedgerDisplay,
Expand All @@ -124,10 +119,7 @@ class LedgerMessengerImpl @Inject constructor(
val ledgerRequest: LedgerInteractionRequest = LedgerInteractionRequest.SignSubintentHash(
interactionId = interactionId,
signers = hdPublicKeys.map {
LedgerInteractionRequest.KeyParameters(
Curve.from(it.publicKey),
it.derivationPath.string
)
LedgerInteractionRequest.KeyParameters.from(it.derivationPath)
},
ledgerDevice = ledgerDevice,
subintentHash = subintentHash
Expand All @@ -148,10 +140,7 @@ class LedgerMessengerImpl @Inject constructor(
val ledgerRequest: LedgerInteractionRequest = LedgerInteractionRequest.SignChallenge(
interactionId = interactionId,
signers = hdPublicKeys.map {
LedgerInteractionRequest.KeyParameters(
Curve.from(it.publicKey),
it.derivationPath.string
)
LedgerInteractionRequest.KeyParameters.from(it.derivationPath)
},
ledgerDevice = ledgerDevice,
challengeHex = challengeHex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ fun DappToWalletInteractionUnvalidated.toDomainModel(remoteEntityId: RemoteEntit
requestId = interactionId,
metadata = metadata
)

is DappToWalletInteractionItems.BatchOfTransactions -> TODO("Not implemented yet")
}
}.mapError {
RadixWalletException.DappRequestException.InvalidRequestChallenge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import com.radixdlt.sargon.FactorSource
import com.radixdlt.sargon.LedgerHardwareWalletModel
import com.radixdlt.sargon.PublicKey
import com.radixdlt.sargon.Slip10Curve
import com.radixdlt.sargon.extensions.bip32CanonicalString
import com.radixdlt.sargon.extensions.curve
import com.radixdlt.sargon.extensions.hex
import com.radixdlt.sargon.extensions.string
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonClassDiscriminator
Expand Down Expand Up @@ -131,7 +131,7 @@ sealed interface LedgerInteractionRequest {

fun from(derivationPath: DerivationPath) = KeyParameters(
curve = Curve.from(derivationPath.curve),
derivationPath = derivationPath.string
derivationPath = derivationPath.bip32CanonicalString
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.babylon.wallet.android.domain.usecases

import com.babylon.wallet.android.data.dapp.LedgerMessenger
import com.babylon.wallet.android.data.dapp.model.Curve
import com.babylon.wallet.android.data.dapp.model.LedgerInteractionRequest
import com.radixdlt.sargon.AccountAddress
import com.radixdlt.sargon.FactorSource
Expand Down Expand Up @@ -38,10 +37,7 @@ class VerifyAddressOnLedgerUseCase @Inject constructor(

return ledgerMessenger.deriveAndDisplayAddressRequest(
interactionId = UUIDGenerator.uuid().toString(),
keyParameters = LedgerInteractionRequest.KeyParameters(
curve = Curve.from(publicKey = factorInstance.publicKey.publicKey),
derivationPath = factorInstance.publicKey.derivationPath.string
),
keyParameters = LedgerInteractionRequest.KeyParameters.from(factorInstance.publicKey.derivationPath),
ledgerDevice = LedgerInteractionRequest.LedgerDevice.from(ledgerFactorSource)
).fold(
onSuccess = { response ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.radixdlt.sargon.OwnedFactorInstance
import com.radixdlt.sargon.PublicKey
import com.radixdlt.sargon.Signature
import com.radixdlt.sargon.SignatureWithPublicKey
import com.radixdlt.sargon.extensions.bip32CanonicalString
import com.radixdlt.sargon.extensions.bytes
import com.radixdlt.sargon.extensions.decompile
import com.radixdlt.sargon.extensions.hash
Expand Down Expand Up @@ -200,7 +201,7 @@ class AccessLedgerHardwareWalletFactorSourceUseCase @Inject constructor(
ownedFactorInstances: List<OwnedFactorInstance>
): HdSignature<Signable.ID> {
val ownedFactorInstance = ownedFactorInstances.find {
it.factorInstance.publicKey.derivationPath.string == derivedPublicKey.derivationPath
it.factorInstance.publicKey.derivationPath.bip32CanonicalString == derivedPublicKey.derivationPath
} ?: error("No derivation path from ledger, matched the input ownedFactorInstances.")

val input = HdSignatureInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.babylon.wallet.android.presentation.accessfactorsources.deriveaccoun

import androidx.lifecycle.viewModelScope
import com.babylon.wallet.android.data.dapp.LedgerMessenger
import com.babylon.wallet.android.data.dapp.model.Curve
import com.babylon.wallet.android.data.dapp.model.LedgerInteractionRequest
import com.babylon.wallet.android.di.coroutines.IoDispatcher
import com.babylon.wallet.android.presentation.accessfactorsources.AccessFactorSourcesIOHandler
Expand All @@ -29,13 +28,13 @@ import com.radixdlt.sargon.PublicKey
import com.radixdlt.sargon.ThirdPartyDeposits
import com.radixdlt.sargon.extensions.accountRecoveryScanned
import com.radixdlt.sargon.extensions.asGeneral
import com.radixdlt.sargon.extensions.bip32CanonicalString
import com.radixdlt.sargon.extensions.derivePublicKey
import com.radixdlt.sargon.extensions.id
import com.radixdlt.sargon.extensions.indexInGlobalKeySpace
import com.radixdlt.sargon.extensions.indexInLocalKeySpace
import com.radixdlt.sargon.extensions.init
import com.radixdlt.sargon.extensions.kind
import com.radixdlt.sargon.extensions.string
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -255,17 +254,14 @@ class DeriveAccountsViewModel @Inject constructor(
ledgerMessenger.sendDerivePublicKeyRequest(
interactionId = UUIDGenerator.uuid().toString(),
keyParameters = derivationPaths.map { derivationPath ->
LedgerInteractionRequest.KeyParameters(
curve = if (input.isForLegacyOlympia) Curve.Secp256k1 else Curve.Curve25519,
derivationPath = derivationPath.string
)
LedgerInteractionRequest.KeyParameters.from(derivationPath)
},
ledgerDevice = LedgerInteractionRequest.LedgerDevice.from(factorSource = factorSource)
).mapCatching { derivePublicKeyResponse ->
derivePublicKeyResponse.publicKeysHex.map { derived ->
HierarchicalDeterministicPublicKey(
publicKey = PublicKey.init(derived.publicKeyHex),
derivationPath = derivationPaths.first { it.string == derived.derivationPath }
derivationPath = derivationPaths.first { it.bip32CanonicalString == derived.derivationPath }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.babylon.wallet.android.presentation.accessfactorsources.derivepublic

import androidx.lifecycle.viewModelScope
import com.babylon.wallet.android.data.dapp.LedgerMessenger
import com.babylon.wallet.android.data.dapp.model.Curve
import com.babylon.wallet.android.data.dapp.model.LedgerInteractionRequest
import com.babylon.wallet.android.presentation.accessfactorsources.AccessFactorSourcesIOHandler
import com.babylon.wallet.android.presentation.accessfactorsources.AccessFactorSourcesInput
Expand All @@ -21,7 +20,6 @@ import com.radixdlt.sargon.NetworkId
import com.radixdlt.sargon.PublicKey
import com.radixdlt.sargon.extensions.init
import com.radixdlt.sargon.extensions.kind
import com.radixdlt.sargon.extensions.string
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -191,7 +189,7 @@ class DerivePublicKeyViewModel @Inject constructor(
)
ledgerMessenger.sendDerivePublicKeyRequest(
interactionId = UUIDGenerator.uuid().toString(),
keyParameters = listOf(LedgerInteractionRequest.KeyParameters(Curve.Curve25519, derivationPath.string)),
keyParameters = listOf(LedgerInteractionRequest.KeyParameters.from(derivationPath)),
ledgerDevice = LedgerInteractionRequest.LedgerDevice.from(factorSource = ledgerFactorSource)
).onSuccess { derivePublicKeyResponse ->
val hdPublicKey = HierarchicalDeterministicPublicKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package com.babylon.wallet.android.presentation.settings.troubleshooting.importl

import androidx.lifecycle.viewModelScope
import com.babylon.wallet.android.data.dapp.LedgerMessenger
import com.babylon.wallet.android.data.dapp.model.Curve
import com.babylon.wallet.android.data.dapp.model.LedgerInteractionRequest
import com.babylon.wallet.android.data.repository.p2plink.P2PLinksRepository
import com.babylon.wallet.android.domain.model.messages.LedgerResponse
Expand All @@ -31,7 +30,6 @@ import com.radixdlt.sargon.MnemonicWithPassphrase
import com.radixdlt.sargon.extensions.SharedConstants.entityNameMaxLength
import com.radixdlt.sargon.extensions.hex
import com.radixdlt.sargon.extensions.id
import com.radixdlt.sargon.extensions.string
import com.radixdlt.sargon.extensions.validate
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
Expand Down Expand Up @@ -414,7 +412,7 @@ class ImportLegacyWalletViewModel @Inject constructor(
ledgerMessenger.sendDerivePublicKeyRequest(
interactionId = interactionId,
keyParameters = hardwareAccountsDerivationPaths.map { derivationPath ->
LedgerInteractionRequest.KeyParameters(Curve.Secp256k1, derivationPath.string)
LedgerInteractionRequest.KeyParameters.from(derivationPath)
},
ledgerDevice = LedgerInteractionRequest.LedgerDevice.from(ledgerFactorSource)
).onFailure {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.babylon.wallet.android.domain.usecases.accessfactorsources

import com.babylon.wallet.android.data.dapp.LedgerMessenger
import com.babylon.wallet.android.data.dapp.model.Curve
import com.babylon.wallet.android.data.dapp.model.LedgerErrorCode
import com.babylon.wallet.android.data.dapp.model.LedgerInteractionRequest
import com.babylon.wallet.android.domain.RadixWalletException
Expand All @@ -24,6 +23,7 @@ import com.radixdlt.sargon.Subintent
import com.radixdlt.sargon.Timestamp
import com.radixdlt.sargon.TransactionIntent
import com.radixdlt.sargon.extensions.asGeneral
import com.radixdlt.sargon.extensions.bip32CanonicalString
import com.radixdlt.sargon.extensions.bytes
import com.radixdlt.sargon.extensions.compile
import com.radixdlt.sargon.extensions.derivePublicKey
Expand Down Expand Up @@ -214,10 +214,7 @@ class AccessLedgerHardwareWalletFactorSourceUseCaseTest {
ledgerMessenger.sendDerivePublicKeyRequest(
interactionId = any(),
keyParameters = listOf(
LedgerInteractionRequest.KeyParameters(
curve = Curve.Curve25519,
derivationPath = ownedFactorInstance.factorInstance.publicKey.derivationPath.string
)
LedgerInteractionRequest.KeyParameters.from(ownedFactorInstance.factorInstance.publicKey.derivationPath)
),
ledgerDevice = any()
)
Expand All @@ -228,7 +225,7 @@ class AccessLedgerHardwareWalletFactorSourceUseCaseTest {
LedgerResponse.DerivedPublicKey(
curve = LedgerResponse.DerivedPublicKey.Curve.Curve25519,
publicKeyHex = expectedHDPublicKey.publicKey.hex,
derivationPath = expectedHDPublicKey.derivationPath.string
derivationPath = expectedHDPublicKey.derivationPath.bip32CanonicalString
)
)
)
Expand Down Expand Up @@ -281,7 +278,7 @@ class AccessLedgerHardwareWalletFactorSourceUseCaseTest {
derivedPublicKey = LedgerResponse.DerivedPublicKey(
curve = LedgerResponse.DerivedPublicKey.Curve.Curve25519,
publicKeyHex = signature.publicKey.hex,
derivationPath = ownedFactorInstance.factorInstance.publicKey.derivationPath.string
derivationPath = ownedFactorInstance.factorInstance.publicKey.derivationPath.bip32CanonicalString
),
signature = signature.signature.bytes.hex
)
Expand Down Expand Up @@ -348,7 +345,7 @@ class AccessLedgerHardwareWalletFactorSourceUseCaseTest {
derivedPublicKey = LedgerResponse.DerivedPublicKey(
curve = LedgerResponse.DerivedPublicKey.Curve.Curve25519,
publicKeyHex = signature.publicKey.hex,
derivationPath = ownedFactorInstance.factorInstance.publicKey.derivationPath.string
derivationPath = ownedFactorInstance.factorInstance.publicKey.derivationPath.bip32CanonicalString
),
signature = signature.signature.bytes.hex
)
Expand Down Expand Up @@ -417,7 +414,7 @@ class AccessLedgerHardwareWalletFactorSourceUseCaseTest {
derivedPublicKey = LedgerResponse.DerivedPublicKey(
curve = LedgerResponse.DerivedPublicKey.Curve.Curve25519,
publicKeyHex = signature.publicKey.hex,
derivationPath = ownedFactorInstance.factorInstance.publicKey.derivationPath.string
derivationPath = ownedFactorInstance.factorInstance.publicKey.derivationPath.bip32CanonicalString
),
signature = signature.signature.bytes.hex
)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hiltNavigation = "1.2.0"
biometricKtx = "1.2.0-alpha05"
coilCompose = "2.6.0"
kotlinxSerialization = "1.6.2"
sargon = "1.1.113-41314642"
sargon = "1.1.117-57664530"
okhttpBom = "5.0.0-alpha.12"
retrofit = "2.11.0"
retrofitKoltinxConverter = "1.0.0"
Expand Down

0 comments on commit 90a0e67

Please sign in to comment.