diff --git a/client/src/main/kotlin/net/corda/client/model/NetworkIdentityModel.kt b/client/src/main/kotlin/net/corda/client/model/NetworkIdentityModel.kt index 2b5cea50bb..ff91f08a32 100644 --- a/client/src/main/kotlin/net/corda/client/model/NetworkIdentityModel.kt +++ b/client/src/main/kotlin/net/corda/client/model/NetworkIdentityModel.kt @@ -40,6 +40,7 @@ class NetworkIdentityModel { return advertisedServices.any { it.info.type == NetworkMapService.type || it.info.type.isNotary() } } + // TODO: Use Identity Service in service hub instead? fun lookup(compositeKey: CompositeKey): ObservableValue = parties.firstOrDefault(notaries.firstOrNullObservable { it.notaryIdentity.owningKey == compositeKey }) { it.legalIdentity.owningKey == compositeKey } diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/views/GuiUtilities.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/views/GuiUtilities.kt index 5ac3650982..1cf7352404 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/views/GuiUtilities.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/views/GuiUtilities.kt @@ -10,7 +10,13 @@ import javafx.scene.layout.GridPane import javafx.scene.layout.Priority import javafx.scene.text.TextAlignment import javafx.util.StringConverter +import net.corda.client.fxutils.map import net.corda.client.model.Models +import net.corda.client.model.NetworkIdentityModel +import net.corda.contracts.asset.Cash +import net.corda.core.contracts.StateAndRef +import net.corda.core.crypto.AnonymousParty +import net.corda.core.crypto.Party import tornadofx.* /** @@ -81,3 +87,7 @@ inline fun UIComponent.getModel(): M = Models.get(M::class, th // Cartesian product of 2 collections. fun Collection.cross(other: Collection) = this.flatMap { a -> other.map { b -> a to b } } + +// TODO: This is a temporary fix for the UI to shows the correct issuer identity, this will break when we start randomizing keys. More work is needed here when the identity work is done. +fun StateAndRef.resolveIssuer(): ObservableValue = state.data.amount.token.issuer.party.resolveIssuer() +fun AnonymousParty.resolveIssuer(): ObservableValue = Models.get(NetworkIdentityModel::class, javaClass.kotlin).lookup(owningKey).map { it?.legalIdentity } diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/views/TransactionViewer.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/views/TransactionViewer.kt index 403cda67eb..061a61847f 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/views/TransactionViewer.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/views/TransactionViewer.kt @@ -15,10 +15,7 @@ import javafx.scene.control.TableView import javafx.scene.control.TitledPane import javafx.scene.layout.BorderPane import javafx.scene.layout.VBox -import net.corda.client.fxutils.filterNotNull -import net.corda.client.fxutils.lift -import net.corda.client.fxutils.map -import net.corda.client.fxutils.sequence +import net.corda.client.fxutils.* import net.corda.client.model.* import net.corda.contracts.asset.Cash import net.corda.core.contracts.* @@ -219,7 +216,8 @@ class TransactionViewer : CordaView("Transactions") { } row { label("Issuer :") { gridpaneConstraints { hAlignment = HPos.RIGHT } } - label("${data.amount.token.issuer}") { + val issuer = data.amount.token.issuer.party.resolveIssuer() + label(issuer.map { it?.name }) { tooltip(data.amount.token.issuer.party.owningKey.toBase58String()) } } diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt index 7bf95c0372..0be2ab8d4c 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt @@ -22,7 +22,6 @@ import net.corda.contracts.asset.Cash import net.corda.core.contracts.Amount import net.corda.core.contracts.StateAndRef import net.corda.core.contracts.withoutIssuer -import net.corda.core.crypto.AnonymousParty import net.corda.core.crypto.Party import net.corda.explorer.formatters.AmountFormatter import net.corda.explorer.identicon.identicon @@ -32,10 +31,7 @@ import net.corda.explorer.model.CordaWidget import net.corda.explorer.model.ReportingCurrencyModel import net.corda.explorer.model.SettingsModel import net.corda.explorer.ui.* -import net.corda.explorer.views.SearchField -import net.corda.explorer.views.runInFxApplicationThread -import net.corda.explorer.views.stringConverter -import net.corda.explorer.views.toStringWithSuffix +import net.corda.explorer.views.* import org.fxmisc.easybind.EasyBind import tornadofx.* import java.time.Instant @@ -85,7 +81,7 @@ class CashViewer : CordaView("Cash") { */ sealed class ViewerNode(val equivAmount: ObservableValue>, val states: ObservableList>) { - class IssuerNode(val issuer: AnonymousParty, + class IssuerNode(val issuer: ObservableValue, sumEquivAmount: ObservableValue>, states: ObservableList>) : ViewerNode(sumEquivAmount, states) @@ -127,7 +123,7 @@ class CashViewer : CordaView("Cash") { tooltip = identiconToolTip(stateRow.stateAndRef.ref.txhash) } equivLabel.textProperty().bind(equivAmount.map { it.token.currencyCode.toString() }) - issuerValueLabel.text = stateRow.stateAndRef.state.data.amount.token.issuer.toString() + issuerValueLabel.textProperty().bind(stateRow.stateAndRef.resolveIssuer().map { it?.name }) originatedValueLabel.text = stateRow.originated.toString() amountValueLabel.text = amountFormatter.format(amountNoIssuer) equivValueLabel.textProperty().bind(equivAmount.map { equivFormatter.format(it) }) @@ -144,7 +140,7 @@ class CashViewer : CordaView("Cash") { */ val searchField = SearchField(cashStates, "Currency" to { state, text -> state.state.data.amount.token.product.toString().contains(text, true) }, - "Issuer" to { state, text -> state.state.data.amount.token.issuer.party.toString().contains(text, true) } + "Issuer" to { state, text -> state.resolveIssuer().value?.name?.contains(text, true) ?: false } ) root.top = hbox(5.0) { button("New Transaction", FontAwesomeIconView(FontAwesomeIcon.PLUS)) { @@ -201,7 +197,7 @@ class CashViewer : CordaView("Cash") { /** * Assemble the Issuer node. */ - val treeItem = TreeItem(ViewerNode.IssuerNode(issuer, equivSumAmount, memberStates)) + val treeItem = TreeItem(ViewerNode.IssuerNode(issuer.resolveIssuer(), equivSumAmount, memberStates)) /** * Bind the children in the TreeTable structure. @@ -230,7 +226,7 @@ class CashViewer : CordaView("Cash") { cashViewerTableIssuerCurrency.setCellValueFactory { val node = it.value.value when (node) { - is ViewerNode.IssuerNode -> node.issuer.toString().lift() + is ViewerNode.IssuerNode -> node.issuer.map { it?.name } is ViewerNode.CurrencyNode -> node.amount.map { it.token.toString() } } }