get collectibles when requested instead of at login
This commit is contained in:
parent
d175e549ac
commit
649d0a2149
|
@ -60,7 +60,6 @@ QtObject:
|
||||||
self.currentAccount.setAccountItem(selectedAccount)
|
self.currentAccount.setAccountItem(selectedAccount)
|
||||||
self.currentAccountChanged()
|
self.currentAccountChanged()
|
||||||
self.setCurrentAssetList(selectedAccount.assetList)
|
self.setCurrentAssetList(selectedAccount.assetList)
|
||||||
self.setCurrentCollectiblesList(selectedAccount.collectibles)
|
|
||||||
|
|
||||||
proc getCurrentAccount*(self: WalletView): QVariant {.slot.} =
|
proc getCurrentAccount*(self: WalletView): QVariant {.slot.} =
|
||||||
result = newQVariant(self.currentAccount)
|
result = newQVariant(self.currentAccount)
|
||||||
|
@ -119,7 +118,6 @@ QtObject:
|
||||||
# If it's the first account we ever get, use its list as our first lists
|
# If it's the first account we ever get, use its list as our first lists
|
||||||
if (self.accounts.rowCount == 1):
|
if (self.accounts.rowCount == 1):
|
||||||
self.setCurrentAssetList(account.assetList)
|
self.setCurrentAssetList(account.assetList)
|
||||||
self.setCurrentCollectiblesList(account.collectibles)
|
|
||||||
self.setCurrentAccountByIndex(0)
|
self.setCurrentAccountByIndex(0)
|
||||||
self.accountListChanged()
|
self.accountListChanged()
|
||||||
|
|
||||||
|
@ -191,10 +189,12 @@ QtObject:
|
||||||
self.accountListChanged()
|
self.accountListChanged()
|
||||||
self.accounts.forceUpdate()
|
self.accounts.forceUpdate()
|
||||||
self.setCurrentAssetList(self.currentAccount.account.assetList)
|
self.setCurrentAssetList(self.currentAccount.account.assetList)
|
||||||
self.setCurrentCollectiblesList(self.currentAccount.account.collectibles)
|
|
||||||
|
|
||||||
proc addCustomToken*(self: WalletView, address: string, name: string, symbol: string, decimals: string) {.slot.} =
|
proc addCustomToken*(self: WalletView, address: string, name: string, symbol: string, decimals: string) {.slot.} =
|
||||||
self.status.wallet.toggleAsset(symbol, true, address, name, parseInt(decimals), "")
|
self.status.wallet.toggleAsset(symbol, true, address, name, parseInt(decimals), "")
|
||||||
|
|
||||||
proc loadTransactionsForAccount*(self: WalletView, address: string) {.slot.} =
|
proc loadTransactionsForAccount*(self: WalletView, address: string) {.slot.} =
|
||||||
self.setCurrentTransactions(self.status.wallet.getTransfersByAddress(address))
|
self.setCurrentTransactions(self.status.wallet.getTransfersByAddress(address))
|
||||||
|
|
||||||
|
proc loadCollectiblesForAccount*(self: WalletView, address: string) {.slot.} =
|
||||||
|
self.setCurrentCollectiblesList(self.status.wallet.getAllCollectibles(address))
|
||||||
|
|
|
@ -71,16 +71,12 @@ proc populateAccount*(self: WalletModel, walletAccount: var WalletAccount, balan
|
||||||
walletAccount.balance = fmt"{balance} {self.defaultCurrency}"
|
walletAccount.balance = fmt"{balance} {self.defaultCurrency}"
|
||||||
walletAccount.assetList = assets
|
walletAccount.assetList = assets
|
||||||
walletAccount.realFiatBalance = 0.0
|
walletAccount.realFiatBalance = 0.0
|
||||||
# Get NFTs
|
|
||||||
# TODO(jrainville): make this async because otherwise it can block the thread for a long time
|
|
||||||
walletAccount.collectibles = getAllCollectibles(parseAddress(walletAccount.address))
|
|
||||||
updateBalance(walletAccount, self.getDefaultCurrency())
|
updateBalance(walletAccount, self.getDefaultCurrency())
|
||||||
|
|
||||||
proc newAccount*(self: WalletModel, name: string, address: string, iconColor: string, balance: string, publicKey: string): WalletAccount =
|
proc newAccount*(self: WalletModel, name: string, address: string, iconColor: string, balance: string, publicKey: string): WalletAccount =
|
||||||
var assets: seq[Asset] = self.generateAccountConfiguredAssets(address)
|
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)
|
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())
|
updateBalance(account, self.getDefaultCurrency())
|
||||||
account.collectibles = getAllCollectibles(parseAddress(account.address))
|
|
||||||
account
|
account
|
||||||
|
|
||||||
proc initAccounts*(self: WalletModel) =
|
proc initAccounts*(self: WalletModel) =
|
||||||
|
@ -158,3 +154,4 @@ proc getTransfersByAddress*(self: WalletModel, address: string): seq[Transaction
|
||||||
proc validateMnemonic*(self: WalletModel, mnemonic: string): string =
|
proc validateMnemonic*(self: WalletModel, mnemonic: string): string =
|
||||||
result = status_wallet.validateMnemonic(mnemonic).parseJSON()["error"].getStr
|
result = status_wallet.validateMnemonic(mnemonic).parseJSON()["error"].getStr
|
||||||
|
|
||||||
|
proc getAllCollectibles*(self: WalletModel, address: string): seq[Collectible] = getAllCollectibles(address)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import strformat, httpclient, json, chronicles, sequtils, strutils, tables
|
import strformat, httpclient, json, chronicles, sequtils, strutils, tables
|
||||||
|
from eth/common/utils import parseAddress
|
||||||
import ../libstatus/core as status
|
import ../libstatus/core as status
|
||||||
import ../libstatus/contracts as contracts
|
import ../libstatus/contracts as contracts
|
||||||
import eth/common/eth_types
|
import eth/common/eth_types
|
||||||
|
@ -114,5 +115,6 @@ proc getKudos*(address: EthAddress): seq[Collectible] =
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error getting Kudos", msg = e.msg
|
error "Error getting Kudos", msg = e.msg
|
||||||
|
|
||||||
proc getAllCollectibles*(address: EthAddress): seq[Collectible] =
|
proc getAllCollectibles*(address: string): seq[Collectible] =
|
||||||
result = concat(getCryptoKitties(address), getEthermons(address), getKudos(address))
|
let eth_address = parseAddress(address)
|
||||||
|
result = concat(getCryptoKitties(eth_address), getEthermons(eth_address), getKudos(eth_address))
|
||||||
|
|
|
@ -75,6 +75,9 @@ SplitView {
|
||||||
anchors.left: assetBtn.right
|
anchors.left: assetBtn.right
|
||||||
anchors.leftMargin: 32
|
anchors.leftMargin: 32
|
||||||
btnText: "Collectibles"
|
btnText: "Collectibles"
|
||||||
|
onClicked: {
|
||||||
|
walletModel.loadCollectiblesForAccount(walletModel.currentAccount.address)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
StatusTabButton {
|
StatusTabButton {
|
||||||
id: historyBtn
|
id: historyBtn
|
||||||
|
|
Loading…
Reference in New Issue