chore(@desktop/wallet): Simplify the wallet networks service

fixes #12717
This commit is contained in:
Khushboo Mehta 2024-03-13 18:38:16 +01:00 committed by Khushboo-dev-cpp
parent d9945b39dc
commit 5473e3b14e
88 changed files with 522 additions and 1060 deletions

View File

@ -43,10 +43,10 @@ proc getIndex*(self: Controller, address: string): int =
return self.walletAccountService.getIndex(address) return self.walletAccountService.getIndex(address)
proc getChainIds*(self: Controller): seq[int] = proc getChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().map(n => n.chainId) return self.networkService.getCurrentNetworks().map(n => n.chainId)
proc getEnabledChainIds*(self: Controller): seq[int] = proc getEnabledChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId) return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
proc getCurrentCurrency*(self: Controller): string = proc getCurrentCurrency*(self: Controller): string =
return self.walletAccountService.getCurrency() return self.walletAccountService.getCurrency()

View File

@ -713,9 +713,9 @@ proc getContractAddressesForToken*(self: Controller, symbol: string): Table[int,
let token = self.tokenService.findTokenBySymbol(symbol) let token = self.tokenService.findTokenBySymbol(symbol)
if token != nil: if token != nil:
for addrPerChain in token.addressPerChainId: for addrPerChain in token.addressPerChainId:
# depending on areTestNetworksEnabled (in getNetwork), contractAddresses will # depending on areTestNetworksEnabled (in getNetworkByChainId), contractAddresses will
# contain mainnets or testnets only # contain mainnets or testnets only
let network = self.networkService.getNetwork(addrPerChain.chainId) let network = self.networkService.getNetworkByChainId(addrPerChain.chainId)
if network == nil: if network == nil:
continue continue
contractAddresses[addrPerChain.chainId] = addrPerChain.address contractAddresses[addrPerChain.chainId] = addrPerChain.address

View File

@ -372,8 +372,8 @@ proc getCommunityTokens*(self: Controller, communityId: string): seq[CommunityTo
proc getAllCommunityTokens*(self: Controller): seq[CommunityTokenDto] = proc getAllCommunityTokens*(self: Controller): seq[CommunityTokenDto] =
self.communityTokensService.getAllCommunityTokens() self.communityTokensService.getAllCommunityTokens()
proc getNetwork*(self:Controller, chainId: int): NetworkDto = proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
self.networksService.getNetwork(chainId) self.networksService.getNetworkByChainId(chainId)
proc getTokenBySymbolList*(self: Controller): seq[TokenBySymbolItem] = proc getTokenBySymbolList*(self: Controller): seq[TokenBySymbolItem] =
return self.tokenService.getTokenBySymbolList() return self.tokenService.getTokenBySymbolList()
@ -480,8 +480,8 @@ proc runSigningOnKeycard*(self: Controller, keyUid: string, path: string, dataTo
proc removeCommunityChat*(self: Controller, communityId: string, channelId: string) = proc removeCommunityChat*(self: Controller, communityId: string, channelId: string) =
self.communityService.deleteCommunityChat(communityId, channelId) self.communityService.deleteCommunityChat(communityId, channelId)
proc getNetworks*(self: Controller): seq[NetworkDto] = proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
return self.networksService.getNetworks() return self.networksService.getCurrentNetworks()
proc promoteSelfToControlNode*(self: Controller, communityId: string) = proc promoteSelfToControlNode*(self: Controller, communityId: string) =
self.communityService.promoteSelfToControlNode(communityId) self.communityService.promoteSelfToControlNode(communityId)

View File

@ -613,7 +613,7 @@ proc buildTokensAndCollectiblesFromWallet(self: Module) =
var tokenListItems: seq[TokenListItem] var tokenListItems: seq[TokenListItem]
# Common ERC20 tokens # Common ERC20 tokens
let allNetworks = self.controller.getNetworks().map(n => n.chainId) let allNetworks = self.controller.getCurrentNetworks().map(n => n.chainId)
let erc20Tokens = self.controller.getTokenBySymbolList().filter(t => (block: let erc20Tokens = self.controller.getTokenBySymbolList().filter(t => (block:
let filteredChains = t.addressPerChainId.filter(apC => allNetworks.contains(apc.chainId)) let filteredChains = t.addressPerChainId.filter(apC => allNetworks.contains(apc.chainId))
return filteredChains.len != 0 return filteredChains.len != 0

View File

@ -159,8 +159,8 @@ proc findContractByUniqueId*(self: Controller, contractUniqueKey: string): Commu
proc computeBurnFee*(self: Controller, contractUniqueKey: string, amount: Uint256, addressFrom: string, requestId: string) = proc computeBurnFee*(self: Controller, contractUniqueKey: string, amount: Uint256, addressFrom: string, requestId: string) =
self.communityTokensService.computeBurnFee(contractUniqueKey, amount, addressFrom, requestId) self.communityTokensService.computeBurnFee(contractUniqueKey, amount, addressFrom, requestId)
proc getNetwork*(self:Controller, chainId: int): NetworkDto = proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
self.networksService.getNetwork(chainId) self.networksService.getNetworkByChainId(chainId)
proc getOwnerToken*(self: Controller, communityId: string): CommunityTokenDto = proc getOwnerToken*(self: Controller, communityId: string): CommunityTokenDto =
return self.communityTokensService.getOwnerToken(communityId) return self.communityTokensService.getOwnerToken(communityId)

View File

@ -299,11 +299,11 @@ method computeBurnFee*(self: Module, contractUniqueKey: string, amount: string,
self.controller.computeBurnFee(contractUniqueKey, amount.parse(Uint256), addressFrom, requestId) self.controller.computeBurnFee(contractUniqueKey, amount.parse(Uint256), addressFrom, requestId)
proc createUrl(self: Module, chainId: int, transactionHash: string): string = proc createUrl(self: Module, chainId: int, transactionHash: string): string =
let network = self.controller.getNetwork(chainId) let network = self.controller.getNetworkByChainId(chainId)
result = if network != nil: network.blockExplorerURL & "/tx/" & transactionHash else: "" result = if network != nil: network.blockExplorerURL & "/tx/" & transactionHash else: ""
proc getChainName(self: Module, chainId: int): string = proc getChainName(self: Module, chainId: int): string =
let network = self.controller.getNetwork(chainId) let network = self.controller.getNetworkByChainId(chainId)
result = if network != nil: network.chainName else: "" result = if network != nil: network.chainName else: ""
method onCommunityTokenDeployStateChanged*(self: Module, communityId: string, chainId: int, transactionHash: string, deployState: DeployState) = method onCommunityTokenDeployStateChanged*(self: Module, communityId: string, chainId: int, transactionHash: string, deployState: DeployState) =

View File

@ -573,8 +573,8 @@ proc getRemainingSupply*(self: Controller, chainId: int, contractAddress: string
proc getRemoteDestructedAmount*(self: Controller, chainId: int, contractAddress: string): Uint256 = proc getRemoteDestructedAmount*(self: Controller, chainId: int, contractAddress: string): Uint256 =
return self.communityTokensService.getRemoteDestructedAmount(chainId, contractAddress) return self.communityTokensService.getRemoteDestructedAmount(chainId, contractAddress)
proc getNetwork*(self:Controller, chainId: int): NetworkDto = proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
self.networksService.getNetwork(chainId) self.networksService.getNetworkByChainId(chainId)
proc getAppNetwork*(self:Controller): NetworkDto = proc getAppNetwork*(self:Controller): NetworkDto =
self.networksService.getAppNetwork() self.networksService.getAppNetwork()

View File

@ -266,7 +266,7 @@ method onAppNetworkChanged*[T](self: Module[T]) =
self.view.emitAppNetworkChangedSignal() self.view.emitAppNetworkChangedSignal()
proc createTokenItem[T](self: Module[T], tokenDto: CommunityTokenDto) : token_item.TokenItem = proc createTokenItem[T](self: Module[T], tokenDto: CommunityTokenDto) : token_item.TokenItem =
let network = self.controller.getNetwork(tokenDto.chainId) let network = self.controller.getNetworkByChainId(tokenDto.chainId)
let tokenOwners = self.controller.getCommunityTokenOwners(tokenDto.communityId, tokenDto.chainId, tokenDto.address) let tokenOwners = self.controller.getCommunityTokenOwners(tokenDto.communityId, tokenDto.chainId, tokenDto.address)
let ownerAddressName = if len(tokenDto.deployer) > 0: self.controller.getCommunityTokenOwnerName(tokenDto.deployer) else: "" let ownerAddressName = if len(tokenDto.deployer) > 0: self.controller.getCommunityTokenOwnerName(tokenDto.deployer) else: ""
let remainingSupply = if tokenDto.infiniteSupply: stint.parse("0", Uint256) else: self.controller.getRemainingSupply(tokenDto.chainId, tokenDto.address) let remainingSupply = if tokenDto.infiniteSupply: stint.parse("0", Uint256) else: self.controller.getRemainingSupply(tokenDto.chainId, tokenDto.address)
@ -277,7 +277,7 @@ proc createTokenItem[T](self: Module[T], tokenDto: CommunityTokenDto) : token_it
proc createTokenItemImproved[T](self: Module[T], tokenDto: CommunityTokenDto, communityTokenJsonItems: JsonNode) : token_item.TokenItem = proc createTokenItemImproved[T](self: Module[T], tokenDto: CommunityTokenDto, communityTokenJsonItems: JsonNode) : token_item.TokenItem =
# These 3 values come from local caches so they can be done sync # These 3 values come from local caches so they can be done sync
let network = self.controller.getNetwork(tokenDto.chainId) let network = self.controller.getNetworkByChainId(tokenDto.chainId)
let tokenOwners = self.controller.getCommunityTokenOwners(tokenDto.communityId, tokenDto.chainId, tokenDto.address) let tokenOwners = self.controller.getCommunityTokenOwners(tokenDto.communityId, tokenDto.chainId, tokenDto.address)
let ownerAddressName = if len(tokenDto.deployer) > 0: self.controller.getCommunityTokenOwnerName(tokenDto.deployer) else: "" let ownerAddressName = if len(tokenDto.deployer) > 0: self.controller.getCommunityTokenOwnerName(tokenDto.deployer) else: ""

View File

@ -102,10 +102,10 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
self.walletAccountService.getWalletAccounts(true) self.walletAccountService.getWalletAccounts(true)
proc getChainIds*(self: Controller): seq[int] = proc getChainIds*(self: Controller): seq[int] =
self.networkService.getNetworks().map(n => n.chainId) self.networkService.getCurrentNetworks().map(n => n.chainId)
proc getEnabledChainIds*(self: Controller): seq[int] = proc getEnabledChainIds*(self: Controller): seq[int] =
self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId) self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
proc setSocialLinks*(self: Controller, links: SocialLinks) = proc setSocialLinks*(self: Controller, links: SocialLinks) =
self.settingsService.setSocialLinks(links) self.settingsService.setSocialLinks(links)

View File

@ -41,7 +41,7 @@ proc init*(self: Controller) =
self.events.on(SIGNAL_NETWORK_ENDPOINT_UPDATED) do(e: Args): self.events.on(SIGNAL_NETWORK_ENDPOINT_UPDATED) do(e: Args):
self.delegate.refreshNetworks() self.delegate.refreshNetworks()
proc getNetworks*(self: Controller): seq[CombinedNetworkDto] = proc getCombinedNetworks*(self: Controller): seq[CombinedNetworkDto] =
return self.networkService.getCombinedNetworks() return self.networkService.getCombinedNetworks()
proc areTestNetworksEnabled*(self: Controller): bool = proc areTestNetworksEnabled*(self: Controller): bool =

View File

@ -41,7 +41,7 @@ method getModuleAsVariant*(self: Module): QVariant =
method refreshNetworks*(self: Module) = method refreshNetworks*(self: Module) =
var items: seq[Item] = @[] var items: seq[Item] = @[]
var combinedItems: seq[CombinedItem] = @[] var combinedItems: seq[CombinedItem] = @[]
for n in self.controller.getNetworks(): for n in self.controller.getCombinedNetworks():
var prod = newItem( var prod = newItem(
n.prod.chainId, n.prod.chainId,
n.prod.layer, n.prod.layer,

View File

@ -40,7 +40,7 @@ proc deleteAccount*(self: Controller, address: string) =
self.walletAccountService.deleteAccount(address) self.walletAccountService.deleteAccount(address)
proc getEnabledChainIds*(self: Controller): seq[int] = proc getEnabledChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId) return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
proc getCurrentCurrency*(self: Controller): string = proc getCurrentCurrency*(self: Controller): string =
return self.walletAccountService.getCurrency() return self.walletAccountService.getCurrency()

View File

@ -50,7 +50,7 @@ proc getWalletAddresses*(self: Controller): seq[string] =
return self.walletAccountService.getWalletAddresses() return self.walletAccountService.getWalletAddresses()
proc getChainIds*(self: Controller): seq[int] = proc getChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().map(n => n.chainId) return self.networkService.getCurrentNetworks().map(n => n.chainId)
proc updateCollectiblePreferences*(self: Controller, tokenPreferencesJson: string) = proc updateCollectiblePreferences*(self: Controller, tokenPreferencesJson: string) =
self.collectibleService.updateCollectiblePreferences(tokenPreferencesJson) self.collectibleService.updateCollectiblePreferences(tokenPreferencesJson)

View File

@ -35,7 +35,7 @@ proc init*(self: Controller) =
discard discard
proc getChainIds*(self: Controller): seq[int] = proc getChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().map(n => n.chainId) return self.networkService.getCurrentNetworks().map(n => n.chainId)
proc getCurrentCurrency*(self: Controller): string = proc getCurrentCurrency*(self: Controller): string =
return self.walletAccountService.getCurrency() return self.walletAccountService.getCurrency()

View File

@ -54,14 +54,14 @@ proc getCurrencyAmount*(self: Controller, amount: float64, symbol: string): Curr
proc updateCurrency*(self: Controller, currency: string) = proc updateCurrency*(self: Controller, currency: string) =
self.walletAccountService.updateCurrency(currency) self.walletAccountService.updateCurrency(currency)
proc getNetworks*(self: Controller): seq[NetworkDto] = proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
return self.networkService.getNetworks() return self.networkService.getCurrentNetworks()
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] = proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
return self.walletAccountService.getWalletAccounts() return self.walletAccountService.getWalletAccounts()
proc getEnabledChainIds*(self: Controller): seq[int] = proc getEnabledChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId) return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto = proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
return self.walletAccountService.getKeypairByAccountAddress(address) return self.walletAccountService.getKeypairByAccountAddress(address)

View File

@ -46,7 +46,7 @@ proc removeAddress*(self: Filter, address: string) =
proc updateNetworks*(self: Filter) = proc updateNetworks*(self: Filter) =
self.chainIds = self.controller.getEnabledChainIds() self.chainIds = self.controller.getEnabledChainIds()
self.allChainsEnabled = (self.chainIds.len == self.controller.getNetworks().len) self.allChainsEnabled = (self.chainIds.len == self.controller.getCurrentNetworks().len)
proc load*(self: Filter) = proc load*(self: Filter) =
self.setFillterAllAddresses() self.setFillterAllAddresses()

View File

@ -88,9 +88,6 @@ method onAddAccountModuleLoaded*(self: AccessInterface) {.base.} =
method destroyAddAccountPopup*(self: AccessInterface) {.base.} = method destroyAddAccountPopup*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getNetworkLayer*(self: AccessInterface, chainId: int): string {.base.} =
raise newException(ValueError, "No implementation available")
method getLatestBlockNumber*(self: AccessInterface, chainId: int): string {.base.} = method getLatestBlockNumber*(self: AccessInterface, chainId: int): string {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -413,9 +413,6 @@ method getAddAccountModule*(self: Module): QVariant =
method onAddAccountModuleLoaded*(self: Module) = method onAddAccountModuleLoaded*(self: Module) =
self.view.emitDisplayAddAccountPopup() self.view.emitDisplayAddAccountPopup()
method getNetworkLayer*(self: Module, chainId: int): string =
return self.networksModule.getNetworkLayer(chainId)
method getLatestBlockNumber*(self: Module, chainId: int): string = method getLatestBlockNumber*(self: Module, chainId: int): string =
return self.transactionService.getLatestBlockNumber(chainId) return self.transactionService.getLatestBlockNumber(chainId)

View File

@ -34,7 +34,7 @@ proc init*(self: Controller) =
self.events.on(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED) do(e: Args): self.events.on(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED) do(e: Args):
self.delegate.refreshNetworks() self.delegate.refreshNetworks()
proc getFlatNetworks*(self: Controller): seq[NetworkDto] = proc getFlatNetworks*(self: Controller): var seq[NetworkDto] =
return self.networkService.getFlatNetworks() return self.networkService.getFlatNetworks()
proc setNetworksState*(self: Controller, chainIds: seq[int], enabled: bool) = proc setNetworksState*(self: Controller, chainIds: seq[int], enabled: bool) =

View File

@ -1,3 +1,10 @@
import app_service/service/network/dto
type
NetworksDataSource* = tuple[
getFlatNetworksList: proc(): var seq[NetworkDto]
]
type type
AccessInterface* {.pure inheritable.} = ref object of RootObj AccessInterface* {.pure inheritable.} = ref object of RootObj
## Abstract class for any input/interaction with this module. ## Abstract class for any input/interaction with this module.
@ -23,5 +30,5 @@ method setNetworksState*(self: AccessInterface, chainIds: seq[int], enable: bool
method refreshNetworks*(self: AccessInterface) {.base.} = method refreshNetworks*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getNetworkLayer*(self: AccessInterface, chainId: int): string {.base.} = method getNetworksDataSource*(self: AccessInterface): NetworksDataSource {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -1,115 +0,0 @@
import stew/shims/strformat
type
UxEnabledState* {.pure.} = enum
Enabled
AllEnabled
Disabled
type
Item* = object
chainId: int
nativeCurrencyDecimals: int
layer: int
chainName: string
rpcURL: string
blockExplorerURL: string
nativeCurrencyName: string
nativeCurrencySymbol: string
isTest: bool
isEnabled: bool
iconUrl: string
chainColor: string
shortName: string
enabledState: UxEnabledState
proc initItem*(
chainId: int,
nativeCurrencyDecimals: int,
layer: int,
chainName: string,
rpcURL: string,
blockExplorerURL: string,
nativeCurrencyName: string,
nativeCurrencySymbol: string,
isTest: bool,
isEnabled: bool,
iconUrl: string,
chainColor: string,
shortName: string,
enabledState: UxEnabledState,
): Item =
result.chainId = chainId
result.nativeCurrencyDecimals = nativeCurrencyDecimals
result.layer = layer
result.chainName = chainName
result.rpcURL = rpcURL
result.blockExplorerURL = blockExplorerURL
result.nativeCurrencyName = nativeCurrencyName
result.nativeCurrencySymbol = nativeCurrencySymbol
result.isTest = isTest
result.isEnabled = isEnabled
result.iconUrl = iconUrl
result.chainColor = chainColor
result.shortName = shortName
result.enabledState = enabledState
proc `$`*(self: Item): string =
result = fmt"""NetworkItem(
chainId: {self.chainId},
chainName: {self.chainName},
layer: {self.layer},
nativeCurrencyDecimals: {self.nativeCurrencyDecimals},
rpcURL: {self.rpcURL},
blockExplorerURL:{self.blockExplorerURL},
nativeCurrencyName:{self.nativeCurrencyName},
nativeCurrencySymbol:{self.nativeCurrencySymbol},
isTest:{self.isTest},
isEnabled:{self.isEnabled},
iconUrl:{self.iconUrl},
shortName: {self.shortName},
chainColor: {self.chainColor},
enabledState: {self.enabledState}
]"""
proc getChainId*(self: Item): int =
return self.chainId
proc getNativeCurrencyDecimals*(self: Item): int =
return self.nativeCurrencyDecimals
proc getLayer*(self: Item): int =
return self.layer
proc getChainName*(self: Item): string =
return self.chainName
proc getRpcURL*(self: Item): string =
return self.rpcURL
proc getBlockExplorerURL*(self: Item): string =
return self.blockExplorerURL
proc getNativeCurrencyName*(self: Item): string =
return self.nativeCurrencyName
proc getNativeCurrencySymbol*(self: Item): string =
return self.nativeCurrencySymbol
proc getIsTest*(self: Item): bool =
return self.isTest
proc getIsEnabled*(self: Item): bool =
return self.isEnabled
proc getIconURL*(self: Item): string =
return self.iconUrl
proc getShortName*(self: Item): string =
return self.shortName
proc getChainColor*(self: Item): string =
return self.chainColor
proc getEnabledState*(self: Item): UxEnabledState =
return self.enabledState

View File

@ -1,7 +1,7 @@
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, sugar import NimQml, Tables, strutils, sequtils, sugar
import app_service/service/network/types import app_service/service/network/dto
import ./item import ./io_interface
const EXPLORER_TX_PREFIX* = "/tx/" const EXPLORER_TX_PREFIX* = "/tx/"
@ -25,34 +25,30 @@ type
QtObject: QtObject:
type type
Model* = ref object of QAbstractListModel Model* = ref object of QAbstractListModel
items: seq[Item] delegate: io_interface.NetworksDataSource
proc delete(self: Model) = proc delete(self: Model) =
self.items = @[]
self.QAbstractListModel.delete self.QAbstractListModel.delete
proc setup(self: Model) = proc setup(self: Model) =
self.QAbstractListModel.setup self.QAbstractListModel.setup
proc newModel*(): Model = proc newModel*(delegate: io_interface.NetworksDataSource): Model =
new(result, delete) new(result, delete)
result.setup result.setup
result.delegate = delegate
proc `$`*(self: Model): string =
for i in 0 ..< self.items.len:
result &= fmt"""[{i}]:({$self.items[i]})"""
proc countChanged(self: Model) {.signal.} proc countChanged(self: Model) {.signal.}
proc getCount(self: Model): int {.slot.} = proc getCount(self: Model): int {.slot.} =
self.items.len return self.delegate.getFlatNetworksList().len
QtProperty[int] count: QtProperty[int] count:
read = getCount read = getCount
notify = countChanged notify = countChanged
method rowCount*(self: Model, index: QModelIndex = nil): int = method rowCount*(self: Model, index: QModelIndex = nil): int =
return self.items.len return self.delegate.getFlatNetworksList().len
method roleNames(self: Model): Table[int, string] = method roleNames(self: Model): Table[int, string] =
{ {
@ -76,179 +72,118 @@ QtObject:
if (not index.isValid): if (not index.isValid):
return return
if (index.row < 0 or index.row >= self.items.len): if (index.row < 0 or index.row >= self.rowCount()):
return return
let item = self.items[index.row] let item = self.delegate.getFlatNetworksList()[index.row]
let enumRole = role.ModelRole let enumRole = role.ModelRole
case enumRole: case enumRole:
of ModelRole.ChainId: of ModelRole.ChainId:
result = newQVariant(item.getChainId()) result = newQVariant(item.chainId)
of ModelRole.NativeCurrencyDecimals: of ModelRole.NativeCurrencyDecimals:
result = newQVariant(item.getNativeCurrencyDecimals()) result = newQVariant(item.nativeCurrencyDecimals)
of ModelRole.Layer: of ModelRole.Layer:
result = newQVariant(item.getLayer()) result = newQVariant(item.layer)
of ModelRole.ChainName: of ModelRole.ChainName:
result = newQVariant(item.getChainName()) result = newQVariant(item.chainName)
of ModelRole.RpcURL: of ModelRole.RpcURL:
result = newQVariant(item.getRpcURL()) result = newQVariant(item.rpcURL)
of ModelRole.BlockExplorerURL: of ModelRole.BlockExplorerURL:
result = newQVariant(item.getBlockExplorerURL()) result = newQVariant(item.blockExplorerURL)
of ModelRole.NativeCurrencyName: of ModelRole.NativeCurrencyName:
result = newQVariant(item.getNativeCurrencyName()) result = newQVariant(item.nativeCurrencyName)
of ModelRole.NativeCurrencySymbol: of ModelRole.NativeCurrencySymbol:
result = newQVariant(item.getNativeCurrencySymbol()) result = newQVariant(item.nativeCurrencySymbol)
of ModelRole.IsTest: of ModelRole.IsTest:
result = newQVariant(item.getIsTest()) result = newQVariant(item.isTest)
of ModelRole.IsEnabled: of ModelRole.IsEnabled:
result = newQVariant(item.getIsEnabled()) result = newQVariant(item.enabled)
of ModelRole.IconUrl: of ModelRole.IconUrl:
result = newQVariant(item.getIconURL()) result = newQVariant(item.iconURL)
of ModelRole.ShortName: of ModelRole.ShortName:
result = newQVariant(item.getShortName()) result = newQVariant(item.shortName)
of ModelRole.ChainColor: of ModelRole.ChainColor:
result = newQVariant(item.getChainColor()) result = newQVariant(item.chainColor)
of ModelRole.EnabledState: of ModelRole.EnabledState:
result = newQVariant(item.getEnabledState().int) result = newQVariant(item.enabledState.int)
proc rowData*(self: Model, index: int, column: string): string {.slot.} = proc rowData*(self: Model, index: int, column: string): string {.slot.} =
if (index >= self.items.len): if (index >= self.rowCount()):
return return
let item = self.items[index] let item = self.delegate.getFlatNetworksList()[index]
case column: case column:
of "chainId": result = $item.getChainId() of "chainId": result = $item.chainId
of "nativeCurrencyDecimals": result = $item.getNativeCurrencyDecimals() of "nativeCurrencyDecimals": result = $item.nativeCurrencyDecimals
of "layer": result = $item.getLayer() of "layer": result = $item.layer
of "chainName": result = $item.getChainName() of "chainName": result = $item.chainName
of "rpcURL": result = $item.getRpcURL() of "rpcURL": result = $item.rpcURL
of "blockExplorerURL": result = $item.getBlockExplorerURL() of "blockExplorerURL": result = $item.blockExplorerURL
of "nativeCurrencyName": result = $item.getNativeCurrencyName() of "nativeCurrencyName": result = $item.nativeCurrencyName
of "nativeCurrencySymbol": result = $item.getNativeCurrencySymbol() of "nativeCurrencySymbol": result = $item.nativeCurrencySymbol
of "isTest": result = $item.getIsTest() of "isTest": result = $item.isTest
of "isEnabled": result = $item.getIsEnabled() of "isEnabled": result = $item.enabled
of "iconUrl": result = $item.getIconURL() of "iconUrl": result = $item.iconURL
of "chainColor": result = $item.getChainColor() of "chainColor": result = $item.chainColor
of "shortName": result = $item.getShortName() of "shortName": result = $item.shortName
of "enabledState": result = $item.getEnabledState().int of "enabledState": result = $item.enabledState.int
proc setItems*(self: Model, items: seq[Item]) = proc refreshModel*(self: Model) =
self.beginResetModel() self.beginResetModel()
self.items = items
self.endResetModel() self.endResetModel()
self.countChanged()
proc getChainColor*(self: Model, chainId: int): string {.slot.} = proc getBlockExplorerURL*(self: Model, chainId: int): string =
for item in self.items: for item in self.delegate.getFlatNetworksList():
if(item.getChainId() == chainId): if(item.chainId == chainId):
return item.getChainColor() return item.blockExplorerURL & EXPLORER_TX_PREFIX
return ""
proc getIconUrl*(self: Model, chainId: int): string {.slot.} =
for item in self.items:
if(item.getChainId() == chainId):
return item.getIconURL()
return ""
proc getNetworkShortName*(self: Model, chainId: int): string {.slot.} =
for item in self.items:
if(item.getChainId() == chainId):
return item.getShortName()
return ""
proc getNetworkFullName*(self: Model, chainId: int): string {.slot.} =
for item in self.items:
if(item.getChainId() == chainId):
return item.getChainName()
return ""
proc getNetworkLayer*(self: Model, chainId: int): string {.slot.} =
for item in self.items:
if(item.getChainId() == chainId):
return $item.getLayer()
return ""
proc getNetworkIconUrl*(self: Model, shortName: string): string {.slot.} =
for item in self.items:
if cmpIgnoreCase(item.getShortName(), shortName) == 0:
return item.getIconURL()
return ""
proc getNetworkName*(self: Model, shortName: string): string {.slot.} =
for item in self.items:
if cmpIgnoreCase(item.getShortName(), shortName) == 0:
return item.getChainName()
return ""
proc getNetworkColor*(self: Model, shortName: string): string {.slot.} =
for item in self.items:
if cmpIgnoreCase(item.getShortName(), shortName) == 0:
return item.getChainColor()
return ""
proc getNetworkChainId*(self: Model, shortName: string): int {.slot.} =
for item in self.items:
if cmpIgnoreCase(item.getShortName(), shortName) == 0:
return item.getChainId()
return 0
proc getLayer1Network*(self: Model, testNet: bool): int =
for item in self.items:
if item.getLayer() == NETWORK_LAYER_1 and item.getIsTest() == testNet:
return item.getChainId()
return 0
proc getBlockExplorerURL*(self: Model, chainId: int): string {.slot.} =
for item in self.items:
if(item.getChainId() == chainId):
return item.getBlockExplorerURL() & EXPLORER_TX_PREFIX
return "" return ""
proc getEnabledState*(self: Model, chainId: int): UxEnabledState = proc getEnabledState*(self: Model, chainId: int): UxEnabledState =
for item in self.items: for item in self.delegate.getFlatNetworksList():
if(item.getChainId() == chainId): if(item.chainId == chainId):
return item.getEnabledState() return item.enabledState
return UxEnabledState.Disabled return UxEnabledState.Disabled
# Returns the chains that need to be enabled or disabled (the second return value) # Returns the chains that need to be enabled or disabled (the second return value)
# to satisty the transitions: all enabled to only chainId enabled and # to satisty the transitions: all enabled to only chainId enabled and
# only chainId enabled to all enabled # only chainId enabled to all enabled
proc networksToChangeStateOnUserActionFor*(self: Model, chainId: int): (seq[int], bool) = proc networksToChangeStateOnUserActionFor*(self: Model, chainId: int, areTestNetworksEnabled: bool): (seq[int], bool) =
let filteredNetworks = self.delegate.getFlatNetworksList().filter(n => n.isTest == areTestNetworksEnabled)
var chainIds: seq[int] = @[] var chainIds: seq[int] = @[]
var enable = false var enable = false
case self.getEnabledState(chainId): case self.getEnabledState(chainId):
of UxEnabledState.Enabled: of UxEnabledState.Enabled:
# Iterate to check for the only chainId enabled case ... # Iterate to check for the only chainId enabled case ...
for item in self.items: for item in filteredNetworks:
if item.getEnabledState() == UxEnabledState.Enabled and item.getChainId() != chainId: if item.enabledState == UxEnabledState.Enabled and item.chainId != chainId:
# ... as soon as we find another enabled chain mark this by adding it to the list # ... as soon as we find another enabled chain mark this by adding it to the list
chainIds.add(chainId) chainIds.add(chainId)
break break
# ... if no other chains are enabled, then it's a transition from only chainId enabled to all enabled # ... if no other chains are enabled, then it's a transition from only chainId enabled to all enabled
if chainIds.len == 0: if chainIds.len == 0:
for item in self.items: for item in filteredNetworks:
if item.getChainId() != chainId: if item.chainId != chainId:
chainIds.add(item.getChainId()) chainIds.add(item.chainId)
enable = true enable = true
of UxEnabledState.Disabled: of UxEnabledState.Disabled:
chainIds.add(chainId) chainIds.add(chainId)
enable = true enable = true
of UxEnabledState.AllEnabled: of UxEnabledState.AllEnabled:
# disable all but chainId # disable all but chainId
for item in self.items: for item in filteredNetworks:
if item.getChainId() != chainId: if item.chainId != chainId:
chainIds.add(item.getChainId()) chainIds.add(item.chainId)
return (chainIds, enable) return (chainIds, enable)
proc getNetworkShortNames*(self: Model, preferredNetworks: string): string = proc getNetworkShortNames*(self: Model, preferredNetworks: string, areTestNetworksEnabled: bool): string =
var networkString = "" var networkString = ""
let networks = preferredNetworks.split(":") let networks = preferredNetworks.split(":")
for nw in networks: for nw in networks:
for item in self.items: for item in self.delegate.getFlatNetworksList():
if $item.getChainId() == nw: if $item.chainId == nw and item.isTest == areTestNetworksEnabled:
networkString = networkString & item.getShortName() & ':' networkString = networkString & item.shortName & ':'
break break
return networkString return networkString
@ -256,11 +191,11 @@ QtObject:
var networkIds = "" var networkIds = ""
let networksNames = shortNames.split(":") let networksNames = shortNames.split(":")
for name in networksNames: for name in networksNames:
for item in self.items: for item in self.delegate.getFlatNetworksList():
if item.getShortName() == name: if item.shortName == name:
networkIds = networkIds & $item.getChainId() & ':' networkIds = networkIds & $item.chainId & ':'
break break
return networkIds return networkIds
proc getAllNetworksChainIds*(self: Model): string = proc getEnabledChainIds*(self: Model, areTestNetworksEnabled: bool): string =
return self.items.map(x => x.getChainId()).join(":") return self.delegate.getFlatNetworksList().filter(n => n.enabled and n.isTest == areTestNetworksEnabled).map(n => n.chainId).join(":")

View File

@ -40,7 +40,7 @@ method delete*(self: Module) =
method refreshNetworks*(self: Module) = method refreshNetworks*(self: Module) =
self.view.setAreTestNetworksEnabled(self.controller.areTestNetworksEnabled()) self.view.setAreTestNetworksEnabled(self.controller.areTestNetworksEnabled())
self.view.setItems(self.controller.getFlatNetworks()) self.view.refreshModel()
method load*(self: Module) = method load*(self: Module) =
self.controller.init() self.controller.init()
@ -63,5 +63,9 @@ method viewDidLoad*(self: Module) =
method setNetworksState*(self: Module, chainIds: seq[int], enabled: bool) = method setNetworksState*(self: Module, chainIds: seq[int], enabled: bool) =
self.controller.setNetworksState(chainIds, enabled) self.controller.setNetworksState(chainIds, enabled)
method getNetworkLayer*(self: Module, chainId: int): string = # Interfaces for getting lists from the service files into the abstract models
return self.view.getNetworkLayer(chainId)
method getNetworksDataSource*(self: Module): NetworksDataSource =
return (
getFlatNetworksList: proc(): var seq[NetworkDto] = self.controller.getFlatNetworks()
)

View File

@ -1,21 +1,12 @@
import NimQml, sequtils, sugar, strutils import NimQml, sequtils, strutils
import app_service/service/network/[dto, types]
import ./io_interface import ./io_interface
import ./model import ./model
import ./item
proc networkEnabledToUxEnabledState(enabled: bool, allEnabled: bool): UxEnabledState
proc areAllEnabled(networks: seq[NetworkDto]): bool
QtObject: QtObject:
type type
View* = ref object of QObject View* = ref object of QObject
delegate: io_interface.AccessInterface delegate: io_interface.AccessInterface
all: Model
enabled: Model
layer1: Model
layer2: Model
flatNetworks: Model flatNetworks: Model
areTestNetworksEnabled: bool areTestNetworksEnabled: bool
enabledChainIds: string enabledChainIds: string
@ -29,11 +20,7 @@ QtObject:
proc newView*(delegate: io_interface.AccessInterface): View = proc newView*(delegate: io_interface.AccessInterface): View =
new(result, delete) new(result, delete)
result.delegate = delegate result.delegate = delegate
result.all = newModel() result.flatNetworks = newModel(delegate.getNetworksDataSource())
result.layer1 = newModel()
result.layer2 = newModel()
result.enabled = newModel()
result.flatNetworks = newModel()
result.enabledChainIds = "" result.enabledChainIds = ""
result.setup() result.setup()
@ -50,34 +37,6 @@ QtObject:
self.areTestNetworksEnabled = areTestNetworksEnabled self.areTestNetworksEnabled = areTestNetworksEnabled
self.areTestNetworksEnabledChanged() self.areTestNetworksEnabledChanged()
proc allChanged*(self: View) {.signal.}
proc getAll(self: View): QVariant {.slot.} =
return newQVariant(self.all)
QtProperty[QVariant] all:
read = getAll
notify = allChanged
proc layer1Changed*(self: View) {.signal.}
proc getLayer1(self: View): QVariant {.slot.} =
return newQVariant(self.layer1)
QtProperty[QVariant] layer1:
read = getLayer1
notify = layer1Changed
proc layer2Changed*(self: View) {.signal.}
proc getLayer2(self: View): QVariant {.slot.} =
return newQVariant(self.layer2)
QtProperty[QVariant] layer2:
read = getLayer2
notify = layer2Changed
proc flatNetworksChanged*(self: View) {.signal.} proc flatNetworksChanged*(self: View) {.signal.}
proc getFlatNetworks(self: View): QVariant {.slot.} = proc getFlatNetworks(self: View): QVariant {.slot.} =
return newQVariant(self.flatNetworks) return newQVariant(self.flatNetworks)
@ -85,15 +44,6 @@ QtObject:
read = getFlatNetworks read = getFlatNetworks
notify = flatNetworksChanged notify = flatNetworksChanged
proc enabledChanged*(self: View) {.signal.}
proc getEnabled(self: View): QVariant {.slot.} =
return newQVariant(self.enabled)
QtProperty[QVariant] enabled:
read = getEnabled
notify = enabledChanged
proc enabledChainIdsChanged*(self: View) {.signal.} proc enabledChainIdsChanged*(self: View) {.signal.}
proc getEnabledChainIds(self: View): QVariant {.slot.} = proc getEnabledChainIds(self: View): QVariant {.slot.} =
return newQVariant(self.enabledChainIds) return newQVariant(self.enabledChainIds)
@ -101,71 +51,24 @@ QtObject:
read = getEnabledChainIds read = getEnabledChainIds
notify = enabledChainIdsChanged notify = enabledChainIdsChanged
proc setItems*(self: View, networks: seq[NetworkDto]) = proc refreshModel*(self: View) =
var items: seq[Item] = @[] self.flatNetworks.refreshModel()
let allEnabled = areAllEnabled(networks) self.enabledChainIds = self.flatNetworks.getEnabledChainIds(self.areTestNetworksEnabled)
for n in networks: self.flatNetworksChanged()
items.add(initItem(
n.chainId,
n.nativeCurrencyDecimals,
n.layer,
n.chainName,
n.rpcURL,
n.blockExplorerURL,
n.nativeCurrencyName,
n.nativeCurrencySymbol,
n.isTest,
n.enabled,
n.iconUrl,
n.chainColor,
n.shortName,
# Ensure we mark all as enabled if all are enabled
networkEnabledToUxEnabledState(n.enabled, allEnabled)
))
let filteredItems = items.filter(i => i.getIsTest() == self.areTestNetworksEnabled)
self.flatNetworks.setItems(items)
self.all.setItems(filteredItems)
self.layer1.setItems(filteredItems.filter(i => i.getLayer() == NETWORK_LAYER_1))
self.layer2.setItems(filteredItems.filter(i => i.getLayer() == NETWORK_LAYER_2))
self.enabled.setItems(filteredItems.filter(i => i.getIsEnabled()))
self.enabledChainIds = filteredItems.filter(i => i.getIsEnabled()).map(a => a.getChainId()).join(":")
self.allChanged()
self.layer1Changed()
self.layer2Changed()
self.enabledChanged()
self.enabledChainIdsChanged() self.enabledChainIdsChanged()
proc load*(self: View) = proc load*(self: View) =
self.delegate.viewDidLoad() self.delegate.viewDidLoad()
proc toggleNetwork*(self: View, chainId: int) {.slot.} = proc toggleNetwork*(self: View, chainId: int) {.slot.} =
let (chainIds, enable) = self.all.networksToChangeStateOnUserActionFor(chainId) let (chainIds, enable) = self.flatNetworks.networksToChangeStateOnUserActionFor(chainId, self.areTestNetworksEnabled)
self.delegate.setNetworksState(chainIds, enable) self.delegate.setNetworksState(chainIds, enable)
proc getMainnetChainId*(self: View): int {.slot.} =
return self.layer1.getLayer1Network(self.areTestNetworksEnabled)
proc getNetworkShortNames*(self: View, preferredNetworks: string): string {.slot.} = proc getNetworkShortNames*(self: View, preferredNetworks: string): string {.slot.} =
return self.all.getNetworkShortNames(preferredNetworks) return self.flatNetworks.getNetworkShortNames(preferredNetworks, self.areTestNetworksEnabled)
proc getNetworkIds*(self: View, shortNames: string): string {.slot.} = proc getNetworkIds*(self: View, shortNames: string): string {.slot.} =
return self.all.getNetworkIds(shortNames) return self.flatNetworks.getNetworkIds(shortNames)
proc getAllNetworksChainIds*(self: View): string {.slot.} = proc getBlockExplorerURL*(self: View, chainId: int): string {.slot.} =
return self.all.getAllNetworksChainIds() return self.flatNetworks.getBlockExplorerURL(chainId)
proc networkEnabledToUxEnabledState(enabled: bool, allEnabled: bool): UxEnabledState =
return if allEnabled:
UxEnabledState.AllEnabled
elif enabled:
UxEnabledState.Enabled
else:
UxEnabledState.Disabled
proc areAllEnabled(networks: seq[NetworkDto]): bool =
return networks.allIt(it.enabled)
proc getNetworkLayer*(self: View, chainId: int): string =
return self.all.getNetworkLayer(chainId)

View File

@ -80,10 +80,10 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
return self.walletAccountService.getWalletAccounts() return self.walletAccountService.getWalletAccounts()
proc getChainIds*(self: Controller): seq[int] = proc getChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().map(n => n.chainId) return self.networkService.getCurrentNetworks().map(n => n.chainId)
proc getEnabledChainIds*(self: Controller): seq[int] = proc getEnabledChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId) return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
proc getCurrentCurrency*(self: Controller): string = proc getCurrentCurrency*(self: Controller): string =
return self.walletAccountService.getCurrency() return self.walletAccountService.getCurrency()
@ -130,8 +130,8 @@ proc areTestNetworksEnabled*(self: Controller): bool =
proc getTotalCurrencyBalance*(self: Controller, address: seq[string], chainIds: seq[int]): float64 = proc getTotalCurrencyBalance*(self: Controller, address: seq[string], chainIds: seq[int]): float64 =
return self.walletAccountService.getTotalCurrencyBalance(address, chainIds) return self.walletAccountService.getTotalCurrencyBalance(address, chainIds)
proc getNetworks*(self: Controller): seq[NetworkDto] = proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
return self.networkService.getNetworks() return self.networkService.getCurrentNetworks()
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto = proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
return self.walletAccountService.getKeypairByAccountAddress(address) return self.walletAccountService.getKeypairByAccountAddress(address)

View File

@ -194,7 +194,7 @@ method refreshWalletAccounts*(self: Module) =
self.view.switchReceiveAccount(self.receiveCurrentAccountIndex) self.view.switchReceiveAccount(self.receiveCurrentAccountIndex)
proc refreshNetworks*(self: Module) = proc refreshNetworks*(self: Module) =
let networks = self.controller.getNetworks() let networks = self.controller.getCurrentNetworks()
let fromNetworks = networks.map(x => self.convertNetworkDtoToNetworkItem(x)) let fromNetworks = networks.map(x => self.convertNetworkDtoToNetworkItem(x))
let toNetworks = networks.map(x => self.convertNetworkDtoToNetworkItem(x)) let toNetworks = networks.map(x => self.convertNetworkDtoToNetworkItem(x))
self.view.setNetworkItems(fromNetworks, toNetworks) self.view.setNetworkItems(fromNetworks, toNetworks)

View File

@ -262,7 +262,7 @@ QtObject:
self.items[i].isPreferred = true self.items[i].isPreferred = true
self.dataChanged(index, index, @[ModelRole.IsPreferred.int]) self.dataChanged(index, index, @[ModelRole.IsPreferred.int])
proc getNetworkColor*(self: NetworkModel, shortName: string): string {.slot.} = proc getNetworkColor*(self: NetworkModel, shortName: string): string =
for item in self.items: for item in self.items:
if cmpIgnoreCase(item.getShortName(), shortName) == 0: if cmpIgnoreCase(item.getShortName(), shortName) == 0:
return item.getChainColor() return item.getChainColor()

View File

@ -54,7 +54,7 @@ QtObject:
notify = isDetailedEntryLoadingChanged notify = isDetailedEntryLoadingChanged
proc getExtraData(self: Controller, chainID: int): ExtraData = proc getExtraData(self: Controller, chainID: int): ExtraData =
let network = self.networkService.getNetwork(chainID) let network = self.networkService.getNetworkByChainId(chainID)
return getExtraData(network) return getExtraData(network)
proc processGetCollectiblesDetailsResponse(self: Controller, response: JsonNode) = proc processGetCollectiblesDetailsResponse(self: Controller, response: JsonNode) =

View File

@ -147,7 +147,7 @@ QtObject:
self.loadMoreItems() self.loadMoreItems()
proc getExtraData(self: Controller, chainID: int): ExtraData = proc getExtraData(self: Controller, chainID: int): ExtraData =
let network = self.networkService.getNetwork(chainID) let network = self.networkService.getNetworkByChainId(chainID)
return getExtraData(network) return getExtraData(network)
proc setTempItems(self: Controller, newItems: seq[CollectiblesEntry], offset: int) = proc setTempItems(self: Controller, newItems: seq[CollectiblesEntry], offset: int) =

View File

@ -470,7 +470,7 @@ QtObject:
self.resetMessageCursor(chatArg.chatId) self.resetMessageCursor(chatArg.chatId)
proc getTransactionDetails*(self: Service, message: MessageDto): (string, string) = proc getTransactionDetails*(self: Service, message: MessageDto): (string, string) =
let networksDto = self.networkService.getNetworks() let networksDto = self.networkService.getCurrentNetworks()
var token = self.tokenService.findTokenByAddress(networksDto[0].chainId, ZERO_ADDRESS) var token = self.tokenService.findTokenByAddress(networksDto[0].chainId, ZERO_ADDRESS)
if message.transactionParameters.contract != "": if message.transactionParameters.contract != "":

View File

@ -5,6 +5,12 @@ import ./types
export types export types
type
UxEnabledState* {.pure.} = enum
Enabled
AllEnabled
Disabled
type NetworkDto* = ref object type NetworkDto* = ref object
chainId* {.serializedFieldName("chainId").}: int chainId* {.serializedFieldName("chainId").}: int
nativeCurrencyDecimals* {.serializedFieldName("nativeCurrencyDecimals").}: int nativeCurrencyDecimals* {.serializedFieldName("nativeCurrencyDecimals").}: int
@ -23,6 +29,7 @@ type NetworkDto* = ref object
chainColor* {.serializedFieldName("chainColor").}: string chainColor* {.serializedFieldName("chainColor").}: string
shortName* {.serializedFieldName("shortName").}: string shortName* {.serializedFieldName("shortName").}: string
relatedChainId* {.serializedFieldName("relatedChainId").}: int relatedChainId* {.serializedFieldName("relatedChainId").}: int
enabledState*: UxEnabledState
proc `$`*(self: NetworkDto): string = proc `$`*(self: NetworkDto): string =
return fmt"""Network( return fmt"""Network(
@ -40,7 +47,8 @@ proc `$`*(self: NetworkDto): string =
isTest:{self.isTest}, enabled:{self.enabled}, isTest:{self.isTest}, enabled:{self.enabled},
chainColor:{self.chainColor}, chainColor:{self.chainColor},
shortName:{self.shortName}, shortName:{self.shortName},
relatedChainId:{self.relatedChainId} relatedChainId:{self.relatedChainId},
enabledState:{self.enabledState}
)""" )"""
proc hash*(self: NetworkDto): Hash = proc hash*(self: NetworkDto): Hash =
@ -56,3 +64,10 @@ proc `$`*(self: CombinedNetworkDto): string =
test:{$self.test}, test:{$self.test},
)""" )"""
proc networkEnabledToUxEnabledState*(enabled: bool, allEnabled: bool): UxEnabledState =
return if allEnabled:
UxEnabledState.AllEnabled
elif enabled:
UxEnabledState.Enabled
else:
UxEnabledState.Disabled

View File

@ -1,4 +1,4 @@
import json, json_serialization, chronicles, atomics import json, json_serialization, chronicles, sugar, sequtils
import ../../../app/core/eventemitter import ../../../app/core/eventemitter
import ../../../backend/backend as backend import ../../../backend/backend as backend
@ -21,12 +21,10 @@ type NetworkEndpointUpdatedArgs* = ref object of Args
type type
Service* = ref object of RootObj Service* = ref object of RootObj
events: EventEmitter events: EventEmitter
networks: seq[CombinedNetworkDto] combinedNetworks: seq[CombinedNetworkDto]
networksInited: bool flatNetworks: seq[NetworkDto]
dirty: Atomic[bool]
settingsService: settings_service.Service settingsService: settings_service.Service
proc delete*(self: Service) = proc delete*(self: Service) =
discard discard
@ -35,50 +33,38 @@ proc newService*(events: EventEmitter, settingsService: settings_service.Service
result.events = events result.events = events
result.settingsService = settingsService result.settingsService = settingsService
proc init*(self: Service) = proc fetchNetworks*(self: Service): seq[CombinedNetworkDto]=
discard let response = backend.getEthereumChains()
if not response.error.isNil:
raise newException(Exception, "Error getting combinedNetworks: " & response.error.message)
result = if response.result.isNil or response.result.kind == JNull: @[]
else: Json.decode($response.result, seq[CombinedNetworkDto], allowUnknownFields = true)
self.combinedNetworks = result
let allTestEnabled = self.combinedNetworks.filter(n => n.test.enabled).len == self.combinedNetworks.len
let allProdEnabled = self.combinedNetworks.filter(n => n.prod.enabled).len == self.combinedNetworks.len
for n in self.combinedNetworks:
n.test.enabledState = networkEnabledToUxEnabledState(n.test.enabled, allTestEnabled)
n.prod.enabledState = networkEnabledToUxEnabledState(n.prod.enabled, allProdEnabled)
self.flatNetworks = @[]
for network in self.combinedNetworks:
self.flatNetworks.add(network.test)
self.flatNetworks.add(network.prod)
proc fetchNetworks*(self: Service, useCached: bool = true): seq[CombinedNetworkDto] = proc init*(self: Service) =
let cacheIsDirty = not self.networksInited or self.dirty.load discard self.fetchNetworks()
if useCached and not cacheIsDirty:
result = self.networks
else:
let response = backend.getEthereumChains()
if not response.error.isNil:
raise newException(Exception, "Error getting networks: " & response.error.message)
result = if response.result.isNil or response.result.kind == JNull: @[]
else: Json.decode($response.result, seq[CombinedNetworkDto], allowUnknownFields = true)
self.dirty.store(false)
self.networks = result
self.networksInited = true
proc resetNetworks*(self: Service) = proc resetNetworks*(self: Service) =
discard self.fetchNetworks(useCached = false) discard self.fetchNetworks()
proc getCombinedNetworks*(self: Service): seq[CombinedNetworkDto] = proc getCombinedNetworks*(self: Service): seq[CombinedNetworkDto] =
return self.fetchNetworks() return self.combinedNetworks
# TODO:: update the networks service to unify the model exposed from this service proc getFlatNetworks*(self: Service): var seq[NetworkDto] =
# We currently have 3 types: combined, test/mainet and flat and probably can be optimized return self.flatNetworks
# follow up task https://github.com/status-im/status-desktop/issues/12717
proc getFlatNetworks*(self: Service): seq[NetworkDto] =
for network in self.fetchNetworks():
result.add(network.test)
result.add(network.prod)
proc getNetworks*(self: Service): seq[NetworkDto] = # passes networks based on users choice of test/mainnet
let testNetworksEnabled = self.settingsService.areTestNetworksEnabled() proc getCurrentNetworks*(self: Service): seq[NetworkDto] =
self.flatNetworks.filter(n => n.isTest == self.settingsService.areTestNetworksEnabled())
for network in self.fetchNetworks():
if testNetworksEnabled:
result.add(network.test)
else:
result.add(network.prod)
proc getAllNetworkChainIds*(self: Service): seq[int] =
for network in self.fetchNetworks():
result.add(network.test.chainId)
result.add(network.prod.chainId)
proc upsertNetwork*(self: Service, network: NetworkDto): bool = proc upsertNetwork*(self: Service, network: NetworkDto): bool =
let response = backend.addEthereumChain(backend.Network( let response = backend.addEthereumChain(backend.Network(
@ -100,48 +86,34 @@ proc upsertNetwork*(self: Service, network: NetworkDto): bool =
shortName: network.shortName, shortName: network.shortName,
relatedChainID: network.relatedChainID, relatedChainID: network.relatedChainID,
)) ))
self.dirty.store(true)
return response.error == nil return response.error == nil
proc deleteNetwork*(self: Service, network: NetworkDto) = proc deleteNetwork*(self: Service, network: NetworkDto) =
discard backend.deleteEthereumChain(network.chainId) discard backend.deleteEthereumChain(network.chainId)
self.dirty.store(true)
proc getNetwork*(self: Service, chainId: int): NetworkDto = proc getNetworkByChainId*(self: Service, chainId: int): NetworkDto =
var networks = self.combinedNetworks
if self.combinedNetworks.len == 0:
networks = self.fetchNetworks()
let testNetworksEnabled = self.settingsService.areTestNetworksEnabled() let testNetworksEnabled = self.settingsService.areTestNetworksEnabled()
for network in self.fetchNetworks(): for network in networks:
let net = if testNetworksEnabled: network.test let net = if testNetworksEnabled: network.test
else: network.prod else: network.prod
if chainId == net.chainId: if chainId == net.chainId:
return net return net
return nil
proc getNetworkByChainId*(self: Service, chainId: int): NetworkDto =
for network in self.fetchNetworks():
if chainId == network.prod.chainId:
return network.prod
elif chainId == network.test.chainId:
return network.test
proc getNetwork*(self: Service, networkType: NetworkType): NetworkDto =
let testNetworksEnabled = self.settingsService.areTestNetworksEnabled()
for network in self.fetchNetworks():
let net = if testNetworksEnabled: network.test
else: network.prod
if networkType.toChainId() == net.chainId:
return net
# Will be removed, this is used in case of legacy chain Id
return NetworkDto(chainId: networkType.toChainId())
proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) = proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
for chainId in chainIds: for chainId in chainIds:
let network = self.getNetwork(chainId) let network = self.getNetworkByChainId(chainId)
if network.enabled == enabled: if not network.isNil:
continue if network.enabled == enabled:
continue
network.enabled = enabled network.enabled = enabled
discard self.upsertNetwork(network) discard self.upsertNetwork(network)
discard self.fetchNetworks()
## This procedure retuns the network to be used based on the app mode (testnet/mainnet). ## This procedure retuns the network to be used based on the app mode (testnet/mainnet).
## We don't need to check if retuned network is nil cause it should never be, but if somehow it is, the app will be closed. ## We don't need to check if retuned network is nil cause it should never be, but if somehow it is, the app will be closed.
@ -159,7 +131,7 @@ proc getAppNetwork*(self: Service): NetworkDto =
networkId = Sepolia networkId = Sepolia
if self.settingsService.isGoerliEnabled(): if self.settingsService.isGoerliEnabled():
networkId = Goerli networkId = Goerli
let network = self.getNetwork(networkId) let network = self.getNetworkByChainId(networkId)
if network.isNil: if network.isNil:
# we should not be here ever # we should not be here ever
error "the app network cannot be resolved" error "the app network cannot be resolved"
@ -169,11 +141,12 @@ proc getAppNetwork*(self: Service): NetworkDto =
proc updateNetworkEndPointValues*(self: Service, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) = proc updateNetworkEndPointValues*(self: Service, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) =
let network = self.getNetworkByChainId(chainId) let network = self.getNetworkByChainId(chainId)
if network.rpcURL != newMainRpcInput: if not network.isNil:
network.rpcURL = newMainRpcInput if network.rpcURL != newMainRpcInput:
network.rpcURL = newMainRpcInput
if network.fallbackURL != newFailoverRpcUrl: if network.fallbackURL != newFailoverRpcUrl:
network.fallbackURL = newFailoverRpcUrl network.fallbackURL = newFailoverRpcUrl
if self.upsertNetwork(network): if self.upsertNetwork(network):
self.events.emit(SIGNAL_NETWORK_ENDPOINT_UPDATED, NetworkEndpointUpdatedArgs(isTest: network.isTest, networkName: network.chainName, revertedToDefault: revertToDefault)) self.events.emit(SIGNAL_NETWORK_ENDPOINT_UPDATED, NetworkEndpointUpdatedArgs(isTest: network.isTest, networkName: network.chainName, revertedToDefault: revertToDefault))

View File

@ -143,7 +143,7 @@ QtObject:
var chaindIdsDown: seq[int] = @[] var chaindIdsDown: seq[int] = @[]
var lastSuccessAt: int = connection_status_backend.INVALID_TIMESTAMP # latest succesful connectinon between the down chains var lastSuccessAt: int = connection_status_backend.INVALID_TIMESTAMP # latest succesful connectinon between the down chains
let allChainIds = self.networkService.getNetworks().map(a => a.chainId) let allChainIds = self.networkService.getCurrentNetworks().map(a => a.chainId)
for id in allChainIds: for id in allChainIds:
if chainStatusTable.hasKey($id) and chainStatusTable[$id].value != connection_status_backend.StateValue.Unknown: if chainStatusTable.hasKey($id) and chainStatusTable[$id].value != connection_status_backend.StateValue.Unknown:
if chainStatusTable[$id].value == connection_status_backend.StateValue.Connected: if chainStatusTable[$id].value == connection_status_backend.StateValue.Connected:

View File

@ -279,12 +279,11 @@ QtObject:
let tokenList = Json.decode($tokensResult, TokenListDto, allowUnknownFields = true) let tokenList = Json.decode($tokensResult, TokenListDto, allowUnknownFields = true)
self.tokenListUpdatedAt = tokenList.updatedAt self.tokenListUpdatedAt = tokenList.updatedAt
let supportedNetworkChains = self.networkService.getAllNetworkChainIds() let supportedNetworkChains = self.networkService.getFlatNetworks().map(n => n.chainId)
var flatTokensList: Table[string, TokenItem] = initTable[string, TokenItem]() var flatTokensList: Table[string, TokenItem] = initTable[string, TokenItem]()
var tokenBySymbolList: Table[string, TokenBySymbolItem] = initTable[string, TokenBySymbolItem]() var tokenBySymbolList: Table[string, TokenBySymbolItem] = initTable[string, TokenBySymbolItem]()
var tokenSymbols: seq[string] = @[] var tokenSymbols: seq[string] = @[]
for s in tokenList.data: for s in tokenList.data:
let newSource = SupportedSourcesItem(name: s.name, source: s.source, version: s.version, tokensCount: s.tokens.len) let newSource = SupportedSourcesItem(name: s.name, source: s.source, version: s.version, tokensCount: s.tokens.len)
self.sourcesOfTokensList.add(newSource) self.sourcesOfTokensList.add(newSource)

View File

@ -487,8 +487,8 @@ QtObject:
if token != nil: if token != nil:
tokenSymbol = token.symbol tokenSymbol = token.symbol
let network = self.networkService.getNetwork(chainID) let network = self.networkService.getNetworkByChainId(chainID)
if network.nativeCurrencySymbol == tokenSymbol: if not network.isNil and network.nativeCurrencySymbol == tokenSymbol:
isEthTx = true isEthTx = true
if(isEthTx): if(isEthTx):

View File

@ -10,7 +10,7 @@ proc tokenBalanceHistoryDataResolved*(self: Service, response: string) {.slot.}
proc fetchHistoricalBalanceForTokenAsJson*(self: Service, addresses: seq[string], allAddresses: bool, tokenSymbol: string, currencySymbol: string, timeInterval: BalanceHistoryTimeInterval) = proc fetchHistoricalBalanceForTokenAsJson*(self: Service, addresses: seq[string], allAddresses: bool, tokenSymbol: string, currencySymbol: string, timeInterval: BalanceHistoryTimeInterval) =
# create an empty list of chain ids # create an empty list of chain ids
var chainIds: seq[int] = self.networkService.getNetworks().filter(n => n.enabled and n.nativeCurrencySymbol == tokenSymbol).map(n => n.chainId) var chainIds: seq[int] = self.networkService.getCurrentNetworks().filter(n => n.enabled and n.nativeCurrencySymbol == tokenSymbol).map(n => n.chainId)
if chainIds.len == 0: if chainIds.len == 0:
let tokenChainIds = self.tokenService.getFlatTokensList().filter(t => t.symbol == tokenSymbol and t.communityId.isEmptyOrWhitespace).map(t => t.chainID) let tokenChainIds = self.tokenService.getFlatTokensList().filter(t => t.symbol == tokenSymbol and t.communityId.isEmptyOrWhitespace).map(t => t.chainID)
chainIds = concat(chainIds, tokenChainIds) chainIds = concat(chainIds, tokenChainIds)

View File

@ -761,7 +761,7 @@ proc fetchChainIdForUrl*(self: Service, url: string, isMainUrl: bool) =
self.threadpool.start(arg) self.threadpool.start(arg)
proc getEnabledChainIds*(self: Service): seq[int] = proc getEnabledChainIds*(self: Service): seq[int] =
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId) return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
proc getCurrencyFormat*(self: Service, symbol: string): CurrencyFormatDto = proc getCurrencyFormat*(self: Service, symbol: string): CurrencyFormatDto =
return self.currencyService.getCurrencyFormat(symbol) return self.currencyService.getCurrencyFormat(symbol)

View File

@ -132,7 +132,7 @@ proc getOrFetchBalanceForAddressInPreferredCurrency*(self: Service, address: str
result.balance = 0.0 result.balance = 0.0
result.fetched = false result.fetched = false
return return
let chainIds = self.networkService.getNetworks().map(n => n.chainId) let chainIds = self.networkService.getCurrentNetworks().map(n => n.chainId)
result.balance = self.getTotalCurrencyBalance(@[acc.address], chainIds) result.balance = self.getTotalCurrencyBalance(@[acc.address], chainIds)
result.fetched = true result.fetched = true
@ -159,7 +159,7 @@ proc checkRecentHistory*(self: Service, addresses: seq[string]) =
if(not main_constants.WALLET_ENABLED): if(not main_constants.WALLET_ENABLED):
return return
try: try:
let chainIds = self.networkService.getNetworks().map(a => a.chainId) let chainIds = self.networkService.getCurrentNetworks().map(a => a.chainId)
status_go_transactions.checkRecentHistory(chainIds, addresses) status_go_transactions.checkRecentHistory(chainIds, addresses)
except Exception as e: except Exception as e:
let errDescription = e.msg let errDescription = e.msg

View File

@ -1,6 +1,8 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import SortFilterProxyModel 0.2
import AppLayouts.Profile.views.wallet 1.0 import AppLayouts.Profile.views.wallet 1.0
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
@ -48,7 +50,10 @@ SplitView {
} }
readonly property QtObject walletStore: QtObject { readonly property QtObject walletStore: QtObject {
property var networks: NetworksModel.mainNetworks property var networks: SortFilterProxyModel {
sourceModel: NetworksModel.flatNetworks
filters: ValueFilter { roleName: "isTest"; value: areTestNetworksEnabledCheckbox.checked }
}
property bool areTestNetworksEnabled: areTestNetworksEnabledCheckbox.checked property bool areTestNetworksEnabled: areTestNetworksEnabledCheckbox.checked
function toggleNetwork(chainId) { function toggleNetwork(chainId) {
} }

View File

@ -146,7 +146,7 @@ SplitView {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
currencyStore: d.currencyStore currencyStore: d.currencyStore
allNetworksModel: NetworksModel.allNetworks allNetworksModel: NetworksModel.flatNetworks
networkFilters: d.networksChainsCurrentlySelected networkFilters: d.networksChainsCurrentlySelected
} }
} }
@ -178,7 +178,7 @@ SplitView {
} }
Repeater { Repeater {
id: networksRepeater id: networksRepeater
model: NetworksModel.allNetworks model: NetworksModel.flatNetworks
delegate: CheckBox { delegate: CheckBox {
property int chainID: chainId property int chainID: chainId
width: parent.width width: parent.width

View File

@ -72,14 +72,6 @@ SplitView {
function formatCurrencyAmount(cryptoValue, symbol) { function formatCurrencyAmount(cryptoValue, symbol) {
return "%L1 %2".arg(cryptoValue).arg(symbol) return "%L1 %2".arg(cryptoValue).arg(symbol)
} }
function getNetworkFullName(chainId) {
return chainId
}
function getNetworkColor(chainId) {
return "pink"
}
} }
walletRootStore: QtObject { walletRootStore: QtObject {
function getNameForAddress(address) { function getNameForAddress(address) {

View File

@ -164,7 +164,7 @@ SplitView {
} }
Repeater { Repeater {
id: networksRepeater id: networksRepeater
model: NetworksModel.allNetworks model: NetworksModel.flatNetworks
delegate: CheckBox { delegate: CheckBox {
property int chainID: chainId property int chainID: chainId
width: parent.width width: parent.width

View File

@ -28,8 +28,6 @@ SplitView {
anchors.fill: parent anchors.fill: parent
anchors.margins: 50 anchors.margins: 50
isAssetView: isAssetBox.checked isAssetView: isAssetBox.checked
layer1Networks: NetworksModel.layer1Networks
layer2Networks: NetworksModel.layer2Networks
accounts: WalletAccountsModel {} accounts: WalletAccountsModel {}
tokensModel: MintedTokensModel {} tokensModel: MintedTokensModel {}
referenceAssetsBySymbolModel: ListModel { referenceAssetsBySymbolModel: ListModel {

View File

@ -2,6 +2,8 @@ import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import SortFilterProxyModel 0.2
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
@ -45,10 +47,10 @@ SplitView {
communityLogo: doodles.checked ? ModelsData.collectibles.doodles : ModelsData.collectibles.mana communityLogo: doodles.checked ? ModelsData.collectibles.doodles : ModelsData.collectibles.mana
communityColor: color1.checked ? "#FFC4E9" : "#f44336" communityColor: color1.checked ? "#FFC4E9" : "#f44336"
layer1Networks: NetworksModel.layer1Networks flatNetworks: SortFilterProxyModel {
layer2Networks: NetworksModel.layer2Networks sourceModel: NetworksModel.flatNetworks
enabledNetworks: NetworksModel.enabledNetworks filters: ValueFilter { roleName: "isTest"; value: false }
allNetworks: enabledNetworks }
accounts: WalletAccountsModel {} accounts: WalletAccountsModel {}
onMintClicked: logs.logEvent("EditOwnerTokenView::onMintClicked") onMintClicked: logs.logEvent("EditOwnerTokenView::onMintClicked")

View File

@ -109,10 +109,10 @@ SplitView {
// Models: // Models:
tokensModel: editorModelChecked.checked ? emptyModel : tokensModel: editorModelChecked.checked ? emptyModel :
privilegedModelChecked.checked ? privilegedTokensModel : mintedTokensModel privilegedModelChecked.checked ? privilegedTokensModel : mintedTokensModel
layer1Networks: NetworksModel.layer1Networks flatNetworks: SortFilterProxyModel {
layer2Networks: NetworksModel.layer2Networks sourceModel: NetworksModel.flatNetworks
enabledNetworks: NetworksModel.enabledNetworks filters: ValueFilter { roleName: "isTest"; value: false }
allNetworks: enabledNetworks }
accounts: WalletAccountsModel {} accounts: WalletAccountsModel {}
referenceAssetsBySymbolModel: ListModel { referenceAssetsBySymbolModel: ListModel {
ListElement { ListElement {

View File

@ -5,6 +5,8 @@ import QtQuick.Layouts 1.13
import Storybook 1.0 import Storybook 1.0
import Models 1.0 import Models 1.0
import SortFilterProxyModel 0.2
import AppLayouts.Wallet.controls 1.0 import AppLayouts.Wallet.controls 1.0
SplitView { SplitView {
@ -36,12 +38,11 @@ SplitView {
id: networkFilter id: networkFilter
anchors.centerIn: parent anchors.centerIn: parent
width: 200
layer1Networks: NetworksModel.layer1Networks flatNetworks: SortFilterProxyModel {
layer2Networks: NetworksModel.layer2Networks sourceModel: NetworksModel.flatNetworks
enabledNetworks: NetworksModel.enabledNetworks filters: ValueFilter { roleName: "isTest"; value: false; }
allNetworks: enabledNetworks }
multiSelection: multiSelectionCheckBox.checked multiSelection: multiSelectionCheckBox.checked

View File

@ -38,23 +38,7 @@ SplitView {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
allNetworks: simulatedNimModel flatNetworks: simulatedNimModel
layer1Networks: SortFilterProxyModel {
function rowData(index, propName) {
return get(index)[propName]
}
sourceModel: simulatedNimModel
filters: ValueFilter { roleName: "layer"; value: 1; }
}
layer2Networks: SortFilterProxyModel {
sourceModel: simulatedNimModel
filters: [ValueFilter { roleName: "layer"; value: 2; },
ValueFilter { roleName: "isTest"; value: false; }]
}
enabledNetworks: SortFilterProxyModel {
sourceModel: simulatedNimModel
filters: ValueFilter { roleName: "isEnabled"; value: true; }
}
onToggleNetwork: (network) => { onToggleNetwork: (network) => {
if(multiSelection) { if(multiSelection) {
@ -77,8 +61,7 @@ SplitView {
NetworkSelectPopup { NetworkSelectPopup {
id: networkSelectPopup id: networkSelectPopup
layer1Networks: networkFilter.layer1Networks flatNetworks: simulatedNimModel
layer2Networks: networkFilter.layer2Networks
useEnabledRole: false useEnabledRole: false
@ -112,7 +95,7 @@ SplitView {
Layout.preferredWidth: selectPopupLoader.item ? selectPopupLoader.item.width : 0 Layout.preferredWidth: selectPopupLoader.item ? selectPopupLoader.item.width : 0
Layout.preferredHeight: selectPopupLoader.item ? selectPopupLoader.item.height : 0 Layout.preferredHeight: selectPopupLoader.item ? selectPopupLoader.item.height : 0
property var currentModel: networkFilter.layer2Networks property var currentModel: networkFilter.flatNetworks
property int currentIndex: 0 property int currentIndex: 0
Loader { Loader {
@ -121,8 +104,7 @@ SplitView {
active: false active: false
sourceComponent: NetworkSelectPopup { sourceComponent: NetworkSelectPopup {
layer1Networks: networkFilter.layer1Networks flatNetworks: simulatedNimModel
layer2Networks: networkFilter.layer2Networks
singleSelection { singleSelection {
enabled: true enabled: true
@ -230,7 +212,7 @@ SplitView {
return get(index)[propName] return get(index)[propName]
} }
sourceModel: NetworksModel.allNetworks sourceModel: NetworksModel.flatNetworks
filters: ValueFilter { roleName: "isTest"; value: testModeCheckbox.checked; } filters: ValueFilter { roleName: "isTest"; value: testModeCheckbox.checked; }
} }

View File

@ -2,6 +2,10 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import SortFilterProxyModel 0.2
import StatusQ.Core.Utils 0.1
import Storybook 1.0 import Storybook 1.0
import Models 1.0 import Models 1.0
import AppLayouts.Wallet.popups 1.0 import AppLayouts.Wallet.popups 1.0
@ -40,19 +44,61 @@ SplitView {
"name": "My account", "name": "My account",
"emoji": "", "emoji": "",
"address": "0x1234567890123456789012345678901234567890", "address": "0x1234567890123456789012345678901234567890",
"preferredSharingChainIds": "opt:eth:" "preferredSharingChainIds": "10:42161:1:"
} }
switchingAccounsEnabled: true switchingAccounsEnabled: true
changingPreferredChainsEnabled: true changingPreferredChainsEnabled: true
hasFloatingButtons: true hasFloatingButtons: true
qrImageSource: "https://upload.wikimedia.org/wikipedia/commons/4/41/QR_Code_Example.svg" qrImageSource: "https://upload.wikimedia.org/wikipedia/commons/4/41/QR_Code_Example.svg"
getNetworkShortNames: function (chainIDsString) { getNetworkShortNames: function (chainIDsString) {
return networksNames let chainArray = chainIDsString.split(":")
let chainNameString = ""
for (let i =0; i<chainArray.length; i++) {
chainNameString += NetworksModel.getShortChainName(Number(chainArray[i])) + ":"
}
return chainNameString
} }
property string networksNames: "opt:arb:eth:" property string networksNames: "opt:arb:eth:"
store: NetworksModel store: QtObject {
property var filteredFlatModel: SortFilterProxyModel {
sourceModel: NetworksModel.flatNetworks
filters: ValueFilter { roleName: "isTest"; value: false }
}
function getAllNetworksChainIds() {
let result = []
let chainIdsArray = ModelUtils.modelToFlatArray(filteredFlatModel, "chainId")
for(let i = 0; i< chainIdsArray.length; i++) {
result.push(chainIdsArray[i].toString())
}
return result
}
function processPreferredSharingNetworkToggle(preferredSharingNetworks, toggledNetwork) {
let prefChains = preferredSharingNetworks
if(prefChains.length === filteredFlatModel.count) {
prefChains = [toggledNetwork.chainId.toString()]
}
else if(!prefChains.includes(toggledNetwork.chainId.toString())) {
prefChains.push(toggledNetwork.chainId.toString())
}
else {
if(prefChains.length === 1) {
prefChains = getAllNetworksChainIds()
}
else {
for(var i = 0; i < prefChains.length;i++) {
if(prefChains[i] === toggledNetwork.chainId.toString()) {
prefChains.splice(i, 1)
}
}
}
}
return prefChains
}
}
} }
} }

View File

@ -2,6 +2,8 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import SortFilterProxyModel 0.2
import Storybook 1.0 import Storybook 1.0
import Models 1.0 import Models 1.0
import AppLayouts.Wallet.popups 1.0 import AppLayouts.Wallet.popups 1.0
@ -32,6 +34,11 @@ SplitView {
id: dialog id: dialog
visible: true visible: true
flatNetworks: SortFilterProxyModel {
sourceModel: NetworksModel.flatNetworks
filters: ValueFilter { roleName: "isTest"; value: false }
}
store: QtObject { store: QtObject {
property var savedAddressNameExists: function() { return false } property var savedAddressNameExists: function() { return false }
} }

View File

@ -20,7 +20,7 @@ SplitView {
readonly property var flatTokensModel: FlatTokensModel {} readonly property var flatTokensModel: FlatTokensModel {}
readonly property var joinModel: LeftJoinModel { readonly property var joinModel: LeftJoinModel {
leftModel: root.flatTokensModel leftModel: root.flatTokensModel
rightModel: NetworksModel.allNetworks rightModel: NetworksModel.flatNetworks
joinRole: "chainId" joinRole: "chainId"
} }

View File

@ -18,7 +18,7 @@ SplitView {
readonly property var flatTokensModel: FlatTokensModel {} readonly property var flatTokensModel: FlatTokensModel {}
readonly property var joinModel: LeftJoinModel { readonly property var joinModel: LeftJoinModel {
leftModel: root.flatTokensModel leftModel: root.flatTokensModel
rightModel: NetworksModel.allNetworks rightModel: NetworksModel.flatNetworks
joinRole: "chainId" joinRole: "chainId"
} }

View File

@ -46,7 +46,7 @@ SplitView {
assets: txStore.processedAssetsModel assets: txStore.processedAssetsModel
collectibles: WalletNestedCollectiblesModel {} collectibles: WalletNestedCollectiblesModel {}
networksModel: NetworksModel.allNetworks networksModel: NetworksModel.flatNetworks
formatCurrentCurrencyAmount: function(balance){ formatCurrentCurrencyAmount: function(balance){
return currencyStore.formatCurrencyAmount(balance, "USD") return currencyStore.formatCurrencyAmount(balance, "USD")
} }

View File

@ -8,6 +8,8 @@ import utils 1.0
import shared.controls 1.0 import shared.controls 1.0
import Models 1.0
SplitView { SplitView {
id: root id: root
@ -82,13 +84,7 @@ SplitView {
return "%L1 %2".arg(cryptoValue).arg(symbol) return "%L1 %2".arg(cryptoValue).arg(symbol)
} }
function getNetworkFullName(chainId) { property var flatNetworks: NetworksModel.flatNetworks
return chainId
}
function getNetworkColor(chainId) {
return "pink"
}
} }
walletRootStore: QtObject { walletRootStore: QtObject {
function getNameForAddress(address) { function getNameForAddress(address) {

View File

@ -13,6 +13,8 @@ import shared.stores 1.0
import utils 1.0 import utils 1.0
import Models 1.0
SplitView { SplitView {
id: root id: root
@ -24,20 +26,16 @@ SplitView {
Component.onCompleted: { Component.onCompleted: {
RootStore.getFiatValue = (cryptoValue, symbol) => { return (cryptoValue * 1800).toPrecision(2) } RootStore.getFiatValue = (cryptoValue, symbol) => { return (cryptoValue * 1800).toPrecision(2) }
RootStore.getNetworkIcon = (chainId) => { return "tiny/network/Network=Ethereum" }
RootStore.getLatestBlockNumber = () => { return 4 } RootStore.getLatestBlockNumber = () => { return 4 }
RootStore.hex2Dec = (number) => { return 10 } RootStore.hex2Dec = (number) => { return 10 }
RootStore.getNetworkColor = (number) => { return "blue" }
RootStore.getNetworkFullName = (chainId) => { return "Ethereum Mainnet" }
RootStore.getNetworkShortName = (chainId) => { return "eth" }
RootStore.formatCurrencyAmount = (value, symbol) => { return value + " " + symbol } RootStore.formatCurrencyAmount = (value, symbol) => { return value + " " + symbol }
RootStore.getNameForSavedWalletAddress = (address) => { return "Saved Wallet Name" } RootStore.getNameForSavedWalletAddress = (address) => { return "Saved Wallet Name" }
RootStore.getNameForAddress = (address) => { return "Address Name" } RootStore.getNameForAddress = (address) => { return "Address Name" }
RootStore.getEnsForSavedWalletAddress = (address) => { return "123" } RootStore.getEnsForSavedWalletAddress = (address) => { return "123" }
RootStore.getChainShortNamesForSavedWalletAddress = (address) => { return "" } RootStore.getChainShortNamesForSavedWalletAddress = (address) => { return "" }
RootStore.getGasEthValue = (gasAmount, gasPrice) => { return (gasAmount * Math.pow(10, -9)).toPrecision(5) } RootStore.getGasEthValue = (gasAmount, gasPrice) => { return (gasAmount * Math.pow(10, -9)).toPrecision(5) }
RootStore.getNetworkLayer = (chainId) => { return 1 }
RootStore.currentCurrency = "USD" RootStore.currentCurrency = "USD"
RootStore.flatNetworks = NetworksModel.flatNetworks
root.rootStoreReady = true root.rootStoreReady = true
} }

View File

@ -1,6 +1,8 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import SortFilterProxyModel 0.2
import AppLayouts.Wallet.panels 1.0 import AppLayouts.Wallet.panels 1.0
import AppLayouts.Wallet.controls 1.0 import AppLayouts.Wallet.controls 1.0
import AppLayouts.Chat.panels 1.0 import AppLayouts.Chat.panels 1.0
@ -78,10 +80,10 @@ SplitView {
} }
readonly property QtObject walletStore: QtObject { readonly property QtObject walletStore: QtObject {
property var allNetworks: enabledNetworks property var filteredFlatModel: SortFilterProxyModel {
property var layer1Networks: NetworksModel.layer1Networks sourceModel: NetworksModel.flatNetworks
property var layer2Networks: NetworksModel.layer2Networks filters: ValueFilter { roleName: "isTest"; value: false }
property var enabledNetworks: NetworksModel.enabledNetworks }
function toggleNetwork(chainId) { function toggleNetwork(chainId) {
} }

View File

@ -12,6 +12,26 @@ QtObject {
readonly property int testnetNet: 5 readonly property int testnetNet: 5
readonly property int customNet: 6 readonly property int customNet: 6
function getShortChainName(chainId) {
if(chainId === root.ethNet)
return "eth"
if(chainId === root.optimismNet)
return "opt"
if(chainId === root.arbitrumNet)
return "arb"
if(chainId === root.hermezNet)
return "her"
if(chainId === root.testnetNet)
return "goe"
if(chainId === root.customNet)
return "cus"
}
function getChainName(chainId) { function getChainName(chainId) {
if(chainId === root.ethNet) if(chainId === root.ethNet)
return "Mainnet" return "Mainnet"
@ -39,157 +59,7 @@ QtObject {
} }
} }
readonly property var layer1Networks: CustomNetworkModel { readonly property var flatNetworks: CustomNetworkModel {
Component.onCompleted:
append([
{
chainId: ethNet,
chainName: "Ethereum Mainnet",
iconUrl: ModelsData.networks.ethereum,
isActive: true,
isEnabled: true,
shortName: "ETH",
chainColor: "blue",
isTest: false
}
])
}
readonly property var layer2Networks: CustomNetworkModel {
Component.onCompleted:
append([
{
chainId: optimismNet,
chainName: "Optimism",
iconUrl: ModelsData.networks.optimism,
isActive: false,
isEnabled: true,
shortName: "OPT",
chainColor: "red",
isTest: false
},
{
chainId: arbitrumNet,
chainName: "Arbitrum",
iconUrl: ModelsData.networks.arbitrum,
isActive: false,
isEnabled: true,
shortName: "ARB",
chainColor: "purple",
isTest: false
}
])
}
readonly property var testNetworks: CustomNetworkModel {
Component.onCompleted:
append([
{
chainId: hermezNet,
chainName: "Hermez",
iconUrl: ModelsData.networks.hermez,
isActive: false,
isEnabled: true,
shortName: "HEZ",
chainColor: "orange",
isTest: true
},
{
chainId: testnetNet,
chainName: "Testnet",
iconUrl: ModelsData.networks.testnet,
isActive: false,
isEnabled: true,
shortName: "TNET",
chainColor: "lightblue",
isTest: true
},
{
chainId: customNet,
chainName: "Custom",
iconUrl: ModelsData.networks.custom,
isActive: false,
isEnabled: true,
shortName: "CUSTOM",
chainColor: "orange",
isTest: true
}
])
}
readonly property var enabledNetworks: CustomNetworkModel {
Component.onCompleted:
append([
{
chainId: 1,
layer: 1,
chainName: "Ethereum Mainnet",
iconUrl: ModelsData.networks.ethereum,
isActive: true,
isEnabled: false,
shortName: "ETH",
chainColor: "blue",
isTest: false
},
{
chainId: 2,
layer: 2,
chainName: "Optimism",
iconUrl: ModelsData.networks.optimism,
isActive: false,
isEnabled: true,
shortName: "OPT",
chainColor: "red",
isTest: false
},
{
chainId: 3,
layer: 2,
chainName: "Arbitrum",
iconUrl: ModelsData.networks.arbitrum,
isActive: false,
isEnabled: true,
shortName: "ARB",
chainColor: "purple",
isTest: false
},
{
chainId: 4,
layer: 2,
chainName: "Hermez",
iconUrl: ModelsData.networks.hermez,
isActive: false,
isEnabled: true,
shortName: "HEZ",
chainColor: "orange",
isTest: false
},
{
chainId: 5,
layer: 1,
chainName: "Testnet",
iconUrl: ModelsData.networks.testnet,
isActive: false,
isEnabled: true,
shortName: "TNET",
chainColor: "lightblue",
isTest: true
},
{
chainId: 6,
layer: 1,
chainName: "Custom",
iconUrl: ModelsData.networks.custom,
isActive: false,
isEnabled: true,
shortName: "CUSTOM",
chainColor: "orange",
isTest: false
}
])
}
readonly property var allNetworks: CustomNetworkModel {
Component.onCompleted: append([ Component.onCompleted: append([
{ {
chainId: 1, chainId: 1,
@ -278,44 +148,6 @@ QtObject {
) )
} }
readonly property var mainNetworks: CustomNetworkModel {
Component.onCompleted: append([
{
chainId: 1,
chainName: "Ethereum Mainnet",
iconUrl: ModelsData.networks.ethereum,
isActive: true,
isEnabled: true,
shortName: "ETH",
chainColor: "blue",
layer: 1,
isTest: false
},
{
chainId: 10,
chainName: "Optimism",
iconUrl: ModelsData.networks.optimism,
isActive: false,
isEnabled: true,
shortName: "OPT",
chainColor: "red",
layer: 2,
isTest: false
},
{
chainId: 42161,
chainName: "Arbitrum",
iconUrl: ModelsData.networks.arbitrum,
isActive: false,
isEnabled: true,
shortName: "ARB",
chainColor: "purple",
layer: 2,
isTest: false
}
])
}
readonly property var sendFromNetworks: CustomNetworkModel { readonly property var sendFromNetworks: CustomNetworkModel {
function updateFromNetworks(paths){ function updateFromNetworks(paths){
reset() reset()

View File

@ -16,7 +16,8 @@ ListModel {
source: "https://gateway.ipfs.io/ipns/tokens.uniswap.org", source: "https://gateway.ipfs.io/ipns/tokens.uniswap.org",
version: "11.6.0", version: "11.6.0",
tokensCount: 731, tokensCount: 731,
image: ModelsData.assets.uni image: ModelsData.assets.uni,
updatedAt: 1710538948
}, },
{ {
key: root.status, key: root.status,
@ -24,7 +25,8 @@ ListModel {
source: "https://status.im/", source: "https://status.im/",
version: "11.6.0", version: "11.6.0",
tokensCount: 250, tokensCount: 250,
image: ModelsData.assets.snt image: ModelsData.assets.snt,
updatedAt: 1710538948
} }
] ]

View File

@ -6,8 +6,5 @@ QtObject {
// //
// Silence warnings // Silence warnings
readonly property ListModel layer1: ListModel {} readonly property ListModel flatNetworks: ListModel {}
readonly property ListModel layer2: ListModel {} }
readonly property ListModel enabled: ListModel {}
readonly property ListModel all: ListModel {}
}

View File

@ -14,20 +14,16 @@ QtObject {
property var currencyStore: CurrenciesStore {} property var currencyStore: CurrenciesStore {}
property var history property var history
property var getNetworkIcon
property var getFiatValue property var getFiatValue
property var getLatestBlockNumber property var getLatestBlockNumber
property var hex2Dec property var hex2Dec
property var getNetworkColor
property var getNetworkFullName
property var getNetworkShortName
property var formatCurrencyAmount property var formatCurrencyAmount
property var getNameForSavedWalletAddress property var getNameForSavedWalletAddress
property var getNameForAddress property var getNameForAddress
property var getEnsForSavedWalletAddress property var getEnsForSavedWalletAddress
property var getChainShortNamesForSavedWalletAddress property var getChainShortNamesForSavedWalletAddress
property var getGasEthValue property var getGasEthValue
property var getNetworkLayer property var flatNetworks
function copyToClipboard(text) { function copyToClipboard(text) {
console.warn("STUB: copyToClipboard:", text) console.warn("STUB: copyToClipboard:", text)

View File

@ -24,7 +24,7 @@ QtObject {
property ListModel model: ListModel{} property ListModel model: ListModel{}
} }
property var allNetworksModel: NetworksModel.allNetworks property var flatNetworksModel: NetworksModel.flatNetworks
property var fromNetworksModel: NetworksModel.sendFromNetworks property var fromNetworksModel: NetworksModel.sendFromNetworks
property var toNetworksModel: NetworksModel.sendToNetworks property var toNetworksModel: NetworksModel.sendToNetworks
property var selectedSenderAccount: senderAccounts.get(0) property var selectedSenderAccount: senderAccounts.get(0)
@ -182,7 +182,7 @@ QtObject {
let listOfChains = chainIds.split(":") let listOfChains = chainIds.split(":")
let listOfChainIds = [] let listOfChainIds = []
for (let k =0;k<listOfChains.length;k++) { for (let k =0;k<listOfChains.length;k++) {
listOfChainIds.push(SQUtils.ModelUtils.getByKey(NetworksModel.allNetworks, "shortName", listOfChains[k], "chainId")) listOfChainIds.push(SQUtils.ModelUtils.getByKey(NetworksModel.flatNetworks, "shortName", listOfChains[k], "chainId"))
} }
return listOfChainIds return listOfChainIds
} }
@ -252,7 +252,7 @@ QtObject {
} }
function getNetworkName(chainId) { function getNetworkName(chainId) {
return SQUtils.ModelUtils.getByKey(NetworksModel.allNetworks, "chainId", chainId, "chainName") return SQUtils.ModelUtils.getByKey(NetworksModel.flatNetworks, "chainId", chainId, "chainName")
} }
function formatCurrencyAmountFromBigInt(balance, symbol, decimals) { function formatCurrencyAmountFromBigInt(balance, symbol, decimals) {

View File

@ -11,7 +11,7 @@ QtObject {
property string signingPhrase: walletSection.signingPhrase property string signingPhrase: walletSection.signingPhrase
function getEtherscanLink(chainID) { function getEtherscanLink(chainID) {
return networksModule.all.getBlockExplorerURL(chainID) return networksModule.getBlockExplorerURL(chainID)
} }
function switchAccountByAddress(address) { function switchAccountByAddress(address) {

View File

@ -491,7 +491,6 @@ QtObject {
property var accounts: walletSectionSendInst.accounts property var accounts: walletSectionSendInst.accounts
property string currentCurrency: walletSection.currentCurrency property string currentCurrency: walletSection.currentCurrency
property CurrenciesStore currencyStore: CurrenciesStore {} property CurrenciesStore currencyStore: CurrenciesStore {}
property var allNetworks: networksModule.all
property var savedAddressesModel: walletSectionSavedAddresses.model property var savedAddressesModel: walletSectionSavedAddresses.model
property var disabledChainIdsFromList: [] property var disabledChainIdsFromList: []

View File

@ -55,10 +55,7 @@ StackView {
required property var referenceAssetsBySymbolModel required property var referenceAssetsBySymbolModel
// Network related properties: // Network related properties:
property var layer1Networks property var flatNetworks
property var layer2Networks
property var enabledNetworks
property var allNetworks
signal mintCollectible(var collectibleItem) signal mintCollectible(var collectibleItem)
signal mintAsset(var assetItem) signal mintAsset(var assetItem)
@ -226,10 +223,7 @@ StackView {
tMasterToken.accountName: ownerTokenPage.accountName tMasterToken.accountName: ownerTokenPage.accountName
tMasterToken.accountAddress: ownerTokenPage.accountAddress tMasterToken.accountAddress: ownerTokenPage.accountAddress
layer1Networks: root.layer1Networks flatNetworks: root.flatNetworks
layer2Networks: root.layer2Networks
enabledNetworks: root.enabledNetworks
allNetworks: root.allNetworks
accounts: root.accounts accounts: root.accounts
feeText: feeSubscriber.feeText feeText: feeSubscriber.feeText
@ -278,14 +272,9 @@ StackView {
id: newTokenPage id: newTokenPage
readonly property int ownerTokenChainId: SQUtils.ModelUtils.get(root.tokensModel, "privilegesLevel", Constants.TokenPrivilegesLevel.Owner).chainId ?? 0 readonly property int ownerTokenChainId: SQUtils.ModelUtils.get(root.tokensModel, "privilegesLevel", Constants.TokenPrivilegesLevel.Owner).chainId ?? 0
readonly property var chainModel: NetworkModelHelpers.getLayerNetworkModelByChainId(root.layer1Networks, readonly property int chainIndex: NetworkModelHelpers.getChainIndexByChainId(root.flatNetworks, ownerTokenChainId)
root.layer2Networks, readonly property string chainName: NetworkModelHelpers.getChainName(root.flatNetworks, chainIndex)
ownerTokenChainId) ?? root.layer2Networks readonly property string chainIcon: NetworkModelHelpers.getChainIconUrl(root.flatNetworks, chainIndex)
readonly property int chainIndex: NetworkModelHelpers.getChainIndexByChainId(root.layer1Networks,
root.layer2Networks,
ownerTokenChainId)
readonly property string chainName: NetworkModelHelpers.getChainName(chainModel, chainIndex)
readonly property string chainIcon: NetworkModelHelpers.getChainIconUrl(chainModel, chainIndex)
property TokenObject asset: TokenObject{ property TokenObject asset: TokenObject{
type: Constants.TokenType.ERC20 type: Constants.TokenType.ERC20
@ -368,8 +357,6 @@ StackView {
id: editView id: editView
viewWidth: root.viewWidth viewWidth: root.viewWidth
layer1Networks: root.layer1Networks
layer2Networks: root.layer2Networks
accounts: root.accounts accounts: root.accounts
tokensModel: root.tokensModel tokensModel: root.tokensModel
referenceAssetsBySymbolModel: root.referenceAssetsBySymbolModel referenceAssetsBySymbolModel: root.referenceAssetsBySymbolModel

View File

@ -354,10 +354,7 @@ StatusSectionLayout {
// Models // Models
tokensModel: root.community.communityTokens tokensModel: root.community.communityTokens
membersModel: root.community.members membersModel: root.community.members
layer1Networks: communityTokensStore.layer1Networks flatNetworks: communityTokensStore.filteredFlatModel
layer2Networks: communityTokensStore.layer2Networks
enabledNetworks: communityTokensStore.enabledNetworks
allNetworks: communityTokensStore.allNetworks
accounts: root.walletAccountsModel accounts: root.walletAccountsModel
referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel

View File

@ -37,10 +37,6 @@ StatusScrollView {
property string referenceName: "" property string referenceName: ""
property string referenceSymbol: "" property string referenceSymbol: ""
// Network related properties:
property var layer1Networks
property var layer2Networks
// Account expected roles: address, name, color, emoji, walletType // Account expected roles: address, name, color, emoji, walletType
property var accounts property var accounts

View File

@ -27,10 +27,7 @@ StatusScrollView {
property color communityColor property color communityColor
// Network related properties: // Network related properties:
property var layer1Networks property var flatNetworks
property var layer2Networks
property var enabledNetworks
property var allNetworks
// Wallet account expected roles: address, name, color, emoji, walletType // Wallet account expected roles: address, name, color, emoji, walletType
property var accounts property var accounts
@ -278,10 +275,7 @@ StatusScrollView {
Layout.fillWidth: true Layout.fillWidth: true
allNetworks: root.allNetworks flatNetworks: root.flatNetworks
layer1Networks: root.layer1Networks
layer2Networks: root.layer2Networks
enabledNetworks: root.enabledNetworks
multiSelection: false multiSelection: false
control.topPadding: 10 control.topPadding: 10
control.background: Rectangle { control.background: Rectangle {

View File

@ -46,7 +46,7 @@ ColumnLayout {
property var preferredSharingNetworksArray: preferredSharingNetworks.split(":").filter(Boolean) property var preferredSharingNetworksArray: preferredSharingNetworks.split(":").filter(Boolean)
property string preferredSharingNetworkShortNames: walletStore.getNetworkShortNames(preferredSharingNetworks) property string preferredSharingNetworkShortNames: walletStore.getNetworkShortNames(preferredSharingNetworks)
onPreferredSharingNetworksChanged: { onPreferredSharingNetworksChanged: {
preferredSharingNetworksArray = preferredSharingNetworks.split(":") preferredSharingNetworksArray = preferredSharingNetworks.split(":").filter(Boolean)
preferredSharingNetworkShortNames = walletStore.getNetworkShortNames(preferredSharingNetworks) preferredSharingNetworkShortNames = walletStore.getNetworkShortNames(preferredSharingNetworks)
} }
} }
@ -256,21 +256,7 @@ ColumnLayout {
color: Theme.palette.transparent color: Theme.palette.transparent
components: [ components: [
NetworkFilter { NetworkFilter {
layer1Networks: SortFilterProxyModel { flatNetworks: root.walletStore.networks
sourceModel: root.walletStore.networks
filters: ValueFilter { roleName: "layer"; value: 1; }
}
layer2Networks: SortFilterProxyModel {
sourceModel: root.walletStore.networks
filters: ValueFilter { roleName: "layer"; value: 2; }
}
allNetworks: root.walletStore.networks
enabledNetworks: SortFilterProxyModel {
sourceModel: root.walletStore.networks
filters: ExpressionFilter {
expression: d.preferredSharingNetworksArray.includes(model.chainId.toString())
}
}
preferredNetworksMode: true preferredNetworksMode: true
preferredSharingNetworks: d.preferredSharingNetworksArray preferredSharingNetworks: d.preferredSharingNetworksArray
onToggleNetwork: (network) => { onToggleNetwork: (network) => {

View File

@ -1,12 +1,15 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import StatusQ 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 import StatusQ.Core.Utils 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import SortFilterProxyModel 0.2
import AppLayouts.Wallet.helpers 1.0 import AppLayouts.Wallet.helpers 1.0
import utils 1.0 import utils 1.0
@ -16,10 +19,7 @@ import "../views"
StatusComboBox { StatusComboBox {
id: root id: root
required property var allNetworks required property var flatNetworks
required property var layer1Networks
required property var layer2Networks
required property var enabledNetworks
property bool multiSelection: true property bool multiSelection: true
property bool preferredNetworksMode: false property bool preferredNetworksMode: false
property var preferredSharingNetworks: [] property var preferredSharingNetworks: []
@ -30,31 +30,31 @@ StatusComboBox {
signal toggleNetwork(var network) signal toggleNetwork(var network)
function setChain(chainId) { function setChain(chainId) {
if(!multiSelection && !!d.currentModel && d.currentModel.count > 0) { if(!multiSelection && !!root.flatNetworks && root.flatNetworks.count > 0) {
d.currentModel = NetworkModelHelpers.getLayerNetworkModelByChainId(root.layer1Networks, d.currentIndex = NetworkModelHelpers.getChainIndexByChainId(root.flatNetworks, chainId)
root.layer2Networks, if(d.currentIndex == -1)
chainId) ?? root.layer2Networks d.currentIndex = NetworkModelHelpers.getChainIndexForFirstLayer2Network(root.flatNetworks)
d.currentIndex = NetworkModelHelpers.getChainIndexByChainId(root.layer1Networks,
root.layer2Networks,
chainId)
// Notify change: // Notify change:
root.toggleNetwork(ModelUtils.get(d.currentModel, d.currentIndex)) root.toggleNetwork(ModelUtils.get(root.flatNetworks, d.currentIndex))
} }
} }
QtObject { QtObject {
id: d id: d
readonly property string selectedChainName: NetworkModelHelpers.getChainName(d.currentModel, d.currentIndex) readonly property string selectedChainName: NetworkModelHelpers.getChainName(root.flatNetworks, d.currentIndex)
readonly property string selectedIconUrl: NetworkModelHelpers.getChainIconUrl(d.currentModel, d.currentIndex) readonly property string selectedIconUrl: NetworkModelHelpers.getChainIconUrl(root.flatNetworks, d.currentIndex)
readonly property bool allSelected: (!!root.enabledNetworks && !!root.allNetworks) ? root.enabledNetworks.count === root.allNetworks.count : readonly property bool allSelected: enabledFlatNetworks.len === root.flatNetworks.count
false readonly property bool noneSelected: enabledFlatNetworks.len === 0
readonly property bool noneSelected: (!!root.enabledNetworks) ? root.enabledNetworks.count === 0 : false
// Persist selection between selectPopupLoader reloads // Persist selection between selectPopupLoader reloads
property var currentModel: layer2Networks
property int currentIndex: 0 property int currentIndex: 0
property SortFilterProxyModel enabledFlatNetworks: SortFilterProxyModel {
sourceModel: root.flatNetworks
filters: ValueFilter { roleName: "isEnabled"; value: true; enabled: !root.preferredNetworksMode}
}
} }
onMultiSelectionChanged: root.setChain() onMultiSelectionChanged: root.setChain()
@ -103,21 +103,20 @@ StatusComboBox {
visible: !d.allSelected && chainRepeater.count > 0 visible: !d.allSelected && chainRepeater.count > 0
Repeater { Repeater {
id: chainRepeater id: chainRepeater
model: root.multiSelection ? root.enabledNetworks : [] model: root.preferredNetworksMode ? root.flatNetworks: root.multiSelection ? d.enabledFlatNetworks: []
delegate: StatusRoundedImage { delegate: StatusRoundedImage {
width: 24 width: 24
height: 24 height: 24
visible: image.source !== ""
image.source: Style.svg(model.iconUrl) image.source: Style.svg(model.iconUrl)
z: index + 1 z: index + 1
visible: root.preferredNetworksMode ? root.preferredSharingNetworks.includes(model.chainId.toString()): image.source !== ""
} }
} }
} }
} }
control.popup.contentItem: NetworkSelectionView { control.popup.contentItem: NetworkSelectionView {
layer1Networks: root.layer1Networks flatNetworks: root.flatNetworks
layer2Networks: root.layer2Networks
preferredSharingNetworks: root.preferredSharingNetworks preferredSharingNetworks: root.preferredSharingNetworks
preferredNetworksMode: root.preferredNetworksMode preferredNetworksMode: root.preferredNetworksMode
@ -126,14 +125,13 @@ StatusComboBox {
singleSelection { singleSelection {
enabled: !root.multiSelection enabled: !root.multiSelection
currentModel: d.currentModel currentModel: root.flatNetworks
currentIndex: d.currentIndex currentIndex: d.currentIndex
} }
useEnabledRole: false useEnabledRole: false
onToggleNetwork: (network, networkModel, index) => { onToggleNetwork: (network, index) => {
d.currentModel = networkModel
d.currentIndex = index d.currentIndex = index
root.toggleNetwork(network) root.toggleNetwork(network)
if(singleSelection.enabled) if(singleSelection.enabled)

View File

@ -20,30 +20,33 @@ QtObject {
return ModelUtils.get(model, index, "iconUrl") ?? "" return ModelUtils.get(model, index, "iconUrl") ?? ""
} }
// Given a layer1 network model and layer2 network model, it looks for the provided chainId and returns // Given a network model, it looks for the provided chainId and returns
// the layer network model that contains the specific chain. If not found, returns undefined. // the layer network model that contains the specific chain. If not found, returns undefined.
function getLayerNetworkModelByChainId(layer1NetworksModel, layer2NetworksModel, chainId) { function getLayerNetworkModelByChainId(networksModel, chainId) {
if(chainId) { if(chainId) {
if(!!layer1NetworksModel && ModelUtils.contains(layer1NetworksModel, "chainId", chainId)) if(!!networksModel && ModelUtils.contains(networksModel, "chainId", chainId))
return layer1NetworksModel return networksModel
else if(!!layer2NetworksModel && ModelUtils.contains(layer2NetworksModel, "chainId", chainId))
return layer2NetworksModel
} }
// Default value if chainId is not part of any provided layer network model // Default value if chainId is not part of any provided layer network model
return undefined return undefined
} }
// Given a layer1 network model and layer2 network model, it looks for the provided chainId and returns // Given a network model, it looks for the provided chainId and returns
// the index of the the specific chain. If not found, returns 0 value. // the index of the the specific chain. If not found, returns 0 value.
function getChainIndexByChainId(layer1NetworksModel, layer2NetworksModel, chainId) { function getChainIndexByChainId(networksModel, chainId) {
const currentModel = getLayerNetworkModelByChainId(layer1NetworksModel, layer2NetworksModel, chainId) if(!!networksModel && chainId !== undefined)
return ModelUtils.indexOf(networksModel, "chainId", chainId)
if(!!currentModel) // Default value if no model specified
return ModelUtils.indexOf(currentModel, "chainId", chainId) return 0
}
// Default value if no model specified function getChainIndexForFirstLayer2Network(networksModel) {
if(!!networksModel)
return ModelUtils.indexOf(networksModel, "layer", 2)
// Default value if no model specified
return 0 return 0
} }
} }

View File

@ -1,12 +1,15 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import StatusQ 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils import StatusQ.Core.Utils 0.1 as StatusQUtils
import SortFilterProxyModel 0.2
import utils 1.0 import utils 1.0
import "../controls" import "../controls"
@ -99,10 +102,7 @@ Item {
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
allNetworks: walletStore.allNetworks flatNetworks: walletStore.filteredFlatModel
layer1Networks: walletStore.layer1Networks
layer2Networks: walletStore.layer2Networks
enabledNetworks: walletStore.enabledNetworks
onToggleNetwork: (network) => { onToggleNetwork: (network) => {
walletStore.toggleNetwork(network.chainId) walletStore.toggleNetwork(network.chainId)

View File

@ -27,7 +27,7 @@ import ".."
StatusModal { StatusModal {
id: root id: root
property var allNetworks property var flatNetworks
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
@ -187,7 +187,7 @@ StatusModal {
d.ens = "" d.ens = ""
d.address = Constants.zeroAddress d.address = Constants.zeroAddress
d.chainShortNames = "" d.chainShortNames = ""
allNetworksModelCopy.setEnabledNetworks([]) flatNetworksModelCopy.setEnabledNetworks([])
} }
d.cardsModel.clear() d.cardsModel.clear()
@ -467,7 +467,7 @@ StatusModal {
if (!prefixArrWithColumn) if (!prefixArrWithColumn)
prefixArrWithColumn = [] prefixArrWithColumn = []
allNetworksModelCopy.setEnabledNetworks(prefixArrWithColumn) flatNetworksModelCopy.setEnabledNetworks(prefixArrWithColumn)
} }
} }
@ -496,8 +496,8 @@ StatusModal {
function getUnknownPrefixes(prefixes) { function getUnknownPrefixes(prefixes) {
let unknownPrefixes = prefixes.filter(e => { let unknownPrefixes = prefixes.filter(e => {
for (let i = 0; i < allNetworksModelCopy.count; i++) { for (let i = 0; i < flatNetworksModelCopy.count; i++) {
if (e == allNetworksModelCopy.get(i).shortName) if (e == flatNetworksModelCopy.get(i).shortName)
return false return false
} }
return true return true
@ -610,7 +610,7 @@ StatusModal {
} }
itemsModel: SortFilterProxyModel { itemsModel: SortFilterProxyModel {
sourceModel: allNetworksModelCopy sourceModel: flatNetworksModelCopy
filters: ValueFilter { filters: ValueFilter {
roleName: "isEnabled" roleName: "isEnabled"
value: true value: true
@ -674,20 +674,7 @@ StatusModal {
NetworkSelectPopup { NetworkSelectPopup {
id: networkSelectPopup id: networkSelectPopup
layer1Networks: SortFilterProxyModel { flatNetworks: flatNetworksModelCopy
sourceModel: allNetworksModelCopy
filters: ValueFilter {
roleName: "layer"
value: 1
}
}
layer2Networks: SortFilterProxyModel {
sourceModel: allNetworksModelCopy
filters: ValueFilter {
roleName: "layer"
value: 2
}
}
onToggleNetwork: (network) => { onToggleNetwork: (network) => {
network.isEnabled = !network.isEnabled network.isEnabled = !network.isEnabled
@ -718,9 +705,9 @@ StatusModal {
] ]
CloneModel { CloneModel {
id: allNetworksModelCopy id: flatNetworksModelCopy
sourceModel: root.allNetworks sourceModel: root.flatNetworks
roles: ["layer", "chainId", "chainColor", "chainName","shortName", "iconUrl"] roles: ["layer", "chainId", "chainColor", "chainName","shortName", "iconUrl"]
rolesOverride: [{ role: "isEnabled", transform: (modelData) => Boolean(false) }] rolesOverride: [{ role: "isEnabled", transform: (modelData) => Boolean(false) }]

View File

@ -2,9 +2,12 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import StatusQ 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Popups.Dialog 0.1 import StatusQ.Popups.Dialog 0.1
import SortFilterProxyModel 0.2
import utils 1.0 import utils 1.0
import "../stores/NetworkSelectPopup" import "../stores/NetworkSelectPopup"
@ -14,8 +17,7 @@ import "../views"
StatusDialog { StatusDialog {
id: root id: root
required property var layer1Networks property var flatNetworks
required property var layer2Networks
property var preferredSharingNetworks: [] property var preferredSharingNetworks: []
property bool preferredNetworksMode: false property bool preferredNetworksMode: false
@ -29,7 +31,7 @@ StatusDialog {
/// It is called for every toggled network if \c singleSelection.enabled is \c false /// It is called for every toggled network if \c singleSelection.enabled is \c false
/// If \c singleSelection.enabled is \c true, it is called only for the selected network when the selection changes /// If \c singleSelection.enabled is \c true, it is called only for the selected network when the selection changes
/// \see SingleSelectionInfo /// \see SingleSelectionInfo
signal toggleNetwork(var network, var model, int index) signal toggleNetwork(var network, int index)
QtObject { QtObject {
id: d id: d
@ -65,15 +67,16 @@ StatusDialog {
NetworkSelectionView { NetworkSelectionView {
id: scrollView id: scrollView
width: parent.width
height: parent.height
anchors.fill: parent anchors.fill: parent
layer1Networks: root.layer1Networks flatNetworks: root.flatNetworks
layer2Networks: root.layer2Networks
preferredNetworksMode: root.preferredNetworksMode preferredNetworksMode: root.preferredNetworksMode
preferredSharingNetworks: root.preferredSharingNetworks preferredSharingNetworks: root.preferredSharingNetworks
useEnabledRole: root.useEnabledRole useEnabledRole: root.useEnabledRole
singleSelection: d.singleSelection singleSelection: d.singleSelection
onToggleNetwork: { onToggleNetwork: {
root.toggleNetwork(network, model, index) root.toggleNetwork(network, index)
if(d.singleSelection.enabled) if(d.singleSelection.enabled)
close() close()
} }

View File

@ -32,9 +32,9 @@ StatusModal {
property bool switchingAccounsEnabled: true property bool switchingAccounsEnabled: true
property bool changingPreferredChainsEnabled: true property bool changingPreferredChainsEnabled: true
property string qrImageSource: RootStore.getQrCode(d.visibleAddress) property string qrImageSource: store.getQrCode(d.visibleAddress)
property var getNetworkShortNames: function(chainIDsString) { property var getNetworkShortNames: function(chainIDsString) {
return RootStore.getNetworkShortNames(chainIDsString) return store.getNetworkShortNames(chainIDsString)
} }
property var store: RootStore property var store: RootStore
@ -131,7 +131,7 @@ StatusModal {
} }
onOpened: { onOpened: {
RootStore.addressWasShown(root.selectedAccount.address) store.addressWasShown(root.selectedAccount.address)
} }
QtObject { QtObject {
@ -145,8 +145,6 @@ StatusModal {
readonly property string preferredChainShortNames: d.multiChainView? root.getNetworkShortNames(d.preferredChainIds) : "" readonly property string preferredChainShortNames: d.multiChainView? root.getNetworkShortNames(d.preferredChainIds) : ""
readonly property string visibleAddress: "%1%2".arg(d.preferredChainShortNames).arg(root.selectedAccount.address) readonly property string visibleAddress: "%1%2".arg(d.preferredChainShortNames).arg(root.selectedAccount.address)
readonly property var networkProxies: [layer1NetworksClone, layer2NetworksClone]
} }
Column { Column {
@ -260,16 +258,13 @@ StatusModal {
spacing: 5 spacing: 5
Repeater { Repeater {
model: d.networkProxies.length model: root.store.filteredFlatModel
delegate: Repeater { delegate: StatusNetworkListItemTag {
model: d.networkProxies[index] enabled: false
delegate: StatusNetworkListItemTag { button.visible: false
enabled: false title: model.shortName
button.visible: false asset.name: Style.svg("tiny/" + model.iconUrl)
title: model.shortName visible: d.preferredChainIdsArray.includes(model.chainId.toString())
asset.name: Style.svg("tiny/" + model.iconUrl)
visible: d.preferredChainIdsArray.includes(model.chainId.toString())
}
} }
} }
} }
@ -295,8 +290,7 @@ StatusModal {
margins: -1 // to allow positioning outside the bounds of the dialog margins: -1 // to allow positioning outside the bounds of the dialog
layer1Networks: layer1NetworksClone flatNetworks: root.store.filteredFlatModel
layer2Networks: layer2NetworksClone
preferredNetworksMode: true preferredNetworksMode: true
preferredSharingNetworks: d.preferredChainIdsArray preferredSharingNetworks: d.preferredChainIdsArray
@ -304,33 +298,13 @@ StatusModal {
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
onToggleNetwork: (network, networkModel, index) => { onToggleNetwork: (network, index) => {
d.preferredChainIdsArray = RootStore.processPreferredSharingNetworkToggle(d.preferredChainIdsArray, network) d.preferredChainIdsArray = store.processPreferredSharingNetworkToggle(d.preferredChainIdsArray, network)
} }
onClosed: { onClosed: {
root.updatePreferredChains(root.selectedAccount.address, d.preferredChainIds) root.updatePreferredChains(root.selectedAccount.address, d.preferredChainIds)
} }
CloneModel {
id: layer1NetworksClone
sourceModel: root.store.layer1Networks
roles: ["layer", "chainId", "chainColor", "chainName","shortName", "iconUrl", "isEnabled"]
// rowData used to clone returns string. Convert it to bool for bool arithmetics
rolesOverride: [{
role: "isEnabled",
transform: (modelData) => root.readOnly ? root.chainShortNames.includes(modelData.shortName) : Boolean(modelData.isEnabled)
}]
}
CloneModel {
id: layer2NetworksClone
sourceModel: root.store.layer2Networks
roles: layer1NetworksClone.roles
rolesOverride: layer1NetworksClone.rolesOverride
}
} }
} }
} }

View File

@ -3,6 +3,6 @@ import QtQml 2.15
/// Inline component was failing on Linux with "Cannot assign to property of unknown type" so we need to use a separate file for it. /// Inline component was failing on Linux with "Cannot assign to property of unknown type" so we need to use a separate file for it.
QtObject { QtObject {
property bool enabled: false property bool enabled: false
property var currentModel: root.layer2Networks property var currentModel
property int currentIndex: 0 property int currentIndex: 0
} }

View File

@ -139,12 +139,14 @@ QtObject {
return d.chainColors[chainShortName] return d.chainColors[chainShortName]
} }
property var layer1Networks: networksModule.layer1 property var flatNetworks: networksModule.flatNetworks
property var layer2Networks: networksModule.layer2 property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
property var enabledNetworks: networksModule.enabled sourceModel: root.flatNetworks
property var allNetworks: networksModule.all filters: ValueFilter { roleName: "isTest"; value: root.areTestNetworksEnabled }
onAllNetworksChanged: { }
d.initChainColors(allNetworks)
onFlatNetworksChanged: {
d.initChainColors(flatNetworks)
} }
property var cryptoRampServicesModel: walletSectionBuySellCrypto.model property var cryptoRampServicesModel: walletSectionBuySellCrypto.model
@ -440,7 +442,12 @@ QtObject {
} }
function getAllNetworksChainIds() { function getAllNetworksChainIds() {
return networksModule.getAllNetworksChainIds() let result = []
let chainIdsArray = SQUtils.ModelUtils.modelToFlatArray(root.filteredFlatModel, "chainId")
for(let i = 0; i< chainIdsArray.length; i++) {
result.push(chainIdsArray[i].toString())
}
return result
} }
function getNetworkShortNames(chainIds) { function getNetworkShortNames(chainIds) {
@ -462,7 +469,7 @@ QtObject {
function processPreferredSharingNetworkToggle(preferredSharingNetworks, toggledNetwork) { function processPreferredSharingNetworkToggle(preferredSharingNetworks, toggledNetwork) {
let prefChains = preferredSharingNetworks let prefChains = preferredSharingNetworks
if(prefChains.length === allNetworks.count) { if(prefChains.length === root.filteredFlatModel.count) {
prefChains = [toggledNetwork.chainId.toString()] prefChains = [toggledNetwork.chainId.toString()]
} }
else if(!prefChains.includes(toggledNetwork.chainId.toString())) { else if(!prefChains.includes(toggledNetwork.chainId.toString())) {
@ -470,7 +477,7 @@ QtObject {
} }
else { else {
if(prefChains.length === 1) { if(prefChains.length === 1) {
prefChains = getAllNetworksChainIds().split(":") prefChains = getAllNetworksChainIds()
} }
else { else {
for(var i = 0; i < prefChains.length;i++) { for(var i = 0; i < prefChains.length;i++) {

View File

@ -11,79 +11,51 @@ import utils 1.0
import "../stores/NetworkSelectPopup" import "../stores/NetworkSelectPopup"
import "../controls" import "../controls"
StatusScrollView { StatusListView {
id: root id: root
required property var layer1Networks required property var flatNetworks
required property var layer2Networks
property bool useEnabledRole: true property bool useEnabledRole: true
property SingleSelectionInfo singleSelection: SingleSelectionInfo {} property SingleSelectionInfo singleSelection: SingleSelectionInfo {}
property var preferredSharingNetworks: [] property var preferredSharingNetworks: []
property bool preferredNetworksMode: false property bool preferredNetworksMode: false
signal toggleNetwork(var network, var model, int index) signal toggleNetwork(var network, int index)
contentWidth: availableWidth model: root.flatNetworks
padding: 0
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff delegate: NetworkSelectItemDelegate {
implicitHeight: 48
Column { implicitWidth: root.width
id: content radioButtonGroup: radioBtnGroup
networkModel: root.model
width: root.availableWidth useEnabledRole: root.useEnabledRole
spacing: 4 singleSelection: root.singleSelection
onToggleNetwork: root.toggleNetwork(network, index)
Repeater { preferredNetworksMode: root.preferredNetworksMode
id: chainRepeater1 preferredSharingNetworks: root.preferredSharingNetworks
allChecked: root.preferredSharingNetworks.length === root.count
}
section {
property: "layer"
delegate: Loader {
required property int section
width: parent.width width: parent.width
height: parent.height sourceComponent: section === 2 ? layer2text: null
objectName: "networkSelectPopupChainRepeaterLayer1" Component {
model: root.layer1Networks id: layer2text
StatusBaseText {
delegate: NetworkSelectItemDelegate { width: parent.width
implicitHeight: 48 font.pixelSize: Style.current.primaryTextFontSize
implicitWidth: root.width color: Theme.palette.baseColor1
radioButtonGroup: radioBtnGroup text: qsTr("Layer 2")
networkModel: chainRepeater1.model height: 40
useEnabledRole: root.useEnabledRole leftPadding: 16
singleSelection: root.singleSelection topPadding: 10
onToggleNetwork: root.toggleNetwork(network, model, index) verticalAlignment: Text.AlignVCenter
preferredNetworksMode: root.preferredNetworksMode }
preferredSharingNetworks: root.preferredSharingNetworks
allChecked: root.preferredSharingNetworks.length === layer1Networks.count + layer2Networks.count
}
}
StatusBaseText {
font.pixelSize: Style.current.primaryTextFontSize
color: Theme.palette.baseColor1
text: qsTr("Layer 2")
height: 40
leftPadding: 16
topPadding: 10
verticalAlignment: Text.AlignVCenter
visible: chainRepeater2.count > 0
}
Repeater {
id: chainRepeater2
model: root.layer2Networks
delegate: NetworkSelectItemDelegate {
implicitHeight: 48
width: parent.width
radioButtonGroup: radioBtnGroup
networkModel: chainRepeater2.model
useEnabledRole: root.useEnabledRole
singleSelection: root.singleSelection
onToggleNetwork: root.toggleNetwork(network, model, index)
preferredNetworksMode: root.preferredNetworksMode
preferredSharingNetworks: root.preferredSharingNetworks
allChecked: root.preferredSharingNetworks.length === layer1Networks.count + layer2Networks.count
} }
} }
} }

View File

@ -255,7 +255,7 @@ RightTabBaseView {
visible: (stack.currentIndex === 2) visible: (stack.currentIndex === 2)
allNetworksModel: RootStore.allNetworks allNetworksModel: RootStore.filteredFlatModel
address: RootStore.overview.mixedcaseAddress address: RootStore.overview.mixedcaseAddress
showAllAccounts: RootStore.showAllAccounts showAllAccounts: RootStore.showAllAccounts
currencyStore: RootStore.currencyStore currencyStore: RootStore.currencyStore

View File

@ -7,6 +7,7 @@ import QtGraphicalEffects 1.15
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Popups 0.1 import StatusQ.Popups 0.1
@ -66,13 +67,13 @@ Item {
} }
readonly property bool isIncoming: transactionType === Constants.TransactionType.Received || transactionType === Constants.TransactionType.ContractDeployment readonly property bool isIncoming: transactionType === Constants.TransactionType.Received || transactionType === Constants.TransactionType.ContractDeployment
readonly property string networkShortName: d.isTransactionValid ? RootStore.getNetworkShortName(transaction.chainId) : "" readonly property string networkShortName: d.isTransactionValid ? ModelUtils.getByKey(RootStore.flatNetworks, "chainId", transaction.chainId, "shortName") : ""
readonly property string networkIcon: isTransactionValid ? RootStore.getNetworkIcon(transaction.chainId) : "network/Network=Custom" readonly property string networkIcon: isTransactionValid ? ModelUtils.getByKey(RootStore.flatNetworks, "chainId", transaction.chainId, "iconUrl") : "network/Network=Custom"
readonly property int blockNumber: isDetailsValid ? details.blockNumber : 0 readonly property int blockNumber: isDetailsValid ? details.blockNumber : 0
readonly property int blockNumberIn: isDetailsValid ? details.blockNumberIn : 0 readonly property int blockNumberIn: isDetailsValid ? details.blockNumberIn : 0
readonly property int blockNumberOut: isDetailsValid ? details.blockNumberOut : 0 readonly property int blockNumberOut: isDetailsValid ? details.blockNumberOut : 0
readonly property string networkShortNameOut: networkShortName readonly property string networkShortNameOut: networkShortName
readonly property string networkShortNameIn: transactionHeader.isMultiTransaction ? RootStore.getNetworkShortName(transaction.chainIdIn) : "" readonly property string networkShortNameIn: transactionHeader.isMultiTransaction ? ModelUtils.getByKey(RootStore.flatNetworks, "chainId", transaction.chainIdIn, "shortName") : ""
readonly property string symbol: isTransactionValid ? transaction.symbol : "" readonly property string symbol: isTransactionValid ? transaction.symbol : ""
readonly property string inSymbol: isTransactionValid ? transaction.inSymbol : "" readonly property string inSymbol: isTransactionValid ? transaction.inSymbol : ""
readonly property string outSymbol: isTransactionValid ? transaction.outSymbol : "" readonly property string outSymbol: isTransactionValid ? transaction.outSymbol : ""
@ -188,8 +189,9 @@ Item {
readonly property int latestBlockNumberIn: d.isTransactionValid && !pending && !error && transactionHeader.isMultiTransaction && d.isBridge ? WalletStores.RootStore.getEstimatedLatestBlockNumber(d.transaction.chainIdIn) : 0 readonly property int latestBlockNumberIn: d.isTransactionValid && !pending && !error && transactionHeader.isMultiTransaction && d.isBridge ? WalletStores.RootStore.getEstimatedLatestBlockNumber(d.transaction.chainIdIn) : 0
error: transactionHeader.transactionStatus === Constants.TransactionStatus.Failed error: transactionHeader.transactionStatus === Constants.TransactionStatus.Failed
pending: transactionHeader.transactionStatus === Constants.TransactionStatus.Pending pending: transactionHeader.transactionStatus === Constants.TransactionStatus.Pending
outNetworkLayer: d.isTransactionValid ? Number(RootStore.getNetworkLayer(transactionHeader.isMultiTransaction ? d.transaction.chainIdOut : d.transaction.chainId)) : 0 outNetworkLayer: d.isTransactionValid ? Number(ModelUtils.getByKey(RootStore.flatNetworks, "chainId", transactionHeader.isMultiTransaction ? d.transaction.chainIdOut : d.transaction.chainId, "layer")) : 0
inNetworkLayer: d.isTransactionValid && transactionHeader.isMultiTransaction && d.isBridge ? Number(RootStore.getNetworkLayer(d.transaction.chainIdIn)) : 0 inNetworkLayer: d.isTransactionValid && transactionHeader.isMultiTransaction && d.isBridge ?
ModelUtils.getByKey(RootStore.flatNetworks, "chainId", d.transaction.chainIdIn, "layer") : 0
outNetworkTimestamp: d.isTransactionValid ? d.transaction.timestamp : 0 outNetworkTimestamp: d.isTransactionValid ? d.transaction.timestamp : 0
inNetworkTimestamp: d.isTransactionValid ? d.transaction.timestamp : 0 inNetworkTimestamp: d.isTransactionValid ? d.transaction.timestamp : 0
outChainName: transactionHeader.isMultiTransaction ? transactionHeader.networkNameOut : transactionHeader.networkName outChainName: transactionHeader.isMultiTransaction ? transactionHeader.networkNameOut : transactionHeader.networkName
@ -260,7 +262,7 @@ Item {
case Constants.TransactionType.Swap: case Constants.TransactionType.Swap:
return Constants.tokenIcon(d.outSymbol) return Constants.tokenIcon(d.outSymbol)
case Constants.TransactionType.Bridge: case Constants.TransactionType.Bridge:
return Style.svg(RootStore.getNetworkIcon(d.transaction.chainIdOut)) ?? Style.svg("network/Network=Custom") return Style.svg(ModelUtils.getByKey(RootStore.flatNetworks, "chainId", d.transaction.chainIdOut, "iconUrl")) ?? Style.svg("network/Network=Custom")
default: default:
return "" return ""
} }
@ -287,7 +289,7 @@ Item {
case Constants.TransactionType.Swap: case Constants.TransactionType.Swap:
return Constants.tokenIcon(d.inSymbol) return Constants.tokenIcon(d.inSymbol)
case Constants.TransactionType.Bridge: case Constants.TransactionType.Bridge:
return Style.svg(RootStore.getNetworkIcon(d.transaction.chainIdIn)) ?? Style.svg("network/Network=Custom") return Style.svg(RootStore.Icon(d.transaction.chainIdIn)) ?? Style.svg("network/Network=Custom")
default: default:
return "" return ""
} }

View File

@ -44,7 +44,10 @@ ListModel {
for (let i = 0; i < model.count; i++) { for (let i = 0; i < model.count; i++) {
const clonedItem = new Object() const clonedItem = new Object()
for (var propName of roles) { for (var propName of roles) {
clonedItem[propName] = model.rowData(i, propName) if(model.rowData === undefined)
clonedItem[propName] = model.get(i, propName)
else
clonedItem[propName] = model.rowData(i, propName)
} }
for (var newProp of rolesOverride) { for (var newProp of rolesOverride) {
clonedItem[newProp.role] = newProp.transform(clonedItem) clonedItem[newProp.role] = newProp.transform(clonedItem)
@ -52,4 +55,4 @@ ListModel {
append(clonedItem) append(clonedItem)
} }
} }
} }

View File

@ -161,10 +161,10 @@ QtObject {
readonly property bool showBrowserSelector: localAccountSensitiveSettings.showBrowserSelector readonly property bool showBrowserSelector: localAccountSensitiveSettings.showBrowserSelector
readonly property bool openLinksInStatus: false readonly property bool openLinksInStatus: false
property var allNetworks: networksModule.all property var flatNetworks: networksModule.flatNetworks
function getEtherscanLink(chainID) { function getEtherscanLink(chainID) {
return allNetworks.getBlockExplorerURL(chainID) return networksModule.getBlockExplorerURL(chainID)
} }
function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityTags, function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityTags,

View File

@ -1809,7 +1809,7 @@ Item {
} }
sourceComponent: WalletPopups.AddEditSavedAddressPopup { sourceComponent: WalletPopups.AddEditSavedAddressPopup {
allNetworks: RootStore.allNetworks flatNetworks: WalletStore.RootStore.filteredFlatModel
onClosed: { onClosed: {
addEditSavedAddress.close() addEditSavedAddress.close()

View File

@ -6,6 +6,7 @@ import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
import AppLayouts.Wallet 1.0 import AppLayouts.Wallet 1.0
@ -62,10 +63,10 @@ StatusListItem {
readonly property double outFiatValue: isModelDataValid && isMultiTransaction ? rootStore.getFiatValue(outCryptoValue, modelData.outSymbol): 0.0 readonly property double outFiatValue: isModelDataValid && isMultiTransaction ? rootStore.getFiatValue(outCryptoValue, modelData.outSymbol): 0.0
readonly property double feeCryptoValue: 0.0 // TODO fill when bridge data is implemented readonly property double feeCryptoValue: 0.0 // TODO fill when bridge data is implemented
readonly property double feeFiatValue: 0.0 // TODO fill when bridge data is implemented readonly property double feeFiatValue: 0.0 // TODO fill when bridge data is implemented
readonly property string networkColor: isModelDataValid ? rootStore.getNetworkColor(modelData.chainId) : "" readonly property string networkColor: isModelDataValid ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "chainColor") : ""
readonly property string networkName: isModelDataValid ? rootStore.getNetworkFullName(modelData.chainId) : "" readonly property string networkName: isModelDataValid ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "chainName") : ""
readonly property string networkNameIn: isMultiTransaction ? rootStore.getNetworkFullName(modelData.chainIdIn) : "" readonly property string networkNameIn: isMultiTransaction ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdIn, "chainName") : ""
readonly property string networkNameOut: isMultiTransaction ? rootStore.getNetworkFullName(modelData.chainIdOut) : "" readonly property string networkNameOut: isMultiTransaction ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdOut, "chainName") : ""
readonly property string addressNameTo: isModelDataValid ? walletRootStore.getNameForAddress(modelData.recipient) : "" readonly property string addressNameTo: isModelDataValid ? walletRootStore.getNameForAddress(modelData.recipient) : ""
readonly property string addressNameFrom: isModelDataValid ? walletRootStore.getNameForAddress(modelData.sender) : "" readonly property string addressNameFrom: isModelDataValid ? walletRootStore.getNameForAddress(modelData.sender) : ""
readonly property bool isNFT: isModelDataValid && modelData.isNFT readonly property bool isNFT: isModelDataValid && modelData.isNFT
@ -246,7 +247,7 @@ StatusListItem {
} }
// PROGRESS // PROGRESS
const networkLayer = rootStore.getNetworkLayer(modelData.chainId) const networkLayer = SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "layer")
const isBridge = type === Constants.TransactionType.Bridge const isBridge = type === Constants.TransactionType.Bridge
switch(transactionStatus) { switch(transactionStatus) {
@ -272,7 +273,7 @@ StatusListItem {
details += qsTr("Confirmed on %1").arg(root.networkName) + endl details += qsTr("Confirmed on %1").arg(root.networkName) + endl
details += LocaleUtils.formatDateTime(confirmationTimeStamp * 1000, Locale.LongFormat) + endl2 details += LocaleUtils.formatDateTime(confirmationTimeStamp * 1000, Locale.LongFormat) + endl2
if (isBridge) { if (isBridge) {
const networkInLayer = rootStore.getNetworkLayer(modelData.chainIdIn) const networkInLayer = SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdIn, "layer")
const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp) const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp)
details += qsTr("Signed on %1").arg(root.networkNameIn) + endl + timestampString + endl2 details += qsTr("Signed on %1").arg(root.networkNameIn) + endl + timestampString + endl2
details += qsTr("Confirmed on %1").arg(root.networkNameIn) + endl details += qsTr("Confirmed on %1").arg(root.networkNameIn) + endl
@ -293,7 +294,7 @@ StatusListItem {
details += qsTr("Finalised on %1").arg(root.networkName) + endl details += qsTr("Finalised on %1").arg(root.networkName) + endl
details += LocaleUtils.formatDateTime(finalisationTimeStamp * 1000, Locale.LongFormat) + endl2 details += LocaleUtils.formatDateTime(finalisationTimeStamp * 1000, Locale.LongFormat) + endl2
if (isBridge) { if (isBridge) {
const networkInLayer = rootStore.getNetworkLayer(modelData.chainIdIn) const networkInLayer = SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdIn, "layer")
const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp) const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp)
const finalisationTimeStampIn = WalletUtils.calculateFinalisationTimestamp(networkInLayer, modelData.timestamp) const finalisationTimeStampIn = WalletUtils.calculateFinalisationTimestamp(networkInLayer, modelData.timestamp)
const epochIn = Math.abs(walletRootStore.getEstimatedLatestBlockNumber(modelData.chainIdIn) - detailsObj.blockNumberIn) const epochIn = Math.abs(walletRootStore.getEstimatedLatestBlockNumber(modelData.chainIdIn) - detailsObj.blockNumberIn)

View File

@ -268,7 +268,7 @@ StatusDialog {
selectedSenderAccount: store.selectedSenderAccount.address selectedSenderAccount: store.selectedSenderAccount.address
assetsModel: popup.store.processedAssetsModel assetsModel: popup.store.processedAssetsModel
collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
networksModel: popup.store.allNetworksModel networksModel: popup.store.flatNetworksModel
currentCurrencySymbol: d.currencyStore.currentCurrencySymbol currentCurrencySymbol: d.currencyStore.currentCurrencySymbol
visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.TokenType.Unknown) || visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.TokenType.Unknown) ||
(!!d.hoveredHolding && d.hoveredHoldingType !== Constants.TokenType.Unknown) (!!d.hoveredHolding && d.hoveredHoldingType !== Constants.TokenType.Unknown)
@ -400,7 +400,7 @@ StatusDialog {
selectedSenderAccount: store.selectedSenderAccount.address selectedSenderAccount: store.selectedSenderAccount.address
assets: popup.store.processedAssetsModel assets: popup.store.processedAssetsModel
collectibles: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null collectibles: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
networksModel: popup.store.allNetworksModel networksModel: popup.store.flatNetworksModel
onlyAssets: holdingSelector.onlyAssets onlyAssets: holdingSelector.onlyAssets
onTokenSelected: { onTokenSelected: {
d.setSelectedHoldingId(symbol, holdingType) d.setSelectedHoldingId(symbol, holdingType)

View File

@ -88,7 +88,7 @@ Item {
errorMode: root.errorMode errorMode: root.errorMode
errorType: root.errorType errorType: root.errorType
toNetworksList: root.toNetworksList toNetworksList: root.toNetworksList
selectedSymbol: root.selectedAsset.symbol selectedSymbol: !!root.selectedAsset ? root.selectedAsset.symbol: ""
weiToEth: function(wei) { weiToEth: function(wei) {
if(!!selectedAsset && root.selectedAsset !== undefined) if(!!selectedAsset && root.selectedAsset !== undefined)
return parseFloat(store.getWei2Eth(wei, root.selectedAsset.decimals)) return parseFloat(store.getWei2Eth(wei, root.selectedAsset.decimals))

View File

@ -1,4 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import SortFilterProxyModel 0.2
import utils 1.0 import utils 1.0
QtObject { QtObject {
@ -7,10 +9,11 @@ QtObject {
property var communityTokensModuleInst: communityTokensModule ?? null property var communityTokensModuleInst: communityTokensModule ?? null
// Network selection properties: // Network selection properties:
property var layer1Networks: networksModule.layer1 property var flatNetworks: networksModule.flatNetworks
property var layer2Networks: networksModule.layer2 property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
property var enabledNetworks: networksModule.enabled sourceModel: root.flatNetworks
property var allNetworks: networksModule.all filters: ValueFilter { roleName: "isTest"; value: networksModule.areTestNetworksEnabled }
}
// set by asyncGetOwnerTokenDetails // set by asyncGetOwnerTokenDetails
readonly property var ownerTokenDetails: { readonly property var ownerTokenDetails: {

View File

@ -1,5 +1,7 @@
import QtQuick 2.13 import QtQuick 2.13
import SortFilterProxyModel 0.2
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1 import StatusQ.Core.Utils 0.1
@ -15,8 +17,13 @@ QtObject {
readonly property bool balanceCache: walletSectionAssets.hasBalanceCache readonly property bool balanceCache: walletSectionAssets.hasBalanceCache
readonly property bool marketValuesCache: walletSectionAssets.hasMarketValuesCache readonly property bool marketValuesCache: walletSectionAssets.hasMarketValuesCache
readonly property SortFilterProxyModel __filteredflatNetworks: SortFilterProxyModel {
sourceModel: networksModule.flatNetworks
filters: ValueFilter { roleName: "isTest"; value: networksModule.areTestNetworksEnabled }
}
readonly property var blockchainNetworksDown: !!networkConnectionModule.blockchainNetworkConnection.chainIds ? networkConnectionModule.blockchainNetworkConnection.chainIds.split(";") : [] readonly property var blockchainNetworksDown: !!networkConnectionModule.blockchainNetworkConnection.chainIds ? networkConnectionModule.blockchainNetworkConnection.chainIds.split(";") : []
readonly property bool atleastOneBlockchainNetworkAvailable: blockchainNetworksDown.length < networksModule.all.count readonly property bool atleastOneBlockchainNetworkAvailable: blockchainNetworksDown.length < __filteredflatNetworks.count
readonly property bool sendBuyBridgeEnabled: localAppSettings.testEnvironment || (isOnline && readonly property bool sendBuyBridgeEnabled: localAppSettings.testEnvironment || (isOnline &&
(!networkConnectionModule.blockchainNetworkConnection.completelyDown && atleastOneBlockchainNetworkAvailable) && (!networkConnectionModule.blockchainNetworkConnection.completelyDown && atleastOneBlockchainNetworkAvailable) &&
@ -52,9 +59,10 @@ QtObject {
readonly property bool noTokenBalanceAvailable: notOnlineWithNoCache || noBlockchainConnectionAndNoCache readonly property bool noTokenBalanceAvailable: notOnlineWithNoCache || noBlockchainConnectionAndNoCache
readonly property bool ensNetworkAvailable: !blockchainNetworksDown.includes(mainModule.appNetworkId.toString()) readonly property bool ensNetworkAvailable: !blockchainNetworksDown.includes(mainModule.appNetworkId.toString())
readonly property string ensNetworkUnavailableText: qsTr("Requires POKT/Infura for %1, which is currently unavailable").arg(networksModule.all.getNetworkFullName(mainModule.appNetworkId)) readonly property string ensNetworkUnavailableText: qsTr("Requires POKT/Infura for %1, which is currently unavailable").arg(appNetworkName)
readonly property bool stickersNetworkAvailable: !blockchainNetworksDown.includes(mainModule.appNetworkId.toString()) readonly property bool stickersNetworkAvailable: !blockchainNetworksDown.includes(mainModule.appNetworkId.toString())
readonly property string stickersNetworkUnavailableText: qsTr("Requires POKT/Infura for %1, which is currently unavailable").arg(networksModule.all.getNetworkFullName(mainModule.appNetworkId)) readonly property string stickersNetworkUnavailableText: qsTr("Requires POKT/Infura for %1, which is currently unavailable").arg(appNetworkName)
readonly property string appNetworkName: ModelUtils.getByKey(networksModule.flatNetworks, "chainId", mainModule.appNetworkId, "chainName")
function getBlockchainNetworkDownTextForToken(balances) { function getBlockchainNetworkDownTextForToken(balances) {
if(!!balances && !networkConnectionModule.blockchainNetworkConnection.completelyDown && !notOnlineWithNoCache) { if(!!balances && !networkConnectionModule.blockchainNetworkConnection.completelyDown && !notOnlineWithNoCache) {
@ -88,7 +96,7 @@ QtObject {
let jointChainIdString = "" let jointChainIdString = ""
for (const chain of chainIdsDown) { for (const chain of chainIdsDown) {
jointChainIdString = (!!jointChainIdString) ? jointChainIdString + " & " : jointChainIdString jointChainIdString = (!!jointChainIdString) ? jointChainIdString + " & " : jointChainIdString
jointChainIdString += networksModule.all.getNetworkFullName(parseInt(chain)) jointChainIdString += ModelUtils.getByKey(networksModule.flatNetworks, "chainId", parseInt(chain), "chainName")
} }
return jointChainIdString return jointChainIdString
} }

View File

@ -30,41 +30,12 @@ QtObject {
property bool isNonArchivalNode: Global.appIsReady && walletSectionInst.isNonArchivalNode property bool isNonArchivalNode: Global.appIsReady && walletSectionInst.isNonArchivalNode
property var marketValueStore: TokenMarketValuesStore{} property var marketValueStore: TokenMarketValuesStore{}
property var allNetworks: networksModule.all
function resetActivityData() { function resetActivityData() {
walletSectionInst.activityController.resetActivityData() walletSectionInst.activityController.resetActivityData()
} }
// TODO remove all these by linking chainId for networks and activity using LeftJoinModel property var flatNetworks: networksModule.flatNetworks
// not possible currently due to the current structure of the activity model
function getNetworkColor(chainId) {
return networksModule.all.getChainColor(chainId)
}
function getNetworkIcon(chainId) {
return networksModule.all.getIconUrl(chainId)
}
function getNetworkShortName(chainId) {
return networksModule.all.getNetworkShortName(chainId)
}
function getNetworkFullName(chainId) {
return networksModule.all.getNetworkFullName(chainId)
}
function getNetworkLayer(chainId) {
return networksModule.all.getNetworkLayer(chainId)
}
function getNetworkIconUrl(symbol) {
return networksModule.all.getNetworkIconUrl(symbol)
}
function getNetworkName(symbol) {
return networksModule.all.getNetworkName(symbol)
}
function hex2Dec(value) { function hex2Dec(value) {
return globalUtils.hex2Dec(value) return globalUtils.hex2Dec(value)

View File

@ -23,7 +23,7 @@ QtObject {
property var fromNetworksModel: walletSectionSendInst.fromNetworksModel property var fromNetworksModel: walletSectionSendInst.fromNetworksModel
property var toNetworksModel: walletSectionSendInst.toNetworksModel property var toNetworksModel: walletSectionSendInst.toNetworksModel
property var allNetworksModel: networksModule.all property var flatNetworksModel: networksModule.flatNetworks
property var senderAccounts: walletSectionSendInst.senderAccounts property var senderAccounts: walletSectionSendInst.senderAccounts
property var selectedSenderAccount: walletSectionSendInst.selectedSenderAccount property var selectedSenderAccount: walletSectionSendInst.selectedSenderAccount
property var accounts: walletSectionSendInst.accounts property var accounts: walletSectionSendInst.accounts
@ -55,7 +55,7 @@ QtObject {
} }
function getEtherscanLink(chainID) { function getEtherscanLink(chainID) {
return networksModule.all.getBlockExplorerURL(chainID) return networksModule.getBlockExplorerURL(chainID)
} }
function copyToClipboard(text) { function copyToClipboard(text) {