feat(@wallet): remove usage of wallet section current
This commit is contained in:
parent
75d17b4a07
commit
542e5fdb6c
|
@ -69,3 +69,6 @@ proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairD
|
|||
|
||||
proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
|
||||
return self.walletAccountService.getAccountByAddress(address)
|
||||
|
||||
proc updateAccount*(self: Controller, address: string, accountName: string, color: string, emoji: string) =
|
||||
discard self.walletAccountService.updateWalletAccount(address, accountName, color, emoji)
|
|
@ -19,6 +19,9 @@ method deleteAccount*(self: AccessInterface, keyUid: string, address: string) {.
|
|||
method refreshWalletAccounts*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method updateAccount*(self: AccessInterface, address: string, accountName: string, color: string, emoji: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# View Delegate Interface
|
||||
# Delegate for the view must be declared here due to use of QtObject and multi
|
||||
# inheritance, which is not well supported in Nim.
|
||||
|
|
|
@ -149,3 +149,6 @@ method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid:
|
|||
return
|
||||
let doPasswordHashing = pin.len != PINLengthForStatusApp
|
||||
self.controller.deleteAccount(self.processingWalletAccount.address, password, doPasswordHashing)
|
||||
|
||||
method updateAccount*(self: Module, address: string, accountName: string, color: string, emoji: string) =
|
||||
self.controller.updateAccount(address, accountName, color, emoji)
|
|
@ -42,3 +42,6 @@ QtObject:
|
|||
|
||||
proc deleteAccount*(self: View, keyUid: string, address: string) {.slot.} =
|
||||
self.delegate.deleteAccount(keyUid, address)
|
||||
|
||||
proc updateAccount(self: View, address: string, accountName: string, color: string, emoji: string) {.slot.} =
|
||||
self.delegate.updateAccount(address, accountName, color, emoji)
|
|
@ -13,7 +13,6 @@ type
|
|||
networkService: network_service.Service
|
||||
tokenService: token_service.Service
|
||||
currencyService: currency_service.Service
|
||||
collectibleService: collectible_service.Service
|
||||
|
||||
proc newController*(
|
||||
delegate: io_interface.AccessInterface,
|
||||
|
@ -21,7 +20,6 @@ proc newController*(
|
|||
networkService: network_service.Service,
|
||||
tokenService: token_service.Service,
|
||||
currencyService: currency_service.Service,
|
||||
collectibleService: collectible_service.Service,
|
||||
): Controller =
|
||||
result = Controller()
|
||||
result.delegate = delegate
|
||||
|
@ -29,7 +27,6 @@ proc newController*(
|
|||
result.networkService = networkService
|
||||
result.tokenService = tokenService
|
||||
result.currencyService = currencyService
|
||||
result.collectibleService = collectibleService
|
||||
|
||||
proc delete*(self: Controller) =
|
||||
discard
|
||||
|
@ -43,12 +40,6 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
|
|||
proc getWalletAccount*(self: Controller, accountIndex: int): wallet_account_service.WalletAccountDto =
|
||||
return self.walletAccountService.getWalletAccount(accountIndex)
|
||||
|
||||
proc update*(self: Controller, address: string, accountName: string, color: string, emoji: string) =
|
||||
discard self.walletAccountService.updateWalletAccount(address, accountName, color, emoji)
|
||||
|
||||
method findTokenSymbolByAddress*(self: Controller, address: string): string =
|
||||
return self.walletAccountService.findTokenSymbolByAddress(address)
|
||||
|
||||
proc getChainIds*(self: Controller): seq[int] =
|
||||
return self.networkService.getNetworks().map(n => n.chainId)
|
||||
|
||||
|
@ -60,9 +51,3 @@ proc getCurrentCurrency*(self: Controller): string =
|
|||
|
||||
proc getCurrencyFormat*(self: Controller, symbol: string): CurrencyFormatDto =
|
||||
return self.currencyService.getCurrencyFormat(symbol)
|
||||
|
||||
proc getAllMigratedKeyPairs*(self: Controller): seq[KeyPairDto] =
|
||||
return self.walletAccountService.getAllMigratedKeyPairs()
|
||||
|
||||
proc getHasCollectiblesCache*(self: Controller, address: string): bool =
|
||||
return self.collectibleService.areCollectionsLoaded(address)
|
||||
|
|
|
@ -14,15 +14,6 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
|||
method switchAccount*(self: AccessInterface, accountIndex: int) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method update*(self: AccessInterface, address: string, accountName: string, color: string, emoji: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method findTokenSymbolByAddress*(self: AccessInterface, address: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getHasCollectiblesCache*(self: AccessInterface, address: string): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# View Delegate Interface
|
||||
# Delegate for the view must be declared here due to use of QtObject and multi
|
||||
# inheritance, which is not well supported in Nim.
|
||||
|
|
|
@ -3,82 +3,26 @@ import ../../../shared_models/currency_amount
|
|||
|
||||
type
|
||||
Item* = object
|
||||
name: string
|
||||
address: string
|
||||
path: string
|
||||
color: string
|
||||
walletType: string
|
||||
currencyBalance: CurrencyAmount
|
||||
emoji: string
|
||||
keyUid: string
|
||||
assetsLoading: bool
|
||||
hasBalanceCache: bool
|
||||
hasMarketValuesCache: bool
|
||||
|
||||
proc initItem*(
|
||||
name: string = "",
|
||||
address: string = "",
|
||||
path: string = "",
|
||||
color: string = "",
|
||||
walletType: string = "",
|
||||
currencyBalance: CurrencyAmount = nil,
|
||||
emoji: string = "",
|
||||
keyUid: string = "",
|
||||
assetsLoading: bool = true,
|
||||
hasBalanceCache: bool = false,
|
||||
hasMarketValuesCache: bool = false
|
||||
): Item =
|
||||
result.name = name
|
||||
result.address = address
|
||||
result.path = path
|
||||
result.color = color
|
||||
result.walletType = walletType
|
||||
result.currencyBalance = currencyBalance
|
||||
result.emoji = emoji
|
||||
result.keyUid = keyUid
|
||||
result.assetsLoading = assetsLoading
|
||||
result.hasBalanceCache = hasBalanceCache
|
||||
result.hasMarketValuesCache = hasMarketValuesCache
|
||||
|
||||
proc `$`*(self: Item): string =
|
||||
result = fmt"""WalletAccountItem(
|
||||
name: {self.name},
|
||||
address: {self.address},
|
||||
path: {self.path},
|
||||
color: {self.color},
|
||||
walletType: {self.walletType},
|
||||
currencyBalance: {self.currencyBalance},
|
||||
emoji: {self.emoji},
|
||||
keyUid: {self.keyUid},
|
||||
assetsLoading: {self.assetsLoading},
|
||||
hasBalanceCache: {self.hasBalanceCache},
|
||||
hasMarketValuesCache: {self.hasMarketValuesCache},
|
||||
]"""
|
||||
|
||||
proc getName*(self: Item): string =
|
||||
return self.name
|
||||
|
||||
proc getAddress*(self: Item): string =
|
||||
return self.address
|
||||
|
||||
proc getPath*(self: Item): string =
|
||||
return self.path
|
||||
|
||||
proc getEmoji*(self: Item): string =
|
||||
return self.emoji
|
||||
|
||||
proc getColor*(self: Item): string =
|
||||
return self.color
|
||||
|
||||
proc getWalletType*(self: Item): string =
|
||||
return self.walletType
|
||||
|
||||
proc getCurrencyBalance*(self: Item): CurrencyAmount =
|
||||
return self.currencyBalance
|
||||
|
||||
proc getKeyUid*(self: Item): string =
|
||||
return self.keyUid
|
||||
|
||||
proc getAssetsLoading*(self: Item): bool =
|
||||
return self.assetsLoading
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import ../../../../../app_service/service/token/service as token_service
|
|||
import ../../../../../app_service/service/currency/service as currency_service
|
||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../../app_service/service/network/service as network_service
|
||||
import ../../../../../app_service/service/node/service as node_service
|
||||
import ../../../../../app_service/service/network_connection/service as network_connection
|
||||
import ../../../../../app_service/service/collectible/service as collectible_service
|
||||
import ../../../../../app_service/service/node/service as node_service
|
||||
import ../../../shared_models/currency_amount_utils
|
||||
import ../../../shared_models/currency_amount
|
||||
import ../../../shared_models/token_model as token_model
|
||||
|
@ -43,14 +43,13 @@ proc newModule*(
|
|||
networkService: network_service.Service,
|
||||
tokenService: token_service.Service,
|
||||
currencyService: currency_service.Service,
|
||||
collectibleService: collectible_service.Service,
|
||||
): Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
result.events = events
|
||||
result.currentAccountIndex = 0
|
||||
result.view = newView(result)
|
||||
result.controller = newController(result, walletAccountService, networkService, tokenService, currencyService, collectibleService)
|
||||
result.controller = newController(result, walletAccountService, networkService, tokenService, currencyService)
|
||||
result.moduleLoaded = false
|
||||
|
||||
method delete*(self: Module) =
|
||||
|
@ -61,10 +60,9 @@ proc setLoadingAssets(self: Module) =
|
|||
for i in 0 ..< 25:
|
||||
loadingTokenItems.add(token_item.initLoadingItem())
|
||||
self.view.getAssetsModel().setItems(loadingTokenItems)
|
||||
self.view.setCurrencyBalance(newCurrencyAmount())
|
||||
|
||||
method load*(self: Module) =
|
||||
singletonInstance.engine.setRootContextProperty("walletSectionCurrent", newQVariant(self.view))
|
||||
singletonInstance.engine.setRootContextProperty("walletSectionAssets", newQVariant(self.view))
|
||||
|
||||
# these connections should be part of the controller's init method
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_SAVED) do(e:Args):
|
||||
|
@ -123,59 +121,22 @@ proc setAssetsAndBalance(self: Module, tokens: seq[WalletTokenDto]) =
|
|||
let totalCurrencyBalanceForAllAssets = tokens.map(t => t.getCurrencyBalance(enabledChainIds, currency)).foldl(a + b, 0.0)
|
||||
|
||||
self.view.getAssetsModel().setItems(items)
|
||||
self.view.setCurrencyBalance(currencyAmountToItem(totalCurrencyBalanceForAllAssets, currencyFormat))
|
||||
|
||||
method switchAccount*(self: Module, accountIndex: int) =
|
||||
var walletAccount = self.controller.getWalletAccount(accountIndex)
|
||||
self.currentAccountIndex = accountIndex
|
||||
if walletAccount.isNil:
|
||||
self.currentAccountIndex = 0
|
||||
walletAccount = self.controller.getWalletAccount(self.currentAccountIndex)
|
||||
|
||||
let keyPairMigrated = proc(migratedKeyPairs: seq[KeyPairDto], keyUid: string): bool =
|
||||
for kp in migratedKeyPairs:
|
||||
if kp.keyUid == keyUid:
|
||||
return true
|
||||
return false
|
||||
let accountItem = walletAccountToItem(walletAccount)
|
||||
self.view.setData(accountItem)
|
||||
|
||||
let migratedKeyPairs = self.controller.getAllMigratedKeyPairs()
|
||||
let currency = self.controller.getCurrentCurrency()
|
||||
let currencyFormat = self.controller.getCurrencyFormat(currency)
|
||||
if walletAccount.tokens.len == 0 and walletAccount.assetsLoading:
|
||||
self.setLoadingAssets()
|
||||
else:
|
||||
self.setAssetsAndBalance(walletAccount.tokens)
|
||||
|
||||
let chainIds = self.controller.getChainIds()
|
||||
let enabledChainIds = self.controller.getEnabledChainIds()
|
||||
|
||||
let defaultAccount = self.controller.getWalletAccount(0) # can safely do this as the account will always contain atleast one account
|
||||
if not defaultAccount.isNil:
|
||||
let defaultAccountTokenFormats = collect(initTable()):
|
||||
for t in defaultAccount.tokens: {t.symbol: self.controller.getCurrencyFormat(t.symbol)}
|
||||
|
||||
let defaultAccountItem = walletAccountToItem(
|
||||
defaultAccount,
|
||||
enabledChainIds,
|
||||
currency,
|
||||
currencyFormat,
|
||||
)
|
||||
|
||||
self.view.setDefaultWalletAccount(defaultAccountItem)
|
||||
|
||||
let walletAccount = self.controller.getWalletAccount(accountIndex)
|
||||
if not walletAccount.isNil:
|
||||
let accountTokenFormats = collect(initTable()):
|
||||
for t in walletAccount.tokens: {t.symbol: self.controller.getCurrencyFormat(t.symbol)}
|
||||
|
||||
let accountItem = walletAccountToItem(
|
||||
walletAccount,
|
||||
enabledChainIds,
|
||||
currency,
|
||||
currencyFormat,
|
||||
)
|
||||
|
||||
self.view.setData(accountItem)
|
||||
|
||||
if walletAccount.tokens.len == 0 and walletAccount.assetsLoading:
|
||||
self.setLoadingAssets()
|
||||
else:
|
||||
self.setAssetsAndBalance(walletAccount.tokens)
|
||||
|
||||
method update*(self: Module, address: string, accountName: string, color: string, emoji: string) =
|
||||
self.controller.update(address, accountName, color, emoji)
|
||||
|
||||
proc onTokensRebuilt(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]], hasBalanceCache: bool, hasMarketValuesCache: bool) =
|
||||
let walletAccount = self.controller.getWalletAccount(self.currentAccountIndex)
|
||||
|
@ -186,21 +147,14 @@ proc onTokensRebuilt(self: Module, accountsTokens: OrderedTable[string, seq[Wall
|
|||
self.view.setCacheValues(hasBalanceCache, hasMarketValuesCache)
|
||||
|
||||
proc onCurrencyFormatsUpdated(self: Module) =
|
||||
# Update assets
|
||||
let walletAccount = self.controller.getWalletAccount(self.currentAccountIndex)
|
||||
if walletAccount.tokens.len == 0 and walletAccount.assetsLoading:
|
||||
self.setLoadingAssets()
|
||||
else:
|
||||
self.setAssetsAndBalance(walletAccount.tokens)
|
||||
|
||||
method findTokenSymbolByAddress*(self: Module, address: string): string =
|
||||
return self.controller.findTokenSymbolByAddress(address)
|
||||
|
||||
proc onAccountAdded(self: Module, account: WalletAccountDto) =
|
||||
self.switchAccount(self.currentAccountIndex)
|
||||
|
||||
proc onAccountRemoved(self: Module, account: WalletAccountDto) =
|
||||
self.switchAccount(self.currentAccountIndex)
|
||||
|
||||
method getHasCollectiblesCache*(self: Module, address: string): bool =
|
||||
return self.controller.getHasCollectiblesCache(address)
|
||||
|
|
|
@ -1,25 +1,10 @@
|
|||
import ./item
|
||||
|
||||
import ../../../../../app_service/service/wallet_account/dto
|
||||
import ../../../../../app_service/service/currency/dto as currency_dto
|
||||
import ../../../shared_models/currency_amount
|
||||
import ../../../shared_models/currency_amount_utils
|
||||
|
||||
|
||||
proc walletAccountToItem*(
|
||||
w: WalletAccountDto,
|
||||
enabledChainIds: seq[int],
|
||||
currency: string,
|
||||
currencyFormat: CurrencyFormatDto,
|
||||
) : item.Item =
|
||||
) : item.Item =
|
||||
return item.initItem(
|
||||
w.name,
|
||||
w.address,
|
||||
w.path,
|
||||
w.color,
|
||||
w.walletType,
|
||||
currencyAmountToItem(w.getCurrencyBalance(enabledChainIds, currency), currencyFormat),
|
||||
w.emoji,
|
||||
w.keyUid,
|
||||
w.assetsLoading,
|
||||
)
|
||||
|
|
|
@ -3,27 +3,14 @@ import NimQml, sequtils, sugar, json
|
|||
import ./io_interface
|
||||
import ../../../shared_models/token_model as token_model
|
||||
import ../../../shared_models/token_item as token_item
|
||||
import ../../../shared_models/currency_amount
|
||||
|
||||
import ./item as account_item
|
||||
|
||||
const GENERATED = "generated"
|
||||
const GENERATED_FROM_IMPORTED = "generated from imported accounts"
|
||||
|
||||
QtObject:
|
||||
type
|
||||
View* = ref object of QObject
|
||||
delegate: io_interface.AccessInterface
|
||||
defaultAccount: account_item.Item
|
||||
name: string
|
||||
keyUid: string
|
||||
address: string
|
||||
path: string
|
||||
color: string
|
||||
walletType: string
|
||||
currencyBalance: CurrencyAmount
|
||||
assets: token_model.Model
|
||||
emoji: string
|
||||
assetsLoading: bool
|
||||
hasBalanceCache: bool
|
||||
hasMarketValuesCache: bool
|
||||
|
@ -44,66 +31,6 @@ QtObject:
|
|||
proc load*(self: View) =
|
||||
self.delegate.viewDidLoad()
|
||||
|
||||
proc getName(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.name)
|
||||
|
||||
proc nameChanged(self: View) {.signal.}
|
||||
|
||||
QtProperty[QVariant] name:
|
||||
read = getName
|
||||
notify = nameChanged
|
||||
|
||||
proc getKeyUid(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.keyUid)
|
||||
proc keyUidChanged(self: View) {.signal.}
|
||||
QtProperty[QVariant] keyUid:
|
||||
read = getKeyUid
|
||||
notify = keyUidChanged
|
||||
|
||||
proc getAddress(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.address)
|
||||
proc addressChanged(self: View) {.signal.}
|
||||
QtProperty[QVariant] address:
|
||||
read = getAddress
|
||||
notify = addressChanged
|
||||
|
||||
proc getPath(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.path)
|
||||
|
||||
proc pathChanged(self: View) {.signal.}
|
||||
|
||||
QtProperty[QVariant] path:
|
||||
read = getPath
|
||||
notify = pathChanged
|
||||
|
||||
proc getColor(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.color)
|
||||
|
||||
proc colorChanged(self: View) {.signal.}
|
||||
|
||||
QtProperty[QVariant] color:
|
||||
read = getColor
|
||||
notify = colorChanged
|
||||
|
||||
proc getWalletType(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.walletType)
|
||||
|
||||
proc walletTypeChanged(self: View) {.signal.}
|
||||
|
||||
QtProperty[QVariant] walletType:
|
||||
read = getWalletType
|
||||
notify = walletTypeChanged
|
||||
|
||||
proc currencyBalanceChanged(self: View) {.signal.}
|
||||
proc getCurrencyBalance*(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.currencyBalance)
|
||||
proc setCurrencyBalance*(self: View, value: CurrencyAmount) =
|
||||
self.currencyBalance = value
|
||||
self.currencyBalanceChanged()
|
||||
QtProperty[QVariant] currencyBalance:
|
||||
read = getCurrencyBalance
|
||||
notify = currencyBalanceChanged
|
||||
|
||||
proc getAssetsModel*(self: View): token_model.Model =
|
||||
return self.assets
|
||||
|
||||
|
@ -114,15 +41,6 @@ QtObject:
|
|||
read = getAssets
|
||||
notify = assetsChanged
|
||||
|
||||
proc getEmoji(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.emoji)
|
||||
|
||||
proc emojiChanged(self: View) {.signal.}
|
||||
|
||||
QtProperty[QVariant] emoji:
|
||||
read = getEmoji
|
||||
notify = emojiChanged
|
||||
|
||||
proc getAssetsLoading(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.assetsLoading)
|
||||
proc assetsLoadingChanged(self: View) {.signal.}
|
||||
|
@ -149,51 +67,15 @@ QtObject:
|
|||
read = getHasMarketValuesCache
|
||||
notify = hasMarketValuesCacheChanged
|
||||
|
||||
proc update(self: View, address: string, accountName: string, color: string, emoji: string) {.slot.} =
|
||||
self.delegate.update(address, accountName, color, emoji)
|
||||
|
||||
proc setDefaultWalletAccount*(self: View, default: account_item.Item) =
|
||||
self.defaultAccount = default
|
||||
|
||||
proc setData*(self: View, item: account_item.Item) =
|
||||
if(self.name != item.getName()):
|
||||
self.name = item.getName()
|
||||
self.nameChanged()
|
||||
if(self.keyUid != item.getKeyUid()):
|
||||
self.keyUid = item.getKeyUid()
|
||||
self.keyUidChanged()
|
||||
if(self.address != item.getAddress()):
|
||||
self.address = item.getAddress()
|
||||
self.addressChanged()
|
||||
if(self.path != item.getPath()):
|
||||
self.path = item.getPath()
|
||||
self.pathChanged()
|
||||
if(self.color != item.getColor()):
|
||||
self.color = item.getColor()
|
||||
self.colorChanged()
|
||||
if(self.walletType != item.getWalletType()):
|
||||
self.walletType = item.getWalletType()
|
||||
self.walletTypeChanged()
|
||||
if(self.emoji != item.getEmoji()):
|
||||
self.emoji = item.getEmoji()
|
||||
self.emojiChanged()
|
||||
self.setAssetsLoading(item.getAssetsLoading())
|
||||
self.hasBalanceCache = item.getHasBalanceCache()
|
||||
self.hasBalanceCacheChanged()
|
||||
self.hasMarketValuesCache = item.getHasMarketValuesCache()
|
||||
self.hasMarketValuesCacheChanged()
|
||||
|
||||
proc findTokenSymbolByAddress*(self: View, address: string): string {.slot.} =
|
||||
return self.delegate.findTokenSymbolByAddress(address)
|
||||
|
||||
proc hasGas*(self: View, chainId: int, nativeGasSymbol: string, requiredGas: float): bool {.slot.} =
|
||||
return self.assets.hasGas(chainId, nativeGasSymbol, requiredGas)
|
||||
|
||||
proc setCacheValues*(self: View, hasBalanceCache: bool, hasMarketValuesCache: bool) =
|
||||
self.hasBalanceCache = hasBalanceCache
|
||||
self.hasBalanceCacheChanged()
|
||||
self.hasMarketValuesCache = hasMarketValuesCache
|
||||
self.hasMarketValuesCacheChanged()
|
||||
|
||||
proc getHasCollectiblesCache(self: View): bool {.slot.} =
|
||||
return self.delegate.getHasCollectiblesCache(self.address)
|
||||
|
|
|
@ -89,3 +89,6 @@ proc getCollectible*(self: Controller, chainId: int, id: UniqueID) : Collectible
|
|||
|
||||
proc getCollection*(self: Controller, chainId: int, slug: string) : CollectionDto =
|
||||
self.collectibleService.getCollection(chainId, slug)
|
||||
|
||||
proc getHasCollectiblesCache*(self: Controller, address: string): bool =
|
||||
return self.collectibleService.areCollectionsLoaded(address)
|
|
@ -31,6 +31,9 @@ method appendCollectibles*(self: AccessInterface, chainId: int, address: string,
|
|||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getHasCollectiblesCache*(self: AccessInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# Methods called by submodules of this module
|
||||
method collectiblesModuleDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -142,3 +142,6 @@ method appendCollectibles*(self: Module, chainId: int, address: string, data: Co
|
|||
self.view.appendCollectibles(newCollectibles)
|
||||
|
||||
self.view.setAllLoaded(data.allLoaded)
|
||||
|
||||
method getHasCollectiblesCache*(self: Module): bool =
|
||||
return self.controller.getHasCollectiblesCache(self.address)
|
|
@ -49,3 +49,5 @@ QtObject:
|
|||
proc appendCollectibles*(self: View, collectibles: seq[Item]) =
|
||||
self.model.appendItems(collectibles)
|
||||
|
||||
proc getHasCollectiblesCache(self: View): bool {.slot.} =
|
||||
return self.delegate.getHasCollectiblesCache()
|
|
@ -87,7 +87,7 @@ proc newModule*(
|
|||
result.accountsModule = accounts_module.newModule(result, events, walletAccountService, networkService, currencyService)
|
||||
result.allTokensModule = all_tokens_module.newModule(result, events, tokenService, walletAccountService)
|
||||
result.collectiblesModule = collectibles_module.newModule(result, events, collectibleService, walletAccountService, networkService, nodeService, networkConnectionService)
|
||||
result.assetsModule = assets_module.newModule(result, events, walletAccountService, networkService, tokenService, currencyService, collectibleService)
|
||||
result.assetsModule = assets_module.newModule(result, events, walletAccountService, networkService, tokenService, currencyService)
|
||||
result.transactionsModule = transactions_module.newModule(result, events, transactionService, walletAccountService, networkService, currencyService)
|
||||
result.sendModule = send_module.newModule(result, events, walletAccountService, networkService, currencyService, transactionService)
|
||||
result.savedAddressesModule = saved_addresses_module.newModule(result, events, savedAddressService)
|
||||
|
|
|
@ -6,20 +6,17 @@ type
|
|||
mixedCaseAddress: string
|
||||
ens: string
|
||||
balanceLoading: bool
|
||||
hasBalanceCache: bool
|
||||
|
||||
proc initItem*(
|
||||
name: string = "",
|
||||
mixedCaseAddress: string = "",
|
||||
ens: string = "",
|
||||
balanceLoading: bool = true,
|
||||
hasBalanceCache: bool = false,
|
||||
): Item =
|
||||
result.name = name
|
||||
result.mixedCaseAddress = mixedCaseAddress
|
||||
result.ens = ens
|
||||
result.balanceLoading = balanceLoading
|
||||
result.hasBalanceCache = hasBalanceCache
|
||||
|
||||
proc `$`*(self: Item): string =
|
||||
result = fmt"""OverviewItem(
|
||||
|
@ -27,7 +24,6 @@ proc `$`*(self: Item): string =
|
|||
mixedCaseAddress: {self.mixedCaseAddress},
|
||||
ens: {self.ens},
|
||||
balanceLoading: {self.balanceLoading},
|
||||
hasBalanceCache: {self.hasBalanceCache},
|
||||
]"""
|
||||
|
||||
proc getName*(self: Item): string =
|
||||
|
@ -41,6 +37,3 @@ proc getEns*(self: Item): string =
|
|||
|
||||
proc getBalanceLoading*(self: Item): bool =
|
||||
return self.balanceLoading
|
||||
|
||||
proc getHasBalanceCache*(self: Item): bool =
|
||||
return self.hasBalanceCache
|
|
@ -23,7 +23,7 @@ type
|
|||
moduleLoaded: bool
|
||||
currentAccountIndex: int
|
||||
|
||||
proc onTokensRebuilt(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]], hasBalanceCache: bool)
|
||||
proc onTokensRebuilt(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]])
|
||||
proc onCurrencyFormatsUpdated(self: Module)
|
||||
proc onAccountAdded(self: Module, account: WalletAccountDto)
|
||||
proc onAccountRemoved(self: Module, account: WalletAccountDto)
|
||||
|
@ -69,7 +69,7 @@ method load*(self: Module) =
|
|||
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args):
|
||||
let arg = TokensPerAccountArgs(e)
|
||||
self.onTokensRebuilt(arg.accountsTokens, arg.hasBalanceCache)
|
||||
self.onTokensRebuilt(arg.accountsTokens)
|
||||
|
||||
self.events.on(SIGNAL_CURRENCY_FORMATS_UPDATED) do(e:Args):
|
||||
self.onCurrencyFormatsUpdated()
|
||||
|
@ -106,7 +106,6 @@ method switchAccount*(self: Module, accountIndex: int) =
|
|||
walletAccount.mixedCaseAddress,
|
||||
walletAccount.ens,
|
||||
walletAccount.assetsLoading,
|
||||
walletAccount.hasBalanceCache,
|
||||
)
|
||||
|
||||
self.view.setData(item)
|
||||
|
@ -115,12 +114,11 @@ method switchAccount*(self: Module, accountIndex: int) =
|
|||
else:
|
||||
self.setBalance(walletAccount.tokens)
|
||||
|
||||
proc onTokensRebuilt(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]], hasBalanceCache: bool) =
|
||||
proc onTokensRebuilt(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]]) =
|
||||
let walletAccount = self.controller.getWalletAccount(self.currentAccountIndex)
|
||||
if not accountsTokens.contains(walletAccount.address):
|
||||
return
|
||||
self.setBalance(accountsTokens[walletAccount.address])
|
||||
self.view.setCacheValues(hasBalanceCache)
|
||||
self.view.setBalanceLoading(false)
|
||||
|
||||
proc onCurrencyFormatsUpdated(self: Module) =
|
||||
|
|
|
@ -14,7 +14,6 @@ QtObject:
|
|||
currencyBalance: CurrencyAmount
|
||||
ens: string
|
||||
balanceLoading: bool
|
||||
hasBalanceCache*: bool
|
||||
|
||||
proc setup(self: View) =
|
||||
self.QObject.setup
|
||||
|
@ -73,13 +72,6 @@ QtObject:
|
|||
self.balanceLoading = balanceLoading
|
||||
self.balanceLoadingChanged()
|
||||
|
||||
proc getHasBalanceCache(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.hasBalanceCache)
|
||||
proc hasBalanceCacheChanged(self: View) {.signal.}
|
||||
QtProperty[QVariant] hasBalanceCache:
|
||||
read = getHasBalanceCache
|
||||
notify = hasBalanceCacheChanged
|
||||
|
||||
proc setData*(self: View, item: Item) =
|
||||
if(self.name != item.getName()):
|
||||
self.name = item.getName()
|
||||
|
@ -91,9 +83,3 @@ QtObject:
|
|||
self.ens = item.getEns()
|
||||
self.ensChanged()
|
||||
self.setBalanceLoading(item.getBalanceLoading())
|
||||
self.hasBalanceCache = item.getHasBalanceCache()
|
||||
self.hasBalanceCacheChanged()
|
||||
|
||||
proc setCacheValues*(self: View, hasBalanceCache: bool) =
|
||||
self.hasBalanceCache = hasBalanceCache
|
||||
self.hasBalanceCacheChanged()
|
|
@ -16,7 +16,7 @@ type
|
|||
QtObject:
|
||||
type
|
||||
AccountsModel* = ref object of QAbstractListModel
|
||||
items: seq[AccountItem]
|
||||
items*: seq[AccountItem]
|
||||
|
||||
proc delete(self: AccountsModel) =
|
||||
self.items = @[]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import NimQml, sequtils, strutils, stint
|
||||
|
||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../shared_models/token_model
|
||||
|
||||
import ./accounts_model
|
||||
import ./account_item
|
||||
|
@ -103,3 +104,10 @@ QtObject:
|
|||
return self.delegate.getEstimatedTime(chainId, maxFeePerGas)
|
||||
|
||||
proc suggestedRoutesReady*(self: View, suggestedRoutes: string) {.signal.}
|
||||
|
||||
proc hasGas*(self: View, address: string, chainId: int, nativeGasSymbol: string, requiredGas: float): bool {.slot.} =
|
||||
for account in self.accounts.items:
|
||||
if account.getAddress() == address:
|
||||
return account.getAssets().hasGas(chainId, nativeGasSymbol, requiredGas)
|
||||
|
||||
return false
|
|
@ -204,11 +204,11 @@ Popup {
|
|||
|
||||
AssetsView {
|
||||
id: assetsTab
|
||||
account: WalletStore.dappBrowserAccount
|
||||
assets: WalletStore.dappBrowserAccount.assets
|
||||
}
|
||||
HistoryView {
|
||||
id: historyTab
|
||||
assets: WalletStore.dappBrowserAccount
|
||||
overview: WalletStore.dappBrowserAccount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -516,7 +516,6 @@ QtObject {
|
|||
// Needed for TX in chat for stickers and via contact
|
||||
|
||||
property var accounts: walletSectionSendInst.accounts
|
||||
property var currentAccount: walletSectionCurrent
|
||||
property string currentCurrency: walletSection.currentCurrency
|
||||
property CurrenciesStore currencyStore: CurrenciesStore {}
|
||||
property var allNetworks: networksModule.all
|
||||
|
|
|
@ -18,7 +18,9 @@ QtObject {
|
|||
}
|
||||
|
||||
// TODO(alaibe): there should be no access to wallet section, create collectible in profile
|
||||
property var overview: walletSectionOverview
|
||||
property var flatCollectibles: Global.appIsReady ? walletSectionCollectibles.model : null
|
||||
|
||||
property var accounts: Global.appIsReady? accountsModule.accounts : null
|
||||
|
||||
function deleteAccount(keyUid, address) {
|
||||
|
|
|
@ -120,7 +120,7 @@ Item {
|
|||
sendType: Constants.SendType.ENSRelease
|
||||
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
|
||||
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0)
|
||||
preSelectedAsset: store.getAsset(releaseEnsModal.store.currentAccount.assets, "ETH")
|
||||
preSelectedAsset: store.getAsset(releaseEnsModal.store.assets, "ETH")
|
||||
sendTransaction: function() {
|
||||
if(bestRoutes.length === 1) {
|
||||
let path = bestRoutes[0]
|
||||
|
|
|
@ -66,7 +66,7 @@ Item {
|
|||
sendType: Constants.SendType.ENSSetPubKey
|
||||
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
|
||||
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0)
|
||||
preSelectedAsset: store.getAsset(connectEnsModal.store.currentAccount.assets, "ETH")
|
||||
preSelectedAsset: store.getAsset(connectEnsModal.store.assets, "ETH")
|
||||
sendTransaction: function() {
|
||||
if(bestRoutes.length === 1) {
|
||||
let path = bestRoutes[0]
|
||||
|
|
|
@ -50,7 +50,7 @@ Item {
|
|||
sendType: Constants.SendType.ENSRegister
|
||||
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
|
||||
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10)
|
||||
preSelectedAsset: store.getAsset(buyEnsModal.store.currentAccount.assets, JSON.parse(root.stickersStore.getStatusToken()).symbol)
|
||||
preSelectedAsset: store.getAsset(buyEnsModal.store.assets, JSON.parse(root.stickersStore.getStatusToken()).symbol)
|
||||
sendTransaction: function() {
|
||||
if(bestRoutes.length === 1) {
|
||||
let path = bestRoutes[0]
|
||||
|
|
|
@ -205,7 +205,7 @@ ColumnLayout {
|
|||
Layout.minimumHeight: implicitHeight
|
||||
Layout.maximumHeight: implicitHeight
|
||||
baseModel: root.walletStore.accounts
|
||||
currentWallet: root.walletStore.currentAccount.address
|
||||
currentWallet: root.walletStore.overview.mixedcaseAddress
|
||||
}
|
||||
|
||||
ProfileShowcaseCollectiblesPanel {
|
||||
|
@ -217,7 +217,7 @@ ColumnLayout {
|
|||
ProfileShowcaseAssetsPanel {
|
||||
Layout.minimumHeight: implicitHeight
|
||||
Layout.maximumHeight: implicitHeight
|
||||
baseModel: root.walletStore.currentAccount.assets
|
||||
baseModel: root.walletStore.assets
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ Rectangle {
|
|||
Component {
|
||||
id: receiveModalComponent
|
||||
ReceiveModal {
|
||||
selectedAccount: walletStore.currentAccount
|
||||
selectedAddress: walletStore.overview.mixedcaseAddress
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ import "../stores"
|
|||
StatusModal {
|
||||
id: root
|
||||
|
||||
property var selectedAccount
|
||||
property string selectedAddress: ""
|
||||
property string networkPrefix: ""
|
||||
property string completeAddressWithNetworkPrefix
|
||||
|
||||
onSelectedAccountChanged: {
|
||||
if (selectedAccount && selectedAccount.address) {
|
||||
txtWalletAddress.text = selectedAccount.address
|
||||
onSelectedAddressChanged: {
|
||||
if (selectedAddress) {
|
||||
txtWalletAddress.text = selectedAddress
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,9 @@ StatusModal {
|
|||
hasFloatingButtons: true
|
||||
advancedHeaderComponent: AccountsModalHeader {
|
||||
model: RootStore.accounts
|
||||
selectedAccount: root.selectedAccount
|
||||
currentAddress: root.selectedAddress
|
||||
changeSelectedAccount: function(newAccount, newIndex) {
|
||||
root.selectedAccount = newAccount
|
||||
root.selectedAddress = newAccount.address
|
||||
}
|
||||
showAllWalletTypes: true
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ StatusModal {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: root
|
||||
completeAddressWithNetworkPrefix: root.selectedAccount.address
|
||||
completeAddressWithNetworkPrefix: root.selectedAddress
|
||||
}
|
||||
},
|
||||
State {
|
||||
|
@ -326,7 +326,7 @@ StatusModal {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: root
|
||||
completeAddressWithNetworkPrefix: root.networkPrefix + root.selectedAccount.address
|
||||
completeAddressWithNetworkPrefix: root.networkPrefix + root.selectedAddress
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -18,8 +18,8 @@ QtObject {
|
|||
|
||||
property string backButtonName: ""
|
||||
property var overview: walletSectionOverview
|
||||
property var assets: walletSectionCurrent
|
||||
property var currentAccount: walletSectionCurrent
|
||||
property var assets: walletSectionAssets.assets
|
||||
property bool assetsLoading: walletSectionAssets.assetsLoading
|
||||
property var accounts: walletSectionAccounts.accounts
|
||||
property var appSettings: localAppSettings
|
||||
property var accountSensitiveSettings: localAccountSensitiveSettings
|
||||
|
@ -138,7 +138,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function updateCurrentAccount(address, accountName, color, emoji) {
|
||||
return walletSectionCurrent.update(address, accountName, color, emoji)
|
||||
return walletSectionAccounts.updateAccount(address, accountName, color, emoji)
|
||||
}
|
||||
|
||||
function updateCurrency(newCurrency) {
|
||||
|
|
|
@ -23,7 +23,7 @@ Item {
|
|||
property var token: ({})
|
||||
property var networkConnectionStore
|
||||
/*required*/ property string address: ""
|
||||
property var account
|
||||
property bool assetsLoading: true
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
@ -57,7 +57,7 @@ Item {
|
|||
secondaryText: token ? LocaleUtils.currencyAmountToLocaleString(token.enabledNetworkBalance) : Constants.dummyText
|
||||
tertiaryText: token ? LocaleUtils.currencyAmountToLocaleString(token.enabledNetworkCurrencyBalance) : Constants.dummyText
|
||||
balances: token && token.balances ? token.balances : null
|
||||
isLoading: account.assetsLoading
|
||||
isLoading: root.assetsLoading
|
||||
errorTooltipText: token && token.balances ? networkConnectionStore.getBlockchainNetworkDownTextForToken(token.balances): ""
|
||||
getNetworkColor: function(chainId){
|
||||
return RootStore.getNetworkColor(chainId)
|
||||
|
@ -279,19 +279,19 @@ Item {
|
|||
maxWidth: parent.width
|
||||
primaryText: qsTr("Market Cap")
|
||||
secondaryText: token && token.marketCap ? LocaleUtils.currencyAmountToLocaleString(token.marketCap) : Constants.dummyText
|
||||
isLoading: account.assetsLoading
|
||||
isLoading: root.assetsLoading
|
||||
}
|
||||
InformationTile {
|
||||
maxWidth: parent.width
|
||||
primaryText: qsTr("Day Low")
|
||||
secondaryText: token && token.lowDay ? LocaleUtils.currencyAmountToLocaleString(token.lowDay) : Constants.dummyText
|
||||
isLoading: account.assetsLoading
|
||||
isLoading: root.assetsLoading
|
||||
}
|
||||
InformationTile {
|
||||
maxWidth: parent.width
|
||||
primaryText: qsTr("Day High")
|
||||
secondaryText: token && token.highDay ? LocaleUtils.currencyAmountToLocaleString(token.highDay) : Constants.dummyText
|
||||
isLoading: account.assetsLoading
|
||||
isLoading: root.assetsLoading
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
|
@ -304,7 +304,7 @@ Item {
|
|||
secondaryLabel.customColor: changePctHour === 0 ? Theme.palette.directColor1 :
|
||||
changePctHour < 0 ? Theme.palette.dangerColor1 :
|
||||
Theme.palette.successColor1
|
||||
isLoading: account.assetsLoading
|
||||
isLoading: root.assetsLoading
|
||||
}
|
||||
InformationTile {
|
||||
readonly property double changePctDay: token.changePctDay ?? 0
|
||||
|
@ -314,7 +314,7 @@ Item {
|
|||
secondaryLabel.customColor: changePctDay === 0 ? Theme.palette.directColor1 :
|
||||
changePctDay < 0 ? Theme.palette.dangerColor1 :
|
||||
Theme.palette.successColor1
|
||||
isLoading: account.assetsLoading
|
||||
isLoading: root.assetsLoading
|
||||
}
|
||||
InformationTile {
|
||||
readonly property double changePct24hour: token.changePct24hour ?? 0
|
||||
|
@ -324,7 +324,7 @@ Item {
|
|||
secondaryLabel.customColor: changePct24hour === 0 ? Theme.palette.directColor1 :
|
||||
changePct24hour < 0 ? Theme.palette.dangerColor1 :
|
||||
Theme.palette.successColor1
|
||||
isLoading: account.assetsLoading
|
||||
isLoading: root.assetsLoading
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ Item {
|
|||
elide: Text.ElideRight
|
||||
wrapMode: Text.Wrap
|
||||
textFormat: Qt.RichText
|
||||
loading: account.assetsLoading
|
||||
loading: root.assetsLoading
|
||||
}
|
||||
ColumnLayout {
|
||||
id: tagsLayout
|
||||
|
|
|
@ -244,7 +244,7 @@ Rectangle {
|
|||
readonly property bool itemLoaded: !model.assetsLoading // needed for e2e tests
|
||||
width: ListView.view.width - Style.current.padding * 2
|
||||
highlighted: !ListView.view.footerItem.button.highlighted &&
|
||||
RootStore.currentAccount.name === model.name
|
||||
RootStore.overview.name === model.name
|
||||
anchors.horizontalCenter: !!parent ? parent.horizontalCenter : undefined
|
||||
title: model.name
|
||||
subTitle: LocaleUtils.currencyAmountToLocaleString(model.currencyBalance)
|
||||
|
@ -258,7 +258,7 @@ Rectangle {
|
|||
asset.bgColor: Theme.palette.primaryColor3
|
||||
statusListItemTitle.font.weight: Font.Medium
|
||||
color: sensor.containsMouse || highlighted ? Theme.palette.baseColor3 : "transparent"
|
||||
statusListItemSubTitle.loading: model.assetsLoading
|
||||
statusListItemSubTitle.loading: !!model.assetsLoading
|
||||
errorMode: networkConnectionStore.accountBalanceNotAvailable
|
||||
errorIcon.tooltip.maxWidth: 300
|
||||
errorIcon.tooltip.text: networkConnectionStore.accountBalanceNotAvailableText
|
||||
|
|
|
@ -87,7 +87,7 @@ Item {
|
|||
currentIndex: walletTabBar.currentIndex
|
||||
|
||||
AssetsView {
|
||||
account: RootStore.currentAccount
|
||||
assets: RootStore.assets
|
||||
networkConnectionStore: root.networkConnectionStore
|
||||
assetDetailsLaunched: stack.currentIndex === 2
|
||||
onAssetClicked: {
|
||||
|
@ -103,7 +103,7 @@ Item {
|
|||
}
|
||||
}
|
||||
HistoryView {
|
||||
assets: RootStore.assets
|
||||
overview: RootStore.overview
|
||||
onLaunchTransactionDetail: {
|
||||
transactionDetailView.transaction = transaction
|
||||
stack.currentIndex = 3
|
||||
|
@ -122,10 +122,12 @@ Item {
|
|||
Layout.fillHeight: true
|
||||
visible: (stack.currentIndex === 2)
|
||||
|
||||
account: RootStore.currentAccount
|
||||
address: RootStore.currentAccount.address
|
||||
assetsLoading: RootStore.assetsLoading
|
||||
address: RootStore.overview.mixedcaseAddress
|
||||
|
||||
networkConnectionStore: root.networkConnectionStore
|
||||
}
|
||||
|
||||
TransactionDetailView {
|
||||
id: transactionDetailView
|
||||
Layout.fillWidth: true
|
||||
|
|
|
@ -20,7 +20,7 @@ import ".."
|
|||
Item {
|
||||
id: root
|
||||
|
||||
property var currentAccount: RootStore.currentAccount
|
||||
property var overview: WalletStores.RootStore.overview
|
||||
property var contactsStore
|
||||
property var transaction
|
||||
property var sendModal
|
||||
|
@ -28,7 +28,7 @@ Item {
|
|||
|
||||
QtObject {
|
||||
id: d
|
||||
readonly property bool isIncoming: root.isTransactionValid ? root.transaction.to === currentAccount.address : false
|
||||
readonly property bool isIncoming: root.isTransactionValid ? root.transaction.to === root.overview.mixedcaseAddress : false
|
||||
readonly property bool isNFT: root.isTransactionValid ? root.transaction.isNFT : false
|
||||
readonly property string savedAddressNameTo: root.isTransactionValid ? d.getNameForSavedWalletAddress(transaction.to) : ""
|
||||
readonly property string savedAddressNameFrom: root.isTransactionValid ? d.getNameForSavedWalletAddress(transaction.from): ""
|
||||
|
|
|
@ -53,7 +53,6 @@ QtObject {
|
|||
property var userProfileInst: userProfile
|
||||
|
||||
property var accounts: walletSectionSendInst.accounts
|
||||
property var currentAccount: walletSectionCurrent
|
||||
// Not Refactored Yet
|
||||
// property var profileModelInst: profileModel
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import "../views"
|
|||
StatusFloatingButtonsSelector {
|
||||
id: root
|
||||
|
||||
property string currentAddress
|
||||
property var selectedAccount
|
||||
// Expected signature: function(newAccount)
|
||||
property var changeSelectedAccount: function(){}
|
||||
|
@ -50,12 +51,15 @@ StatusFloatingButtonsSelector {
|
|||
}
|
||||
Component.onCompleted: {
|
||||
// on model reset, set the selected account to the one that was previously selected
|
||||
if(root.selectedAccount === null) {
|
||||
if(!root.selectedAccount) {
|
||||
if(root.currentIndex === index) {
|
||||
changeSelectedAccount(model)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(root.currentAddress === model.address) {
|
||||
root.currentIndex = index
|
||||
changeSelectedAccount(model)
|
||||
}
|
||||
} else {
|
||||
// if the selectedAccount is watch only then select 0th item
|
||||
if(index === 0 && !!root.selectedAccount && root.selectedAccount.walletType === Constants.watchWalletType) {
|
||||
changeSelectedAccount(model)
|
||||
|
|
|
@ -36,7 +36,7 @@ StatusDialog {
|
|||
property var store: TransactionStore{}
|
||||
property var contactsStore: store.contactStore
|
||||
property var currencyStore: store.currencyStore
|
||||
property var selectedAccount: store.currentAccount
|
||||
property var selectedAccount
|
||||
property var bestRoutes
|
||||
property alias addressText: recipientLoader.addressText
|
||||
property bool isLoading: false
|
||||
|
@ -159,10 +159,12 @@ StatusDialog {
|
|||
inverted: true
|
||||
}
|
||||
}
|
||||
selectedAccount: popup.selectedAccount
|
||||
currentAddress: popup.store.overview.mixedcaseAddress
|
||||
changeSelectedAccount: function(newAccount) {
|
||||
popup.selectedAccount = newAccount
|
||||
assetSelector.selectedAsset = store.getAsset(selectedAccount.assets, assetSelector.selectedAsset.symbol)
|
||||
if (assetSelector.selectedAsset) {
|
||||
assetSelector.selectedAsset = store.getAsset(popup.selectedAccount.assets, assetSelector.selectedAsset.symbol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ Item {
|
|||
sendType: Constants.SendType.StickersBuy
|
||||
preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress()
|
||||
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
|
||||
preSelectedAsset: store.getAsset(buyStickersModal.store.currentAccount.assets, JSON.parse(root.store.stickersStore.getStatusToken()).symbol)
|
||||
preSelectedAsset: store.getAsset(buyStickersModal.store.assets, JSON.parse(root.store.stickersStore.getStatusToken()).symbol)
|
||||
sendTransaction: function() {
|
||||
if(bestRoutes.length === 1) {
|
||||
let path = bestRoutes[0]
|
||||
|
|
|
@ -71,7 +71,7 @@ ModalPopup {
|
|||
sendType: Constants.SendType.StickersBuy
|
||||
preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
|
||||
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
|
||||
preSelectedAsset: store.getAsset(buyStickersPackModal.store.currentAccount.assets, JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol)
|
||||
preSelectedAsset: store.getAsset(buyStickersPackModal.store.assets, JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol)
|
||||
sendTransaction: function() {
|
||||
if(bestRoutes.length === 1) {
|
||||
let path = bestRoutes[0]
|
||||
|
|
|
@ -11,9 +11,9 @@ QtObject {
|
|||
|
||||
readonly property bool isOnline: mainModule.isOnline
|
||||
|
||||
readonly property bool balanceCache: walletSectionCurrent.hasBalanceCache
|
||||
readonly property bool marketValuesCache: walletSectionCurrent.hasMarketValuesCache
|
||||
readonly property bool collectiblesCache: walletSectionCurrent.getHasCollectiblesCache()
|
||||
readonly property bool balanceCache: walletSectionAssets.hasBalanceCache
|
||||
readonly property bool marketValuesCache: walletSectionAssets.hasMarketValuesCache
|
||||
readonly property bool collectiblesCache: walletSectionCollectibles.getHasCollectiblesCache()
|
||||
|
||||
readonly property var blockchainNetworksDown: !!networkConnectionModule.blockchainNetworkConnection.chainIds ? networkConnectionModule.blockchainNetworkConnection.chainIds.split(";") : []
|
||||
readonly property bool atleastOneBlockchainNetworkAvailable: blockchainNetworksDown.length < networksModule.all.count
|
||||
|
@ -31,13 +31,13 @@ QtObject {
|
|||
networkConnectionModule.marketValuesNetworkConnection.completelyDown ?
|
||||
qsTr("Requires CryptoCompare or CoinGecko, both of which are currently unavailable"): ""
|
||||
|
||||
readonly property bool notOnlineWithNoCache: !isOnline && !walletSectionCurrent.hasBalanceCache && !walletSectionCurrent.hasMarketValuesCache
|
||||
readonly property bool notOnlineWithNoCache: !isOnline && !walletSectionAssets.hasBalanceCache && !walletSectionAssets.hasMarketValuesCache
|
||||
readonly property string notOnlineWithNoCacheText: qsTr("Internet connection lost. Data could not be retrieved.")
|
||||
|
||||
readonly property bool noBlockchainConnectionAndNoCache: networkConnectionModule.blockchainNetworkConnection.completelyDown && !walletSectionCurrent.hasBalanceCache
|
||||
readonly property bool noBlockchainConnectionAndNoCache: networkConnectionModule.blockchainNetworkConnection.completelyDown && !walletSectionAssets.hasBalanceCache
|
||||
readonly property string noBlockchainConnectionAndNoCacheText: qsTr("Token balances are fetched from Pocket Network (POKT) and Infura which are both curently unavailable")
|
||||
|
||||
readonly property bool noMarketConnectionAndNoCache: networkConnectionModule.marketValuesNetworkConnection.completelyDown && !walletSectionCurrent.hasMarketValuesCache
|
||||
readonly property bool noMarketConnectionAndNoCache: networkConnectionModule.marketValuesNetworkConnection.completelyDown && !walletSectionAssets.hasMarketValuesCache
|
||||
readonly property string noMarketConnectionAndNoCacheText: qsTr("Market values are fetched from CryptoCompare and CoinGecko which are both currently unavailable")
|
||||
|
||||
readonly property bool noBlockchainAndMarketConnectionAndNoCache: noBlockchainConnectionAndNoCache && noMarketConnectionAndNoCache
|
||||
|
|
|
@ -40,7 +40,6 @@ QtObject {
|
|||
property var historyTransactions: Global.appIsReady? walletSectionTransactions.model : null
|
||||
property bool isNonArchivalNode: history ? history.isNonArchivalNode
|
||||
: false
|
||||
property var currentAccount: Global.appIsReady? walletSectionCurrent : null
|
||||
property var marketValueStore: TokenMarketValuesStore{}
|
||||
|
||||
function getNetworkColor(chainId) {
|
||||
|
|
|
@ -19,8 +19,8 @@ QtObject {
|
|||
|
||||
property string currentCurrency: walletSection.currentCurrency
|
||||
property var allNetworks: networksModule.all
|
||||
property var overview: walletSectionOverview
|
||||
property var accounts: walletSectionSendInst.accounts
|
||||
property var currentAccount: walletSectionCurrent
|
||||
property string signingPhrase: walletSection.signingPhrase
|
||||
property var savedAddressesModel: SortFilterProxyModel {
|
||||
sourceModel: walletSectionSavedAddresses.model
|
||||
|
|
|
@ -16,7 +16,7 @@ import shared.controls 1.0
|
|||
Item {
|
||||
id: root
|
||||
|
||||
property var account
|
||||
property var assets
|
||||
property var networkConnectionStore
|
||||
property bool assetDetailsLaunched: false
|
||||
|
||||
|
@ -39,7 +39,7 @@ Item {
|
|||
|
||||
SortFilterProxyModel {
|
||||
id: filteredModel
|
||||
sourceModel: account.assets
|
||||
sourceModel: assets
|
||||
filters: [
|
||||
ExpressionFilter {
|
||||
expression: visibleForNetworkWithPositiveBalance || loading
|
||||
|
|
|
@ -20,15 +20,15 @@ import "../controls"
|
|||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
property var assets
|
||||
property var overview
|
||||
property int pageSize: 20 // number of transactions per page
|
||||
|
||||
signal launchTransactionDetail(var transaction)
|
||||
|
||||
function fetchHistory() {
|
||||
if (!RootStore.isFetchingHistory(root.assets.address)) {
|
||||
if (!RootStore.isFetchingHistory(root.overview.mixedcaseAddress)) {
|
||||
d.isLoading = true
|
||||
RootStore.loadTransactionsForAccount(root.assets.address, pageSize)
|
||||
RootStore.loadTransactionsForAccount(root.overview.mixedcaseAddress, pageSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ ColumnLayout {
|
|||
Connections {
|
||||
target: RootStore.history
|
||||
function onLoadingTrxHistoryChanged(isLoading: bool, address: string) {
|
||||
if (root.assets.address.toLowerCase() === address.toLowerCase()) {
|
||||
if (root.overview.mixedcaseAddress.toLowerCase() === address.toLowerCase()) {
|
||||
d.isLoading = isLoading
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ ColumnLayout {
|
|||
TransactionDelegate {
|
||||
width: ListView.view.width
|
||||
modelData: model
|
||||
isIncoming: isModelDataValid ? modelData.to === root.assets.address: false
|
||||
isIncoming: isModelDataValid ? modelData.to === root.overview.mixedcaseAddress: false
|
||||
currentCurrency: RootStore.currentCurrency
|
||||
cryptoValue: isModelDataValid ? modelData.value.amount : 0.0
|
||||
fiatValue: isModelDataValid ? RootStore.getFiatValue(cryptoValue, symbol, currentCurrency): 0.0
|
||||
|
|
|
@ -99,7 +99,7 @@ Item {
|
|||
property int routeOnNetwork: 0
|
||||
property bool selectedAssetValid: selectedAccount && selectedAccount !== undefined && selectedAsset !== undefined
|
||||
property double tokenBalanceOnChain: selectedAssetValid ? root.store.getTokenBalanceOnChain(selectedAccount, model.chainId, root.selectedSymbol).amount : 0.0
|
||||
property bool hasGas: selectedAssetValid && requiredGasInEth !== undefined ? selectedAccount.hasGas(model.chainId, model.nativeCurrencySymbol, requiredGasInEth) : false
|
||||
property bool hasGas: selectedAssetValid && requiredGasInEth !== undefined ? root.store.walletSectionSendInst.hasGas(selectedAccount.address, model.chainId, model.nativeCurrencySymbol, requiredGasInEth) : false
|
||||
property double advancedInputCurrencyAmount: selectedAssetValid && advancedInput.valid ? LocaleUtils.numberFromLocaleString(advancedInputText, LocaleUtils.userInputLocale) : 0.0
|
||||
|
||||
primaryText: model.chainName
|
||||
|
|
|
@ -335,7 +335,7 @@ Control {
|
|||
visible: count
|
||||
model: SortFilterProxyModel {
|
||||
// TODO show assets for all accounts, not just the current one?
|
||||
sourceModel: root.isCurrentUser ? root.walletStore.currentAccount.assets : null // TODO show other users too
|
||||
sourceModel: root.isCurrentUser ? root.walletStore.assets : null // TODO show other users too
|
||||
filters: ValueFilter {
|
||||
roleName: "visibleForNetworkWithPositiveBalance"
|
||||
value: true
|
||||
|
|
Loading…
Reference in New Issue