Skip to content
Draft
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
8 changes: 7 additions & 1 deletion androidApp/src/main/java/org/multipaz/wallet/android/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import org.multipaz.trustmanagement.TrustManager
import org.multipaz.trustmanagement.TrustMetadata
import org.multipaz.util.Logger
import org.multipaz.util.Platform
import org.multipaz.utopia.knowntypes.addDelegateTransactionType
import org.multipaz.utopia.knowntypes.addUtopiaTypes
import org.multipaz.wallet.android.navigation.AppNavHost
import org.multipaz.wallet.android.navigation.Destination
Expand All @@ -93,6 +94,7 @@ import org.multipaz.wallet.android.navigation.ProvisioningNavHost
import org.multipaz.wallet.android.navigation.VerificationShowResponseDestination
import org.multipaz.wallet.android.navigation.WalletDestination
import org.multipaz.wallet.android.ui.CommunicatingWithBackendDialog
import org.multipaz.wallet.android.ui.presentment.walletTransactionDataRenderers
import org.multipaz.wallet.android.settings.SettingsModel
import org.multipaz.wallet.client.WalletClient
import org.multipaz.wallet.client.clearOnSignOut
Expand Down Expand Up @@ -206,6 +208,9 @@ class App private constructor() {
documentTypeRepository = DocumentTypeRepository()
documentTypeRepository.addKnownTypes()
documentTypeRepository.addUtopiaTypes()
// Not part of the utopia types: it is only registered alongside the renderer that shows
// the mandate (walletTransactionDataRenderers).
documentTypeRepository.addDelegateTransactionType()
documentStore = buildDocumentStore(storage = storage, secureAreaRepository = secureAreaRepository) {}
documentModel = DocumentModel.create(
documentStore = documentStore,
Expand Down Expand Up @@ -491,7 +496,8 @@ class App private constructor() {
trustedRequesterIdentity = trustedRequesterIdentity,
presentmentData = presentmentData,
preselectedDocuments = preselectedDocuments,
onDocumentsInFocus = onDocumentsInFocus
onDocumentsInFocus = onDocumentsInFocus,
transactionDataRendererRepository = walletTransactionDataRenderers,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.multipaz.wallet.android.ui.presentment

import org.multipaz.compose.presentment.DelegateTransactionRendererCompose
import org.multipaz.prompt.TransactionDataRendererRepository
import org.multipaz.utopia.knowntypes.DelegateTransaction

/**
* The wallet's renderers for transaction data in the consent prompt.
*
* A [DelegateTransaction] is drawn by the SDK's [DelegateTransactionRendererCompose], as a
* spending permission. Transaction types without a renderer here keep the consent prompt's
* built-in rendering.
*/
val walletTransactionDataRenderers = TransactionDataRendererRepository().apply {
addRenderer(DelegateTransaction.identifier, DelegateTransactionRendererCompose)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.multipaz.wallet.android.ui.presentment

import org.junit.Assert.assertSame
import org.junit.Test
import org.multipaz.compose.presentment.DelegateTransactionRendererCompose
import org.multipaz.utopia.knowntypes.DelegateTransaction

class WalletTransactionDataRenderersTest {

// AP2 requires the signed Mandate Content to be shown, so `delegate` must not fall back to the
// consent prompt's built-in rendering, which shows only a heading for it.
@Test
fun delegateIsDrawnByTheSdkRenderer() {
assertSame(
DelegateTransactionRendererCompose,
walletTransactionDataRenderers.getRenderer(DelegateTransaction.identifier)
)
}
}
6 changes: 5 additions & 1 deletion iosApp/iosApp/ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class ViewModel {
documentTypeRepository = DocumentTypeRepository()
documentTypeRepository.addKnownTypes(locale: currentLocale)
documentTypeRepository.addUtopiaTypes(locale: currentLocale)
// Not part of the utopia types: it is only registered alongside the renderer that shows
// the mandate (walletTransactionDataRenderers).
documentTypeRepository.addDelegateTransactionType()
documentStore = DocumentStore.Builder(
storage: storage,
secureAreaRepository: secureAreaRepository
Expand Down Expand Up @@ -489,7 +492,8 @@ class ViewModel {
preselectedDocuments: preselectedDocuments,
onDocumentsInFocus: { documents in
onDocumentsInFocus(documents)
}
},
transactionDataRendererRepository: walletTransactionDataRenderers
)
},
getFaceMatchingModeFn: { credential, requesterIdentities in
Expand Down
15 changes: 15 additions & 0 deletions iosApp/iosApp/WalletTransactionDataRenderers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Multipaz

/// The wallet's renderers for transaction data in the consent prompt.
///
/// A `DelegateTransaction` is drawn by the SDK's `DelegateTransactionRendererSwiftUi`, as a
/// spending permission. Transaction types without a renderer here keep the consent prompt's
/// built-in rendering.
let walletTransactionDataRenderers: TransactionDataRendererRepository = {
let repository = TransactionDataRendererRepository()
repository.addRenderer(
identifier: DelegateTransaction.shared.identifier,
renderer: DelegateTransactionRendererSwiftUi()
)
return repository
}()
Loading