Skip to content

Commit

Permalink
Use NonEmptyString
Browse files Browse the repository at this point in the history
  • Loading branch information
kugel3 committed Aug 16, 2023
1 parent 57b47d2 commit b81019f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ extension AccountPortfoliosClient {

extension AccountPortfoliosClient {
@Sendable static func extractTags(item: GatewayAPI.StateEntityDetailsResponseItem) -> [AssetTag] {
item.metadata.tags?.map(AssetTag.init) ?? []
item.metadata.tags?.compactMap(NonEmptyString.init(rawValue:)).map(AssetTag.init) ?? []
}
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/Core/SharedModels/Assets/AssetTag.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Foundation
import NonEmpty

// MARK: - AssetTag
public enum AssetTag: Hashable, Sendable, Codable {
case officialRadix
case custom(String)
case custom(NonEmptyString)
}

extension AssetTag {
public init(_ customString: String) {
public init(_ customString: NonEmptyString) {
self = .custom(customString)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension AssetTag {
return "Official Radix" // FIXME: Strings

case let .custom(string):
return string
return string.rawValue
}
}

Expand Down

0 comments on commit b81019f

Please sign in to comment.