Skip to content

Commit

Permalink
Adding additional UI components to help with debugging / inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiehanson committed Nov 14, 2024
1 parent 9ad43d0 commit d035ab4
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
12 changes: 12 additions & 0 deletions phoenix-ios/phoenix-ios/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9103,6 +9103,9 @@
}
}
}
},
"BLIP 42 (DEBUG build only)" : {

},
"Block height" : {
"localizations" : {
Expand Down Expand Up @@ -12519,6 +12522,9 @@
}
}
}
},
"contact secret" : {

},
"Contact support if needed." : {
"localizations" : {
Expand Down Expand Up @@ -29891,6 +29897,12 @@
}
}
}
},
"payer address" : {

},
"payer offer" : {

},
"Payment" : {
"localizations" : {
Expand Down
101 changes: 101 additions & 0 deletions phoenix-ios/phoenix-ios/views/inspect/DetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ fileprivate struct DetailsInfoGrid: InfoGridView {
paymentRequest_invoice(paymentRequest)
}
}

#if DEBUG
if let metadata = incomingPayment.incomingOfferMetadataV2() {

InlineSection {
header("BLIP 42 (DEBUG build only)")
} content: {
blip42_contactSecret(metadata.contactSecret)
blip42_offer(metadata.payerOffer)
blip42_address(metadata.payerAddress)
}
}
#endif

if let received = incomingPayment.received {

Expand Down Expand Up @@ -274,6 +287,19 @@ fileprivate struct DetailsInfoGrid: InfoGridView {
}
}

#if DEBUG
if let request = outgoingPayment.outgoingInvoiceRequest() {

InlineSection {
header("BLIP 42 (DEBUG build only)")
} content: {
blip42_contactSecret(request.contactSecret)
blip42_offer(request.payerOffer)
blip42_address(request.payerAddress)
}
}
#endif

} else if let spliceOut = outgoingPayment as? Lightning_kmpSpliceOutgoingPayment {

InlineSection {
Expand Down Expand Up @@ -1163,6 +1189,81 @@ fileprivate struct DetailsInfoGrid: InfoGridView {
common_channelId(payment.channelId)
}

@ViewBuilder
func blip42_contactSecret(
_ secret: Bitcoin_kmpByteVector32?
) -> some View {
let identifier: String = #function

InfoGridRowWrapper(
identifier: identifier,
keyColumnWidth: keyColumnWidth(identifier: identifier)
) {
keyColumn("contact secret")

} valueColumn: {

if let str = secret?.toHex() {
Text(str)
.lineLimit(2)
.truncationMode(.middle)
} else {
Text(verbatim: "<null>")
.foregroundStyle(Color.secondary)
}
}
}

@ViewBuilder
func blip42_offer(
_ offer: Lightning_kmpOfferTypesOffer?
) -> some View {
let identifier: String = #function

InfoGridRowWrapper(
identifier: identifier,
keyColumnWidth: keyColumnWidth(identifier: identifier)
) {
keyColumn("payer offer")

} valueColumn: {

if let str = offer?.encode() {
Text(str)
.lineLimit(2)
.truncationMode(.middle)
} else {
Text(verbatim: "<null>")
.foregroundStyle(Color.secondary)
}
}
}

@ViewBuilder
func blip42_address(
_ address: Lightning_kmpContactAddress?
) -> some View {
let identifier: String = #function

InfoGridRowWrapper(
identifier: identifier,
keyColumnWidth: keyColumnWidth(identifier: identifier)
) {
keyColumn("payer address")

} valueColumn: {

if let str = address?.description() {
Text(str)
.lineLimit(2)
.truncationMode(.middle)
} else {
Text(verbatim: "<null>")
.foregroundStyle(Color.secondary)
}
}
}

// --------------------------------------------------
// MARK: View Builders: Common Rows
// --------------------------------------------------
Expand Down

0 comments on commit d035ab4

Please sign in to comment.