chore(@dekstop/wallet): cleanup collectibles data types
This commit is contained in:
parent
74d3bedc11
commit
7e8cf4fa4d
|
@ -46,6 +46,7 @@ proc newModule*(
|
||||||
result.collectiblesController = collectiblesc.newController(
|
result.collectiblesController = collectiblesc.newController(
|
||||||
requestId = int32(backend_collectibles.CollectiblesRequestID.ProfileShowcase),
|
requestId = int32(backend_collectibles.CollectiblesRequestID.ProfileShowcase),
|
||||||
autofetch = false,
|
autofetch = false,
|
||||||
|
networkService = networkService,
|
||||||
events = events
|
events = events
|
||||||
)
|
)
|
||||||
result.moduleLoaded = false
|
result.moduleLoaded = false
|
||||||
|
|
|
@ -131,6 +131,7 @@ proc newModule*(
|
||||||
let collectiblesController = collectiblesc.newController(
|
let collectiblesController = collectiblesc.newController(
|
||||||
requestId = int32(backend_collectibles.CollectiblesRequestID.WalletAccount),
|
requestId = int32(backend_collectibles.CollectiblesRequestID.WalletAccount),
|
||||||
autofetch = false,
|
autofetch = false,
|
||||||
|
networkService = networkService,
|
||||||
events = events
|
events = events
|
||||||
)
|
)
|
||||||
result.collectiblesController = collectiblesController
|
result.collectiblesController = collectiblesController
|
||||||
|
|
|
@ -77,6 +77,7 @@ proc newModule*(
|
||||||
result.collectiblesController = collectiblesc.newController(
|
result.collectiblesController = collectiblesc.newController(
|
||||||
requestId = int32(backend_collectibles.CollectiblesRequestID.WalletSend),
|
requestId = int32(backend_collectibles.CollectiblesRequestID.WalletSend),
|
||||||
autofetch = true,
|
autofetch = true,
|
||||||
|
networkService = networkService,
|
||||||
events = events
|
events = events
|
||||||
)
|
)
|
||||||
result.nestedCollectiblesModel = nested_collectibles.newModel(result.collectiblesController.getModel())
|
result.nestedCollectiblesModel = nested_collectibles.newModel(result.collectiblesController.getModel())
|
||||||
|
|
|
@ -17,19 +17,19 @@ type
|
||||||
# It is used to display a detailed collectibles entry in the QML UI
|
# It is used to display a detailed collectibles entry in the QML UI
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
CollectibleDetailsEntry* = ref object of QObject
|
CollectiblesEntry* = ref object of QObject
|
||||||
id: backend.CollectibleUniqueID
|
id: backend.CollectibleUniqueID
|
||||||
data: backend.Collectible
|
data: backend.Collectible
|
||||||
extradata: ExtraData
|
extradata: ExtraData
|
||||||
traits: TraitModel
|
traits: TraitModel
|
||||||
|
|
||||||
proc setup(self: CollectibleDetailsEntry) =
|
proc setup(self: CollectiblesEntry) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
|
||||||
proc delete*(self: CollectibleDetailsEntry) =
|
proc delete*(self: CollectiblesEntry) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
|
||||||
proc newCollectibleDetailsFullEntry*(data: backend.Collectible, extradata: ExtraData): CollectibleDetailsEntry =
|
proc newCollectibleDetailsFullEntry*(data: backend.Collectible, extradata: ExtraData): CollectiblesEntry =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.id = data.id
|
result.id = data.id
|
||||||
result.data = data
|
result.data = data
|
||||||
|
@ -40,14 +40,14 @@ QtObject:
|
||||||
result.traits.setItems(traits)
|
result.traits.setItems(traits)
|
||||||
result.setup()
|
result.setup()
|
||||||
|
|
||||||
proc newCollectibleDetailsBasicEntry*(id: backend.CollectibleUniqueID, extradata: ExtraData): CollectibleDetailsEntry =
|
proc newCollectibleDetailsBasicEntry*(id: backend.CollectibleUniqueID, extradata: ExtraData): CollectiblesEntry =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.id = id
|
result.id = id
|
||||||
result.extradata = extradata
|
result.extradata = extradata
|
||||||
result.traits = newTraitModel()
|
result.traits = newTraitModel()
|
||||||
result.setup()
|
result.setup()
|
||||||
|
|
||||||
proc newCollectibleDetailsEmptyEntry*(): CollectibleDetailsEntry =
|
proc newCollectibleDetailsEmptyEntry*(): CollectiblesEntry =
|
||||||
let id = backend.CollectibleUniqueID(
|
let id = backend.CollectibleUniqueID(
|
||||||
contractID: backend.ContractID(
|
contractID: backend.ContractID(
|
||||||
chainID: 0,
|
chainID: 0,
|
||||||
|
@ -58,51 +58,62 @@ QtObject:
|
||||||
let extradata = ExtraData()
|
let extradata = ExtraData()
|
||||||
return newCollectibleDetailsBasicEntry(id, extradata)
|
return newCollectibleDetailsBasicEntry(id, extradata)
|
||||||
|
|
||||||
proc `$`*(self: CollectibleDetailsEntry): string =
|
proc `$`*(self: CollectiblesEntry): string =
|
||||||
return fmt"""CollectibleDetailsEntry(
|
return fmt"""CollectiblesEntry(
|
||||||
id:{self.id},
|
id:{self.id},
|
||||||
data:{self.data},
|
data:{self.data},
|
||||||
extradata:{self.extradata},
|
extradata:{self.extradata},
|
||||||
traits:{self.traits}
|
traits:{self.traits}
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
proc hasCollectibleData(self: CollectibleDetailsEntry): bool =
|
proc hasCollectibleData(self: CollectiblesEntry): bool =
|
||||||
return self.data != nil and isSome(self.data.collectibleData)
|
return self.data != nil and isSome(self.data.collectibleData)
|
||||||
|
|
||||||
proc getCollectibleData(self: CollectibleDetailsEntry): backend.CollectibleData =
|
proc getCollectibleData(self: CollectiblesEntry): backend.CollectibleData =
|
||||||
return self.data.collectibleData.get()
|
return self.data.collectibleData.get()
|
||||||
|
|
||||||
proc hasCollectionData(self: CollectibleDetailsEntry): bool =
|
proc hasCollectionData(self: CollectiblesEntry): bool =
|
||||||
return self.data != nil and isSome(self.data.collectionData)
|
return self.data != nil and isSome(self.data.collectionData)
|
||||||
|
|
||||||
proc getCollectionData(self: CollectibleDetailsEntry): backend.CollectionData =
|
proc getCollectionData(self: CollectiblesEntry): backend.CollectionData =
|
||||||
return self.data.collectionData.get()
|
return self.data.collectionData.get()
|
||||||
|
|
||||||
proc hasCommunityData(self: CollectibleDetailsEntry): bool =
|
proc hasCommunityData(self: CollectiblesEntry): bool =
|
||||||
return self.data != nil and isSome(self.data.communityData)
|
return self.data != nil and isSome(self.data.communityData)
|
||||||
|
|
||||||
proc getCommunityData(self: CollectibleDetailsEntry): backend.CommunityData =
|
proc getCommunityData(self: CollectiblesEntry): backend.CommunityData =
|
||||||
return self.data.communityData.get()
|
return self.data.communityData.get()
|
||||||
|
|
||||||
proc getChainID*(self: CollectibleDetailsEntry): int {.slot.} =
|
proc getChainID*(self: CollectiblesEntry): int {.slot.} =
|
||||||
return self.id.contractID.chainID
|
return self.id.contractID.chainID
|
||||||
|
|
||||||
QtProperty[int] chainId:
|
QtProperty[int] chainId:
|
||||||
read = getChainID
|
read = getChainID
|
||||||
|
|
||||||
proc getContractAddress*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getContractAddress*(self: CollectiblesEntry): string {.slot.} =
|
||||||
return self.id.contractID.address
|
return self.id.contractID.address
|
||||||
|
|
||||||
QtProperty[string] contractAddress:
|
QtProperty[string] contractAddress:
|
||||||
read = getContractAddress
|
read = getContractAddress
|
||||||
|
|
||||||
proc getTokenID*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getTokenID*(self: CollectiblesEntry): UInt256 =
|
||||||
return self.id.tokenID.toString()
|
return self.id.tokenID
|
||||||
|
|
||||||
|
proc getTokenIDAsString*(self: CollectiblesEntry): string {.slot.} =
|
||||||
|
return self.getTokenID().toString()
|
||||||
|
|
||||||
QtProperty[string] tokenId:
|
QtProperty[string] tokenId:
|
||||||
read = getTokenID
|
read = getTokenIDAsString
|
||||||
|
|
||||||
proc getName*(self: CollectibleDetailsEntry): string {.slot.} =
|
# Unique ID to identify collectible, generated by us
|
||||||
|
proc getID*(self: CollectiblesEntry): string =
|
||||||
|
return fmt"{self.getChainId}+{self.getContractAddress}+{self.getTokenID}"
|
||||||
|
|
||||||
|
# Unique ID to identify collection, generated by us
|
||||||
|
proc getCollectionID*(self: CollectiblesEntry): string =
|
||||||
|
return fmt"{self.getChainId}+{self.getContractAddress}"
|
||||||
|
|
||||||
|
proc getName*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCollectibleData():
|
if not self.hasCollectibleData():
|
||||||
return ""
|
return ""
|
||||||
return self.data.collectibleData.get().name
|
return self.data.collectibleData.get().name
|
||||||
|
@ -110,7 +121,7 @@ QtObject:
|
||||||
QtProperty[string] name:
|
QtProperty[string] name:
|
||||||
read = getName
|
read = getName
|
||||||
|
|
||||||
proc getImageURL*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getImageURL*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCollectibleData() or isNone(self.getCollectibleData().imageUrl):
|
if not self.hasCollectibleData() or isNone(self.getCollectibleData().imageUrl):
|
||||||
return ""
|
return ""
|
||||||
return self.getCollectibleData().imageUrl.get()
|
return self.getCollectibleData().imageUrl.get()
|
||||||
|
@ -118,23 +129,33 @@ QtObject:
|
||||||
QtProperty[string] imageUrl:
|
QtProperty[string] imageUrl:
|
||||||
read = getImageURL
|
read = getImageURL
|
||||||
|
|
||||||
proc getMediaURL*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getOriginalMediaURL(self: CollectiblesEntry): string =
|
||||||
if not self.hasCollectibleData() or isNone(self.getCollectibleData().animationUrl):
|
if not self.hasCollectibleData() or isNone(self.getCollectibleData().animationUrl):
|
||||||
return ""
|
return ""
|
||||||
return self.getCollectibleData().animationUrl.get()
|
return self.getCollectibleData().animationUrl.get()
|
||||||
|
|
||||||
|
proc getMediaURL*(self: CollectiblesEntry): string {.slot.} =
|
||||||
|
result = self.getOriginalMediaURL()
|
||||||
|
if result == "":
|
||||||
|
result = self.getImageURL()
|
||||||
|
|
||||||
QtProperty[string] mediaUrl:
|
QtProperty[string] mediaUrl:
|
||||||
read = getMediaURL
|
read = getMediaURL
|
||||||
|
|
||||||
proc getMediaType*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getOriginalMediaType(self: CollectiblesEntry): string =
|
||||||
if not self.hasCollectibleData() or isNone(self.getCollectibleData().animationMediaType):
|
if not self.hasCollectibleData() or isNone(self.getCollectibleData().animationMediaType):
|
||||||
return ""
|
return ""
|
||||||
return self.getCollectibleData().animationMediaType.get()
|
return self.getCollectibleData().animationMediaType.get()
|
||||||
|
|
||||||
|
proc getMediaType*(self: CollectiblesEntry): string {.slot.} =
|
||||||
|
result = self.getOriginalMediaType()
|
||||||
|
if result == "":
|
||||||
|
result = "image"
|
||||||
|
|
||||||
QtProperty[string] mediaType:
|
QtProperty[string] mediaType:
|
||||||
read = getMediaType
|
read = getMediaType
|
||||||
|
|
||||||
proc getBackgroundColor*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getBackgroundColor*(self: CollectiblesEntry): string {.slot.} =
|
||||||
var color = "transparent"
|
var color = "transparent"
|
||||||
if self.hasCollectibleData() and isSome(self.getCollectibleData().backgroundColor):
|
if self.hasCollectibleData() and isSome(self.getCollectibleData().backgroundColor):
|
||||||
let backgroundColor = self.getCollectibleData().backgroundColor.get()
|
let backgroundColor = self.getCollectibleData().backgroundColor.get()
|
||||||
|
@ -145,7 +166,7 @@ QtObject:
|
||||||
QtProperty[string] backgroundColor:
|
QtProperty[string] backgroundColor:
|
||||||
read = getBackgroundColor
|
read = getBackgroundColor
|
||||||
|
|
||||||
proc getDescription*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getDescription*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCollectibleData() or isNone(self.getCollectibleData().description):
|
if not self.hasCollectibleData() or isNone(self.getCollectibleData().description):
|
||||||
return ""
|
return ""
|
||||||
return self.getCollectibleData().description.get()
|
return self.getCollectibleData().description.get()
|
||||||
|
@ -153,7 +174,15 @@ QtObject:
|
||||||
QtProperty[string] description:
|
QtProperty[string] description:
|
||||||
read = getDescription
|
read = getDescription
|
||||||
|
|
||||||
proc getCollectionName*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCollectionSlug*(self: CollectiblesEntry): string {.slot.} =
|
||||||
|
if not self.hasCollectionData():
|
||||||
|
return ""
|
||||||
|
return self.getCollectionData().slug
|
||||||
|
|
||||||
|
QtProperty[string] collectionSlug:
|
||||||
|
read = getCollectionSlug
|
||||||
|
|
||||||
|
proc getCollectionName*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCollectionData():
|
if not self.hasCollectionData():
|
||||||
return ""
|
return ""
|
||||||
return self.getCollectionData().name
|
return self.getCollectionData().name
|
||||||
|
@ -161,7 +190,7 @@ QtObject:
|
||||||
QtProperty[string] collectionName:
|
QtProperty[string] collectionName:
|
||||||
read = getCollectionName
|
read = getCollectionName
|
||||||
|
|
||||||
proc getCollectionImageURL*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCollectionImageURL*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCollectionData():
|
if not self.hasCollectionData():
|
||||||
return ""
|
return ""
|
||||||
return self.getCollectionData().imageUrl
|
return self.getCollectionData().imageUrl
|
||||||
|
@ -169,19 +198,19 @@ QtObject:
|
||||||
QtProperty[string] collectionImageUrl:
|
QtProperty[string] collectionImageUrl:
|
||||||
read = getCollectionImageURL
|
read = getCollectionImageURL
|
||||||
|
|
||||||
proc getTraits*(self: CollectibleDetailsEntry): QVariant {.slot.} =
|
proc getTraits*(self: CollectiblesEntry): QVariant {.slot.} =
|
||||||
return newQVariant(self.traits)
|
return newQVariant(self.traits)
|
||||||
|
|
||||||
QtProperty[QVariant] traits:
|
QtProperty[QVariant] traits:
|
||||||
read = getTraits
|
read = getTraits
|
||||||
|
|
||||||
proc getNetworkShortName*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getNetworkShortName*(self: CollectiblesEntry): string {.slot.} =
|
||||||
return self.extradata.networkShortName
|
return self.extradata.networkShortName
|
||||||
|
|
||||||
QtProperty[string] networkShortName:
|
QtProperty[string] networkShortName:
|
||||||
read = getNetworkShortName
|
read = getNetworkShortName
|
||||||
|
|
||||||
proc getCommunityId*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCommunityID*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCommunityData():
|
if not self.hasCommunityData():
|
||||||
return ""
|
return ""
|
||||||
return self.getCommunityData().id
|
return self.getCommunityData().id
|
||||||
|
@ -189,7 +218,7 @@ QtObject:
|
||||||
QtProperty[string] communityId:
|
QtProperty[string] communityId:
|
||||||
read = getCommunityId
|
read = getCommunityId
|
||||||
|
|
||||||
proc getCommunityName*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCommunityName*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCommunityData():
|
if not self.hasCommunityData():
|
||||||
return ""
|
return ""
|
||||||
return self.getCommunityData().name
|
return self.getCommunityData().name
|
||||||
|
@ -197,7 +226,7 @@ QtObject:
|
||||||
QtProperty[string] communityName:
|
QtProperty[string] communityName:
|
||||||
read = getCommunityName
|
read = getCommunityName
|
||||||
|
|
||||||
proc getCommunityColor*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCommunityColor*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCommunityData():
|
if not self.hasCommunityData():
|
||||||
return ""
|
return ""
|
||||||
return self.getCommunityData().color
|
return self.getCommunityData().color
|
||||||
|
@ -205,7 +234,7 @@ QtObject:
|
||||||
QtProperty[string] communityColor:
|
QtProperty[string] communityColor:
|
||||||
read = getCommunityColor
|
read = getCommunityColor
|
||||||
|
|
||||||
proc getCommunityPrivilegesLevel*(self: CollectibleDetailsEntry): int {.slot.} =
|
proc getCommunityPrivilegesLevel*(self: CollectiblesEntry): int {.slot.} =
|
||||||
if not self.hasCommunityData():
|
if not self.hasCommunityData():
|
||||||
return PrivilegesLevel.Community.int
|
return PrivilegesLevel.Community.int
|
||||||
return int(self.getCommunityData().privilegesLevel)
|
return int(self.getCommunityData().privilegesLevel)
|
||||||
|
@ -213,7 +242,7 @@ QtObject:
|
||||||
QtProperty[int] communityPrivilegesLevel:
|
QtProperty[int] communityPrivilegesLevel:
|
||||||
read = getCommunityPrivilegesLevel
|
read = getCommunityPrivilegesLevel
|
||||||
|
|
||||||
proc getCommunityImage*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCommunityImage*(self: CollectiblesEntry): string {.slot.} =
|
||||||
if not self.hasCommunityData() or isNone(self.getCommunityData().imageUrl):
|
if not self.hasCommunityData() or isNone(self.getCommunityData().imageUrl):
|
||||||
return ""
|
return ""
|
||||||
return self.getCommunityData().imageUrl.get()
|
return self.getCommunityData().imageUrl.get()
|
||||||
|
@ -221,13 +250,13 @@ QtObject:
|
||||||
QtProperty[string] communityImage:
|
QtProperty[string] communityImage:
|
||||||
read = getCommunityImage
|
read = getCommunityImage
|
||||||
|
|
||||||
proc getNetworkColor*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getNetworkColor*(self: CollectiblesEntry): string {.slot.} =
|
||||||
return self.extradata.networkColor
|
return self.extradata.networkColor
|
||||||
|
|
||||||
QtProperty[string] networkColor:
|
QtProperty[string] networkColor:
|
||||||
read = getNetworkColor
|
read = getNetworkColor
|
||||||
|
|
||||||
proc getNetworkIconURL*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getNetworkIconURL*(self: CollectiblesEntry): string {.slot.} =
|
||||||
return self.extradata.networkIconURL
|
return self.extradata.networkIconURL
|
||||||
|
|
||||||
QtProperty[string] networkIconUrl:
|
QtProperty[string] networkIconUrl:
|
|
@ -1,145 +0,0 @@
|
||||||
import strformat, stint
|
|
||||||
|
|
||||||
type
|
|
||||||
Item* = object
|
|
||||||
chainId: int
|
|
||||||
contractAddress: string
|
|
||||||
tokenId: UInt256
|
|
||||||
name: string
|
|
||||||
mediaUrl: string
|
|
||||||
mediaType: string
|
|
||||||
imageUrl: string
|
|
||||||
backgroundColor: string
|
|
||||||
collectionName: string
|
|
||||||
collectionSlug: string
|
|
||||||
collectionImageUrl: string
|
|
||||||
isLoading: bool
|
|
||||||
isPinned: bool
|
|
||||||
communityId: string
|
|
||||||
communityName: string
|
|
||||||
communityColor: string
|
|
||||||
communityPrivilegesLevel: int
|
|
||||||
|
|
||||||
proc initItem*(
|
|
||||||
chainId: int,
|
|
||||||
contractAddress: string,
|
|
||||||
tokenId: UInt256,
|
|
||||||
name: string,
|
|
||||||
mediaUrl: string,
|
|
||||||
mediaType: string,
|
|
||||||
imageUrl: string,
|
|
||||||
backgroundColor: string,
|
|
||||||
collectionName: string,
|
|
||||||
collectionSlug: string,
|
|
||||||
collectionImageUrl: string,
|
|
||||||
isPinned: bool,
|
|
||||||
communityId: string,
|
|
||||||
communityName: string,
|
|
||||||
communityColor: string,
|
|
||||||
communityPrivilegesLevel: int
|
|
||||||
|
|
||||||
): Item =
|
|
||||||
result.chainId = chainId
|
|
||||||
result.contractAddress = contractAddress
|
|
||||||
result.tokenId = tokenId
|
|
||||||
result.name = if (name != ""): name else: ("#" & tokenId.toString())
|
|
||||||
result.mediaUrl = mediaUrl
|
|
||||||
result.mediaType = mediaType
|
|
||||||
result.imageUrl = imageUrl
|
|
||||||
result.backgroundColor = if (backgroundColor == ""): "transparent" else: ("#" & backgroundColor)
|
|
||||||
result.collectionName = collectionName
|
|
||||||
result.collectionSlug = collectionSlug
|
|
||||||
result.collectionImageUrl = collectionImageUrl
|
|
||||||
result.isLoading = false
|
|
||||||
result.isPinned = isPinned
|
|
||||||
result.communityId = communityId
|
|
||||||
result.communityName = communityName
|
|
||||||
result.communityColor = communityColor
|
|
||||||
result.communityPrivilegesLevel = communityPrivilegesLevel
|
|
||||||
|
|
||||||
proc initItem*: Item =
|
|
||||||
result = initItem(0, "", u256(0), "", "", "", "", "transparent", "Collectibles", "", "", false, "", "", "", 0)
|
|
||||||
|
|
||||||
proc initLoadingItem*: Item =
|
|
||||||
result = initItem()
|
|
||||||
result.isLoading = true
|
|
||||||
|
|
||||||
proc `$`*(self: Item): string =
|
|
||||||
result = fmt"""Collectibles(
|
|
||||||
chainId: {self.chainId},
|
|
||||||
contractAddress: {self.contractAddress},
|
|
||||||
tokenId: {self.tokenId},
|
|
||||||
name: {self.name},
|
|
||||||
mediaUrl: {self.mediaUrl},
|
|
||||||
mediaType: {self.mediaType},
|
|
||||||
imageUrl: {self.imageUrl},
|
|
||||||
backgroundColor: {self.backgroundColor},
|
|
||||||
collectionName: {self.collectionName},
|
|
||||||
collectionSlug: {self.collectionSlug},
|
|
||||||
collectionImageUrl: {self.collectionImageUrl},
|
|
||||||
isLoading: {self.isLoading},
|
|
||||||
isPinned: {self.isPinned},
|
|
||||||
communityId: {self.communityId},
|
|
||||||
communityName: {self.communityName},
|
|
||||||
communityColor: {self.communityColor},
|
|
||||||
communityPrivilegesLevel: {self.communityPrivilegesLevel},
|
|
||||||
]"""
|
|
||||||
|
|
||||||
proc getChainId*(self: Item): int =
|
|
||||||
return self.chainId
|
|
||||||
|
|
||||||
proc getContractAddress*(self: Item): string =
|
|
||||||
return self.contractAddress
|
|
||||||
|
|
||||||
proc getTokenId*(self: Item): UInt256 =
|
|
||||||
return self.tokenId
|
|
||||||
|
|
||||||
# Unique ID to identify collectible, generated by us
|
|
||||||
proc getId*(self: Item): string =
|
|
||||||
return fmt"{self.getChainId}+{self.getContractAddress}+{self.getTokenID}"
|
|
||||||
|
|
||||||
proc getName*(self: Item): string =
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
proc getMediaUrl*(self: Item): string =
|
|
||||||
return self.mediaUrl
|
|
||||||
|
|
||||||
proc getMediaType*(self: Item): string =
|
|
||||||
return self.mediaType
|
|
||||||
|
|
||||||
proc getImageUrl*(self: Item): string =
|
|
||||||
return self.imageUrl
|
|
||||||
|
|
||||||
proc getBackgroundColor*(self: Item): string =
|
|
||||||
return self.backgroundColor
|
|
||||||
|
|
||||||
# Unique ID to identify collection, generated by us
|
|
||||||
proc getCollectionId*(self: Item): string =
|
|
||||||
return fmt"{self.getChainId}+{self.getContractAddress}"
|
|
||||||
|
|
||||||
proc getCollectionName*(self: Item): string =
|
|
||||||
return self.collectionName
|
|
||||||
|
|
||||||
proc getCollectionSlug*(self: Item): string =
|
|
||||||
return self.collectionSlug
|
|
||||||
|
|
||||||
proc getCollectionImageUrl*(self: Item): string =
|
|
||||||
return self.collectionImageUrl
|
|
||||||
|
|
||||||
proc getIsLoading*(self: Item): bool =
|
|
||||||
return self.isLoading
|
|
||||||
|
|
||||||
proc getIsPinned*(self: Item): bool =
|
|
||||||
return self.isPinned
|
|
||||||
|
|
||||||
proc getCommunityId*(self: Item): string =
|
|
||||||
return self.communityId
|
|
||||||
|
|
||||||
proc getCommunityName*(self: Item): string =
|
|
||||||
return self.communityName
|
|
||||||
|
|
||||||
proc getCommunityColor*(self: Item): string =
|
|
||||||
return self.communityColor
|
|
||||||
|
|
||||||
proc getCommunityPrivilegesLevel*(self: Item): int =
|
|
||||||
return self.communityPrivilegesLevel
|
|
|
@ -1,7 +1,7 @@
|
||||||
import NimQml, Tables, strutils, strformat, sequtils, stint, json
|
import NimQml, Tables, strutils, strformat, sequtils, stint, json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import ./collectibles_item
|
import ./collectibles_entry
|
||||||
import web3/ethtypes as eth
|
import web3/ethtypes as eth
|
||||||
import backend/activity as backend_activity
|
import backend/activity as backend_activity
|
||||||
import app_service/common/utils as common_utils
|
import app_service/common/utils as common_utils
|
||||||
|
@ -22,7 +22,6 @@ type
|
||||||
CollectionName
|
CollectionName
|
||||||
CollectionSlug
|
CollectionSlug
|
||||||
IsLoading
|
IsLoading
|
||||||
IsPinned
|
|
||||||
# Community-related roles
|
# Community-related roles
|
||||||
CommunityId
|
CommunityId
|
||||||
CommunityName
|
CommunityName
|
||||||
|
@ -34,7 +33,7 @@ const loadingItemsCount = 10
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
Model* = ref object of QAbstractListModel
|
Model* = ref object of QAbstractListModel
|
||||||
items: seq[Item]
|
items: seq[CollectiblesEntry]
|
||||||
hasMore: bool
|
hasMore: bool
|
||||||
isFetching: bool
|
isFetching: bool
|
||||||
isUpdating: bool
|
isUpdating: bool
|
||||||
|
@ -160,7 +159,6 @@ QtObject:
|
||||||
CollectibleRole.CollectionName.int:"collectionName",
|
CollectibleRole.CollectionName.int:"collectionName",
|
||||||
CollectibleRole.CollectionSlug.int:"collectionSlug",
|
CollectibleRole.CollectionSlug.int:"collectionSlug",
|
||||||
CollectibleRole.IsLoading.int:"isLoading",
|
CollectibleRole.IsLoading.int:"isLoading",
|
||||||
CollectibleRole.IsPinned.int:"isPinned",
|
|
||||||
CollectibleRole.CommunityId.int:"communityId",
|
CollectibleRole.CommunityId.int:"communityId",
|
||||||
CollectibleRole.CommunityName.int:"communityName",
|
CollectibleRole.CommunityName.int:"communityName",
|
||||||
CollectibleRole.CommunityColor.int:"communityColor",
|
CollectibleRole.CommunityColor.int:"communityColor",
|
||||||
|
@ -180,33 +178,31 @@ QtObject:
|
||||||
let item = self.items[index.row]
|
let item = self.items[index.row]
|
||||||
case enumRole:
|
case enumRole:
|
||||||
of CollectibleRole.Uid:
|
of CollectibleRole.Uid:
|
||||||
result = newQVariant(item.getId())
|
result = newQVariant(item.getID())
|
||||||
of CollectibleRole.ChainId:
|
of CollectibleRole.ChainId:
|
||||||
result = newQVariant(item.getChainId())
|
result = newQVariant(item.getChainID())
|
||||||
of CollectibleRole.ContractAddress:
|
of CollectibleRole.ContractAddress:
|
||||||
result = newQVariant(item.getContractAddress())
|
result = newQVariant(item.getContractAddress())
|
||||||
of CollectibleRole.TokenId:
|
of CollectibleRole.TokenId:
|
||||||
result = newQVariant(item.getTokenId().toString())
|
result = newQVariant(item.getTokenIDAsString())
|
||||||
of CollectibleRole.Name:
|
of CollectibleRole.Name:
|
||||||
result = newQVariant(item.getName())
|
result = newQVariant(item.getName())
|
||||||
of CollectibleRole.MediaUrl:
|
of CollectibleRole.MediaUrl:
|
||||||
result = newQVariant(item.getMediaUrl())
|
result = newQVariant(item.getMediaURL())
|
||||||
of CollectibleRole.MediaType:
|
of CollectibleRole.MediaType:
|
||||||
result = newQVariant(item.getMediaType())
|
result = newQVariant(item.getMediaType())
|
||||||
of CollectibleRole.ImageUrl:
|
of CollectibleRole.ImageUrl:
|
||||||
result = newQVariant(item.getImageUrl())
|
result = newQVariant(item.getImageURL())
|
||||||
of CollectibleRole.BackgroundColor:
|
of CollectibleRole.BackgroundColor:
|
||||||
result = newQVariant(item.getBackgroundColor())
|
result = newQVariant(item.getBackgroundColor())
|
||||||
of CollectibleRole.CollectionUid:
|
of CollectibleRole.CollectionUid:
|
||||||
result = newQVariant(item.getCollectionId())
|
result = newQVariant(item.getCollectionID())
|
||||||
of CollectibleRole.CollectionName:
|
of CollectibleRole.CollectionName:
|
||||||
result = newQVariant(item.getCollectionName())
|
result = newQVariant(item.getCollectionName())
|
||||||
of CollectibleRole.CollectionSlug:
|
of CollectibleRole.CollectionSlug:
|
||||||
result = newQVariant(item.getCollectionSlug())
|
result = newQVariant(item.getCollectionSlug())
|
||||||
of CollectibleRole.IsLoading:
|
of CollectibleRole.IsLoading:
|
||||||
result = newQVariant(false)
|
result = newQVariant(false)
|
||||||
of CollectibleRole.IsPinned:
|
|
||||||
result = newQVariant(item.getIsPinned())
|
|
||||||
of CollectibleRole.CommunityId:
|
of CollectibleRole.CommunityId:
|
||||||
result = newQVariant(item.getCommunityId())
|
result = newQVariant(item.getCommunityId())
|
||||||
of CollectibleRole.CommunityName:
|
of CollectibleRole.CommunityName:
|
||||||
|
@ -229,26 +225,25 @@ QtObject:
|
||||||
return
|
return
|
||||||
let item = self.items[index]
|
let item = self.items[index]
|
||||||
case column:
|
case column:
|
||||||
of "uid": result = item.getId()
|
of "uid": result = item.getID()
|
||||||
of "chainId": result = $item.getChainId()
|
of "chainId": result = $item.getChainID()
|
||||||
of "contractAddress": result = item.getContractAddress()
|
of "contractAddress": result = item.getContractAddress()
|
||||||
of "tokenId": result = item.getTokenId().toString()
|
of "tokenId": result = item.getTokenIDAsString()
|
||||||
of "name": result = item.getName()
|
of "name": result = item.getName()
|
||||||
of "mediaUrl": result = item.getMediaUrl()
|
of "mediaUrl": result = item.getMediaURL()
|
||||||
of "mediaType": result = item.getMediaType()
|
of "mediaType": result = item.getMediaType()
|
||||||
of "imageUrl": result = item.getImageUrl()
|
of "imageUrl": result = item.getImageURL()
|
||||||
of "backgroundColor": result = item.getBackgroundColor()
|
of "backgroundColor": result = item.getBackgroundColor()
|
||||||
of "collectionUid": result = item.getCollectionId()
|
of "collectionUid": result = item.getCollectionID()
|
||||||
of "collectionName": result = item.getCollectionName()
|
of "collectionName": result = item.getCollectionName()
|
||||||
of "collectionSlug": result = item.getCollectionSlug()
|
of "collectionSlug": result = item.getCollectionSlug()
|
||||||
of "isLoading": result = $false
|
of "isLoading": result = $false
|
||||||
of "isPinned": result = $item.getIsPinned()
|
of "communityId": result = item.getCommunityID()
|
||||||
of "communityId": result = item.getCommunityId()
|
|
||||||
of "communityName": result = item.getCommunityName()
|
of "communityName": result = item.getCommunityName()
|
||||||
of "communityColor": result = item.getCommunityColor()
|
of "communityColor": result = item.getCommunityColor()
|
||||||
of "communityPrivilegesLevel": result = $item.getCommunityPrivilegesLevel()
|
of "communityPrivilegesLevel": result = $item.getCommunityPrivilegesLevel()
|
||||||
|
|
||||||
proc appendCollectibleItems(self: Model, newItems: seq[Item]) =
|
proc appendCollectibleItems(self: Model, newItems: seq[CollectiblesEntry]) =
|
||||||
if len(newItems) == 0:
|
if len(newItems) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -324,10 +319,10 @@ QtObject:
|
||||||
else:
|
else:
|
||||||
self.removeLoadingItems()
|
self.removeLoadingItems()
|
||||||
|
|
||||||
proc getItems*(self: Model): seq[Item] =
|
proc getItems*(self: Model): seq[CollectiblesEntry] =
|
||||||
return self.items
|
return self.items
|
||||||
|
|
||||||
proc setItems*(self: Model, newItems: seq[Item], offset: int, hasMore: bool) =
|
proc setItems*(self: Model, newItems: seq[CollectiblesEntry], offset: int, hasMore: bool) =
|
||||||
if offset == 0:
|
if offset == 0:
|
||||||
self.removeCollectibleItems()
|
self.removeCollectibleItems()
|
||||||
elif offset != self.getCollectiblesCount():
|
elif offset != self.getCollectiblesCount():
|
||||||
|
@ -351,15 +346,15 @@ QtObject:
|
||||||
|
|
||||||
proc getActivityToken*(self: Model, id: string): backend_activity.Token =
|
proc getActivityToken*(self: Model, id: string): backend_activity.Token =
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
if(cmpIgnoreCase(item.getId(), id) == 0):
|
if(cmpIgnoreCase(item.getID(), id) == 0):
|
||||||
result.tokenType = TokenType.ERC721
|
result.tokenType = TokenType.ERC721
|
||||||
result.chainId = backend_activity.ChainId(item.getChainId())
|
result.chainId = backend_activity.ChainId(item.getChainID())
|
||||||
var contract = item.getContractAddress()
|
var contract = item.getContractAddress()
|
||||||
if len(contract) > 0:
|
if len(contract) > 0:
|
||||||
var address: eth.Address
|
var address: eth.Address
|
||||||
address = eth.fromHex(eth.Address, contract)
|
address = eth.fromHex(eth.Address, contract)
|
||||||
result.address = some(address)
|
result.address = some(address)
|
||||||
var tokenId = item.getTokenId()
|
var tokenId = item.getTokenID()
|
||||||
if tokenId > 0:
|
if tokenId > 0:
|
||||||
result.tokenId = some(backend_activity.TokenId("0x" & stint.toHex(tokenId)))
|
result.tokenId = some(backend_activity.TokenId("0x" & stint.toHex(tokenId)))
|
||||||
return result
|
return result
|
||||||
|
@ -376,8 +371,8 @@ QtObject:
|
||||||
|
|
||||||
proc getUidForData*(self: Model, tokenId: string, tokenAddress: string, chainId: int): string {.slot.} =
|
proc getUidForData*(self: Model, tokenId: string, tokenAddress: string, chainId: int): string {.slot.} =
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
if(cmpIgnoreCase(item.getTokenId().toString(), tokenId) == 0 and cmpIgnoreCase(item.getContractAddress(), tokenAddress) == 0):
|
if(cmpIgnoreCase(item.getTokenIDAsString(), tokenId) == 0 and cmpIgnoreCase(item.getContractAddress(), tokenAddress) == 0):
|
||||||
return item.getId()
|
return item.getID()
|
||||||
# Fallback, create uid from data, because it still might not be fetched
|
# Fallback, create uid from data, because it still might not be fetched
|
||||||
if chainId > 0 and len(tokenAddress) > 0 and len(tokenId) > 0:
|
if chainId > 0 and len(tokenAddress) > 0 and len(tokenId) > 0:
|
||||||
return $chainId & "+" & tokenAddress & "+" & tokenId
|
return $chainId & "+" & tokenAddress & "+" & tokenId
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import NimQml, Tables, strutils, strformat, sequtils
|
import NimQml, Tables, strutils, strformat, sequtils
|
||||||
|
|
||||||
import ./collectibles_model as flat_model
|
import ./collectibles_model as flat_model
|
||||||
import ./collectibles_item as flat_item
|
import ./collectibles_entry as flat_item
|
||||||
import ./collectibles_nested_item as nested_item
|
import ./collectibles_nested_item as nested_item
|
||||||
|
|
||||||
import ./collectibles_nested_utils
|
import ./collectibles_nested_utils
|
||||||
|
@ -120,11 +120,11 @@ QtObject:
|
||||||
of "collectionName": result = item.getCollectionName()
|
of "collectionName": result = item.getCollectionName()
|
||||||
of "isCollection": result = $item.getIsCollection()
|
of "isCollection": result = $item.getIsCollection()
|
||||||
|
|
||||||
proc getCollectiblesPerCollectionId(items: seq[flat_item.Item]): Table[string, seq[flat_item.Item]] =
|
proc getCollectiblesPerCollectionId(items: seq[flat_item.CollectiblesEntry]): Table[string, seq[flat_item.CollectiblesEntry]] =
|
||||||
var collectiblesPerCollection = initTable[string, seq[flat_item.Item]]()
|
var collectiblesPerCollection = initTable[string, seq[flat_item.CollectiblesEntry]]()
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
let collectionId = item.getCollectionId()
|
let collectionId = item.getCollectionID()
|
||||||
if not collectiblesPerCollection.hasKey(collectionId):
|
if not collectiblesPerCollection.hasKey(collectionId):
|
||||||
collectiblesPerCollection[collectionId] = @[]
|
collectiblesPerCollection[collectionId] = @[]
|
||||||
collectiblesPerCollection[collectionId].add(item)
|
collectiblesPerCollection[collectionId].add(item)
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
import collectibles_item as flat_item
|
import ./collectibles_entry as flat_item
|
||||||
import collectibles_nested_item as nested_item
|
import ./collectibles_nested_item as nested_item
|
||||||
|
|
||||||
proc collectibleToCollectibleNestedItem*(flatItem: flat_item.Item): nested_item.Item =
|
proc collectibleToCollectibleNestedItem*(flatItem: flat_item.CollectiblesEntry): nested_item.Item =
|
||||||
return nested_item.initItem(
|
return nested_item.initItem(
|
||||||
flatItem.getId(),
|
flatItem.getID(),
|
||||||
flatItem.getChainId(),
|
flatItem.getChainID(),
|
||||||
flatItem.getName(),
|
flatItem.getName(),
|
||||||
flatItem.getImageUrl(),
|
flatItem.getImageURL(),
|
||||||
flatItem.getCollectionId(),
|
flatItem.getCollectionID(),
|
||||||
flatItem.getCollectionName(),
|
flatItem.getCollectionName(),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
proc collectibleToCollectionNestedItem*(flatItem: flat_item.Item): nested_item.Item =
|
proc collectibleToCollectionNestedItem*(flatItem: flat_item.CollectiblesEntry): nested_item.Item =
|
||||||
return nested_item.initItem(
|
return nested_item.initItem(
|
||||||
flatItem.getCollectionId(),
|
flatItem.getCollectionID(),
|
||||||
flatItem.getChainId(),
|
flatItem.getChainID(),
|
||||||
flatItem.getCollectionName(),
|
flatItem.getCollectionName(),
|
||||||
flatItem.getCollectionImageUrl(),
|
flatItem.getCollectionImageURL(),
|
||||||
flatItem.getCollectionId(),
|
flatItem.getCollectionID(),
|
||||||
flatItem.getCollectionName(),
|
flatItem.getCollectionName(),
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,67 +1,9 @@
|
||||||
import options
|
import app_service/service/network/dto as network_dto
|
||||||
import backend/collectibles as backend
|
import ./collectibles_entry
|
||||||
import collectibles_item
|
|
||||||
import ../../../app_service/service/community_tokens/dto/community_token
|
|
||||||
|
|
||||||
proc collectibleToItem*(c: backend.Collectible, isPinned: bool = false) : Item =
|
proc getExtraData*(network: network_dto.NetworkDto): ExtraData =
|
||||||
var collectibleName = ""
|
return ExtraData(
|
||||||
var collectibleDescription = ""
|
networkShortName: network.shortName,
|
||||||
var collectibleMediaUrl = ""
|
networkColor: network.chainColor,
|
||||||
var collectibleMediaType = ""
|
networkIconUrl: network.iconURL
|
||||||
var collectibleImageUrl = ""
|
)
|
||||||
var collectibleBackgroundColor = ""
|
|
||||||
if isSome(c.collectibleData):
|
|
||||||
let collectibleData = c.collectibleData.get()
|
|
||||||
collectibleName = collectibleData.name
|
|
||||||
if isSome(collectibleData.description):
|
|
||||||
collectibleDescription = collectibleData.description.get()
|
|
||||||
if isSome(collectibleData.animationUrl):
|
|
||||||
collectibleMediaUrl = collectibleData.animationUrl.get()
|
|
||||||
if isSome(collectibleData.animationMediaType):
|
|
||||||
collectibleMediaType = collectibleData.animationMediaType.get()
|
|
||||||
if isSome(collectibleData.imageUrl):
|
|
||||||
collectibleImageUrl = collectibleData.imageUrl.get()
|
|
||||||
if isSome(collectibleData.backgroundColor):
|
|
||||||
collectibleBackgroundColor = collectibleData.backgroundColor.get()
|
|
||||||
if collectibleMediaUrl == "":
|
|
||||||
collectibleMediaUrl = collectibleImageUrl
|
|
||||||
collectibleMediaType = "image"
|
|
||||||
|
|
||||||
var collectionName = ""
|
|
||||||
var collectionSlug = ""
|
|
||||||
var collectionImageUrl = ""
|
|
||||||
if isSome(c.collectionData):
|
|
||||||
let collectionData = c.collectionData.get()
|
|
||||||
collectionName = collectionData.name
|
|
||||||
collectionSlug = collectionData.slug
|
|
||||||
collectionImageUrl = collectionData.imageUrl
|
|
||||||
|
|
||||||
var communityId = ""
|
|
||||||
var communityName = ""
|
|
||||||
var communityColor = ""
|
|
||||||
var communityPrivilegesLevel = PrivilegesLevel.Community.int
|
|
||||||
if isSome(c.communityData):
|
|
||||||
let communityData = c.communityData.get()
|
|
||||||
communityId = communityData.id
|
|
||||||
communityName = communityData.name
|
|
||||||
communityColor = communityData.color
|
|
||||||
communityPrivilegesLevel = int(communityData.privilegesLevel)
|
|
||||||
|
|
||||||
return initItem(
|
|
||||||
c.id.contractID.chainID,
|
|
||||||
c.id.contractID.address,
|
|
||||||
c.id.tokenID,
|
|
||||||
collectibleName,
|
|
||||||
collectibleMediaUrl,
|
|
||||||
collectibleMediaType,
|
|
||||||
collectibleImageUrl,
|
|
||||||
collectibleBackgroundColor,
|
|
||||||
collectionName,
|
|
||||||
collectionSlug,
|
|
||||||
collectionImageUrl,
|
|
||||||
isPinned,
|
|
||||||
communityId,
|
|
||||||
communityName,
|
|
||||||
communityColor,
|
|
||||||
communityPrivilegesLevel
|
|
||||||
)
|
|
|
@ -1,7 +1,8 @@
|
||||||
import NimQml, logging, std/json, sequtils, strutils
|
import NimQml, logging, std/json, sequtils, strutils
|
||||||
import stint
|
import stint
|
||||||
|
|
||||||
import app/modules/shared_models/collectible_details_entry
|
import app/modules/shared_models/collectibles_entry
|
||||||
|
import app/modules/shared_models/collectibles_utils
|
||||||
import events_handler
|
import events_handler
|
||||||
|
|
||||||
import app/core/eventemitter
|
import app/core/eventemitter
|
||||||
|
@ -15,7 +16,7 @@ QtObject:
|
||||||
networkService: network_service.Service
|
networkService: network_service.Service
|
||||||
|
|
||||||
isDetailedEntryLoading: bool
|
isDetailedEntryLoading: bool
|
||||||
detailedEntry: CollectibleDetailsEntry
|
detailedEntry: CollectiblesEntry
|
||||||
|
|
||||||
eventsHandler: EventsHandler
|
eventsHandler: EventsHandler
|
||||||
|
|
||||||
|
@ -54,12 +55,7 @@ QtObject:
|
||||||
|
|
||||||
proc getExtraData(self: Controller, chainID: int): ExtraData =
|
proc getExtraData(self: Controller, chainID: int): ExtraData =
|
||||||
let network = self.networkService.getNetwork(chainID)
|
let network = self.networkService.getNetwork(chainID)
|
||||||
|
return getExtraData(network)
|
||||||
return ExtraData(
|
|
||||||
networkShortName: network.shortName,
|
|
||||||
networkColor: network.chainColor,
|
|
||||||
networkIconUrl: network.iconURL
|
|
||||||
)
|
|
||||||
|
|
||||||
proc processGetCollectiblesDetailsResponse(self: Controller, response: JsonNode) =
|
proc processGetCollectiblesDetailsResponse(self: Controller, response: JsonNode) =
|
||||||
defer: self.setIsDetailedEntryLoading(false)
|
defer: self.setIsDetailedEntryLoading(false)
|
||||||
|
@ -106,7 +102,8 @@ QtObject:
|
||||||
self.processGetCollectiblesDetailsResponse(jsonObj)
|
self.processGetCollectiblesDetailsResponse(jsonObj)
|
||||||
)
|
)
|
||||||
|
|
||||||
proc newController*(requestId: int32,
|
proc newController*(
|
||||||
|
requestId: int32,
|
||||||
networkService: network_service.Service,
|
networkService: network_service.Service,
|
||||||
events: EventEmitter,
|
events: EventEmitter,
|
||||||
dataType: backend_collectibles.CollectibleDataType = backend_collectibles.CollectibleDataType.Details
|
dataType: backend_collectibles.CollectibleDataType = backend_collectibles.CollectibleDataType.Details
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import NimQml, std/json, sequtils, sugar, strutils
|
import NimQml, std/json, sequtils, sugar, strutils
|
||||||
import stint, logging, Tables
|
import stint, logging, Tables
|
||||||
|
|
||||||
|
import app/modules/shared_models/collectibles_entry
|
||||||
import app/modules/shared_models/collectibles_model
|
import app/modules/shared_models/collectibles_model
|
||||||
import app/modules/shared_models/collectibles_utils
|
import app/modules/shared_models/collectibles_utils
|
||||||
import events_handler
|
import events_handler
|
||||||
|
@ -9,12 +10,15 @@ import app/core/eventemitter
|
||||||
|
|
||||||
import backend/collectibles as backend_collectibles
|
import backend/collectibles as backend_collectibles
|
||||||
import backend/activity as backend_activity
|
import backend/activity as backend_activity
|
||||||
|
import app_service/service/network/service as network_service
|
||||||
|
|
||||||
const FETCH_BATCH_COUNT_DEFAULT = 50
|
const FETCH_BATCH_COUNT_DEFAULT = 50
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
Controller* = ref object of QObject
|
Controller* = ref object of QObject
|
||||||
|
networkService: network_service.Service
|
||||||
|
|
||||||
model: Model
|
model: Model
|
||||||
fetchFromStart: bool
|
fetchFromStart: bool
|
||||||
|
|
||||||
|
@ -122,6 +126,10 @@ QtObject:
|
||||||
self.fetchFromStart = true
|
self.fetchFromStart = true
|
||||||
error "error fetching collectibles entries: ", response.error
|
error "error fetching collectibles entries: ", response.error
|
||||||
|
|
||||||
|
proc getExtraData(self: Controller, chainID: int): ExtraData =
|
||||||
|
let network = self.networkService.getNetwork(chainID)
|
||||||
|
return getExtraData(network)
|
||||||
|
|
||||||
proc processGetOwnedCollectiblesResponse(self: Controller, response: JsonNode) =
|
proc processGetOwnedCollectiblesResponse(self: Controller, response: JsonNode) =
|
||||||
defer: self.model.setIsFetching(false)
|
defer: self.model.setIsFetching(false)
|
||||||
|
|
||||||
|
@ -135,7 +143,10 @@ QtObject:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
let items = res.collectibles.map(header => collectibleToItem(header))
|
let items = res.collectibles.map(header => (block:
|
||||||
|
let extradata = self.getExtraData(header.id.contractID.chainID)
|
||||||
|
newCollectibleDetailsFullEntry(header, extradata)
|
||||||
|
))
|
||||||
self.model.setItems(items, res.offset, res.hasMore)
|
self.model.setItems(items, res.offset, res.hasMore)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error converting activity entries: ", e.msg
|
error "Error converting activity entries: ", e.msg
|
||||||
|
@ -175,6 +186,7 @@ QtObject:
|
||||||
)
|
)
|
||||||
proc newController*(
|
proc newController*(
|
||||||
requestId: int32,
|
requestId: int32,
|
||||||
|
networkService: network_service.Service,
|
||||||
events: EventEmitter,
|
events: EventEmitter,
|
||||||
autofetch: bool = true,
|
autofetch: bool = true,
|
||||||
dataType: backend_collectibles.CollectibleDataType = backend_collectibles.CollectibleDataType.Header,
|
dataType: backend_collectibles.CollectibleDataType = backend_collectibles.CollectibleDataType.Header,
|
||||||
|
@ -188,6 +200,8 @@ QtObject:
|
||||||
result.dataType = dataType
|
result.dataType = dataType
|
||||||
result.fetchCriteria = fetchCriteria
|
result.fetchCriteria = fetchCriteria
|
||||||
|
|
||||||
|
result.networkService = networkService
|
||||||
|
|
||||||
result.model = newModel()
|
result.model = newModel()
|
||||||
result.fetchFromStart = true
|
result.fetchFromStart = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue