Refactor `traitsAssetInternalValueValue` with `traitsValue` #3936

pull/3938/head
Krypto Pank 3 years ago
parent ba5001f920
commit 5722140555
  1. 9
      AlphaWallet/TokenScriptClient/Models/AssetAttributeSyntaxValue.swift
  2. 14
      AlphaWallet/Tokens/Types/TokenHolder.swift

@ -272,8 +272,13 @@ extension Dictionary where Key == AttributeId, Value == AssetAttributeSyntaxValu
self["street"]?.subscribableStringValue
}
var traitsAssetInternalValueValue: AssetInternalValue? {
self["traits"]?.value
var traitsValue: [OpenSeaNonFungibleTrait]? {
switch self["traits"]?.value {
case .openSeaNonFungibleTraits(let traits):
return traits
case .address, .string, .int, .uint, .generalisedTime, .bool, .subscribable, .bytes, .none:
return nil
}
}
var meltStringValue: String? {

@ -177,12 +177,7 @@ class TokenHolder: Hashable {
}
var openSeaNonFungibleTraits: [OpenSeaNonFungibleTrait]? {
switch values.traitsAssetInternalValueValue {
case .openSeaNonFungibleTraits(let traits):
return traits
case .address, .string, .int, .uint, .generalisedTime, .bool, .subscribable, .bytes, .none:
return nil
}
return values.traitsValue
}
var status: Token.Status {
@ -232,12 +227,7 @@ class TokenHolder: Hashable {
}
func openSeaNonFungibleTraits(tokenId: TokenId) -> [OpenSeaNonFungibleTrait]? {
switch token(tokenId: tokenId).flatMap({ $0.values.traitsAssetInternalValueValue }) {
case .openSeaNonFungibleTraits(let traits):
return traits
case .address, .string, .int, .uint, .generalisedTime, .bool, .subscribable, .bytes, .none:
return nil
}
return token(tokenId: tokenId)?.values.traitsValue
}
func imageUrl(tokenId: TokenId) -> WebImageURL? {

Loading…
Cancel
Save