chore: adapt to new collectibles api
This commit is contained in:
parent
570f312617
commit
06f8ef2186
|
@ -57,10 +57,10 @@ QtObject:
|
||||||
networkIconUrl: network.iconURL
|
networkIconUrl: network.iconURL
|
||||||
)
|
)
|
||||||
|
|
||||||
proc processGetCollectiblesDataResponse(self: Controller, response: JsonNode) =
|
proc processGetCollectiblesDetailsResponse(self: Controller, response: JsonNode) =
|
||||||
defer: self.setIsDetailedEntryLoading(false)
|
defer: self.setIsDetailedEntryLoading(false)
|
||||||
|
|
||||||
let res = fromJson(response, backend_collectibles.GetCollectiblesDataResponse)
|
let res = fromJson(response, backend_collectibles.GetCollectiblesDetailsResponse)
|
||||||
|
|
||||||
if res.errorCode != ErrorCodeSuccess:
|
if res.errorCode != ErrorCodeSuccess:
|
||||||
error "error fetching collectible details: ", res.errorCode
|
error "error fetching collectible details: ", res.errorCode
|
||||||
|
@ -71,7 +71,7 @@ QtObject:
|
||||||
return
|
return
|
||||||
|
|
||||||
let collectible = res.collectibles[0]
|
let collectible = res.collectibles[0]
|
||||||
let extradata = self.getExtraData(collectible.id.chainID)
|
let extradata = self.getExtraData(collectible.id.contractID.chainID)
|
||||||
|
|
||||||
self.detailedEntry = newCollectibleDetailsFullEntry(collectible, extradata)
|
self.detailedEntry = newCollectibleDetailsFullEntry(collectible, extradata)
|
||||||
self.detailedEntryChanged()
|
self.detailedEntryChanged()
|
||||||
|
@ -80,8 +80,10 @@ QtObject:
|
||||||
self.setIsDetailedEntryLoading(true)
|
self.setIsDetailedEntryLoading(true)
|
||||||
|
|
||||||
let id = backend_collectibles.CollectibleUniqueID(
|
let id = backend_collectibles.CollectibleUniqueID(
|
||||||
chainID: chainId,
|
contractID: backend_collectibles.ContractID(
|
||||||
contractAddress: contractAddress,
|
chainID: chainId,
|
||||||
|
address: contractAddress
|
||||||
|
),
|
||||||
tokenID: stint.u256(tokenId)
|
tokenID: stint.u256(tokenId)
|
||||||
)
|
)
|
||||||
let extradata = self.getExtraData(chainId)
|
let extradata = self.getExtraData(chainId)
|
||||||
|
@ -89,15 +91,15 @@ QtObject:
|
||||||
self.detailedEntry = newCollectibleDetailsBasicEntry(id, extradata)
|
self.detailedEntry = newCollectibleDetailsBasicEntry(id, extradata)
|
||||||
self.detailedEntryChanged()
|
self.detailedEntryChanged()
|
||||||
|
|
||||||
let response = backend_collectibles.getCollectiblesDataAsync(@[id])
|
let response = backend_collectibles.getCollectiblesDetailsAsync(@[id])
|
||||||
if response.error != nil:
|
if response.error != nil:
|
||||||
self.setIsDetailedEntryLoading(false)
|
self.setIsDetailedEntryLoading(false)
|
||||||
error "error fetching collectible details: ", response.error
|
error "error fetching collectible details: ", response.error
|
||||||
return
|
return
|
||||||
|
|
||||||
proc setupEventHandlers(self: Controller) =
|
proc setupEventHandlers(self: Controller) =
|
||||||
self.eventsHandler.onGetCollectiblesDataDone(proc (jsonObj: JsonNode) =
|
self.eventsHandler.onGetCollectiblesDetailsDone(proc (jsonObj: JsonNode) =
|
||||||
self.processGetCollectiblesDataResponse(jsonObj)
|
self.processGetCollectiblesDetailsResponse(jsonObj)
|
||||||
)
|
)
|
||||||
|
|
||||||
proc newController*(networkService: network_service.Service,
|
proc newController*(networkService: network_service.Service,
|
||||||
|
|
|
@ -21,8 +21,8 @@ QtObject:
|
||||||
proc delete*(self: EventsHandler) =
|
proc delete*(self: EventsHandler) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
|
||||||
proc onGetCollectiblesDataDone*(self: EventsHandler, handler: EventCallbackProc) =
|
proc onGetCollectiblesDetailsDone*(self: EventsHandler, handler: EventCallbackProc) =
|
||||||
self.eventHandlers[backend_collectibles.eventGetCollectiblesDataDone] = handler
|
self.eventHandlers[backend_collectibles.eventGetCollectiblesDetailsDone] = handler
|
||||||
|
|
||||||
proc handleApiEvents(self: EventsHandler, e: Args) =
|
proc handleApiEvents(self: EventsHandler, e: Args) =
|
||||||
var data = WalletSignal(e)
|
var data = WalletSignal(e)
|
||||||
|
|
|
@ -17,7 +17,7 @@ QtObject:
|
||||||
type
|
type
|
||||||
CollectibleDetailsEntry* = ref object of QObject
|
CollectibleDetailsEntry* = ref object of QObject
|
||||||
id: backend.CollectibleUniqueID
|
id: backend.CollectibleUniqueID
|
||||||
data: backend.CollectibleData
|
data: backend.CollectibleDetails
|
||||||
extradata: ExtraData
|
extradata: ExtraData
|
||||||
traits: TraitModel
|
traits: TraitModel
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ QtObject:
|
||||||
proc delete*(self: CollectibleDetailsEntry) =
|
proc delete*(self: CollectibleDetailsEntry) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
|
||||||
proc newCollectibleDetailsFullEntry*(data: backend.CollectibleData, extradata: ExtraData): CollectibleDetailsEntry =
|
proc newCollectibleDetailsFullEntry*(data: backend.CollectibleDetails, extradata: ExtraData): CollectibleDetailsEntry =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.id = data.id
|
result.id = data.id
|
||||||
result.data = data
|
result.data = data
|
||||||
|
@ -45,6 +45,10 @@ QtObject:
|
||||||
|
|
||||||
proc newCollectibleDetailsEmptyEntry*(): CollectibleDetailsEntry =
|
proc newCollectibleDetailsEmptyEntry*(): CollectibleDetailsEntry =
|
||||||
let id = backend.CollectibleUniqueID(
|
let id = backend.CollectibleUniqueID(
|
||||||
|
contractID: backend.ContractID(
|
||||||
|
chainID: 0,
|
||||||
|
address: ""
|
||||||
|
),
|
||||||
tokenID: stint.u256(0)
|
tokenID: stint.u256(0)
|
||||||
)
|
)
|
||||||
let extradata = ExtraData()
|
let extradata = ExtraData()
|
||||||
|
@ -59,13 +63,13 @@ QtObject:
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
proc getChainID*(self: CollectibleDetailsEntry): int {.slot.} =
|
proc getChainID*(self: CollectibleDetailsEntry): int {.slot.} =
|
||||||
return self.id.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: CollectibleDetailsEntry): string {.slot.} =
|
||||||
return self.id.contractAddress
|
return self.id.contractID.address
|
||||||
|
|
||||||
QtProperty[string] contractAddress:
|
QtProperty[string] contractAddress:
|
||||||
read = getContractAddress
|
read = getContractAddress
|
||||||
|
@ -119,7 +123,7 @@ QtObject:
|
||||||
proc getCollectionName*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCollectionName*(self: CollectibleDetailsEntry): string {.slot.} =
|
||||||
if self.data == nil:
|
if self.data == nil:
|
||||||
return ""
|
return ""
|
||||||
return self.data.collectionData.name
|
return self.data.collectionName
|
||||||
|
|
||||||
QtProperty[string] collectionName:
|
QtProperty[string] collectionName:
|
||||||
read = getCollectionName
|
read = getCollectionName
|
||||||
|
@ -135,7 +139,7 @@ QtObject:
|
||||||
proc getCollectionImageURL*(self: CollectibleDetailsEntry): string {.slot.} =
|
proc getCollectionImageURL*(self: CollectibleDetailsEntry): string {.slot.} =
|
||||||
if self.data == nil:
|
if self.data == nil:
|
||||||
return ""
|
return ""
|
||||||
return self.data.collectionData.imageUrl
|
return self.data.collectionImageUrl
|
||||||
|
|
||||||
QtProperty[string] collectionImageUrl:
|
QtProperty[string] collectionImageUrl:
|
||||||
read = getCollectionImageURL
|
read = getCollectionImageURL
|
||||||
|
|
|
@ -10,8 +10,8 @@ proc collectibleToItem*(c: backend.CollectibleHeader, isPinned: bool = false) :
|
||||||
mediaType = "image"
|
mediaType = "image"
|
||||||
|
|
||||||
return initItem(
|
return initItem(
|
||||||
c.id.chainID,
|
c.id.contractID.chainID,
|
||||||
c.id.contractAddress,
|
c.id.contractID.address,
|
||||||
c.id.tokenID,
|
c.id.tokenID,
|
||||||
c.name,
|
c.name,
|
||||||
mediaUrl,
|
mediaUrl,
|
||||||
|
|
|
@ -14,7 +14,7 @@ const eventCollectiblesOwnershipUpdateFinished*: string = "wallet-collectibles-o
|
||||||
const eventCollectiblesOwnershipUpdateFinishedWithError*: string = "wallet-collectibles-ownership-update-finished-with-error"
|
const eventCollectiblesOwnershipUpdateFinishedWithError*: string = "wallet-collectibles-ownership-update-finished-with-error"
|
||||||
|
|
||||||
const eventOwnedCollectiblesFilteringDone*: string = "wallet-owned-collectibles-filtering-done"
|
const eventOwnedCollectiblesFilteringDone*: string = "wallet-owned-collectibles-filtering-done"
|
||||||
const eventGetCollectiblesDataDone*: string = "wallet-get-collectibles-data-done"
|
const eventGetCollectiblesDetailsDone*: string = "wallet-get-collectibles-details-done"
|
||||||
|
|
||||||
type
|
type
|
||||||
# Mirrors services/wallet/collectibles/service.go ErrorCode
|
# Mirrors services/wallet/collectibles/service.go ErrorCode
|
||||||
|
@ -30,9 +30,9 @@ type
|
||||||
hasMore*: bool
|
hasMore*: bool
|
||||||
errorCode*: ErrorCode
|
errorCode*: ErrorCode
|
||||||
|
|
||||||
# Mirrors services/wallet/collectibles/service.go GetCollectiblesDataResponse
|
# Mirrors services/wallet/collectibles/service.go GetCollectiblesDetailsResponse
|
||||||
GetCollectiblesDataResponse* = object
|
GetCollectiblesDetailsResponse* = object
|
||||||
collectibles*: seq[CollectibleData]
|
collectibles*: seq[CollectibleDetails]
|
||||||
errorCode*: ErrorCode
|
errorCode*: ErrorCode
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,12 +53,12 @@ proc fromJson*(e: JsonNode, T: typedesc[FilterOwnedCollectiblesResponse]): Filte
|
||||||
errorCode: ErrorCode(e["errorCode"].getInt())
|
errorCode: ErrorCode(e["errorCode"].getInt())
|
||||||
)
|
)
|
||||||
|
|
||||||
proc fromJson*(e: JsonNode, T: typedesc[GetCollectiblesDataResponse]): GetCollectiblesDataResponse {.inline.} =
|
proc fromJson*(e: JsonNode, T: typedesc[GetCollectiblesDetailsResponse]): GetCollectiblesDetailsResponse {.inline.} =
|
||||||
var collectibles: seq[CollectibleData] = @[]
|
var collectibles: seq[CollectibleDetails] = @[]
|
||||||
if e.hasKey("collectibles"):
|
if e.hasKey("collectibles"):
|
||||||
let jsonCollectibles = e["collectibles"]
|
let jsonCollectibles = e["collectibles"]
|
||||||
for item in jsonCollectibles.getElems():
|
for item in jsonCollectibles.getElems():
|
||||||
collectibles.add(fromJson(item, CollectibleData))
|
collectibles.add(fromJson(item, CollectibleDetails))
|
||||||
|
|
||||||
result = T(
|
result = T(
|
||||||
collectibles: collectibles,
|
collectibles: collectibles,
|
||||||
|
@ -91,5 +91,5 @@ rpc(filterOwnedCollectiblesAsync, "wallet"):
|
||||||
offset: int
|
offset: int
|
||||||
limit: int
|
limit: int
|
||||||
|
|
||||||
rpc(getCollectiblesDataAsync, "wallet"):
|
rpc(getCollectiblesDetailsAsync, "wallet"):
|
||||||
uniqueIds: seq[CollectibleUniqueID]
|
uniqueIds: seq[CollectibleUniqueID]
|
||||||
|
|
|
@ -2,22 +2,16 @@ import json, strformat
|
||||||
import stint, Tables
|
import stint, Tables
|
||||||
|
|
||||||
type
|
type
|
||||||
|
# Mirrors services/wallet/thirdparty/collectible_types.go ContractID
|
||||||
|
ContractID* = ref object of RootObj
|
||||||
|
chainID*: int
|
||||||
|
address*: string
|
||||||
|
|
||||||
# Mirrors services/wallet/thirdparty/collectible_types.go CollectibleUniqueID
|
# Mirrors services/wallet/thirdparty/collectible_types.go CollectibleUniqueID
|
||||||
CollectibleUniqueID* = ref object of RootObj
|
CollectibleUniqueID* = ref object of RootObj
|
||||||
chainID*: int
|
contractID*: ContractID
|
||||||
contractAddress*: string
|
|
||||||
tokenID*: UInt256
|
tokenID*: UInt256
|
||||||
|
|
||||||
# Mirrors services/wallet/thirdparty/collectible_types.go CollectibleHeader
|
|
||||||
CollectibleHeader* = ref object of RootObj
|
|
||||||
id* : CollectibleUniqueID
|
|
||||||
name*: string
|
|
||||||
imageUrl*: string
|
|
||||||
animationUrl*: string
|
|
||||||
animationMediaType*: string
|
|
||||||
backgroundColor*: string
|
|
||||||
collectionName*: string
|
|
||||||
|
|
||||||
# Mirrors services/wallet/thirdparty/collectible_types.go CollectibleTrait
|
# Mirrors services/wallet/thirdparty/collectible_types.go CollectibleTrait
|
||||||
CollectibleTrait* = ref object of RootObj
|
CollectibleTrait* = ref object of RootObj
|
||||||
trait_type*: string
|
trait_type*: string
|
||||||
|
@ -51,6 +45,31 @@ type
|
||||||
tokenUri*: string
|
tokenUri*: string
|
||||||
collectionData*: CollectionData
|
collectionData*: CollectionData
|
||||||
|
|
||||||
|
# Mirrors services/wallet/collectibles/types.go CollectibleHeader
|
||||||
|
CollectibleHeader* = ref object of RootObj
|
||||||
|
id* : CollectibleUniqueID
|
||||||
|
name*: string
|
||||||
|
imageUrl*: string
|
||||||
|
animationUrl*: string
|
||||||
|
animationMediaType*: string
|
||||||
|
backgroundColor*: string
|
||||||
|
collectionName*: string
|
||||||
|
|
||||||
|
# Mirrors services/wallet/collectibles/types.go CollectibleDetails
|
||||||
|
CollectibleDetails* = ref object of RootObj
|
||||||
|
id* : CollectibleUniqueID
|
||||||
|
name*: string
|
||||||
|
description*: string
|
||||||
|
imageUrl*: string
|
||||||
|
animationUrl*: string
|
||||||
|
animationMediaType*: string
|
||||||
|
traits*: seq[CollectibleTrait]
|
||||||
|
backgroundColor*: string
|
||||||
|
tokenUri*: string
|
||||||
|
collectionName*: string
|
||||||
|
collectionSlug*: string
|
||||||
|
collectionImageUrl*: string
|
||||||
|
|
||||||
# Mirrors services/wallet/thirdparty/collectible_types.go TokenBalance
|
# Mirrors services/wallet/thirdparty/collectible_types.go TokenBalance
|
||||||
CollectibleBalance* = ref object
|
CollectibleBalance* = ref object
|
||||||
tokenId*: UInt256
|
tokenId*: UInt256
|
||||||
|
@ -66,23 +85,48 @@ type
|
||||||
contractAddress*: string
|
contractAddress*: string
|
||||||
owners*: seq[CollectibleOwner]
|
owners*: seq[CollectibleOwner]
|
||||||
|
|
||||||
|
# ContractID
|
||||||
|
proc `$`*(self: ContractID): string =
|
||||||
|
return fmt"""ContractID(
|
||||||
|
chainID:{self.chainID},
|
||||||
|
address:{self.address}
|
||||||
|
)"""
|
||||||
|
|
||||||
|
proc `==`*(a, b: ContractID): bool =
|
||||||
|
result = a.chainID == b.chainID and
|
||||||
|
a.address == b.address
|
||||||
|
|
||||||
|
proc `%`*(t: ContractID): JsonNode {.inline.} =
|
||||||
|
result = newJObject()
|
||||||
|
result["chainID"] = %(t.chainID)
|
||||||
|
result["address"] = %(t.address)
|
||||||
|
|
||||||
|
proc `%`*(t: ref ContractID): JsonNode {.inline.} =
|
||||||
|
return %(t[])
|
||||||
|
|
||||||
|
proc fromJson*(t: JsonNode, T: typedesc[ContractID]): ContractID {.inline.} =
|
||||||
|
result = ContractID()
|
||||||
|
result.chainID = t["chainID"].getInt()
|
||||||
|
result.address = t["address"].getStr()
|
||||||
|
|
||||||
|
proc fromJson*(t: JsonNode, T: typedesc[ref ContractID]): ref ContractID {.inline.} =
|
||||||
|
result = new(ContractID)
|
||||||
|
result[] = fromJson(t, ContractID)
|
||||||
|
|
||||||
# CollectibleUniqueID
|
# CollectibleUniqueID
|
||||||
proc `$`*(self: CollectibleUniqueID): string =
|
proc `$`*(self: CollectibleUniqueID): string =
|
||||||
return fmt"""CollectibleUniqueID(
|
return fmt"""CollectibleUniqueID(
|
||||||
chainID:{self.chainID},
|
contractID:{self.contractID},
|
||||||
contractAddress:{self.contractAddress},
|
|
||||||
tokenID:{self.tokenID}
|
tokenID:{self.tokenID}
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
proc `==`*(a, b: CollectibleUniqueID): bool =
|
proc `==`*(a, b: CollectibleUniqueID): bool =
|
||||||
result = a.chainID == b.chainID and
|
result = a.contractID == b.contractID and
|
||||||
a.contractAddress == b.contractAddress and
|
|
||||||
a.tokenID == b.tokenID
|
a.tokenID == b.tokenID
|
||||||
|
|
||||||
proc `%`*(t: CollectibleUniqueID): JsonNode {.inline.} =
|
proc `%`*(t: CollectibleUniqueID): JsonNode {.inline.} =
|
||||||
result = newJObject()
|
result = newJObject()
|
||||||
result["chainID"] = %(t.chainID)
|
result["contractID"] = %(t.contractID)
|
||||||
result["contractAddress"] = %(t.contractAddress)
|
|
||||||
result["tokenID"] = %(t.tokenID.toString())
|
result["tokenID"] = %(t.tokenID.toString())
|
||||||
|
|
||||||
proc `%`*(t: ref CollectibleUniqueID): JsonNode {.inline.} =
|
proc `%`*(t: ref CollectibleUniqueID): JsonNode {.inline.} =
|
||||||
|
@ -90,36 +134,13 @@ proc `%`*(t: ref CollectibleUniqueID): JsonNode {.inline.} =
|
||||||
|
|
||||||
proc fromJson*(t: JsonNode, T: typedesc[CollectibleUniqueID]): CollectibleUniqueID {.inline.} =
|
proc fromJson*(t: JsonNode, T: typedesc[CollectibleUniqueID]): CollectibleUniqueID {.inline.} =
|
||||||
result = CollectibleUniqueID()
|
result = CollectibleUniqueID()
|
||||||
result.chainID = t["chainID"].getInt()
|
result.contractID = fromJson(t["contractID"], ContractID)
|
||||||
result.contractAddress = t["contractAddress"].getStr()
|
|
||||||
result.tokenID = stint.parse(t["tokenID"].getStr(), UInt256)
|
result.tokenID = stint.parse(t["tokenID"].getStr(), UInt256)
|
||||||
|
|
||||||
proc fromJson*(t: JsonNode, T: typedesc[ref CollectibleUniqueID]): ref CollectibleUniqueID {.inline.} =
|
proc fromJson*(t: JsonNode, T: typedesc[ref CollectibleUniqueID]): ref CollectibleUniqueID {.inline.} =
|
||||||
result = new(CollectibleUniqueID)
|
result = new(CollectibleUniqueID)
|
||||||
result[] = fromJson(t, CollectibleUniqueID)
|
result[] = fromJson(t, CollectibleUniqueID)
|
||||||
|
|
||||||
# CollectibleHeader
|
|
||||||
proc `$`*(self: CollectibleHeader): string =
|
|
||||||
return fmt"""CollectibleHeader(
|
|
||||||
id:{self.id},
|
|
||||||
name:{self.name},
|
|
||||||
imageUrl:{self.imageUrl},
|
|
||||||
animationUrl:{self.animationUrl},
|
|
||||||
animationMediaType:{self.animationMediaType},
|
|
||||||
backgroundColor:{self.backgroundColor},
|
|
||||||
collectionName:{self.collectionName}
|
|
||||||
)"""
|
|
||||||
|
|
||||||
proc fromJson*(t: JsonNode, T: typedesc[CollectibleHeader]): CollectibleHeader {.inline.} =
|
|
||||||
result = CollectibleHeader()
|
|
||||||
result.id = fromJson(t["id"], CollectibleUniqueID)
|
|
||||||
result.name = t["name"].getStr()
|
|
||||||
result.imageUrl = t["image_url"].getStr()
|
|
||||||
result.animationUrl = t["animation_url"].getStr()
|
|
||||||
result.animationMediaType = t["animation_media_type"].getStr()
|
|
||||||
result.backgroundColor = t["background_color"].getStr()
|
|
||||||
result.collectionName = t["collection_name"].getStr()
|
|
||||||
|
|
||||||
# CollectibleTrait
|
# CollectibleTrait
|
||||||
proc `$`*(self: CollectibleTrait): string =
|
proc `$`*(self: CollectibleTrait): string =
|
||||||
return fmt"""CollectibleTrait(
|
return fmt"""CollectibleTrait(
|
||||||
|
@ -195,7 +216,6 @@ proc `$`*(self: CollectibleData): string =
|
||||||
traits:{self.traits},
|
traits:{self.traits},
|
||||||
backgroundColor:{self.backgroundColor},
|
backgroundColor:{self.backgroundColor},
|
||||||
tokenUri:{self.tokenUri},
|
tokenUri:{self.tokenUri},
|
||||||
collectionData:{self.collectionData}
|
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
proc getCollectibleTraits*(t: JsonNode): seq[CollectibleTrait] =
|
proc getCollectibleTraits*(t: JsonNode): seq[CollectibleTrait] =
|
||||||
|
@ -216,12 +236,67 @@ proc fromJson*(t: JsonNode, T: typedesc[CollectibleData]): CollectibleData {.inl
|
||||||
result.traits = getCollectibleTraits(t["traits"])
|
result.traits = getCollectibleTraits(t["traits"])
|
||||||
result.backgroundColor = t["background_color"].getStr()
|
result.backgroundColor = t["background_color"].getStr()
|
||||||
result.tokenUri = t["token_uri"].getStr()
|
result.tokenUri = t["token_uri"].getStr()
|
||||||
result.collectionData = fromJson(t["collection_data"], CollectionData)
|
|
||||||
|
|
||||||
proc fromJson*(t: JsonNode, T: typedesc[ref CollectibleData]): ref CollectibleData {.inline.} =
|
proc fromJson*(t: JsonNode, T: typedesc[ref CollectibleData]): ref CollectibleData {.inline.} =
|
||||||
result = new(CollectibleData)
|
result = new(CollectibleData)
|
||||||
result[] = fromJson(t, CollectibleData)
|
result[] = fromJson(t, CollectibleData)
|
||||||
|
|
||||||
|
# CollectibleHeader
|
||||||
|
proc `$`*(self: CollectibleHeader): string =
|
||||||
|
return fmt"""CollectibleHeader(
|
||||||
|
id:{self.id},
|
||||||
|
name:{self.name},
|
||||||
|
imageUrl:{self.imageUrl},
|
||||||
|
animationUrl:{self.animationUrl},
|
||||||
|
animationMediaType:{self.animationMediaType},
|
||||||
|
backgroundColor:{self.backgroundColor},
|
||||||
|
collectionName:{self.collectionName}
|
||||||
|
)"""
|
||||||
|
|
||||||
|
proc fromJson*(t: JsonNode, T: typedesc[CollectibleHeader]): CollectibleHeader {.inline.} =
|
||||||
|
result = CollectibleHeader()
|
||||||
|
result.id = fromJson(t["id"], CollectibleUniqueID)
|
||||||
|
result.name = t["name"].getStr()
|
||||||
|
result.imageUrl = t["image_url"].getStr()
|
||||||
|
result.animationUrl = t["animation_url"].getStr()
|
||||||
|
result.animationMediaType = t["animation_media_type"].getStr()
|
||||||
|
result.backgroundColor = t["background_color"].getStr()
|
||||||
|
result.collectionName = t["collection_name"].getStr()
|
||||||
|
|
||||||
|
# CollectibleDetails
|
||||||
|
proc `$`*(self: CollectibleDetails): string =
|
||||||
|
return fmt"""CollectibleDetails(
|
||||||
|
id:{self.id},
|
||||||
|
name:{self.name},
|
||||||
|
description:{self.description},
|
||||||
|
imageUrl:{self.imageUrl},
|
||||||
|
animationUrl:{self.animationUrl},
|
||||||
|
animationMediaType:{self.animationMediaType},
|
||||||
|
traits:{self.traits},
|
||||||
|
backgroundColor:{self.backgroundColor},
|
||||||
|
collectionName:{self.collectionName},
|
||||||
|
collectionSlug:{self.collectionSlug},
|
||||||
|
collectionImageUrl:{self.collectionImageUrl},
|
||||||
|
)"""
|
||||||
|
|
||||||
|
proc fromJson*(t: JsonNode, T: typedesc[CollectibleDetails]): CollectibleDetails {.inline.} =
|
||||||
|
result = CollectibleDetails()
|
||||||
|
result.id = fromJson(t["id"], CollectibleUniqueID)
|
||||||
|
result.name = t["name"].getStr()
|
||||||
|
result.description = t["description"].getStr()
|
||||||
|
result.imageUrl = t["image_url"].getStr()
|
||||||
|
result.animationUrl = t["animation_url"].getStr()
|
||||||
|
result.animationMediaType = t["animation_media_type"].getStr()
|
||||||
|
result.traits = getCollectibleTraits(t["traits"])
|
||||||
|
result.backgroundColor = t["background_color"].getStr()
|
||||||
|
result.collectionName = t["collection_name"].getStr()
|
||||||
|
result.collectionSlug = t["collection_slug"].getStr()
|
||||||
|
result.collectionImageUrl = t["collection_image_url"].getStr()
|
||||||
|
|
||||||
|
proc fromJson*(t: JsonNode, T: typedesc[ref CollectibleDetails]): ref CollectibleDetails {.inline.} =
|
||||||
|
result = new(CollectibleDetails)
|
||||||
|
result[] = fromJson(t, CollectibleDetails)
|
||||||
|
|
||||||
# CollectibleBalance
|
# CollectibleBalance
|
||||||
proc `$`*(self: CollectibleBalance): string =
|
proc `$`*(self: CollectibleBalance): string =
|
||||||
return fmt"""CollectibleBalance(
|
return fmt"""CollectibleBalance(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9267e581436db4e6c761f9600243bc4f14aec36e
|
Subproject commit 078f71a23582e4ffe5e52f75317db0b1ad756542
|
Loading…
Reference in New Issue