-
Notifications
You must be signed in to change notification settings - Fork 6
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
Mobile Connect #907
Mobile Connect #907
Conversation
74a8e1b
to
1da79f0
Compare
1da79f0
to
06dbe6f
Compare
5efeb07
to
01b9513
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
@@ -43,5 +70,14 @@ | |||
tools:node="remove" /> | |||
|
|||
</application> | |||
|
|||
<queries> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
): Result<Unit> { | ||
val messageJson = try { | ||
Json.encodeToString(response) | ||
response.toJson() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should not throw as per https://github.com/radixdlt/sargon/blob/b1fb6d6fe04dbee9a114008cce2327834cf2ea72/jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/WalletToDappInteractionResponse.kt#L11
We can remove the try/catch here.
} | ||
|
||
class LedgerMessengerImpl @Inject constructor( | ||
private val peerdroidClient: PeerdroidClient, | ||
private val json: Json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename this to jsonSerializer
, or something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you decide to rename it, please do the same in ObserveAccountsAndSyncWithConnectorExtensionUseCase
is WalletInteraction -> payload.toDomainModel(remoteConnectorId = remoteConnectorId) | ||
else -> (payload as LedgerInteractionResponse).toDomainModel() | ||
val dappInteraction = runCatching { | ||
DappToWalletInteractionUnvalidated.Companion.fromJson(messageInJsonString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for Companion
here.
import rdx.works.core.domain.TransactionManifestData | ||
|
||
fun DappToWalletInteractionUnvalidated.toDomainModel(remoteEntityId: IncomingMessage.RemoteEntityID): IncomingMessage.IncomingRequest { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methods like these could be easier readable my converting them as
= runCatching {
....
}.mapError {
RadixWalletException.IncomingMessageException.MessageParse(it)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
|
||
val isInternal: Boolean | ||
open val isInternal: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice that you did split the incoming messages with the notion of RemoteEntityId
. On the other hand, the isInternal
is becoming now confusing. I will see what I can do when I will work on this PR. We could explore maybe renaming the RemoteEntityID
to RequestEntity
. This entity can be
- for radix connect
- for CE
- for internal messages.
I have not yet though about it throughout, but I think it is worth exploring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it definitely makes sense and worth exploring, I didn't have time to actually think about this but seem very reasonable suggestion
@@ -37,7 +37,7 @@ import javax.inject.Inject | |||
*/ | |||
class AuthorizeSpecifiedPersonaUseCase @Inject constructor( | |||
private val dAppConnectionRepository: DAppConnectionRepository, | |||
private val dAppMessenger: DappMessenger, | |||
private val respondToIncomingRequestUseCase: RespondToIncomingRequestUseCase, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
fun NavGraphBuilder.mobileConnect(onBackClick: () -> Unit) { | ||
composable( | ||
route = ROUTE, | ||
deepLinks = listOf( | ||
navDeepLink { | ||
uriPattern = | ||
"https://dr6vsuukf8610.cloudfront.net/?$ROUTE_ARGS" | ||
}, | ||
navDeepLink { | ||
uriPattern = "radixwallet://?${ROUTE_ARGS}" | ||
} | ||
), | ||
arguments = listOf( | ||
navArgument(ARG_PUBLIC_KEY) { | ||
type = NavType.StringType | ||
nullable = true | ||
}, | ||
navArgument(ARG_SESSION_ID) { | ||
type = NavType.StringType | ||
nullable = true | ||
}, | ||
navArgument(ARG_DAPP_ORIGIN) { | ||
type = NavType.StringType | ||
nullable = true | ||
}, | ||
navArgument(ARG_INTERACTION_ID) { | ||
type = NavType.StringType | ||
nullable = true | ||
}, | ||
navArgument(ARG_BROWSER) { | ||
type = NavType.StringType | ||
nullable = true | ||
} | ||
), | ||
enterTransition = { | ||
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Up) | ||
}, | ||
exitTransition = { | ||
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Down) | ||
} | ||
) { | ||
MobileConnectScreen(onBackClick = onBackClick) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess this will be eventually removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
||
@Suppress("MagicNumber") | ||
fun String.decodeHex(): ByteArray { | ||
check(length % 2 == 0) { "Must have an even length" } | ||
|
||
return chunked(2) | ||
.map { it.toInt(16).toByte() } | ||
.toByteArray() | ||
} | ||
|
||
fun generateX25519KeyPair(): Result<Pair<String, String>> { | ||
return runCatching { | ||
val generator = X25519KeyPairGenerator() | ||
val params = X25519KeyGenerationParameters(SecureRandom()) | ||
generator.init(params) | ||
val keypair1: AsymmetricCipherKeyPair = generator.generateKeyPair() | ||
val priv1 = keypair1.private as X25519PrivateKeyParameters | ||
val pub1 = keypair1.public as X25519PublicKeyParameters | ||
Pair(priv1.encoded.toHexString(), pub1.encoded.toHexString()) | ||
} | ||
} | ||
|
||
fun generateX25519SharedSecret(privateKeyCompressed: ByteArray, publicKeyCompressed: ByteArray): Result<String> { | ||
return runCatching { | ||
val agreement = X25519Agreement().apply { | ||
init(X25519PrivateKeyParameters(privateKeyCompressed)) | ||
} | ||
|
||
val secret = ByteArray(agreement.agreementSize) | ||
agreement.calculateAgreement(X25519PublicKeyParameters(publicKeyCompressed), secret, 0) | ||
secret.toHexString() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to remove this code before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after using sargon for linking flow this goes away, it's just temporary for the PoC to work now.
RCfM api changes
…ling [ABW-3406] - RCfM Deep link handling
New request handling flow for mobile connect
# Conflicts: # app/src/main/java/com/babylon/wallet/android/utils/Constants.kt # gradle/libs.versions.toml
…flow # Conflicts: # app/src/main/java/com/babylon/wallet/android/MainActivity.kt # app/src/main/java/com/babylon/wallet/android/presentation/navigation/NavigationHost.kt # app/src/main/res/values-en/strings.xml # gradle/libs.versions.toml
…ed-flow Update mobile connect flow and UI
# Conflicts: # app/src/main/res/values-en/strings.xml
Quality Gate failedFailed conditions |
Description
Mobile Connect requests handling implementation flow
Changes:
MobileConnectScreen
MobieConnectViewModel
MessageFromDataChannel
toIncomingMessage
since now messages could come from deep link or data channel.remoteEntityId
which is sealed interface hierarchy representing origin of that request (mobile connect or CE`WalletInteraction
was replaced withDappToWalletInteractionUnvalidated
from sargon andWalletInteractionResponse
withWalletToDappInteractionResponse
, while our domain models built from those network models are the same.RespondToIncomingRequestUseCase
. Use case decides if it should respond as usual viaDappMessenger
or if it should use Radix Connect Relay.Test scenarios