Skip to content

Commit 96423b3

Browse files
committed
feat: customizing tags
1 parent 5d18661 commit 96423b3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/SolanaSwift/SolanaTokenMetadata/TokenMetadata.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ public struct TokenMetadata: Hashable, Codable, Equatable {
3333
case chainId, mintAddress = "address", symbol, name, decimals, logoURI, extensions, _tags = "tags", supply
3434
}
3535

36+
public init(from decoder: Decoder) throws {
37+
let container = try decoder.container(keyedBy: CodingKeys.self)
38+
chainId = try container.decode(Int.self, forKey: .chainId)
39+
mintAddress = try container.decode(String.self, forKey: .mintAddress)
40+
symbol = try container.decode(String.self, forKey: .symbol)
41+
name = try container.decode(String.self, forKey: .name)
42+
decimals = try container.decode(Decimals.self, forKey: .decimals)
43+
logoURI = try container.decodeIfPresent(String.self, forKey: .logoURI)
44+
extensions = try container.decodeIfPresent([String: TokenExtensionValue].self, forKey: .extensions)
45+
_tags = try container.decodeIfPresent([String].self, forKey: ._tags)
46+
supply = try container.decodeIfPresent(UInt64.self, forKey: .supply)
47+
48+
// Customizing tags
49+
tags = _tags?.map { tag in TokenTag(name: tag, description: tag) } ?? []
50+
}
51+
3652
public init(
3753
_tags: [String]?,
3854
chainId: Int,

0 commit comments

Comments
 (0)