feat(@desktop/wallet): support received community collectibles event
Fixes #12425
This commit is contained in:
parent
ae915b6036
commit
febc2d061f
|
@ -19,6 +19,7 @@ const eventCollectiblesOwnershipUpdateStarted*: string = "wallet-collectibles-ow
|
|||
const eventCollectiblesOwnershipUpdatePartial*: string = "wallet-collectibles-ownership-update-partial"
|
||||
const eventCollectiblesOwnershipUpdateFinished*: string = "wallet-collectibles-ownership-update-finished"
|
||||
const eventCollectiblesOwnershipUpdateFinishedWithError*: string = "wallet-collectibles-ownership-update-finished-with-error"
|
||||
const eventCommunityCollectiblesReceived*: string = "wallet-collectibles-community-collectibles-received"
|
||||
|
||||
const eventOwnedCollectiblesFilteringDone*: string = "wallet-owned-collectibles-filtering-done"
|
||||
const eventGetCollectiblesDetailsDone*: string = "wallet-get-collectibles-details-done"
|
||||
|
@ -57,6 +58,9 @@ type
|
|||
collectibles*: seq[CollectibleDetails]
|
||||
errorCode*: ErrorCode
|
||||
|
||||
CommunityCollectiblesReceivedPayload* = object
|
||||
collectibles*: seq[CommunityCollectibleHeader]
|
||||
|
||||
# CollectibleOwnershipState
|
||||
proc `$`*(self: OwnershipStatus): string =
|
||||
return fmt"""OwnershipStatus(
|
||||
|
@ -109,6 +113,15 @@ proc fromJson*(e: JsonNode, T: typedesc[GetCollectiblesDetailsResponse]): GetCol
|
|||
errorCode: ErrorCode(e["errorCode"].getInt())
|
||||
)
|
||||
|
||||
proc fromJson*(e: JsonNode, T: typedesc[CommunityCollectiblesReceivedPayload]): CommunityCollectiblesReceivedPayload {.inline.} =
|
||||
var collectibles: seq[CommunityCollectibleHeader] = @[]
|
||||
for item in e.getElems():
|
||||
collectibles.add(fromJson(item, CommunityCollectibleHeader))
|
||||
|
||||
result = T(
|
||||
collectibles: collectibles
|
||||
)
|
||||
|
||||
rpc(getCollectiblesByOwnerWithCursor, "wallet"):
|
||||
chainId: int
|
||||
address: string
|
||||
|
|
|
@ -94,6 +94,12 @@ type
|
|||
collectionImageUrl*: string
|
||||
communityInfo*: Option[CollectibleCommunityInfo]
|
||||
|
||||
# Mirrors services/wallet/collectibles/types.go CommunityCollectibleHeader
|
||||
CommunityCollectibleHeader* = ref object of RootObj
|
||||
id* : CollectibleUniqueID
|
||||
name*: string
|
||||
communityHeader*: CollectibleCommunityHeader
|
||||
|
||||
# Mirrors services/wallet/thirdparty/collectible_types.go TokenBalance
|
||||
CollectibleBalance* = ref object
|
||||
tokenId*: UInt256
|
||||
|
@ -375,6 +381,20 @@ proc fromJson*(t: JsonNode, T: typedesc[ref CollectibleDetails]): ref Collectibl
|
|||
result = new(CollectibleDetails)
|
||||
result[] = fromJson(t, CollectibleDetails)
|
||||
|
||||
# CommunityCollectibleHeader
|
||||
proc `$`*(self: CommunityCollectibleHeader): string =
|
||||
return fmt"""CommunityCollectibleHeader(
|
||||
id:{self.id},
|
||||
name:{self.name},
|
||||
communityHeader:{self.communityHeader}
|
||||
)"""
|
||||
|
||||
proc fromJson*(t: JsonNode, T: typedesc[CommunityCollectibleHeader]): CommunityCollectibleHeader {.inline.} =
|
||||
result = CommunityCollectibleHeader()
|
||||
result.id = fromJson(t["id"], CollectibleUniqueID)
|
||||
result.name = t["name"].getStr()
|
||||
result.communityHeader = fromJson(t[communityHeaderField], CollectibleCommunityHeader)
|
||||
|
||||
# CollectibleBalance
|
||||
proc `$`*(self: CollectibleBalance): string =
|
||||
return fmt"""CollectibleBalance(
|
||||
|
|
Loading…
Reference in New Issue