Skip to content

Commit

Permalink
[ABW-1964] Fix mapping between metadata and metadata types (#649)
Browse files Browse the repository at this point in the history
Co-authored-by: Maciek Czarnik <maciek.czarnik@rdx.works>
  • Loading branch information
micbakos-rdx and maciek-rdx authored Jul 27, 2023
1 parent d4c41c1 commit a133997
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
20 changes: 16 additions & 4 deletions Sources/Clients/GatewayAPI/GatewayAPI+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ extension GatewayAPI.EntityMetadataItemValue {
typed?.urlArrayValue?.values.compactMap(URL.init)
}

public var asOriginCollection: [URL]? {
typed?.originArrayValue?.values.compactMap(URL.init)
}

public var asGlobalAddress: String? {
typed?.globalAddressValue?.value
}

public var asGlobalAddressCollection: [String]? {
typed?.globalAddressArrayValue?.values
}

public var publicKeyHashes: [GatewayAPI.PublicKeyHash]? {
typed?.publicKeyHashArrayValue?.values
}
Expand All @@ -84,19 +96,19 @@ extension GatewayAPI.EntityMetadataCollection {
}

public var dappDefinition: String? {
items[.dappDefinition]?.asString
items[.dappDefinition]?.asGlobalAddress
}

public var dappDefinitions: [String]? {
items[.dappDefinitions]?.asStringCollection
items[.dappDefinitions]?.asGlobalAddressCollection
}

public var claimedEntities: [String]? {
items[.claimedEntities]?.asStringCollection
items[.claimedEntities]?.asGlobalAddressCollection
}

public var claimedWebsites: [URL]? {
items[.claimedWebsites]?.asURLCollection
items[.claimedWebsites]?.asOriginCollection
}

public var accountType: AccountType? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ extension DappDetails.View {
if let domain = viewStore.domain {
Text(L10n.AuthorizedDapps.DAppDetails.website)
.sectionHeading
// FIXME: Update
// Button(domain.stringValue) {
// viewStore.send(.openURLTapped(domain))
// }
// .buttonStyle(.url)

Button(domain.absoluteString) {
viewStore.send(.openURLTapped(domain))
}
.buttonStyle(.url)
}
}
.padding(.horizontal, .medium1)
Expand Down

0 comments on commit a133997

Please sign in to comment.