fix: fix watchonly collectibles
This commit is contained in:
parent
98d4c7ef1e
commit
c2ed0da1ca
|
@ -43,6 +43,20 @@ QtObject:
|
|||
|
||||
proc setCurrentAssetList*(self: WalletView, assetList: seq[Asset])
|
||||
|
||||
proc currentCollectiblesListChanged*(self: WalletView) {.signal.}
|
||||
|
||||
proc getCurrentCollectiblesList(self: WalletView): QVariant {.slot.} =
|
||||
return newQVariant(self.currentCollectiblesList)
|
||||
|
||||
proc setCurrentCollectiblesList*(self: WalletView, collectibles: seq[Collectible]) =
|
||||
self.currentCollectiblesList.setNewData(collectibles)
|
||||
self.currentCollectiblesListChanged()
|
||||
|
||||
QtProperty[QVariant] collectibles:
|
||||
read = getCurrentCollectiblesList
|
||||
write = setCurrentCollectiblesList
|
||||
notify = currentCollectiblesListChanged
|
||||
|
||||
proc setCurrentAccountByIndex*(self: WalletView, index: int) {.slot.} =
|
||||
if(self.accounts.rowCount() == 0): return
|
||||
|
||||
|
@ -51,6 +65,7 @@ QtObject:
|
|||
self.currentAccount.setAccountItem(selectedAccount)
|
||||
self.currentAccountChanged()
|
||||
self.setCurrentAssetList(selectedAccount.assetList)
|
||||
self.setCurrentCollectiblesList(selectedAccount.collectibles)
|
||||
|
||||
proc getCurrentAccount*(self: WalletView): QVariant {.slot.} =
|
||||
result = newQVariant(self.currentAccount)
|
||||
|
@ -88,20 +103,6 @@ QtObject:
|
|||
write = setCurrentTransactions
|
||||
notify = currentTransactionsChanged
|
||||
|
||||
proc currentCollectiblesListChanged*(self: WalletView) {.signal.}
|
||||
|
||||
proc getCurrentCollectiblesList(self: WalletView): QVariant {.slot.} =
|
||||
return newQVariant(self.currentCollectiblesList)
|
||||
|
||||
proc setCurrentCollectiblesList*(self: WalletView, collectibles: seq[Collectible]) =
|
||||
self.currentCollectiblesList.setNewData(collectibles)
|
||||
self.currentCollectiblesListChanged()
|
||||
|
||||
QtProperty[QVariant] collectibles:
|
||||
read = getCurrentCollectiblesList
|
||||
write = setCurrentCollectiblesList
|
||||
notify = currentCollectiblesListChanged
|
||||
|
||||
proc totalFiatBalanceChanged*(self: WalletView) {.signal.}
|
||||
|
||||
proc getTotalFiatBalance(self: WalletView): string {.slot.} =
|
||||
|
|
|
@ -80,6 +80,7 @@ proc newAccount*(self: WalletModel, name: string, address: string, iconColor: st
|
|||
var assets: seq[Asset] = self.generateAccountConfiguredAssets(address)
|
||||
var account = WalletAccount(name: name, address: address, iconColor: iconColor, balance: fmt"{balance} {self.defaultCurrency}", assetList: assets, realFiatBalance: 0.0, publicKey: publicKey)
|
||||
updateBalance(account, self.getDefaultCurrency())
|
||||
account.collectibles = getAllCollectibles(parseAddress(account.address))
|
||||
account
|
||||
|
||||
proc initAccounts*(self: WalletModel) =
|
||||
|
|
|
@ -57,7 +57,11 @@ proc getCryptoKitties*(address: EthAddress): seq[Collectible] =
|
|||
let response = client.request(url)
|
||||
let kitties = parseJson(response.body)["kitties"]
|
||||
for kitty in kitties:
|
||||
result.add(Collectible(id: kitty["id"].str, name: kitty["name"].str, image: kitty["image_url"].str))
|
||||
var id = kitty["id"]
|
||||
var finalId = ""
|
||||
if (not (id.kind == JNull)):
|
||||
finalId = $id
|
||||
result.add(Collectible(id: finalId, name: kitty["name"].str, image: kitty["image_url"].str))
|
||||
except Exception as e:
|
||||
error "Error getting Cryptokitties", msg = e.msg
|
||||
|
||||
|
@ -77,9 +81,11 @@ proc getEthermons*(address: EthAddress): seq[Collectible] =
|
|||
|
||||
let response = client.request(url)
|
||||
let monsters = parseJson(response.body)["data"]
|
||||
var i = 0
|
||||
for monsterKey in json.keys(monsters):
|
||||
let monster = monsters[monsterKey]
|
||||
result.add(Collectible(id: monster["monster_id"].str, name: monster["class_name"].str, image: monster["image"].str))
|
||||
result.add(Collectible(id: $tokens[i], name: monster["class_name"].str, image: monster["image"].str))
|
||||
i = i + 1
|
||||
except Exception as e:
|
||||
error "Error getting Ethermons", msg = e.msg
|
||||
|
||||
|
|
Loading…
Reference in New Issue